int GMScanner::yylex() { if (itsCurrentPosition == 0) { itsIs >> std::ws; itsCurrentPosition = JTellg(*itsIs); itsCurrentHeaderStart = itsCurrentPosition; itsText = JReadLine(*itsIs); JRegex regex; JBoolean matched; JArray<JStringRange>* subList = new JArray<JStringRange>; assert(subList != NULL); err = regex.SetPattern("^From[[:space:]]+.*.{3}[[:space:]]+.{3}[[:space:]]+[[:digit:]]+[[:space:]]+[[:digit:]]+:[[:digit:]]+:[[:digit:]]+[[:space:]]+[[:digit:]]{4}"); assert(err.OK()); matched = regex.Match(itsText, subList); delete subList; if (matched) { itsState = kHeaderStart; return itsState; } }
JBoolean MatchesCookie ( const JCharacter* cookie, const JDirEntry& entry ) { JString file = entry.GetFullName(); if (!JFileReadable(file)) { return kJFalse; } mode_t perms; JError err = JGetPermissions(file, &perms); if (!err.OK()) { perms = 0600; } ifstream is(file); is >> ws; JString line1 = JReadLine(is); is.close(); if (line1 == "") { return kJTrue; } JArray<JIndexRange> subList; JRegex regex; err = regex.SetPattern(cookie); JBoolean matched = regex.Match(line1, &subList); if (matched) { return kJTrue; } return kJFalse; }