Var Var::parseObject(const std::string& val, std::string::size_type& pos) { poco_assert_dbg (val[pos] == '{'); ++pos; skipWhiteSpace(val, pos); DynamicStruct aStruct; while (val[pos] != '}' && pos < val.size()) { std::string key = parseString(val, pos); skipWhiteSpace(val, pos); if (val[pos] != ':') throw DataFormatException("Incorrect object, must contain: key : value pairs"); ++pos; // skip past : Var value = parse(val, pos); aStruct.insert(key, value); skipWhiteSpace(val, pos); if (val[pos] == ',') { ++pos; skipWhiteSpace(val, pos); } } if (val[pos] != '}') throw DataFormatException("Unterminated object"); ++pos; return aStruct; }
/** * Skips the opening "{" or "{#" depending upon the ending flag * @param str Pointer to a string structure * @param ending Flag indicating if it is an ending structure to expect a '#' * @return Returns 0 on failure, 1 on success **/ int skipOpen( pstring str, int ending ) { if (str == NULL ) { return 0; } skipWhiteSpace(str); if ( !atChar( str, '{' ) ) { return 0; } /// Skip the opening brace if ( incChar(str) == -1 ) { return 0; } /// Skip to the element id value or '#' if it is an end skipWhiteSpace(str); if ( ending ) { if (!atChar( str, '#') ) { return 0; } if ( incChar( str ) == -1 ) { return 0; } } return 1; }
WebVTTParser::ParseState WebVTTParser::collectTimingsAndSettings(const String& line) { // 4.8.10.13.3 Collect WebVTT cue timings and settings. // 1-3 - Let input be the string being parsed and position be a pointer into input unsigned position = 0; skipWhiteSpace(line, &position); // 4-5 - Collect a WebVTT timestamp. If that fails, then abort and return failure. Otherwise, let cue's text track cue start time be the collected time. m_currentStartTime = collectTimeStamp(line, &position); if (m_currentStartTime == malformedTime) return BadCue; if (position >= line.length()) return BadCue; skipWhiteSpace(line, &position); // 6-9 - If the next three characters are not "-->", abort and return failure. if (line.find("-->", position) == kNotFound) return BadCue; position += 3; if (position >= line.length()) return BadCue; skipWhiteSpace(line, &position); // 10-11 - Collect a WebVTT timestamp. If that fails, then abort and return failure. Otherwise, let cue's text track cue end time be the collected time. m_currentEndTime = collectTimeStamp(line, &position); if (m_currentEndTime == malformedTime) return BadCue; skipWhiteSpace(line, &position); // 12 - Parse the WebVTT settings for the cue (conducted in TextTrackCue). m_currentSettings = line.substring(position, line.length()-1); return CueText; }
SingleClauseArgs::SingleClauseArgs(std::string setClause, std::string argsStr) { clause = setClause; int index = skipWhiteSpace(argsStr, 0); if (clause == "if") { // Single argument always args.push_back(argsStr); } else { while (index < argsStr.size()) { int start = index; int end = seekPastToken(argsStr, index); std::string token = argsStr.substr(start, end - start); args.push_back(token); const int delimiterIndex = skipWhiteSpace(argsStr, end); if (!(delimiterIndex == argsStr.size() || argsStr.at(delimiterIndex) == ',' || argsStr.at(delimiterIndex) == ':')) { std::cerr << "Unexpected delimiter '" << argsStr.at(delimiterIndex) << "' in args '" << argsStr << "'" << std::endl; exit(1); } index = skipWhiteSpace(argsStr, delimiterIndex + 1); } } }
bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url) { unsigned len = refresh.length(); unsigned pos = 0; if (!skipWhiteSpace(refresh, pos, fromHttpEquivMeta)) return false; while (pos != len && refresh[pos] != ',' && refresh[pos] != ';') ++pos; if (pos == len) { // no URL url = String(); bool ok; delay = refresh.stripWhiteSpace().toDouble(&ok); return ok; } else { bool ok; delay = refresh.left(pos).stripWhiteSpace().toDouble(&ok); if (!ok) return false; ++pos; skipWhiteSpace(refresh, pos, fromHttpEquivMeta); unsigned urlStartPos = pos; if (refresh.find("url", urlStartPos, false) == urlStartPos) { urlStartPos += 3; skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); if (refresh[urlStartPos] == '=') { ++urlStartPos; skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); } else urlStartPos = pos; // e.g. "Refresh: 0; url.html" } unsigned urlEndPos = len; if (refresh[urlStartPos] == '"' || refresh[urlStartPos] == '\'') { UChar quotationMark = refresh[urlStartPos]; urlStartPos++; while (urlEndPos > urlStartPos) { urlEndPos--; if (refresh[urlEndPos] == quotationMark) break; } // https://bugs.webkit.org/show_bug.cgi?id=27868 // Sometimes there is no closing quote for the end of the URL even though there was an opening quote. // If we looped over the entire alleged URL string back to the opening quote, just go ahead and use everything // after the opening quote instead. if (urlEndPos == urlStartPos) urlEndPos = len; } url = refresh.substring(urlStartPos, urlEndPos - urlStartPos).stripWhiteSpace(); return true; } }
void loadSettingsFile (const std::string& file, CategorySettingValueMap& settings) { mFile = file; boost::filesystem::ifstream stream; stream.open(boost::filesystem::path(file)); std::cout << "Loading settings file: " << file << std::endl; std::string currentCategory; mLine = 0; while (!stream.eof() && !stream.fail()) { ++mLine; std::string line; std::getline( stream, line ); size_t i = 0; if (!skipWhiteSpace(i, line)) continue; if (line[i] == '#') // skip comment continue; if (line[i] == '[') { size_t end = line.find(']', i); if (end == std::string::npos) fail("unterminated category"); currentCategory = line.substr(i+1, end - (i+1)); boost::algorithm::trim(currentCategory); i = end+1; } if (!skipWhiteSpace(i, line)) continue; if (currentCategory.empty()) fail("empty category name"); size_t settingEnd = line.find('=', i); if (settingEnd == std::string::npos) fail("unterminated setting name"); std::string setting = line.substr(i, (settingEnd-i)); boost::algorithm::trim(setting); size_t valueBegin = settingEnd+1; std::string value = line.substr(valueBegin); boost::algorithm::trim(value); if (settings.insert(std::make_pair(std::make_pair(currentCategory, setting), value)).second == false) fail(std::string("duplicate setting: [" + currentCategory + "] " + setting)); } }
bool parseHTTPRefresh(const String& refresh, bool fromHttpEquivMeta, double& delay, String& url) { int len = refresh.length(); int pos = 0; if (!skipWhiteSpace(refresh, pos, fromHttpEquivMeta)) return false; while (pos != len && refresh[pos] != ',' && refresh[pos] != ';') ++pos; if (pos == len) { // no URL url = String(); bool ok; delay = refresh.stripWhiteSpace().toDouble(&ok); return ok; } else { bool ok; delay = refresh.left(pos).stripWhiteSpace().toDouble(&ok); if (!ok) return false; ++pos; skipWhiteSpace(refresh, pos, fromHttpEquivMeta); int urlStartPos = pos; if (refresh.find("url", urlStartPos, false) == urlStartPos) { urlStartPos += 3; skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); if (refresh[urlStartPos] == '=') { ++urlStartPos; skipWhiteSpace(refresh, urlStartPos, fromHttpEquivMeta); } else urlStartPos = pos; // e.g. "Refresh: 0; url.html" } int urlEndPos = len; if (refresh[urlStartPos] == '"' || refresh[urlStartPos] == '\'') { UChar quotationMark = refresh[urlStartPos]; urlStartPos++; while (urlEndPos > urlStartPos) { urlEndPos--; if (refresh[urlEndPos] == quotationMark) break; } } url = refresh.substring(urlStartPos, urlEndPos - urlStartPos).stripWhiteSpace(); return true; } }
/* parse a syslog name from the string. This is the generic code that is * called by the facility/severity functions. Note that we do not check the * validity of numerical values, something that should probably change over * time (TODO). -- rgerhards, 2008-02-14 */ static rsRetVal doSyslogName(uchar **pp, rsRetVal (*pSetHdlr)(void*, int), void *pVal, syslogName_t *pNameTable) { DEFiRet; cstr_t *pStrB; int iNewVal; ASSERT(pp != NULL); ASSERT(*pp != NULL); CHKiRet(getWord(pp, &pStrB)); /* get word */ iNewVal = decodeSyslogName(cstrGetSzStr(pStrB), pNameTable); if(pSetHdlr == NULL) { /* we should set value directly to var */ *((int*)pVal) = iNewVal; /* set new one */ } else { /* we set value via a set function */ CHKiRet(pSetHdlr(pVal, iNewVal)); } skipWhiteSpace(pp); /* skip over any whitespace */ finalize_it: if(pStrB != NULL) rsCStrDestruct(&pStrB); RETiRet; }
UCHAR getToken( unsigned n, // size of s[] UCHAR expected // STRING means get line ) // w/o checking for #;:= { char *s; char *end; int c; s = buf; end = buf + n; if (firstToken) { // global var ++line; firstToken = FALSE; // parser needs to see some kind of c = lgetc(); // newline to initialize it if ((colZero = (BOOL) !WHITESPACE(c))) { if (c == EOF) return(determineTokenFor(c,s,end)); else UngetTxtChr(c,file); return(NEWLINE); } return(NEWLINESPACE); } if (expected == STRING || expected == VALUE) { // get everything up to \n getString(expected,s,end); return(expected); } // were/are we c = skipWhiteSpace(FROMLOCAL); // past col 0? *s++ = (char) c; // save the letter *s = '\0'; // terminate s return(determineTokenFor(c,s,end)); }
/* parse a character from the config line * added 2007-07-17 by rgerhards * TODO: enhance this function to handle different classes of characters * HINT: check if char is ' and, if so, use 'c' where c may also be things * like \t etc. */ static rsRetVal doGetChar(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal) { DEFiRet; assert(pp != NULL); assert(*pp != NULL); skipWhiteSpace(pp); /* skip over any whitespace */ /* if we are not at a '\0', we have our new char - no validity checks here... */ if(**pp == '\0') { errmsg.LogError(0, RS_RET_NOT_FOUND, "No character available"); iRet = RS_RET_NOT_FOUND; } else { if(pSetHdlr == NULL) { /* we should set value directly to var */ *((uchar*)pVal) = **pp; } else { /* we set value via a set function */ CHKiRet(pSetHdlr(pVal, **pp)); } ++(*pp); /* eat processed char */ } finalize_it: RETiRet; }
int* ITFReader::decodeEnd(Ref<BitArray> row) { // For convenience, reverse the row and then // search from 'the start' for the end block row->reverse(); int* endPattern = 0; try { int endStart = skipWhiteSpace(row); endPattern = findGuardPattern(row, endStart, END_PATTERN_REVERSED, END_PATTERN_REVERSED_LEN); // The start & end patterns must be pre/post fixed by a quiet zone. This // zone must be at least 10 times the width of a narrow line. // ref: http://www.barcode-1.net/i25code.html validateQuietZone(row, endPattern[0]); // Now recalculate the indices of where the 'endblock' starts & stops to // accommodate // the reversed nature of the search int temp = endPattern[0]; endPattern[0] = (int)(row->getSize() - endPattern[1]); endPattern[1] = (int)(row->getSize() - temp); row->reverse(); return endPattern; } catch (ReaderException const& re) { delete [] endPattern; row->reverse(); throw re; } }
void THtmlParser::parseCloseTag() { ++pos; skipWhiteSpace(); QString tag = parseWord(); skipUpTo(">"); // Finds corresponding open element int i = lastIndex(); while (i > 0) { if (!tag.isEmpty() && at(i).tag.toLower() == tag.toLower() && !isElementClosed(i)) { break; } i = at(i).parent; } if (i > 0) { at(i).tagClosed = true; } else { // Can't find a corresponding open element last().text += QLatin1String("</"); last().text += tag; last().text += QLatin1Char('>'); return; } // Append a empty element for next entry int p = at(i).parent; appendNewElement(p); }
/* Parse and interpret an on/off inside a config file line. This is most * often used for boolean options, but of course it may also be used * for other things. The passed-in pointer is updated to point to * the first unparsed character on exit. Function emits error messages * if the value is neither on or off. It returns 0 if the option is off, * 1 if it is on and another value if there was an error. * rgerhards, 2007-07-15 */ static int doParseOnOffOption(uchar **pp) { uchar *pOptStart; uchar szOpt[32]; assert(pp != NULL); assert(*pp != NULL); pOptStart = *pp; skipWhiteSpace(pp); /* skip over any whitespace */ if(getSubString(pp, (char*) szOpt, sizeof(szOpt), ' ') != 0) { errmsg.LogError(0, NO_ERRCODE, "Invalid $-configline - could not extract on/off option"); return -1; } if(!strcmp((char*)szOpt, "on")) { return 1; } else if(!strcmp((char*)szOpt, "off")) { return 0; } else { errmsg.LogError(0, NO_ERRCODE, "Option value must be on or off, but is '%s'", (char*)pOptStart); return -1; } }
/* * returns string containing the value; 0 when out of memory; empty string when no value found * allocates memory for value on heap */ static char* readValue(char* line) { char* temp; char* value = NULL; temp = line; /* move after option name (next whitespace) */ for(; *temp!='\0' && *temp!='\n' && *temp!='\r' && *temp!=' ' && *temp!='\t'; temp++) ; temp = skipWhiteSpace(temp); stripSpaceAtEnd(temp); if(*temp) { value = malloc(strlen(temp) + 1); if(!value) /* out of memory */ return NULL; strcpy(value, temp); return value; } else { value = calloc(1, sizeof(char)); if(!value) /* out of memory */ return NULL; return value; } }
/* parse a whitespace-delimited word from the provided string. This is a * helper function for a number of syntaxes. The parsed value is returned * in ppStrB (which must be provided by caller). * rgerhards, 2008-02-14 */ static rsRetVal getWord(uchar **pp, cstr_t **ppStrB) { DEFiRet; uchar *p; ASSERT(pp != NULL); ASSERT(*pp != NULL); ASSERT(ppStrB != NULL); CHKiRet(cstrConstruct(ppStrB)); skipWhiteSpace(pp); /* skip over any whitespace */ /* parse out the word */ p = *pp; while(*p && !isspace((int) *p)) { CHKiRet(cstrAppendChar(*ppStrB, *p++)); } CHKiRet(cstrFinalize(*ppStrB)); *pp = p; finalize_it: RETiRet; }
/* ugly workaround to handle facility numbers; values * derived from names need to be eight times smaller, * i.e.: 0..23 */ static rsRetVal facilityHdlr(uchar **pp, void *pVal) { DEFiRet; char *p; skipWhiteSpace(pp); p = (char *) *pp; if (isdigit((int) *p)) { *((int *) pVal) = (int) strtol(p, (char **) pp, 10); } else { int len; syslogName_t *c; for (len = 0; p[len] && !isspace((int) p[len]); len++) /* noop */; for (c = syslogFacNames; c->c_name; c++) { if (!strncasecmp(p, (char *) c->c_name, len)) { *((int *) pVal) = LOG_FAC(c->c_val); break; } } *pp += len; } RETiRet; }
/* Parse and a word config line option. A word is a consequtive * sequence of non-whitespace characters. pVal must be * a pointer to a string which is to receive the option * value. The returned string must be freed by the caller. * rgerhards, 2007-09-07 * To facilitate multiple instances of the same command line * directive, doGetWord() now checks if pVal is already a * non-NULL pointer. If so, we assume it was created by a previous * incarnation and is automatically freed. This happens only when * no custom handler is defined. If it is, the customer handler * must do the cleanup. I have checked and this was al also memory * leak with some code. Obviously, not a large one. -- rgerhards, 2007-12-20 * Just to clarify: if pVal is parsed to a custom handler, this handler * is responsible for freeing pVal. -- rgerhards, 2008-03-20 */ static rsRetVal doGetWord(uchar **pp, rsRetVal (*pSetHdlr)(void*, uchar*), void *pVal) { DEFiRet; cstr_t *pStrB = NULL; uchar *pNewVal; ASSERT(pp != NULL); ASSERT(*pp != NULL); CHKiRet(getWord(pp, &pStrB)); CHKiRet(cstrConvSzStrAndDestruct(&pStrB, &pNewVal, 0)); DBGPRINTF("doGetWord: get newval '%s' (len %d), hdlr %p\n", pNewVal, (int) ustrlen(pNewVal), pSetHdlr); /* we got the word, now set it */ if(pSetHdlr == NULL) { /* we should set value directly to var */ if(*((uchar**)pVal) != NULL) free(*((uchar**)pVal)); /* free previous entry */ *((uchar**)pVal) = pNewVal; /* set new one */ } else { /* we set value via a set function */ CHKiRet(pSetHdlr(pVal, pNewVal)); } skipWhiteSpace(pp); /* skip over any whitespace */ finalize_it: if(iRet != RS_RET_OK) { if(pStrB != NULL) cstrDestruct(&pStrB); } RETiRet; }
/** * If the first none space character is a quotation mark, returns the string * between two quotation marks, else returns the content before the first comma. * Updates *p_cur. */ static char *nextTok(char **p_cur) { char *ret = NULL; skipWhiteSpace(p_cur); if (*p_cur == NULL) { ret = NULL; } else if (**p_cur == '"') { enum State {END, NORMAL, ESCAPE} state = NORMAL; (*p_cur)++; ret = *p_cur; while (state != END) { switch (state) { case NORMAL: switch (**p_cur) { case '\\': state = ESCAPE; break; case '"': state = END; break; case '\0': /* * Error case, parsing string is not quoted by ending * double quote, e.g. "bla bla, this function expects input * string to be NULL terminated, so that the loop can exit. */ ret = NULL; goto exit; default: /* Stays in normal case. */ break; } break; case ESCAPE: state = NORMAL; break; default: /* This should never happen. */ break; } if (state == END) { **p_cur = '\0'; } (*p_cur)++; } skipNextComma(p_cur); } else { ret = strsep(p_cur, ","); } exit: return ret; }
static int isComment(const char* line) { line = skipWhiteSpace(line); if(*line == '#') return 1; else return 0; }
void parseNumber() { skipWhiteSpace(); while (!eof() && !isWhiteSpace() && (isSign() || isDot() || isDigit())) { put(); next(); } }
/* extract a groupname and return its gid. * rgerhards, 2007-07-17 */ static rsRetVal doGetGID(uchar **pp, rsRetVal (*pSetHdlr)(void*, uid_t), void *pVal) { struct group *pgBuf = NULL; struct group gBuf; DEFiRet; uchar szName[256]; int bufSize = 1024; char * stringBuf = NULL; int err; assert(pp != NULL); assert(*pp != NULL); if(getSubString(pp, (char*) szName, sizeof(szName), ' ') != 0) { errmsg.LogError(0, RS_RET_NOT_FOUND, "could not extract group name"); ABORT_FINALIZE(RS_RET_NOT_FOUND); } do { char *p; /* Increase bufsize and try again.*/ bufSize *= 2; CHKmalloc(p = realloc(stringBuf, bufSize)); stringBuf = p; err = getgrnam_r((char*)szName, &gBuf, stringBuf, bufSize, &pgBuf); } while((pgBuf == NULL) && (err == ERANGE)); if(pgBuf == NULL) { if (err != 0) { errmsg.LogError(err, RS_RET_NOT_FOUND, "Query for group '%s' resulted in an error", szName); } else { errmsg.LogError(0, RS_RET_NOT_FOUND, "ID for group '%s' could not be found", szName); } iRet = RS_RET_NOT_FOUND; } else { if(pSetHdlr == NULL) { /* we should set value directly to var */ *((gid_t*)pVal) = pgBuf->gr_gid; } else { /* we set value via a set function */ CHKiRet(pSetHdlr(pVal, pgBuf->gr_gid)); } dbgprintf("gid %d obtained for group '%s'\n", (int) pgBuf->gr_gid, szName); } skipWhiteSpace(pp); /* skip over any whitespace */ finalize_it: free(stringBuf); RETiRet; }
Var Var::parseArray(const std::string& val, std::string::size_type& pos) { poco_assert_dbg (val[pos] == '['); ++pos; skipWhiteSpace(val, pos); std::vector<Var> result; while (val[pos] != ']' && pos < val.size()) { result.push_back(parse(val, pos)); skipWhiteSpace(val, pos); if (val[pos] == ',') { ++pos; skipWhiteSpace(val, pos); } } if (val[pos] != ']') throw DataFormatException("Unterminated array"); ++pos; return result; }
QList<QPair<QString, QString>> THtmlParser::parseAttributes() { QList<QPair<QString, QString>> attrs; QString newline, key, value; while (pos < txt.length()) { int cr = 0, lf = 0; skipWhiteSpace(&cr, &lf); if (txt.at(pos) == QLatin1Char('>') || txt.at(pos) == QLatin1Char('/')) { break; } // Newline if (lf > 0) { newline = (lf == cr) ? QLatin1String("\r\n") : QLatin1String("\n"); attrs << qMakePair(newline, QString()); // Appends the newline as a attribute } // Appends the key-value key = parseWord(); if (key.isEmpty()) { break; } skipWhiteSpace(); if (pos < txt.length() && txt.at(pos) == QLatin1Char('=')) { pos++; skipWhiteSpace(); value = parseWord(); } else { value.clear(); } attrs << qMakePair(key, value); } return attrs; }
void myParser::charData(const XML_Char *s, int len) { const int leadingSpace = skipWhiteSpace(s); if (len==0 || len==leadingSpace) return; // called with whitespace between elements WriteIndent(); /* write out the user data bracketed by ()*/ putchar('('); fwrite(s, len, 1, stdout); puts(")"); }
//NOTE: I DO NOT deal with comments in the PGM image file, so it will //be completely screwed up if a (###comment like this) is there. GIMP //does this, so when I was testing this and saved images from GIMP, I had //to go into a hex editor and remove the comments void PGMImage::parseData(BYTE* data, ptype size) { string sdata((char*)data); //Optional: Output magic number P5 ptype index = 2; skipWhiteSpace(&sdata, &index); width = getint(&sdata, &index); skipWhiteSpace(&sdata, &index); height = getint(&sdata, &index); skipWhiteSpace(&sdata, &index); maxvalue = getint(&sdata, &index); skipWhiteSpace(&sdata, &index); //////////////////////////////////////// ///Now store the image data /////////////////////////////////////// skipWhiteSpace(&sdata, &index); int imgindex = 0; //cout << width << " x " << height << "\n\n\n"; imgdata = new BYTE[width * height]; while (index < size && imgindex < width * height) { imgdata[imgindex] = data[index]; index++;imgindex++; } }
bool IniFile::getValue(const char* section, const char* key, char* buffer, size_t len, IniFileState &state) const { bool done = false; if (!_file.isOpen()) { _error = errorFileNotOpen; return true; } switch (state.getValueState) { case IniFileState::funcUnset: state.getValueState = (section == NULL ? IniFileState::funcFindKey : IniFileState::funcFindSection); state.readLinePosition = 0; break; case IniFileState::funcFindSection: if (findSection(section, buffer, len, state)) { if (_error != errorNoError) return true; state.getValueState = IniFileState::funcFindKey; } break; case IniFileState::funcFindKey: char *cp; if (findKey(section, key, buffer, len, &cp, state)) { if (_error != errorNoError) return true; // Found key line in correct section cp = skipWhiteSpace(cp); removeTrailingWhiteSpace(cp); // Copy from cp to buffer, but the strings overlap so strcpy is out while (*cp != '\0') *buffer++ = *cp++; *buffer = '\0'; return true; } break; default: // How did this happen? _error = errorUnknownError; done = true; break; } return done; }
const char *StringTokenizer::nextToken() { skipWhiteSpace(); char *q=buffer; while(*p && !isWhiteSpace(*p)) { *q=*p; ++p, ++q; } *q='\0'; return buffer; }
int8_t IniFile::findSection(const char* section, char* buffer, int len, IniFileState &state) const { if (section == NULL) return errorSectionNotFound; int8_t done = IniFile::readLine(_file, buffer, len, state.readLinePosition); if (done < 0) return done; char *cp = skipWhiteSpace(buffer); if (isCommentChar(*cp)) return (done ? errorSectionNotFound : 0); if (*cp == '[') { // Start of section ++cp; cp = skipWhiteSpace(cp); char *ep = strchr(cp, ']'); if (ep != NULL) { *ep = '\0'; // make ] be end of string removeTrailingWhiteSpace(cp); if (_caseSensitive) { if (strcmp(cp, section) == 0) return 1; } else { if (strcasecmp(cp, section) == 0) return 1; } } } // Not a valid section line return (done ? errorSectionNotFound : 0); }
static OBJ readList(OBJ inStream){ int ch; OBJ car, cdr; ch = skipWhiteSpace(inStream); if( ch == ')'){ return js_nil; } unreadChar(inStream, ch); car = js_read(inStream); cdr = readList(inStream); return newCons(car, cdr); }
void PolicyTokenizer::generateTokens(policyTokens& outTokens) { POLICYTOKENIZERLOG(("PolicyTokenizer::generateTokens")); // dirAndSrcs holds one set of [ name, src, src, src, ... ] nsTArray<nsString> dirAndSrcs; while (!atEnd()) { generateNextToken(); dirAndSrcs.AppendElement(mCurToken); skipWhiteSpace(); if (atEnd() || accept(SEMICOL)) { outTokens.AppendElement(std::move(dirAndSrcs)); dirAndSrcs.ClearAndRetainStorage(); } } }