1064 |
|
|
1065 |
/* In multiline mode, we want to print to the end of the line in which |
/* In multiline mode, we want to print to the end of the line in which |
1066 |
the end of the matched string is found, so we adjust linelength and the |
the end of the matched string is found, so we adjust linelength and the |
1067 |
line number appropriately. Because the PCRE_FIRSTLINE option is set, the |
line number appropriately, but only when there actually was a match |
1068 |
start of the match will always be before the first newline sequence. */ |
(invert not set). Because the PCRE_FIRSTLINE option is set, the start of |
1069 |
|
the match will always be before the first newline sequence. */ |
1070 |
|
|
1071 |
if (multiline) |
if (multiline) |
1072 |
{ |
{ |
1073 |
int ellength; |
int ellength; |
1074 |
char *endmatch = ptr + offsets[1]; |
char *endmatch = ptr; |
1075 |
t = ptr; |
if (!invert) |
|
while (t < endmatch) |
|
1076 |
{ |
{ |
1077 |
t = end_of_line(t, endptr, &ellength); |
endmatch += offsets[1]; |
1078 |
if (t <= endmatch) linenumber++; else break; |
t = ptr; |
1079 |
|
while (t < endmatch) |
1080 |
|
{ |
1081 |
|
t = end_of_line(t, endptr, &ellength); |
1082 |
|
if (t <= endmatch) linenumber++; else break; |
1083 |
|
} |
1084 |
} |
} |
1085 |
endmatch = end_of_line(endmatch, endptr, &ellength); |
endmatch = end_of_line(endmatch, endptr, &ellength); |
1086 |
linelength = endmatch - ptr - ellength; |
linelength = endmatch - ptr - ellength; |
1129 |
lastmatchnumber = linenumber + 1; |
lastmatchnumber = linenumber + 1; |
1130 |
} |
} |
1131 |
|
|
1132 |
|
/* For a match in multiline inverted mode (which of course did not cause |
1133 |
|
anything to be printed), we have to move on to the end of the match before |
1134 |
|
proceeding. */ |
1135 |
|
|
1136 |
|
if (multiline && invert && match) |
1137 |
|
{ |
1138 |
|
int ellength; |
1139 |
|
char *endmatch = ptr + offsets[1]; |
1140 |
|
t = ptr; |
1141 |
|
while (t < endmatch) |
1142 |
|
{ |
1143 |
|
t = end_of_line(t, endptr, &ellength); |
1144 |
|
if (t <= endmatch) linenumber++; else break; |
1145 |
|
} |
1146 |
|
endmatch = end_of_line(endmatch, endptr, &ellength); |
1147 |
|
linelength = endmatch - ptr - ellength; |
1148 |
|
} |
1149 |
|
|
1150 |
/* Advance to after the newline and increment the line number. */ |
/* Advance to after the newline and increment the line number. */ |
1151 |
|
|
1152 |
ptr += linelength + endlinelength; |
ptr += linelength + endlinelength; |