*/
int i;
int add_nl_to_tail = 0;
+ int add_cr_to_tail = 0;
int fixed = 0;
int last_tab_in_indent = -1;
int last_space_in_indent = -1;
*/
if ((ws_rule & WS_TRAILING_SPACE) &&
(2 < plen && isspace(patch[plen-2]))) {
- if (patch[plen-1] == '\n')
+ if (patch[plen - 1] == '\n') {
add_nl_to_tail = 1;
- plen--;
- while (0 < plen && isspace(patch[plen-1]))
plen--;
- fixed = 1;
+ if (1 < plen && patch[plen - 1] == '\r') {
+ add_cr_to_tail = !!(ws_rule & WS_CR_AT_EOL);
+ plen--;
+ }
+ }
+ if (0 < plen && isspace(patch[plen - 1])) {
+ while (0 < plen && isspace(patch[plen-1]))
+ plen--;
+ fixed = 1;
+ }
}
/*
}
memcpy(output, patch, plen);
+ if (add_cr_to_tail)
+ output[plen++] = '\r';
if (add_nl_to_tail)
output[plen++] = '\n';
if (fixed && count_error)
else if (match_end)
line = img->nr - preimage->nr;
+ if (line > img->nr)
+ line = img->nr;
+
try = 0;
for (i = 0; i < line; i++)
try += img->line[i].len;