QString translateCommitDesc(const QString& input) { QString value = input; if (value.startsWith("Reverted repo")) { value.replace("repo", "library"); } if (value.startsWith("Reverted library")) { return value.replace("Reverted library to status at", QObject::tr("Reverted library to status at")); } else if (value.startsWith("Reverted file")) { QRegExp regex("Reverted file \"(.*)\" to status at (.*)"); if (regex.indexIn(value) >= 0) { QString name = regex.cap(1); QString time = regex.cap(2); return QObject::tr("Reverted file \"%1\" to status at %2.").arg(name).arg(time); } } else if (value.startsWith("Recovered deleted directory")) { return value.replace("Recovered deleted directory", QObject::tr("Recovered deleted directory")); } else if (value.startsWith("Changed library")) { return value.replace("Changed library name or description", QObject::tr("Changed library name or description")); } else if (value.startsWith("Merged") || value.startsWith("Auto merge")) { return QObject::tr("Auto merge by %1 system").arg(getBrand()); } QStringList lines = value.split("\n"); QStringList out; for (int i = 0; i < lines.size(); i++) { out << translateLine(lines.at(i)); } return out.join("\n"); }
int main(int argc, char **argv) { SDL_Window *win; SDL_Renderer *g; int win_width = 1152, win_height = 720; int flag_forceinwin = 1, dtime = 1000; struct color *renderColor = &GHETTO_WHITE; struct color *backgroundColor = &GHETTO_BLACK; // dem args int c; while ((c = getopt(argc, argv, "t:yh")) != -1) { switch (c) { case 't': // reset delay time dtime = atoi(optarg); printf("Delay time set to: %ims\n", dtime); break; case 'y': // yolo mode flag_forceinwin = 0; printf("YOLO mode intiated\n"); break; case 'h': printHelp(argv[0]); return 0; default: break; } } // seed dat RNG srand((unsigned int) time(NULL)); initSDL(); // grab a window and a renderer win = getWindow(win_width, win_height); g = getRenderer(win); // clear screen setClearColor(backgroundColor); clearScreen(g); // blue lines (for now) setColor(g, renderColor); // line number; used to decide direction // start at 1 int lineNo = 1; // necesary line node structures for linked list: // root line node in list struct node *root = malloc(sizeof(struct node)); // previously generated line node struct node *previous; // line node undergoing generation struct node *current; // first line, start at middle, rand length, go from there struct line *firstLine = genNextLine(NULL, lineNo); // move line to center (genNextLine starts at (0, 0) when // previous is NULL) translateLine(firstLine, win_width / 2, win_height / 2); root->line = firstLine; root->next = current; previous = root; clearScreen(g); drawLine(g, root->line); render(g); // increment line count so loop starts on horizonal lineNo++; delay(dtime); while (1) { if (!handleEvents()) break; // allocate memory for new node current = malloc(sizeof(struct node)); // add to linked list; // new is old's next previous->next = current; if (flag_forceinwin) { // keep line bound to window bounds while (1) { current->line = genNextLine(previous->line, lineNo); if (current->line->x2 > win_width || current->line->y2 > win_height) free(current->line); else break; } } else { // line can do whatever tf it wants current->line = genNextLine(previous->line, lineNo); } // THIS is very necessary; // in rendering: // iterate through linked list until next is NULL // if you don't set new next to null, it thinks theres another // value (will be reset to next element in next iteration of loop) current->next = NULL; clearScreen(g); drawAllLines(g, root); render(g); previous = current; lineNo++; // break up sleeping into smaller segments // to allow user to exit faster int i; for (i = 0; i < 10; i++) { if (!handleEvents()) break; delay(dtime / 10); } if (i < 10) break; } freeLineList(root); cleanup(g, win); return 0; }
/// ParseDirective - Go through the comment and see if it indicates expected /// diagnostics. If so, then put them in the appropriate directive list. /// /// Returns true if any valid directives were found. static bool ParseDirective(StringRef S, ExpectedData *ED, const llvm::SourceMgr &SM, Lexer *PP, const SourceLocation& Pos, VerifyDiagnosticConsumer::DirectiveStatus &Status) { DiagnosticsEngine &Diags = PP->getDiagnostics(); // A single comment may contain multiple directives. bool FoundDirective = false; for (ParseHelper PH(S); !PH.Done();) { // Search for token: expected if (!PH.Search("expected", true)) break; PH.Advance(); // Next token: - if (!PH.Next("-")) continue; PH.Advance(); // Next token: { error | warning | note } DirectiveList* DL = NULL; if (PH.Next("error")) DL = ED ? &ED->Errors : NULL; else if (PH.Next("warning")) DL = ED ? &ED->Warnings : NULL; else if (PH.Next("note")) DL = ED ? &ED->Notes : NULL; else if (PH.Next("no-diagnostics")) { if (Status == VerifyDiagnosticConsumer::HasOtherExpectedDirectives) { Diags.Report(Pos, diag::err_verify_invalid_no_diags) << /*IsExpectedNoDiagnostics=*/true; } else Status = VerifyDiagnosticConsumer::HasExpectedNoDiagnostics; continue; } else continue; PH.Advance(); if (Status == VerifyDiagnosticConsumer::HasExpectedNoDiagnostics) { Diags.Report(Pos, diag::err_verify_invalid_no_diags) << /*IsExpectedNoDiagnostics=*/false; continue; } Status = VerifyDiagnosticConsumer::HasOtherExpectedDirectives; // If a directive has been found but we're not interested // in storing the directive information, return now. if (!DL) return true; // Default directive kind. bool RegexKind = false; const char* KindStr = "string"; // Next optional token: - if (PH.Next("-re")) { PH.Advance(); RegexKind = true; KindStr = "regex"; } // Next optional token: @ SourceLocation ExpectedLoc; if (!PH.Next("@")) { ExpectedLoc = Pos; } else { PH.Advance(); unsigned Line = 0; bool FoundPlus = PH.Next("+"); if (FoundPlus || PH.Next("-")) { // Relative to current line. PH.Advance(); bool Invalid = false; unsigned ExpectedLine = SM.FindLineNumber(Pos); if (!Invalid && PH.Next(Line) && (FoundPlus || Line < ExpectedLine)) { if (FoundPlus) ExpectedLine += Line; else ExpectedLine -= Line; ExpectedLoc = translateLine(SM,SM.FindBufferContainingLoc(Pos), ExpectedLine); } } else if (PH.Next(Line)) { // Absolute line number. if (Line > 0) ExpectedLoc = translateLine(SM,SM.FindBufferContainingLoc(Pos), Line); } if (!ExpectedLoc.isValid()) { Diags.Report(getLocWithOffset(Pos,PH.C-PH.Begin), diag::err_verify_missing_line) << KindStr; continue; } PH.Advance(); } // Skip optional whitespace. PH.SkipWhitespace(); // Next optional token: positive integer or a '+'. unsigned Min = 1; unsigned Max = 1; if (PH.Next(Min)) { PH.Advance(); // A positive integer can be followed by a '+' meaning min // or more, or by a '-' meaning a range from min to max. if (PH.Next("+")) { Max = Directive::MaxCount; PH.Advance(); } else if (PH.Next("-")) { PH.Advance(); if (!PH.Next(Max) || Max < Min) { Diags.Report(getLocWithOffset(Pos,PH.C-PH.Begin), diag::err_verify_invalid_range) << KindStr; continue; } PH.Advance(); } else { Max = Min; } } else if (PH.Next("+")) { // '+' on its own means "1 or more". Max = Directive::MaxCount; PH.Advance(); } // Skip optional whitespace. PH.SkipWhitespace(); // Next token: {{ if (!PH.Next("{{")) { Diags.Report(getLocWithOffset(Pos,PH.C-PH.Begin), diag::err_verify_missing_start) << KindStr; continue; } PH.Advance(); const char* const ContentBegin = PH.C; // mark content begin // Search for token: }} if (!PH.Search("}}")) { Diags.Report(getLocWithOffset(Pos,PH.C-PH.Begin), diag::err_verify_missing_end) << KindStr; continue; } const char* const ContentEnd = PH.P; // mark content end PH.Advance(); // Build directive text; convert \n to newlines. std::string Text; StringRef NewlineStr = "\\n"; StringRef Content(ContentBegin, ContentEnd-ContentBegin); size_t CPos = 0; size_t FPos; while ((FPos = Content.find(NewlineStr, CPos)) != StringRef::npos) { Text += Content.substr(CPos, FPos-CPos); Text += '\n'; CPos = FPos + NewlineStr.size(); } if (Text.empty()) Text.assign(ContentBegin, ContentEnd); // Construct new directive. Directive *D = Directive::create(RegexKind, Pos, ExpectedLoc, Text, Min, Max); std::string Error; if (D->isValid(Error)) { DL->push_back(D); FoundDirective = true; } else { Diags.Report(getLocWithOffset(Pos,ContentBegin-PH.Begin), diag::err_verify_invalid_content) << KindStr << Error; } } return FoundDirective; }