Mercurial > hg > toybox
changeset 325:5d0fbdb2fc86
The epoch can also show up as 1970-01-01 (depending on timezone), so treat any year >0 and <= 1970 as meaning "file does not exist".
author | Rob Landley <rob@landley.net> |
---|---|
date | Tue, 18 Nov 2008 22:22:18 -0600 |
parents | 50c8afc263ee |
children | 531b4d716460 |
files | toys/patch.c |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/toys/patch.c Tue Nov 18 22:17:43 2008 -0600 +++ b/toys/patch.c Tue Nov 18 22:22:18 2008 -0600 @@ -40,7 +40,7 @@ a file when all all hunks to that file apply. Patch prints failed hunks to stderr, and exits with nonzero status if any hunks fail. - A file compared against /dev/null (or with a date in 1969) is + A file compared against /dev/null (or with a date <= the epoch) is created/deleted as appropriate. */ @@ -229,12 +229,15 @@ // Open a new file? if (!strncmp("--- ", patchline, 4)) { char *s; + int i; + free(TT.oldname); // Trim date from end of filename (if any). We don't care. for (s = patchline+4; *s && *s!='\t'; s++) if (*s=='\\' && s[1]) s++; - if (!strncmp(s, "\t1969-12-31", 10)) + i = atoi(s); + if (i && i<=1970) TT.oldname = xstrdup("/dev/null"); else { *s = 0;