diff options
Diffstat (limited to 'editors')
| -rw-r--r-- | editors/patch.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/editors/patch.c b/editors/patch.c index 5a768b23f..9f0689ec7 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
| @@ -57,6 +57,9 @@ struct double_list { | |||
| 57 | struct double_list *next; | 57 | struct double_list *next; |
| 58 | struct double_list *prev; | 58 | struct double_list *prev; |
| 59 | char *data; | 59 | char *data; |
| 60 | #if ENABLE_PLATFORM_MINGW32 | ||
| 61 | int no_newline; | ||
| 62 | #endif | ||
| 60 | }; | 63 | }; |
| 61 | 64 | ||
| 62 | // Free all the elements of a linked list | 65 | // Free all the elements of a linked list |
| @@ -76,7 +79,11 @@ static void dlist_free(struct double_list *list, void (*freeit)(void *data)) | |||
| 76 | static struct double_list *dlist_add(struct double_list **list, char *data) | 79 | static struct double_list *dlist_add(struct double_list **list, char *data) |
| 77 | { | 80 | { |
| 78 | struct double_list *llist; | 81 | struct double_list *llist; |
| 82 | #if ENABLE_PLATFORM_MINGW32 | ||
| 83 | struct double_list *line = xzalloc(sizeof(*line)); | ||
| 84 | #else | ||
| 79 | struct double_list *line = xmalloc(sizeof(*line)); | 85 | struct double_list *line = xmalloc(sizeof(*line)); |
| 86 | #endif | ||
| 80 | 87 | ||
| 81 | line->data = data; | 88 | line->data = data; |
| 82 | llist = *list; | 89 | llist = *list; |
| @@ -140,6 +147,9 @@ static void do_line(void *data) | |||
| 140 | 147 | ||
| 141 | if (TT.state > 1 && *dlist->data != TT.state) | 148 | if (TT.state > 1 && *dlist->data != TT.state) |
| 142 | fdprintf(TT.state == 2 ? 2 : TT.fileout, | 149 | fdprintf(TT.state == 2 ? 2 : TT.fileout, |
| 150 | #if ENABLE_PLATFORM_MINGW32 | ||
| 151 | dlist->no_newline && TT.state != 2 ? "%s" : | ||
| 152 | #endif | ||
| 143 | "%s\n", dlist->data + (TT.state > 3 ? 1 : 0)); | 153 | "%s\n", dlist->data + (TT.state > 3 ? 1 : 0)); |
| 144 | 154 | ||
| 145 | if (PATCH_DEBUG) fdprintf(2, "DO %d: %s\n", TT.state, dlist->data); | 155 | if (PATCH_DEBUG) fdprintf(2, "DO %d: %s\n", TT.state, dlist->data); |
| @@ -448,6 +458,14 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
| 448 | if (!oldlen && !newlen) state = apply_one_hunk(); | 458 | if (!oldlen && !newlen) state = apply_one_hunk(); |
| 449 | continue; | 459 | continue; |
| 450 | } | 460 | } |
| 461 | #if ENABLE_PLATFORM_MINGW32 | ||
| 462 | else if (*patchline == '\\' && TT.current_hunk->prev) { | ||
| 463 | // detect '\ No newline at end of file' and mark previous | ||
| 464 | // line, if it exists. | ||
| 465 | TT.current_hunk->prev->no_newline = TRUE; | ||
| 466 | continue; | ||
| 467 | } | ||
| 468 | #endif | ||
| 451 | fail_hunk(); | 469 | fail_hunk(); |
| 452 | state = 0; | 470 | state = 0; |
| 453 | continue; | 471 | continue; |
