/* * ChPhrase() * * This is necessary to search the files found for a phrase either in their * file comments or in the data part of a 'strange' file (GIF, etc). */ void *ChPhrase(DirEntry *e, DirEntry *d) { FILE *fd; int format; char buf[100]; extern FunnyInfo Formats[]; if (!FindFileComment(e->unambig, FALSE) || matchString(msgBuf.mbtext, Phrase, lbyte(msgBuf.mbtext)) == NULL) { /* * This code extracts information from the GIF, etc file and * matches it against the given phrase. */ format = CompressType(e->unambig); if (format == ERROR || Formats[format].Many) return d; if ((fd = fopen(e->unambig, READ_ANY)) == NULL) return d; (*Formats[format].Func)(fd, FALSE, buf); fclose(fd); if (matchString(buf, Phrase, lbyte(buf)) == NULL) return d; } return NULL; }
bool necessaryExtensionsSupported() { const char *extensionString = reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)); const char *p = extensionString; const int GL_EXT_FBO = 1; const int GL_ARB_VS = 2; const int GL_ARB_FS = 4; const int GL_ARB_SO = 8; int extensions = 0; while (*p) { if (matchString(p, "GL_EXT_framebuffer_object")) extensions |= GL_EXT_FBO; else if (matchString(p, "GL_ARB_vertex_shader")) extensions |= GL_ARB_VS; else if (matchString(p, "GL_ARB_fragment_shader")) extensions |= GL_ARB_FS; else if (matchString(p, "GL_ARB_shader_objects")) extensions |= GL_ARB_SO; while ((*p != ' ') && (*p != '\0')) ++p; if (*p == ' ') ++p; } return (extensions == 15); }
void SearchWidget::findStation(const QString& str) { removeMatches(); matchString(str.toStdString()); removeContent(); updateContent(); }
int read_tarfs_file(char * fileName, char *binary_tarfs_start, char* binary_tarfs_end) { //printk("Indisde : %s",fileName); int found_file = 0; struct posix_header_ustar *tar_p = (struct posix_header_ustar *) (binary_tarfs_start); // print_posix_header(tar_p); //printk("\n Binary Start %x", binary_tarfs_start); // printk("\n Binary End %x", binary_tarfs_end); char *temp = binary_tarfs_start; // int size = octal_decimal(atoi(tar_p->size)); while (temp < binary_tarfs_end) { if (matchString(tar_p->name, fileName) == 0) { found_file = 1; return found_file; } int size = octal_decimal(atoi(tar_p->size)); int padding = 0; if (size % 512 != 0) { padding = 512 - size % 512; } temp = temp + 512 + size + padding; tar_p = (struct posix_header_ustar *) temp; // print_posix_header(tar_p); // printk("\n temp : %x",temp); } return found_file; }
static bool matchStringOrNone(QByteArray *s) { bool matches = matchString(s); if (!matches) matches = match(Tok_None); return matches; }
static bool matchStringOrNull(QString &s) { bool matches = matchString(s); if (!matches) { matches = (yyTok == Tok_null); if (matches) yyTok = getToken(); } return matches; }
int parseCommand(token *tok, char **s) { int line; int r; if (matchNumber(tok, s)) { line = tok->n; if (!matchWhiteSpace(tok, s)) // delete line return deleteLine(line); else // add line { matchString(tok, s); return insertLine(line, tok->s); } } if (matchSize(tok, s)) { puts(itos(programGetSize())); return 1; } if (matchFree(tok, s)) { puts(itos(programGetFree())); return 1; } if (matchClear(tok, s)) { programInit(); return 1; } if (matchBye(tok, s)) { exit(0); } if (parseRun(tok, s)) return 1; else if (errorGet() != ERROR_OK) return 0; if (parseList(tok, s)) return 1; else if (errorGet() != ERROR_OK) return 0; programSetMode(progModeImmediate); r = parseLine(tok, s); programSetMode(progModeStored); return r; }
/* Code Reference : My Previous Submission */ int get_elf_file(char *binary_tarfs_start, char * filename, char* binary_tarfs_end) { int found_file = 0; struct posix_header_ustar *tar_p = (struct posix_header_ustar *) (binary_tarfs_start); // print_posix_header(tar_p); // printk("\n Binary Start %x", binary_tarfs_start); //printk("\n Binary End %x", binary_tarfs_end); char *temp = binary_tarfs_start; // int size = octal_decimal(atoi(tar_p->size)); while (temp < binary_tarfs_end) { if (matchString(tar_p->name, filename) == 0) { found_file = 1; break; // return found_file; } int size = octal_decimal(atoi(tar_p->size)); int padding = 0; if (size % 512 != 0) { padding = 512 - size % 512; } temp = temp + 512 + size + padding; tar_p = (struct posix_header_ustar *) temp; print_posix_header(tar_p); // printk("\n temp : %x",temp); } if (found_file == 0) { return 0; } else { temp = temp + 512; } // printk("\n size : %d",atoi(tar_p->size) ); // printk("\n Header:"); elf_start = (uint64_t) temp; // printk("\n temp: %x",temp); parse_ELF(temp, atoi(tar_p->size), &exeFormat, &pdr); //printk("\n exe format :%d", Parse_ELF_Executable(temp, atoi(tar_p->size),&exeFormat,&pdr)); return 1; }
bool JParamSpec::SetParam(const vector<string> param){ string line; for (int i = 0; i < param.size(); i++){ line = param.at(i); matchString(line, "name:", &m_name); if (line.find("share_mode:") != string::npos){ if (line.find("PERMISSIVE") != string::npos){ m_share_mode = PERMISSIVE; } } matchFloat(line, "lr_mult:", &m_lr_mult); matchFloat(line, "decay_mult:", &m_decay_mult); } return true; }
/* -------------------------------------------------------------------- */ void replaceString(char *buf, int lim, char ver) { char oldString[256]; char newString[256]; char *loc, *textEnd; char *pc; int incr, length; /* find terminal null */ for (textEnd = buf, length = 0; *textEnd; length++, textEnd++); getString("text", oldString, 256, FALSE, ECHO, ""); if (!*oldString) { mPrintf(" Text not found.\n"); return; } if ((loc = matchString(buf, oldString, textEnd, ver)) == NULL) { mPrintf(" Text not found.\n "); return; } getString("replacement text", newString, 256, FALSE, ECHO, ""); if (strlen(newString) > strlen(oldString) && ((strlen(newString) - strlen(oldString)) >= lim - length)) { mPrintf(" Buffer overflow.\n "); /* FJM: should be trapped ??? */ return; /* nope, it's a user error. */ } /* delete old string: */ for (pc = loc, incr = strlen(oldString); (*pc = *(pc + incr)) != 0; pc++) ; textEnd -= incr; /* make room for new string: */ for (pc = textEnd, incr = strlen(newString); pc >= loc; pc--) { *(pc + incr) = *pc; } /* insert new string: */ for (pc = newString; *pc; *loc++ = *pc++) ; }
static int matchGeneric(CSSParser *p, int *invalid) { if (p->pos >= p->length) return 1; switch (p->chars[p->pos]) { case '"': case '\'': return matchString(p,invalid); case '(': p->pos++; return matchPast(p,')',invalid); case '[': p->pos++; return matchPast(p,']',invalid); case '{': p->pos++; return matchPast(p,'}',invalid); default: p->pos++; return 1; } }
inline bool isString(TToken &tk) { return matchString(tk); }
DFArray *CSSParserContent(CSSParser *p) { DFArray *result = DFArrayNew((DFCopyFunction)ContentPartRetain,(DFFreeFunction)ContentPartRelease); matchWhitespace(p); while (p->pos < p->length) { size_t start = p->pos; switch (p->chars[p->pos]) { case '"': case '\'': { int invalid = 0; if (!matchString(p,&invalid)) return result; char *quotedValue = trimmedSubstring(p,start,p->pos); char *unquotedValue = DFUnquote(quotedValue); ContentPart *part = ContentPartNew(ContentPartString,unquotedValue,NULL); DFArrayAppend(result,part); ContentPartRelease(part); free(quotedValue); free(unquotedValue); if ((p->pos < p->length) && !matchWhitespace(p)) return result; break; } case 'C': case 'c': { if (matchSpecific(p,"counters(")) { // Not yet supported return result; } else if (matchSpecific(p,"counter(")) { size_t nameStart = p->pos; if (!matchIdent(p)) return result; char *name = DFSubstring(p->chars,nameStart,p->pos); char *type = NULL; if (match(p,',')) { size_t typeStart = p->pos; if (!matchIdent(p)) { free(name); free(type); return result; } type = DFSubstring(p->chars,typeStart,p->pos); } ContentPart *part = ContentPartNew(ContentPartCounter,name,type); DFArrayAppend(result,part); ContentPartRelease(part); if (!match(p,')')) { free(name); free(type); return result; } if ((p->pos < p->length) && !matchWhitespace(p)) { free(name); free(type); return result; } free(name); free(type); } else { return result; } break; } default: return result; } } return result; }
static void parse( MetaTranslator *tor, const char *initialContext, const char *defaultContext ) { QMap<QCString, QCString> qualifiedContexts; QStringList namespaces; QCString context; QCString text; QCString com; QCString functionContext = initialContext; QCString prefix; bool utf8 = FALSE; bool missing_Q_OBJECT = FALSE; yyTok = getToken(); while ( yyTok != Tok_Eof ) { switch ( yyTok ) { case Tok_class: /* Partial support for inlined functions. */ yyTok = getToken(); if ( yyBraceDepth == (int) namespaces.count() && yyParenDepth == 0 ) { do { /* This code should execute only once, but we play safe with impure definitions such as 'class Q_EXPORT QMessageBox', in which case 'QMessageBox' is the class name, not 'Q_EXPORT'. */ functionContext = yyIdent; yyTok = getToken(); } while ( yyTok == Tok_Ident ); while ( yyTok == Tok_Gulbrandsen ) { yyTok = getToken(); functionContext += "::"; functionContext += yyIdent; yyTok = getToken(); } if ( yyTok == Tok_Colon ) { missing_Q_OBJECT = TRUE; } else { functionContext = defaultContext; } } break; case Tok_namespace: yyTok = getToken(); if ( yyTok == Tok_Ident ) { QCString ns = yyIdent; yyTok = getToken(); if ( yyTok == Tok_LeftBrace && yyBraceDepth == (int) namespaces.count() + 1 ) namespaces.append( QString(ns) ); } break; case Tok_tr: case Tok_trUtf8: utf8 = ( yyTok == Tok_trUtf8 ); yyTok = getToken(); if ( match(Tok_LeftParen) && matchString(&text) ) { com = ""; if ( match(Tok_RightParen) || (match(Tok_Comma) && matchString(&com) && match(Tok_RightParen)) ) { if ( prefix.isNull() ) { context = functionContext; if ( !namespaces.isEmpty() ) context.prepend( (namespaces.join(QString("::")) + QString("::")).latin1() ); } else { context = prefix; } prefix = (const char *) 0; if ( qualifiedContexts.contains(context) ) context = qualifiedContexts[context]; tor->insert( MetaTranslatorMessage(context, text, com, QString::null, utf8) ); if ( lacks_Q_OBJECT.contains(context) ) { qWarning( "%s:%d: Class '%s' lacks Q_OBJECT macro", (const char *) yyFileName, yyLineNo, (const char *) context ); lacks_Q_OBJECT.remove( context ); } else { needs_Q_OBJECT.insert( context, 0 ); } } } break; case Tok_translate: utf8 = FALSE; yyTok = getToken(); if ( match(Tok_LeftParen) && matchString(&context) && match(Tok_Comma) && matchString(&text) ) { com = ""; if ( match(Tok_RightParen) || (match(Tok_Comma) && matchString(&com) && (match(Tok_RightParen) || match(Tok_Comma) && matchEncoding(&utf8) && match(Tok_RightParen))) ) tor->insert( MetaTranslatorMessage(context, text, com, QString::null, utf8) ); } break; case Tok_Q_OBJECT: missing_Q_OBJECT = FALSE; yyTok = getToken(); break; case Tok_Ident: if ( !prefix.isNull() ) prefix += "::"; prefix += yyIdent; yyTok = getToken(); if ( yyTok != Tok_Gulbrandsen ) prefix = (const char *) 0; break; case Tok_Comment: com = yyComment; com = com.simplifyWhiteSpace(); if ( com.left(sizeof(MagicComment) - 1) == MagicComment ) { com.remove( 0, sizeof(MagicComment) - 1 ); int k = com.find( ' ' ); if ( k == -1 ) { context = com; } else { context = com.left( k ); com.remove( 0, k + 1 ); tor->insert( MetaTranslatorMessage(context, "", com, QString::null, FALSE) ); } /* Provide a backdoor for people using "using namespace". See the manual for details. */ k = 0; while ( (k = context.find("::", k)) != -1 ) { qualifiedContexts.insert( context.mid(k + 2), context ); k++; } } yyTok = getToken(); break; case Tok_Arrow: yyTok = getToken(); if ( yyTok == Tok_tr || yyTok == Tok_trUtf8 ) qWarning( "%s:%d: Cannot invoke tr() like this", (const char *) yyFileName, yyLineNo ); break; case Tok_Gulbrandsen: // at top level? if ( yyBraceDepth == (int) namespaces.count() && yyParenDepth == 0 ) functionContext = prefix; yyTok = getToken(); break; case Tok_RightBrace: case Tok_Semicolon: if ( yyBraceDepth >= 0 && yyBraceDepth + 1 == (int) namespaces.count() ) namespaces.remove( namespaces.fromLast() ); if ( yyBraceDepth == (int) namespaces.count() ) { if ( missing_Q_OBJECT ) { if ( needs_Q_OBJECT.contains(functionContext) ) { qWarning( "%s:%d: Class '%s' lacks Q_OBJECT macro", (const char *) yyFileName, yyLineNo, (const char *) functionContext ); } else { lacks_Q_OBJECT.insert( functionContext, 0 ); } } functionContext = defaultContext; missing_Q_OBJECT = FALSE; } yyTok = getToken(); break; default: yyTok = getToken(); } } if ( yyBraceDepth != 0 ) fprintf( stderr, "%s:%d: Unbalanced braces in C++ code (or abuse of the C++" " preprocessor)\n", (const char *)yyFileName, yyBraceLineNo ); else if ( yyParenDepth != 0 ) fprintf( stderr, "%s:%d: Unbalanced parentheses in C++ code (or abuse of the C++" " preprocessor)\n", (const char *)yyFileName, yyParenLineNo ); }
/*! Matches the string against the given wildcard pattern. Returns either MATCH_OK, or NO_MATCH when everything went fine, or values < 0 (see enum at the top of Query.cpp) if an error occurs. */ status_t matchString(char* pattern, char* string) { while (*pattern) { // end of string == valid end of pattern? if (!string[0]) { while (pattern[0] == '*') pattern++; return !pattern[0] ? MATCH_OK : NO_MATCH; } switch (*pattern++) { case '?': { // match exactly one UTF-8 character; we are // not interested in the result utf8ToUnicode(&string); break; } case '*': { // compact pattern while (true) { if (pattern[0] == '?') { if (!*++string) return NO_MATCH; } else if (pattern[0] != '*') break; pattern++; } // if the pattern is done, we have matched the string if (!pattern[0]) return MATCH_OK; while(true) { // we have removed all occurences of '*' and '?' if (pattern[0] == string[0] || pattern[0] == '[' || pattern[0] == '\\') { status_t status = matchString(pattern, string); if (status < B_OK || status == MATCH_OK) return status; } // we could be nice here and just jump to the next // UTF-8 character - but we wouldn't gain that much // and it'd be slower (since we're checking for // equality before entering the recursion) if (!*++string) return NO_MATCH; } break; } case '[': { bool invert = false; if (pattern[0] == '^' || pattern[0] == '!') { invert = true; pattern++; } if (!pattern[0] || pattern[0] == ']') return MATCH_BAD_PATTERN; uint32 c = utf8ToUnicode(&string); bool matched = false; while (pattern[0] != ']') { if (!pattern[0]) return MATCH_BAD_PATTERN; if (pattern[0] == '\\') pattern++; uint32 first = utf8ToUnicode(&pattern); // Does this character match, or is this a range? if (first == c) { matched = true; break; } else if (pattern[0] == '-' && pattern[1] != ']' && pattern[1]) { pattern++; if (pattern[0] == '\\') { pattern++; if (!pattern[0]) return MATCH_BAD_PATTERN; } uint32 last = utf8ToUnicode(&pattern); if (c >= first && c <= last) { matched = true; break; } } } if (invert) matched = !matched; if (matched) { while (pattern[0] != ']') { if (!pattern[0]) return MATCH_BAD_PATTERN; pattern++; } pattern++; break; } return NO_MATCH; } case '\\': if (!pattern[0]) return MATCH_BAD_PATTERN; // supposed to fall through default: if (pattern[-1] != string[0]) return NO_MATCH; string++; break; } } if (string[0]) return NO_MATCH; return MATCH_OK; }
static void parse( MetaTranslator *tor, const char *initialContext, const char *defaultContext ) { QMap<QByteArray, QByteArray> qualifiedContexts; QByteArray context; QByteArray text; QByteArray com; QByteArray functionContext = initialContext; QByteArray prefix; bool utf8 = false; yyTok = getToken(); while ( yyTok != Tok_Eof ) { switch ( yyTok ) { case Tok_class: yyTok = getToken(); functionContext = yyIdent; yyTok = getToken(); break; case Tok_tr: case Tok_trUtf8: utf8 = (yyTok == Tok_trUtf8 || (yyCodecForTr && strcmp(yyCodecForTr->name(), "UTF-8") == 0)); yyTok = getToken(); if (match(Tok_LeftParen) && matchString(&text)) { com = ""; bool plural = false; if (match(Tok_RightParen)) { // There is no comment or plural arguments. } else if (match(Tok_Comma) && matchStringOrNone(&com)) { // There is a comment argument. if (match(Tok_RightParen)) { // There is no plural argument. } else if (match(Tok_Comma)) { // There is a plural argument. plural = true; } } if (prefix.isNull()) context = defaultContext; else if (qstrcmp(prefix, "self") == 0) context = functionContext; else context = prefix; prefix = (const char *) 0; if (qualifiedContexts.contains(context)) context = qualifiedContexts[context]; if (!text.isEmpty()) { tor->insert(MetaTranslatorMessage(context, text, com, yyFileName, yyParenLineNo, QStringList(), utf8, MetaTranslatorMessage::Unfinished, plural)); } } break; case Tok_translate: utf8 = false; yyTok = getToken(); if ( match(Tok_LeftParen) && matchString(&context) && match(Tok_Comma) && matchString(&text) ) { com = ""; bool plural = false; if (!match(Tok_RightParen)) { // look for comment if ( match(Tok_Comma) && matchStringOrNone(&com)) { if (!match(Tok_RightParen)) { // look for encoding if (match(Tok_Comma)) { if (matchEncoding(&utf8)) { if (!match(Tok_RightParen)) { // look for the plural quantifier, // this can be a number, an identifier or a function call, // so for simplicity we mark it as plural if we know we have a comma instead of an // right parentheses. plural = match(Tok_Comma); } } else { // This can be a QTranslator::translate("context", "source", "comment", n) plural translation if (matchExpression() && match(Tok_RightParen)) { plural = true; } else { break; } } } else { break; } } } else { break; } } if (!text.isEmpty()) { tor->insert( MetaTranslatorMessage(context, text, com, yyFileName, yyParenLineNo, QStringList(), utf8, MetaTranslatorMessage::Unfinished, plural) ); } } break; case Tok_Ident: if ( !prefix.isNull() ) prefix += "."; prefix += yyIdent; yyTok = getToken(); if ( yyTok != Tok_Dot ) prefix = (const char *) 0; break; case Tok_Comment: com = yyComment; com = com.simplified(); if ( com.left(sizeof(MagicComment) - 1) == MagicComment ) { com.remove( 0, sizeof(MagicComment) - 1 ); int k = com.indexOf( ' ' ); if ( k == -1 ) { context = com; } else { context = com.left( k ); com.remove( 0, k + 1 ); tor->insert( MetaTranslatorMessage(context, "", com, yyFileName, yyParenLineNo, QStringList(), false) ); } } yyTok = getToken(); break; default: yyTok = getToken(); } } if ( yyParenDepth != 0 ) qWarning( "%s: Unbalanced parentheses in Python code", (const char *) yyFileName ); }
bool EventHandler::IsEqual(const char *str) { return matchString(str, this->name) == 0; }
static void parse( Translator *tor ) { QString text; QString com; QString extracomment; yyCh = getChar(); yyTok = getToken(); while ( yyTok != Tok_Eof ) { switch ( yyTok ) { case Tok_class: yyTok = getToken(); if(yyTok == Tok_Ident) { yyScope.push(new Scope(yyIdent, Scope::Clazz, yyLineNo)); } else { yyMsg() << qPrintable(LU::tr("'class' must be followed by a class name.\n")); break; } while (!match(Tok_LeftBrace)) { yyTok = getToken(); } break; case Tok_tr: yyTok = getToken(); if ( match(Tok_LeftParen) && matchString(text) ) { com.clear(); bool plural = false; if ( match(Tok_RightParen) ) { // no comment } else if (match(Tok_Comma) && matchStringOrNull(com)) { //comment if ( match(Tok_RightParen)) { // ok, } else if (match(Tok_Comma)) { plural = true; } } if (!text.isEmpty()) recordMessage(tor, context(), text, com, extracomment, plural); } break; case Tok_translate: { QString contextOverride; yyTok = getToken(); if ( match(Tok_LeftParen) && matchString(contextOverride) && match(Tok_Comma) && matchString(text) ) { com.clear(); bool plural = false; if (!match(Tok_RightParen)) { // look for comment if ( match(Tok_Comma) && matchStringOrNull(com)) { if (!match(Tok_RightParen)) { if (match(Tok_Comma) && matchExpression() && match(Tok_RightParen)) { plural = true; } else { break; } } } else { break; } } if (!text.isEmpty()) recordMessage(tor, contextOverride, text, com, extracomment, plural); } } break; case Tok_Ident: yyTok = getToken(); break; case Tok_Comment: if (yyComment.startsWith(QLatin1Char(':'))) { yyComment.remove(0, 1); extracomment.append(yyComment); } yyTok = getToken(); break; case Tok_RightBrace: if ( yyScope.isEmpty() ) { yyMsg() << qPrintable(LU::tr("Excess closing brace.\n")); } else delete (yyScope.pop()); extracomment.clear(); yyTok = getToken(); break; case Tok_LeftBrace: yyScope.push(new Scope(QString(), Scope::Other, yyLineNo)); yyTok = getToken(); break; case Tok_Semicolon: extracomment.clear(); yyTok = getToken(); break; case Tok_Package: yyTok = getToken(); while(!match(Tok_Semicolon)) { switch(yyTok) { case Tok_Ident: yyPackage.append(yyIdent); break; case Tok_Dot: yyPackage.append(QLatin1String(".")); break; default: yyMsg() << qPrintable(LU::tr("'package' must be followed by package name.\n")); break; } yyTok = getToken(); } break; default: yyTok = getToken(); } } if ( !yyScope.isEmpty() ) yyMsg(yyScope.top()->line) << qPrintable(LU::tr("Unbalanced opening brace.\n")); else if ( yyParenDepth != 0 ) yyMsg(yyParenLineNo) << qPrintable(LU::tr("Unbalanced opening parenthesis.\n")); }
WikiLexer::TOKEN WikiLexer::next_token( ) { QChar ch; m_lastToken = m_currentToken; m_lastChar = m_currentChar; m_currentChar = QChar(); if ( matchString ( "~" ) ) { if ( getChar ( &ch ) ) { m_currentChar = ch; m_currentToken = TOKEN_TEXT; } else m_currentToken = TOKEN_EOF; } else if ( matchString ( "\n\n" ) ) m_currentToken = TOKEN_PARA_BREAK; else if ( matchString ( "*****" ) ) m_currentToken = TOKEN_ULIST_5; else if ( matchString ( "****" ) ) m_currentToken = TOKEN_ULIST_4; else if ( matchString ( "***" ) ) m_currentToken = TOKEN_ULIST_3; else if ( matchString ( "**" ) ) m_currentToken = TOKEN_ULIST_2; else if ( matchString ( "*" ) ) m_currentToken = TOKEN_ULIST_1; else if ( matchString ( "#####" ) ) m_currentToken = TOKEN_OLIST_5; else if ( matchString ( "####" ) ) m_currentToken = TOKEN_OLIST_4; else if ( matchString ( "###" ) ) m_currentToken = TOKEN_OLIST_3; else if ( matchString ( "##" ) ) m_currentToken = TOKEN_OLIST_2; else if ( matchString ( "#" ) ) m_currentToken = TOKEN_OLIST_1; else if ( matchString ( "=====" ) ) m_currentToken = TOKEN_HEADING_5; else if ( matchString ( "====" ) ) m_currentToken = TOKEN_HEADING_4; else if ( matchString ( "===" ) ) m_currentToken = TOKEN_HEADING_3; else if ( matchString ( "==" ) ) m_currentToken = TOKEN_HEADING_2; else if ( matchString ( "=" ) ) m_currentToken = TOKEN_HEADING_1; else if ( matchString ( "{{{" ) ) m_currentToken = TOKEN_START_PRE; else if ( matchString ( "}}}" ) ) m_currentToken = TOKEN_END_PRE; else if ( matchString ( "|=" ) ) m_currentToken = TOKEN_TABLE_HEAD; else if ( matchString ( "|" ) ) m_currentToken = TOKEN_TABLE_CELL; else if ( matchString ( "\n" ) ) m_currentToken = TOKEN_NEWLINE; else if ( matchString ( "[[" ) ) m_currentToken = TOKEN_START_LINK; else if ( matchString ( "]]" ) ) m_currentToken = TOKEN_END_LINK; else if ( matchString ( "{{" ) ) m_currentToken = TOKEN_START_IMAGE; else if ( matchString ( "}}" ) ) m_currentToken = TOKEN_END_IMAGE; else if ( matchString ( "----" ) ) m_currentToken = TOKEN_HRULE; else if ( matchString ( "\\\\" ) ) m_currentToken = TOKEN_LINEBREAK; else if ( matchString ( "--" ) ) m_currentToken = TOKEN_CROSSOUT; else if ( matchString ( "__" ) ) m_currentToken = TOKEN_UNDERLINE; else if ( matchString ( "//" ) ) m_currentToken = TOKEN_ITALICS; else if ( matchString ( ",," ) ) m_currentToken = TOKEN_SUBSCRIPT; else if ( matchString ( "^^" ) ) m_currentToken = TOKEN_SUPERSCRIPT; else if ( matchString ( "<<" ) ) m_currentToken = TOKEN_START_PLACEHOLDER; else if ( matchString ( ">>" ) ) m_currentToken = TOKEN_END_PLACEHOLDER; else if ( matchString ( "http://" ) ) m_currentToken = TOKEN_URL_START; else if ( matchString ( "ftp://" ) ) m_currentToken = TOKEN_URL_START; else if ( matchString ( "https://" ) ) m_currentToken = TOKEN_URL_START; else if ( matchString ( "\t" ) || matchString ( " ") ) { m_currentToken = TOKEN_WHITESPACE; m_currentChar = ' '; } else if ( getChar ( &ch ) ) { m_currentChar = ch; m_currentToken = TOKEN_TEXT; } else m_currentToken = TOKEN_EOF; return m_currentToken; }
inline bool isLiteral(TToken &tk) { return matchNumber(tk)||matchBool(tk)|| matchChar(tk)|| matchString(tk); }
/* Code Reference : My Previous Submission */ int get_next_file(uint64_t previous, uint64_t base) { struct posix_header_ustar *start = (struct posix_header_ustar *) base; //print_posix_header(start); char *start_f = (char *) start->name; char *temp_start_f = (char *) start->name; char *temp = (char*) previous; struct posix_header_ustar *tar_p = (struct posix_header_ustar *) previous; char *previous_f = (char *) tar_p->name; print_posix_header(tar_p); int size = octal_decimal(atoi(tar_p->size)); int padding = 0; if (size % 512 != 0) { padding = 512 - size % 512; } temp = temp + 512 + size + padding; struct posix_header_ustar *next = (struct posix_header_ustar *) temp; char *next_f = (char *) next->name; if (contains(next_f, start_f)) { while (*next_f == *start_f) { next_f++; start_f++; } // printk("\n %s \n", next_f); char next_file_name[50] = { 0 }; int i = 0; while (*next_f != '\0') { if (*next_f == '/') { break; } next_file_name[i] = *next_f; next_f++; i++; } next_file_name[i] = '\0'; // printk("%s",next_file_name); // printk("\n %s ", temp_start_f); if (matchString(previous_f, temp_start_f) == 0) { // printk("\n Matced"); return 3; } while (*previous_f == *temp_start_f) { previous_f++; temp_start_f++; } // printk("\n sss: %s ", previous_f); char previous_file_name[50] = { 0 }; i = 0; while (*previous_f != '\0') { if (*previous_f == '/') { break; } previous_file_name[i] = *previous_f; previous_f++; i++; } previous_file_name[i] = '\0'; // printk(" %s",previous_file_name); if (matchString(previous_file_name, next_file_name) == 0) { // printk("\n Matced"); return 2; } else { // printk("\n Didinot match"); return 3; } // return 1; } else { return 1; } return 0; }
int RegularExpression::match(Context* const context, const Op* const operations , int offset, const short direction) { const Op* tmpOp = operations; bool ignoreCase = isSet(fOptions, IGNORE_CASE); while (true) { if (tmpOp == 0) break; if (offset > context->fLimit || offset < context->fStart) return -1; switch(tmpOp->getOpType()) { case Op::O_CHAR: if (!matchChar(context, tmpOp->getData(), offset, direction, ignoreCase)) return -1; tmpOp = tmpOp->getNextOp(); break; case Op::O_DOT: if (!matchDot(context, offset, direction)) return -1; tmpOp = tmpOp->getNextOp(); break; case Op::O_RANGE: case Op::O_NRANGE: if (!matchRange(context, tmpOp, offset, direction, ignoreCase)) return -1; tmpOp = tmpOp->getNextOp(); break; case Op::O_ANCHOR: if (!matchAnchor(context, tmpOp->getData(), offset)) return -1; tmpOp = tmpOp->getNextOp(); break; case Op::O_BACKREFERENCE: if (!matchBackReference(context, tmpOp->getData(), offset, direction, ignoreCase)) return -1; tmpOp = tmpOp->getNextOp(); break; case Op::O_STRING: if (!matchString(context, tmpOp->getLiteral(), offset, direction, ignoreCase)) return -1; tmpOp = tmpOp->getNextOp(); break; case Op::O_CLOSURE: { XMLInt32 id = tmpOp->getData(); if (id >= 0) { int prevOffset = context->fOffsets[id]; if (prevOffset < 0 || prevOffset != offset) { context->fOffsets[id] = offset; } else { context->fOffsets[id] = -1; tmpOp = tmpOp->getNextOp(); break; } } int ret = match(context, tmpOp->getChild(), offset, direction); if (id >= 0) { context->fOffsets[id] = -1; } if (ret >= 0) return ret; tmpOp = tmpOp->getNextOp(); } break; case Op::O_QUESTION: { int ret = match(context, tmpOp->getChild(), offset, direction); if (ret >= 0) return ret; tmpOp = tmpOp->getNextOp(); } break; case Op::O_NONGREEDYCLOSURE: case Op::O_NONGREEDYQUESTION: { int ret = match(context,tmpOp->getNextOp(),offset,direction); if (ret >= 0) return ret; tmpOp = tmpOp->getChild(); } break; case Op::O_UNION: { return matchUnion(context, tmpOp, offset, direction); } case Op::O_CAPTURE: if (context->fMatch != 0 && tmpOp->getData() != 0) return matchCapture(context, tmpOp, offset, direction); tmpOp = tmpOp->getNextOp(); break; case Op::O_LOOKAHEAD: if (0 > match(context, tmpOp->getChild(), offset, 1)) return -1; tmpOp = tmpOp->getNextOp(); break; case Op::O_NEGATIVELOOKAHEAD: if (0 <= match(context, tmpOp->getChild(), offset, 1)) return -1; tmpOp = tmpOp->getNextOp(); break; case Op::O_LOOKBEHIND: if (0 > match(context, tmpOp->getChild(), offset, -1)) return - 1; tmpOp = tmpOp->getNextOp(); break; case Op::O_NEGATIVELOOKBEHIND: if (0 <= match(context, tmpOp->getChild(), offset, -1)) return -1; tmpOp = tmpOp->getNextOp(); break; case Op::O_INDEPENDENT: case Op::O_MODIFIER: { int ret = (tmpOp->getOpType() == Op::O_INDEPENDENT) ? match(context, tmpOp->getChild(), offset, direction) : matchModifier(context, tmpOp, offset, direction); if (ret < 0) return ret; offset = ret; tmpOp = tmpOp->getNextOp(); } break; case Op::O_CONDITION: if (tmpOp->getRefNo() >= fNoGroups) return -1; if (matchCondition(context, tmpOp, offset, direction)) tmpOp = tmpOp->getYesFlow(); else if (tmpOp->getNoFlow() != 0) tmpOp = tmpOp->getNoFlow(); else tmpOp = tmpOp->getNextOp(); break; } } return offset; }
static void parse( MetaTranslator *tor, const char *initialContext, const char *defaultContext ) { QMap<QCString, QCString> qualifiedContexts; QStringList namespaces; QCString context; QCString ext; QCString text; QCString comment; QCString functionContext = initialContext; QCString prefix; bool utf8 = FALSE; yyTok = getToken(); while ( yyTok != Tok_Eof ) { switch ( yyTok ) { case Tok_i18n: utf8 = FALSE; yyTok = getToken(); if ( match( Tok_LeftParen ) && ( matchString( &context ) || matchSString( &context ) ) && match( Tok_Comma ) && ( matchString( &text ) || matchSString( &text ) ) ) { if ( ( match( Tok_Comma ) && ( matchString( &comment ) || matchSString( &comment ) ) && match( Tok_RightParen ) ) == false ) { comment = ""; } tor->insert( MetaTranslatorMessage( context, text, comment, QString::null, utf8 ) ); } // else // qDebug( " --- token failed ------------" ); break; case Tok_x18n: utf8 = FALSE; yyTok = getToken(); if ( match( Tok_LeftParen ) && ( matchString( &ext ) || matchSString( &ext ) ) && match( Tok_Comma ) && ( matchString( &context ) || matchSString( &context ) ) && match( Tok_Comma ) && ( matchString( &text ) || matchSString( &text ) ) ) { if ( ( match( Tok_Comma ) && ( matchString( &comment ) || matchSString( &comment ) ) && match( Tok_RightParen ) ) == false ) { comment = ""; } tor->insert( MetaTranslatorMessage( context, text, comment, QString::null, utf8 ) ); } // else // qDebug( " --- token failed ------------" ); break; case Tok_Ident: if ( !prefix.isNull() ) prefix += "::"; prefix += yyIdent; yyTok = getToken(); if ( yyTok != Tok_Gulbrandsen ) prefix = (const char *) 0; break; case Tok_Comment: comment = yyComment; comment = comment.simplifyWhiteSpace(); yyTok = getToken(); break; case Tok_Gulbrandsen: // at top level? if ( yyBraceDepth == (int) namespaces.count() && yyParenDepth == 0 ) functionContext = prefix; yyTok = getToken(); break; case Tok_RightBrace: case Tok_Semicolon: if ( yyBraceDepth >= 0 && yyBraceDepth + 1 == (int) namespaces.count() ) namespaces.remove( namespaces.fromLast() ); if ( yyBraceDepth == (int) namespaces.count() ) { functionContext = defaultContext; } yyTok = getToken(); break; default: yyTok = getToken(); } } // if ( yyBraceDepth != 0 ) // qWarning( "%s: Unbalanced braces in PHP code", (const char *) yyFileName ); // if ( yyParenDepth != 0 ) // qWarning( "%s: Unbalanced parentheses in PHP code", (const char *) yyFileName ); }