commit - 0335d24d8aee21c0754bcee3471af5d81b515221
commit + 4f34ed97e0f428b8e9695ed8c18c681c339f7f02
blob - 121278b253ae2dfd4d7089d23651bac456257f0d
blob + 6e31c8d2cf7df53c75d28271fdeb51d2590fd306
--- lib/patch.c
+++ lib/patch.c
}
return NULL;
}
+
+static int linecmp(const char *, const char *, int *);
static const struct got_error *
locate_hunk(FILE *orig, struct got_patch_hunk *h, off_t *pos, int *lineno)
size_t linesize = 0;
ssize_t linelen;
off_t match = -1;
- int match_lineno = -1;
+ int mangled = 0, match_lineno = -1;
for (;;) {
linelen = getline(&line, &linesize, orig);
line[linelen - 1] = '\0';
(*lineno)++;
- if ((mode == ' ' && !strcmp(h->lines[0] + 1, line)) ||
- (mode == '-' && !strcmp(h->lines[0] + 1, line)) ||
+ if ((mode == ' ' && !linecmp(h->lines[0] + 1, line, &mangled)) ||
+ (mode == '-' && !linecmp(h->lines[0] + 1, line, &mangled)) ||
(mode == '+' && *lineno == h->old_from)) {
match = ftello(orig);
if (match == -1) {
break;
}
+ if (mangled)
+ h->ws_mangled = 1;
+
if (err == NULL) {
*pos = match;
*lineno = match_lineno;