@@ -1926,7 +1926,6 @@ static bool matchMultilineRegexPattern (struct lregexControlBlock *lcb,
19261926{
19271927 const char * start ;
19281928 const char * current ;
1929- off_t offset = 0 ;
19301929 regexPattern * patbuf = entry -> pattern ;
19311930 struct mGroupSpec * mgroup = & patbuf -> mgroup ;
19321931 struct guestSpec * guest = & patbuf -> guest ;
@@ -1958,9 +1957,6 @@ static bool matchMultilineRegexPattern (struct lregexControlBlock *lcb,
19581957 if (hasMessage (patbuf ))
19591958 printMessage (lcb -> owner , patbuf , (current + pmatch [0 ].rm_so ) - start , current , pmatch );
19601959
1961- offset = (current + pmatch [mgroup -> forLineNumberDetermination ].rm_so )
1962- - start ;
1963-
19641960 entry -> statistics .match ++ ;
19651961 scriptWindow window = {
19661962 .line = current ,
@@ -1983,6 +1979,9 @@ static bool matchMultilineRegexPattern (struct lregexControlBlock *lcb,
19831979
19841980 if (patbuf -> type == PTRN_TAG )
19851981 {
1982+ Assert (mgroup -> forLineNumberDetermination != NO_MULTILINE );
1983+ off_t offset = (current + pmatch [mgroup -> forLineNumberDetermination ].rm_so )
1984+ - start ;
19861985 matchTagPattern (lcb , current , patbuf , pmatch , offset ,
19871986 (patbuf -> optscript && hasNameSlot (patbuf ))? & window : NULL );
19881987 result = true;
@@ -2290,8 +2289,16 @@ extern void addTagMultiLineRegex (struct lregexControlBlock *lcb, const char* co
22902289 const char * const name , const char * const kinds , const char * const flags ,
22912290 bool * disabled )
22922291{
2293- addTagRegexInternal (lcb , TABLE_INDEX_UNUSED ,
2294- REG_PARSER_MULTI_LINE , regex , name , kinds , flags , disabled );
2292+ regexPattern * ptrn = addTagRegexInternal (lcb , TABLE_INDEX_UNUSED ,
2293+ REG_PARSER_MULTI_LINE , regex , name , kinds , flags , disabled );
2294+ if (ptrn -> mgroup .forLineNumberDetermination == NO_MULTILINE )
2295+ {
2296+ if (hasNameSlot (ptrn ))
2297+ error (WARNING , "%s: no {mgroup=N} flag given in --mline-regex-<LANG>=/%s/... (%s)" ,
2298+ regex ,
2299+ getLanguageName (lcb -> owner ), ASSERT_FUNCTION );
2300+ ptrn -> mgroup .forLineNumberDetermination = 0 ;
2301+ }
22952302}
22962303
22972304extern void addTagMultiTableRegex (struct lregexControlBlock * lcb ,
@@ -2383,8 +2390,19 @@ static void addTagRegexOption (struct lregexControlBlock *lcb,
23832390 regex_pat = eStrdup (pattern );
23842391
23852392 if (parseTagRegex (regptype , regex_pat , & name , & kinds , & flags ))
2386- addTagRegexInternal (lcb , table_index , regptype , regex_pat , name , kinds , flags ,
2387- NULL );
2393+ {
2394+ regexPattern * ptrn = addTagRegexInternal (lcb , table_index , regptype , regex_pat , name , kinds , flags ,
2395+ NULL );
2396+ if (regptype == REG_PARSER_MULTI_LINE
2397+ && ptrn -> mgroup .forLineNumberDetermination == NO_MULTILINE )
2398+ {
2399+ if (hasNameSlot (ptrn ))
2400+ error (WARNING , "%s: no {mgroup=N} flag given in --mline-regex-<LANG>=%s... (%s)" ,
2401+ getLanguageName (lcb -> owner ),
2402+ pattern , ASSERT_FUNCTION );
2403+ ptrn -> mgroup .forLineNumberDetermination = 0 ;
2404+ }
2405+ }
23882406
23892407 eFree (regex_pat );
23902408}
@@ -2738,9 +2756,6 @@ static struct regexTable * matchMultitableRegexTable (struct lregexControlBlock
27382756 if (match == 0 )
27392757 {
27402758 entry -> statistics .match ++ ;
2741- off_t offset_for_tag = (current
2742- + pmatch [ptrn -> mgroup .forLineNumberDetermination ].rm_so )
2743- - cstart ;
27442759 scriptWindow window = {
27452760 .line = current ,
27462761 .start = cstart ,
@@ -2763,6 +2778,10 @@ static struct regexTable * matchMultitableRegexTable (struct lregexControlBlock
27632778
27642779 if (ptrn -> type == PTRN_TAG )
27652780 {
2781+ Assert (ptrn -> mgroup .forLineNumberDetermination != NO_MULTILINE );
2782+ off_t offset_for_tag = (current
2783+ + pmatch [ptrn -> mgroup .forLineNumberDetermination ].rm_so )
2784+ - cstart ;
27662785 matchTagPattern (lcb , current , ptrn , pmatch , offset_for_tag ,
27672786 (ptrn -> optscript && hasNameSlot (ptrn ))? & window : NULL );
27682787
0 commit comments