diff options
author | Rob Landley <rob@landley.net> | 2008-11-18 22:22:18 -0600 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2008-11-18 22:22:18 -0600 |
commit | a605d68ac03543b383ba5b1ad2963a92b584bac0 (patch) | |
tree | d7de16a0fb354f8485a17cc941c5d912c3d2a659 | |
parent | 7dbbe0d9ddc3d1b43b6699dc3c9cdd8a7b61851e (diff) | |
download | toybox-a605d68ac03543b383ba5b1ad2963a92b584bac0.tar.gz |
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".
-rw-r--r-- | toys/patch.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/toys/patch.c b/toys/patch.c index 41371a3e..b1f8d413 100644 --- a/toys/patch.c +++ b/toys/patch.c @@ -40,7 +40,7 @@ config PATCH 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 @@ void patch_main(void) // 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; |