| 1189 |
captured portion of it, as long as this string is not empty, and the |
captured portion of it, as long as this string is not empty, and the |
| 1190 |
--file-offsets and --line-offsets options output offsets for the matching |
--file-offsets and --line-offsets options output offsets for the matching |
| 1191 |
substring (they both force --only-matching = 0). None of these options |
substring (they both force --only-matching = 0). None of these options |
| 1192 |
prints any context. Afterwards, adjust the start and length, and then jump |
prints any context. Afterwards, adjust the start and then jump back to look |
| 1193 |
back to look for further matches in the same line. If we are in invert |
for further matches in the same line. If we are in invert mode, however, |
| 1194 |
mode, however, nothing is printed and we do not restart - this could still |
nothing is printed and we do not restart - this could still be useful |
| 1195 |
be useful because the return code is set. */ |
because the return code is set. */ |
| 1196 |
|
|
| 1197 |
else if (only_matching >= 0) |
else if (only_matching >= 0) |
| 1198 |
{ |
{ |
| 1219 |
} |
} |
| 1220 |
} |
} |
| 1221 |
else if (printname != NULL || number) fprintf(stdout, "\n"); |
else if (printname != NULL || number) fprintf(stdout, "\n"); |
|
/* |
|
|
matchptr += offsets[1]; |
|
|
length -= offsets[1]; |
|
|
*/ |
|
| 1222 |
match = FALSE; |
match = FALSE; |
| 1223 |
if (line_buffered) fflush(stdout); |
if (line_buffered) fflush(stdout); |
| 1224 |
rc = 0; /* Had some success */ |
rc = 0; /* Had some success */ |
| 1225 |
startoffset = offsets[1]; |
startoffset = offsets[1]; /* Restart after the match */ |
| 1226 |
goto ONLY_MATCHING_RESTART; |
goto ONLY_MATCHING_RESTART; |
| 1227 |
} |
} |
| 1228 |
} |
} |
| 1355 |
if (do_colour && !invert) |
if (do_colour && !invert) |
| 1356 |
{ |
{ |
| 1357 |
int plength; |
int plength; |
|
int last_offset = 0; |
|
| 1358 |
FWRITE(ptr, 1, offsets[0], stdout); |
FWRITE(ptr, 1, offsets[0], stdout); |
| 1359 |
fprintf(stdout, "%c[%sm", 0x1b, colour_string); |
fprintf(stdout, "%c[%sm", 0x1b, colour_string); |
| 1360 |
FWRITE(ptr + offsets[0], 1, offsets[1] - offsets[0], stdout); |
FWRITE(ptr + offsets[0], 1, offsets[1] - offsets[0], stdout); |
| 1361 |
fprintf(stdout, "%c[00m", 0x1b); |
fprintf(stdout, "%c[00m", 0x1b); |
| 1362 |
for (;;) |
for (;;) |
| 1363 |
{ |
{ |
|
/* |
|
|
last_offset += offsets[1]; |
|
|
matchptr += offsets[1]; |
|
|
length -= offsets[1]; |
|
|
*/ |
|
|
|
|
| 1364 |
startoffset = offsets[1]; |
startoffset = offsets[1]; |
| 1365 |
last_offset = startoffset; |
if (startoffset >= linelength + endlinelength || |
|
if (last_offset >= linelength + endlinelength || |
|
| 1366 |
!match_patterns(matchptr, length, startoffset, offsets, &mrc)) |
!match_patterns(matchptr, length, startoffset, offsets, &mrc)) |
| 1367 |
break; |
break; |
| 1368 |
FWRITE(matchptr + startoffset, 1, offsets[0] - startoffset, stdout); |
FWRITE(matchptr + startoffset, 1, offsets[0] - startoffset, stdout); |
| 1375 |
and its line-ending characters (if they matched the pattern), so there |
and its line-ending characters (if they matched the pattern), so there |
| 1376 |
may be no more to print. */ |
may be no more to print. */ |
| 1377 |
|
|
| 1378 |
plength = (linelength + endlinelength) - last_offset; |
plength = (linelength + endlinelength) - startoffset; |
| 1379 |
if (plength > 0) |
if (plength > 0) FWRITE(ptr + startoffset, 1, plength, stdout); |
|
FWRITE(ptr + last_offset, 1, plength, stdout); |
|
| 1380 |
} |
} |
| 1381 |
|
|
| 1382 |
/* Not colouring; no need to search for further matches */ |
/* Not colouring; no need to search for further matches */ |