1 //===- FileCheck.cpp - Check that File's Contents match what is expected --===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // FileCheck does a line-by line check of a file that validates whether it
11 // contains the expected content. This is useful for regression tests etc.
13 // This program exits with an error status of 2 on error, exit status of 0 if
14 // the file matched the expected contents, and exit status of 1 if it did not
15 // contain the expected contents.
17 //===----------------------------------------------------------------------===//
19 #include "llvm/ADT/OwningPtr.h"
20 #include "llvm/Support/CommandLine.h"
21 #include "llvm/Support/MemoryBuffer.h"
22 #include "llvm/Support/PrettyStackTrace.h"
23 #include "llvm/Support/Regex.h"
24 #include "llvm/Support/SourceMgr.h"
25 #include "llvm/Support/raw_ostream.h"
26 #include "llvm/Support/Signals.h"
27 #include "llvm/Support/system_error.h"
28 #include "llvm/ADT/SmallString.h"
29 #include "llvm/ADT/StringMap.h"
33 static cl::opt<std::string>
34 CheckFilename(cl::Positional, cl::desc("<check-file>"), cl::Required);
36 static cl::opt<std::string>
37 InputFilename("input-file", cl::desc("File to check (defaults to stdin)"),
38 cl::init("-"), cl::value_desc("filename"));
40 static cl::opt<std::string>
41 CheckPrefix("check-prefix", cl::init("CHECK"),
42 cl::desc("Prefix to use from check file (defaults to 'CHECK')"));
45 NoCanonicalizeWhiteSpace("strict-whitespace",
46 cl::desc("Do not treat all horizontal whitespace as equivalent"));
48 //===----------------------------------------------------------------------===//
49 // Pattern Handling Code.
50 //===----------------------------------------------------------------------===//
55 /// MatchEOF - When set, this pattern only matches the end of file. This is
56 /// used for trailing CHECK-NOTs.
59 /// FixedStr - If non-empty, this pattern is a fixed string match with the
60 /// specified fixed string.
63 /// RegEx - If non-empty, this is a regex pattern.
66 /// VariableUses - Entries in this vector map to uses of a variable in the
67 /// pattern, e.g. "foo[[bar]]baz". In this case, the RegExStr will contain
68 /// "foobaz" and we'll get an entry in this vector that tells us to insert the
69 /// value of bar at offset 3.
70 std::vector<std::pair<StringRef, unsigned> > VariableUses;
72 /// VariableDefs - Entries in this vector map to definitions of a variable in
73 /// the pattern, e.g. "foo[[bar:.*]]baz". In this case, the RegExStr will
74 /// contain "foo(.*)baz" and VariableDefs will contain the pair "bar",1. The
75 /// index indicates what parenthesized value captures the variable value.
76 std::vector<std::pair<StringRef, unsigned> > VariableDefs;
80 Pattern(bool matchEOF = false) : MatchEOF(matchEOF) { }
82 bool ParsePattern(StringRef PatternStr, SourceMgr &SM);
84 /// Match - Match the pattern string against the input buffer Buffer. This
85 /// returns the position that is matched or npos if there is no match. If
86 /// there is a match, the size of the matched string is returned in MatchLen.
88 /// The VariableTable StringMap provides the current values of filecheck
89 /// variables and is updated if this match defines new values.
90 size_t Match(StringRef Buffer, size_t &MatchLen,
91 StringMap<StringRef> &VariableTable) const;
93 /// PrintFailureInfo - Print additional information about a failure to match
94 /// involving this pattern.
95 void PrintFailureInfo(const SourceMgr &SM, StringRef Buffer,
96 const StringMap<StringRef> &VariableTable) const;
99 static void AddFixedStringToRegEx(StringRef FixedStr, std::string &TheStr);
100 bool AddRegExToRegEx(StringRef RegExStr, unsigned &CurParen, SourceMgr &SM);
102 /// ComputeMatchDistance - Compute an arbitrary estimate for the quality of
103 /// matching this pattern at the start of \arg Buffer; a distance of zero
104 /// should correspond to a perfect match.
105 unsigned ComputeMatchDistance(StringRef Buffer,
106 const StringMap<StringRef> &VariableTable) const;
110 bool Pattern::ParsePattern(StringRef PatternStr, SourceMgr &SM) {
111 PatternLoc = SMLoc::getFromPointer(PatternStr.data());
113 // Ignore trailing whitespace.
114 while (!PatternStr.empty() &&
115 (PatternStr.back() == ' ' || PatternStr.back() == '\t'))
116 PatternStr = PatternStr.substr(0, PatternStr.size()-1);
118 // Check that there is something on the line.
119 if (PatternStr.empty()) {
120 SM.PrintMessage(PatternLoc, "found empty check string with prefix '" +
121 CheckPrefix+":'", "error");
125 // Check to see if this is a fixed string, or if it has regex pieces.
126 if (PatternStr.size() < 2 ||
127 (PatternStr.find("{{") == StringRef::npos &&
128 PatternStr.find("[[") == StringRef::npos)) {
129 FixedStr = PatternStr;
133 // Paren value #0 is for the fully matched string. Any new parenthesized
134 // values add from there.
135 unsigned CurParen = 1;
137 // Otherwise, there is at least one regex piece. Build up the regex pattern
138 // by escaping scary characters in fixed strings, building up one big regex.
139 while (!PatternStr.empty()) {
141 if (PatternStr.startswith("{{")) {
143 // Otherwise, this is the start of a regex match. Scan for the }}.
144 size_t End = PatternStr.find("}}");
145 if (End == StringRef::npos) {
146 SM.PrintMessage(SMLoc::getFromPointer(PatternStr.data()),
147 "found start of regex string with no end '}}'","error");
151 if (AddRegExToRegEx(PatternStr.substr(2, End-2), CurParen, SM))
154 PatternStr = PatternStr.substr(End+2);
158 // Named RegEx matches. These are of two forms: [[foo:.*]] which matches .*
159 // (or some other regex) and assigns it to the FileCheck variable 'foo'. The
160 // second form is [[foo]] which is a reference to foo. The variable name
161 // itself must be of the form "[a-zA-Z_][0-9a-zA-Z_]*", otherwise we reject
162 // it. This is to catch some common errors.
163 if (PatternStr.startswith("[[")) {
164 // Verify that it is terminated properly.
165 size_t End = PatternStr.find("]]");
166 if (End == StringRef::npos) {
167 SM.PrintMessage(SMLoc::getFromPointer(PatternStr.data()),
168 "invalid named regex reference, no ]] found", "error");
172 StringRef MatchStr = PatternStr.substr(2, End-2);
173 PatternStr = PatternStr.substr(End+2);
175 // Get the regex name (e.g. "foo").
176 size_t NameEnd = MatchStr.find(':');
177 StringRef Name = MatchStr.substr(0, NameEnd);
180 SM.PrintMessage(SMLoc::getFromPointer(Name.data()),
181 "invalid name in named regex: empty name", "error");
185 // Verify that the name is well formed.
186 for (unsigned i = 0, e = Name.size(); i != e; ++i)
187 if (Name[i] != '_' && !isalnum(Name[i])) {
188 SM.PrintMessage(SMLoc::getFromPointer(Name.data()+i),
189 "invalid name in named regex", "error");
193 // Name can't start with a digit.
194 if (isdigit(Name[0])) {
195 SM.PrintMessage(SMLoc::getFromPointer(Name.data()),
196 "invalid name in named regex", "error");
201 if (NameEnd == StringRef::npos) {
202 VariableUses.push_back(std::make_pair(Name, RegExStr.size()));
206 // Handle [[foo:.*]].
207 VariableDefs.push_back(std::make_pair(Name, CurParen));
211 if (AddRegExToRegEx(MatchStr.substr(NameEnd+1), CurParen, SM))
217 // Handle fixed string matches.
218 // Find the end, which is the start of the next regex.
219 size_t FixedMatchEnd = PatternStr.find("{{");
220 FixedMatchEnd = std::min(FixedMatchEnd, PatternStr.find("[["));
221 AddFixedStringToRegEx(PatternStr.substr(0, FixedMatchEnd), RegExStr);
222 PatternStr = PatternStr.substr(FixedMatchEnd);
229 void Pattern::AddFixedStringToRegEx(StringRef FixedStr, std::string &TheStr) {
230 // Add the characters from FixedStr to the regex, escaping as needed. This
231 // avoids "leaning toothpicks" in common patterns.
232 for (unsigned i = 0, e = FixedStr.size(); i != e; ++i) {
233 switch (FixedStr[i]) {
234 // These are the special characters matched in "p_ere_exp".
250 TheStr += FixedStr[i];
256 bool Pattern::AddRegExToRegEx(StringRef RegexStr, unsigned &CurParen,
260 if (!R.isValid(Error)) {
261 SM.PrintMessage(SMLoc::getFromPointer(RegexStr.data()),
262 "invalid regex: " + Error, "error");
266 RegExStr += RegexStr.str();
267 CurParen += R.getNumMatches();
271 /// Match - Match the pattern string against the input buffer Buffer. This
272 /// returns the position that is matched or npos if there is no match. If
273 /// there is a match, the size of the matched string is returned in MatchLen.
274 size_t Pattern::Match(StringRef Buffer, size_t &MatchLen,
275 StringMap<StringRef> &VariableTable) const {
276 // If this is the EOF pattern, match it immediately.
279 return Buffer.size();
282 // If this is a fixed string pattern, just match it now.
283 if (!FixedStr.empty()) {
284 MatchLen = FixedStr.size();
285 return Buffer.find(FixedStr);
290 // If there are variable uses, we need to create a temporary string with the
292 StringRef RegExToMatch = RegExStr;
294 if (!VariableUses.empty()) {
297 unsigned InsertOffset = 0;
298 for (unsigned i = 0, e = VariableUses.size(); i != e; ++i) {
299 StringMap<StringRef>::iterator it =
300 VariableTable.find(VariableUses[i].first);
301 // If the variable is undefined, return an error.
302 if (it == VariableTable.end())
303 return StringRef::npos;
305 // Look up the value and escape it so that we can plop it into the regex.
307 AddFixedStringToRegEx(it->second, Value);
309 // Plop it into the regex at the adjusted offset.
310 TmpStr.insert(TmpStr.begin()+VariableUses[i].second+InsertOffset,
311 Value.begin(), Value.end());
312 InsertOffset += Value.size();
315 // Match the newly constructed regex.
316 RegExToMatch = TmpStr;
320 SmallVector<StringRef, 4> MatchInfo;
321 if (!Regex(RegExToMatch, Regex::Newline).match(Buffer, &MatchInfo))
322 return StringRef::npos;
324 // Successful regex match.
325 assert(!MatchInfo.empty() && "Didn't get any match");
326 StringRef FullMatch = MatchInfo[0];
328 // If this defines any variables, remember their values.
329 for (unsigned i = 0, e = VariableDefs.size(); i != e; ++i) {
330 assert(VariableDefs[i].second < MatchInfo.size() &&
331 "Internal paren error");
332 VariableTable[VariableDefs[i].first] = MatchInfo[VariableDefs[i].second];
335 MatchLen = FullMatch.size();
336 return FullMatch.data()-Buffer.data();
339 unsigned Pattern::ComputeMatchDistance(StringRef Buffer,
340 const StringMap<StringRef> &VariableTable) const {
341 // Just compute the number of matching characters. For regular expressions, we
342 // just compare against the regex itself and hope for the best.
344 // FIXME: One easy improvement here is have the regex lib generate a single
345 // example regular expression which matches, and use that as the example
347 StringRef ExampleString(FixedStr);
348 if (ExampleString.empty())
349 ExampleString = RegExStr;
351 // Only compare up to the first line in the buffer, or the string size.
352 StringRef BufferPrefix = Buffer.substr(0, ExampleString.size());
353 BufferPrefix = BufferPrefix.split('\n').first;
354 return BufferPrefix.edit_distance(ExampleString);
357 void Pattern::PrintFailureInfo(const SourceMgr &SM, StringRef Buffer,
358 const StringMap<StringRef> &VariableTable) const{
359 // If this was a regular expression using variables, print the current
361 if (!VariableUses.empty()) {
362 for (unsigned i = 0, e = VariableUses.size(); i != e; ++i) {
363 StringRef Var = VariableUses[i].first;
364 StringMap<StringRef>::const_iterator it = VariableTable.find(Var);
365 SmallString<256> Msg;
366 raw_svector_ostream OS(Msg);
368 // Check for undefined variable references.
369 if (it == VariableTable.end()) {
370 OS << "uses undefined variable \"";
371 OS.write_escaped(Var) << "\"";;
373 OS << "with variable \"";
374 OS.write_escaped(Var) << "\" equal to \"";
375 OS.write_escaped(it->second) << "\"";
378 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), OS.str(), "note",
383 // Attempt to find the closest/best fuzzy match. Usually an error happens
384 // because some string in the output didn't exactly match. In these cases, we
385 // would like to show the user a best guess at what "should have" matched, to
386 // save them having to actually check the input manually.
387 size_t NumLinesForward = 0;
388 size_t Best = StringRef::npos;
389 double BestQuality = 0;
391 // Use an arbitrary 4k limit on how far we will search.
392 for (size_t i = 0, e = std::min(size_t(4096), Buffer.size()); i != e; ++i) {
393 if (Buffer[i] == '\n')
396 // Patterns have leading whitespace stripped, so skip whitespace when
397 // looking for something which looks like a pattern.
398 if (Buffer[i] == ' ' || Buffer[i] == '\t')
401 // Compute the "quality" of this match as an arbitrary combination of the
402 // match distance and the number of lines skipped to get to this match.
403 unsigned Distance = ComputeMatchDistance(Buffer.substr(i), VariableTable);
404 double Quality = Distance + (NumLinesForward / 100.);
406 if (Quality < BestQuality || Best == StringRef::npos) {
408 BestQuality = Quality;
412 // Print the "possible intended match here" line if we found something
413 // reasonable and not equal to what we showed in the "scanning from here"
415 if (Best && Best != StringRef::npos && BestQuality < 50) {
416 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data() + Best),
417 "possible intended match here", "note");
419 // FIXME: If we wanted to be really friendly we would show why the match
420 // failed, as it can be hard to spot simple one character differences.
424 //===----------------------------------------------------------------------===//
426 //===----------------------------------------------------------------------===//
428 /// CheckString - This is a check that we found in the input file.
430 /// Pat - The pattern to match.
433 /// Loc - The location in the match file that the check string was specified.
436 /// IsCheckNext - This is true if this is a CHECK-NEXT: directive (as opposed
437 /// to a CHECK: directive.
440 /// NotStrings - These are all of the strings that are disallowed from
441 /// occurring between this match string and the previous one (or start of
443 std::vector<std::pair<SMLoc, Pattern> > NotStrings;
445 CheckString(const Pattern &P, SMLoc L, bool isCheckNext)
446 : Pat(P), Loc(L), IsCheckNext(isCheckNext) {}
449 /// CanonicalizeInputFile - Remove duplicate horizontal space from the specified
450 /// memory buffer, free it, and return a new one.
451 static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB) {
452 SmallString<128> NewFile;
453 NewFile.reserve(MB->getBufferSize());
455 for (const char *Ptr = MB->getBufferStart(), *End = MB->getBufferEnd();
457 // Eliminate trailing dosish \r.
458 if (Ptr <= End - 2 && Ptr[0] == '\r' && Ptr[1] == '\n') {
462 // If C is not a horizontal whitespace, skip it.
463 if (*Ptr != ' ' && *Ptr != '\t') {
464 NewFile.push_back(*Ptr);
468 // Otherwise, add one space and advance over neighboring space.
469 NewFile.push_back(' ');
470 while (Ptr+1 != End &&
471 (Ptr[1] == ' ' || Ptr[1] == '\t'))
475 // Free the old buffer and return a new one.
477 MemoryBuffer::getMemBufferCopy(NewFile.str(), MB->getBufferIdentifier());
484 /// ReadCheckFile - Read the check file, which specifies the sequence of
485 /// expected strings. The strings are added to the CheckStrings vector.
486 static bool ReadCheckFile(SourceMgr &SM,
487 std::vector<CheckString> &CheckStrings) {
488 // Open the check file, and tell SourceMgr about it.
489 OwningPtr<MemoryBuffer> File;
491 MemoryBuffer::getFileOrSTDIN(CheckFilename.c_str(), File)) {
492 errs() << "Could not open check file '" << CheckFilename << "': "
493 << ec.message() << '\n';
496 MemoryBuffer *F = File.take();
498 // If we want to canonicalize whitespace, strip excess whitespace from the
499 // buffer containing the CHECK lines.
500 if (!NoCanonicalizeWhiteSpace)
501 F = CanonicalizeInputFile(F);
503 SM.AddNewSourceBuffer(F, SMLoc());
505 // Find all instances of CheckPrefix followed by : in the file.
506 StringRef Buffer = F->getBuffer();
508 std::vector<std::pair<SMLoc, Pattern> > NotMatches;
511 // See if Prefix occurs in the memory buffer.
512 Buffer = Buffer.substr(Buffer.find(CheckPrefix));
514 // If we didn't find a match, we're done.
518 const char *CheckPrefixStart = Buffer.data();
520 // When we find a check prefix, keep track of whether we find CHECK: or
522 bool IsCheckNext = false, IsCheckNot = false;
524 // Verify that the : is present after the prefix.
525 if (Buffer[CheckPrefix.size()] == ':') {
526 Buffer = Buffer.substr(CheckPrefix.size()+1);
527 } else if (Buffer.size() > CheckPrefix.size()+6 &&
528 memcmp(Buffer.data()+CheckPrefix.size(), "-NEXT:", 6) == 0) {
529 Buffer = Buffer.substr(CheckPrefix.size()+7);
531 } else if (Buffer.size() > CheckPrefix.size()+5 &&
532 memcmp(Buffer.data()+CheckPrefix.size(), "-NOT:", 5) == 0) {
533 Buffer = Buffer.substr(CheckPrefix.size()+6);
536 Buffer = Buffer.substr(1);
540 // Okay, we found the prefix, yay. Remember the rest of the line, but
541 // ignore leading and trailing whitespace.
542 Buffer = Buffer.substr(Buffer.find_first_not_of(" \t"));
544 // Scan ahead to the end of line.
545 size_t EOL = Buffer.find_first_of("\n\r");
547 // Remember the location of the start of the pattern, for diagnostics.
548 SMLoc PatternLoc = SMLoc::getFromPointer(Buffer.data());
550 // Parse the pattern.
552 if (P.ParsePattern(Buffer.substr(0, EOL), SM))
555 Buffer = Buffer.substr(EOL);
558 // Verify that CHECK-NEXT lines have at least one CHECK line before them.
559 if (IsCheckNext && CheckStrings.empty()) {
560 SM.PrintMessage(SMLoc::getFromPointer(CheckPrefixStart),
561 "found '"+CheckPrefix+"-NEXT:' without previous '"+
562 CheckPrefix+ ": line", "error");
568 NotMatches.push_back(std::make_pair(SMLoc::getFromPointer(Buffer.data()),
574 // Okay, add the string we captured to the output vector and move on.
575 CheckStrings.push_back(CheckString(P,
578 std::swap(NotMatches, CheckStrings.back().NotStrings);
581 // Add an EOF pattern for any trailing CHECK-NOTs.
582 if (!NotMatches.empty()) {
583 CheckStrings.push_back(CheckString(Pattern(true),
584 SMLoc::getFromPointer(Buffer.data()),
586 std::swap(NotMatches, CheckStrings.back().NotStrings);
589 if (CheckStrings.empty()) {
590 errs() << "error: no check strings found with prefix '" << CheckPrefix
598 static void PrintCheckFailed(const SourceMgr &SM, const CheckString &CheckStr,
600 StringMap<StringRef> &VariableTable) {
601 // Otherwise, we have an error, emit an error message.
602 SM.PrintMessage(CheckStr.Loc, "expected string not found in input",
605 // Print the "scanning from here" line. If the current position is at the
606 // end of a line, advance to the start of the next line.
607 Buffer = Buffer.substr(Buffer.find_first_not_of(" \t\n\r"));
609 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()), "scanning from here",
612 // Allow the pattern to print additional information if desired.
613 CheckStr.Pat.PrintFailureInfo(SM, Buffer, VariableTable);
616 /// CountNumNewlinesBetween - Count the number of newlines in the specified
618 static unsigned CountNumNewlinesBetween(StringRef Range) {
619 unsigned NumNewLines = 0;
622 Range = Range.substr(Range.find_first_of("\n\r"));
623 if (Range.empty()) return NumNewLines;
627 // Handle \n\r and \r\n as a single newline.
628 if (Range.size() > 1 &&
629 (Range[1] == '\n' || Range[1] == '\r') &&
630 (Range[0] != Range[1]))
631 Range = Range.substr(1);
632 Range = Range.substr(1);
636 int main(int argc, char **argv) {
637 sys::PrintStackTraceOnErrorSignal();
638 PrettyStackTraceProgram X(argc, argv);
639 cl::ParseCommandLineOptions(argc, argv);
643 // Read the expected strings from the check file.
644 std::vector<CheckString> CheckStrings;
645 if (ReadCheckFile(SM, CheckStrings))
648 // Open the file to check and add it to SourceMgr.
649 OwningPtr<MemoryBuffer> File;
651 MemoryBuffer::getFileOrSTDIN(InputFilename.c_str(), File)) {
652 errs() << "Could not open input file '" << InputFilename << "': "
653 << ec.message() << '\n';
656 MemoryBuffer *F = File.take();
658 if (F->getBufferSize() == 0) {
659 errs() << "FileCheck error: '" << InputFilename << "' is empty.\n";
663 // Remove duplicate spaces in the input file if requested.
664 if (!NoCanonicalizeWhiteSpace)
665 F = CanonicalizeInputFile(F);
667 SM.AddNewSourceBuffer(F, SMLoc());
669 /// VariableTable - This holds all the current filecheck variables.
670 StringMap<StringRef> VariableTable;
672 // Check that we have all of the expected strings, in order, in the input
674 StringRef Buffer = F->getBuffer();
676 const char *LastMatch = Buffer.data();
678 for (unsigned StrNo = 0, e = CheckStrings.size(); StrNo != e; ++StrNo) {
679 const CheckString &CheckStr = CheckStrings[StrNo];
681 StringRef SearchFrom = Buffer;
683 // Find StrNo in the file.
685 size_t MatchPos = CheckStr.Pat.Match(Buffer, MatchLen, VariableTable);
686 Buffer = Buffer.substr(MatchPos);
688 // If we didn't find a match, reject the input.
689 if (MatchPos == StringRef::npos) {
690 PrintCheckFailed(SM, CheckStr, SearchFrom, VariableTable);
694 StringRef SkippedRegion(LastMatch, Buffer.data()-LastMatch);
696 // If this check is a "CHECK-NEXT", verify that the previous match was on
697 // the previous line (i.e. that there is one newline between them).
698 if (CheckStr.IsCheckNext) {
699 // Count the number of newlines between the previous match and this one.
700 assert(LastMatch != F->getBufferStart() &&
701 "CHECK-NEXT can't be the first check in a file");
703 unsigned NumNewLines = CountNumNewlinesBetween(SkippedRegion);
704 if (NumNewLines == 0) {
705 SM.PrintMessage(CheckStr.Loc,
706 CheckPrefix+"-NEXT: is on the same line as previous match",
708 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()),
709 "'next' match was here", "note");
710 SM.PrintMessage(SMLoc::getFromPointer(LastMatch),
711 "previous match was here", "note");
715 if (NumNewLines != 1) {
716 SM.PrintMessage(CheckStr.Loc,
718 "-NEXT: is not on the line after the previous match",
720 SM.PrintMessage(SMLoc::getFromPointer(Buffer.data()),
721 "'next' match was here", "note");
722 SM.PrintMessage(SMLoc::getFromPointer(LastMatch),
723 "previous match was here", "note");
728 // If this match had "not strings", verify that they don't exist in the
730 for (unsigned ChunkNo = 0, e = CheckStr.NotStrings.size();
731 ChunkNo != e; ++ChunkNo) {
733 size_t Pos = CheckStr.NotStrings[ChunkNo].second.Match(SkippedRegion,
736 if (Pos == StringRef::npos) continue;
738 SM.PrintMessage(SMLoc::getFromPointer(LastMatch+Pos),
739 CheckPrefix+"-NOT: string occurred!", "error");
740 SM.PrintMessage(CheckStr.NotStrings[ChunkNo].first,
741 CheckPrefix+"-NOT: pattern specified here", "note");
746 // Otherwise, everything is good. Step over the matched text and remember
747 // the position after the match as the end of the last match.
748 Buffer = Buffer.substr(MatchLen);
749 LastMatch = Buffer.data();