[Toybox] [PATCH]patch: support unified diffs with unusual timestamp formats

William Haddon william at haddonthethird.net
Wed Aug 28 13:16:11 PDT 2019


This supports patches that have timestamp formats like
"--- a/libgomp/config/posix/time.c	Thu Dec 24 11:24:47 2015
-0500"
which do not begin with a digit. An example is the musl support patches 
for GCC 5 at https://github.com/GregorR/musl-gcc-patches , which seem 
to have been generated by Mercurial.


diff -rupN toybox/toys/posix/patch.c toybox-patch/toys/posix/patch.c
--- toybox/toys/posix/patch.c	2019-08-28 14:42:47.000000000 -0400
+++ toybox-patch/toys/posix/patch.c	2019-08-28 15:42:54.000000000

-0400
@@ -322,7 +322,7 @@ void patch_main(void)
       finish_oldfile();
 
       // Trim date from end of filename (if any).  We don't care.
-      for (s = patchline+4; *s && (*s!='\t' || !isdigit(s[1])); s++)
+      for (s = patchline+4; *s && *s!='\t'; s++)
         if (*s=='\\' && s[1]) s++;
       i = atoi(s);
       if (i>1900 && i<=1970) *name = xstrdup("/dev/null");


More information about the Toybox mailing list