diff options
Diffstat (limited to 'editors')
-rw-r--r-- | editors/patch.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/editors/patch.c b/editors/patch.c index 3ed4eba45..c40f54155 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -447,10 +447,21 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
447 | INIT_TT(); | 447 | INIT_TT(); |
448 | 448 | ||
449 | opts = getopt32(argv, FLAG_STR, &opt_p, &opt_i); | 449 | opts = getopt32(argv, FLAG_STR, &opt_p, &opt_i); |
450 | argv += optind; | ||
450 | reverse = opts & FLAG_REVERSE; | 451 | reverse = opts & FLAG_REVERSE; |
451 | TT.prefix = (opts & FLAG_PATHLEN) ? xatoi(opt_p) : 0; // can be negative! | 452 | TT.prefix = (opts & FLAG_PATHLEN) ? xatoi(opt_p) : 0; // can be negative! |
452 | if (opts & FLAG_INPUT) TT.filepatch = xopen(opt_i, O_RDONLY); | ||
453 | TT.filein = TT.fileout = -1; | 453 | TT.filein = TT.fileout = -1; |
454 | if (opts & FLAG_INPUT) { | ||
455 | TT.filepatch = xopen_stdin(opt_i); | ||
456 | } else { | ||
457 | if (argv[0] && argv[1]) { | ||
458 | TT.filepatch = xopen_stdin(argv[1]); | ||
459 | } | ||
460 | } | ||
461 | if (argv[0]) { | ||
462 | oldname = xstrdup(argv[0]); | ||
463 | newname = xstrdup(argv[0]); | ||
464 | } | ||
454 | 465 | ||
455 | // Loop through the lines in the patch | 466 | // Loop through the lines in the patch |
456 | for(;;) { | 467 | for(;;) { |
@@ -498,18 +509,20 @@ int patch_main(int argc UNUSED_PARAM, char **argv) | |||
498 | state = 1; | 509 | state = 1; |
499 | } | 510 | } |
500 | 511 | ||
501 | free(*name); | ||
502 | finish_oldfile(); | 512 | finish_oldfile(); |
503 | 513 | ||
504 | // Trim date from end of filename (if any). We don't care. | 514 | if (!argv[0]) { |
505 | for (s = patchline+4; *s && *s!='\t'; s++) | 515 | free(*name); |
506 | if (*s=='\\' && s[1]) s++; | 516 | // Trim date from end of filename (if any). We don't care. |
507 | i = atoi(s); | 517 | for (s = patchline+4; *s && *s!='\t'; s++) |
508 | if (i>1900 && i<=1970) | 518 | if (*s=='\\' && s[1]) s++; |
509 | *name = xstrdup("/dev/null"); | 519 | i = atoi(s); |
510 | else { | 520 | if (i>1900 && i<=1970) |
511 | *s = 0; | 521 | *name = xstrdup("/dev/null"); |
512 | *name = xstrdup(patchline+4); | 522 | else { |
523 | *s = 0; | ||
524 | *name = xstrdup(patchline+4); | ||
525 | } | ||
513 | } | 526 | } |
514 | 527 | ||
515 | // We defer actually opening the file because svn produces broken | 528 | // We defer actually opening the file because svn produces broken |