OSDN Git Service

buildsys: update unifdef
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 8 Jan 2014 09:44:05 +0000 (10:44 +0100)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 8 Jan 2014 09:49:09 +0000 (10:49 +0100)
sync up to 1542ea42da59018860a987f34f065cd120982e8c
(2.10 + cleaner exit status handling)

Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
extra/scripts/install_headers.sh
extra/scripts/unifdef.c
extra/scripts/unifdef.h
extra/scripts/version.h

index d40ae13..8c8d715 100755 (executable)
@@ -34,7 +34,7 @@ fi
 
 # Sanitize and copy uclibc headers
 (
-# We must cd, or else we'll prepend "${srcdir}" to filenames!
+# We must cd, or else we will prepend "${srcdir}" to filenames!
 cd "${srcdir}" || exit 1
 find . ! -name '.' -a ! -path '*/.*' | sed -e 's/^\.\///' -e '/^config\//d' \
        -e '/^config$/d'
@@ -50,13 +50,12 @@ while read -r filename; do
                # Do not install libc-XXXX.h files
                continue
        fi
-       # NB: unifdef exits with 1 if output is not
-       # exactly the same as input. That's ok.
        # Do not abort the script if unifdef "fails"!
        # NB2: careful with sed command arguments, they contain tab character
        "$top_builddir/extra/scripts/unifdef" \
                -B \
                -t \
+               -x 2 \
                -f "$top_builddir/include/generated/unifdef_config.h" \
                -U_LIBC \
                -U__UCLIBC_GEN_LOCALE \
index f18bea8..0f05920 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002 - 2013 Tony Finch <dot@dotat.at>
+ * Copyright (c) 2002 - 2014 Tony Finch <dot@dotat.at>
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -207,6 +207,7 @@ static bool             firstsym;           /* ditto */
 
 static int              exitmode;              /* exit status mode */
 static int              exitstat;              /* program exit status */
+static bool             altered;               /* was this file modified? */
 
 static void             addsym1(bool, bool, char *);
 static void             addsym2(bool, const char *, const char *);
@@ -415,7 +416,11 @@ processinout(const char *ifn, const char *ofn)
                        err(2, "can't rename \"%s\" to \"%s\"", ofn, backname);
                free(backname);
        }
-       if (replace(tempname, ofn) < 0)
+       /* leave file unmodified if unifdef made no changes */
+       if (!altered && backext == NULL) {
+               if (remove(tempname) < 0)
+                       warn("can't remove \"%s\"", tempname);
+       } else if (replace(tempname, ofn) < 0)
                err(2, "can't rename \"%s\" to \"%s\"", tempname, ofn);
        free(tempname);
        tempname = NULL;
@@ -637,6 +642,7 @@ keywordedit(const char *replacement)
 {
        snprintf(keyword, tline + sizeof(tline) - keyword,
            "%s%s", replacement, newline);
+       altered = true;
        print();
 }
 static void
@@ -699,7 +705,7 @@ flushline(bool keep)
        } else {
                if (lnblank && fputs(newline, output) == EOF)
                        closeio();
-               exitstat = 1;
+               altered = true;
                delcount += 1;
                blankcount = 0;
        }
@@ -751,6 +757,7 @@ process(void)
        zerosyms = true;
        newline = NULL;
        linenum = 0;
+       altered = false;
        while (lineval != LT_EOF) {
                lineval = parseline();
                trans_table[ifstate[depth]][lineval]();
@@ -758,6 +765,7 @@ process(void)
                    linenum, linetype_name[lineval],
                    ifstate_name[ifstate[depth]], depth);
        }
+       exitstat |= altered;
 }
 
 /*
@@ -1097,14 +1105,12 @@ skiphash(void)
 {
        const char *cp;
 
-       if (linestate == LS_START) {
-               linenum++;
-               if (fgets(tline, MAXLINE, input) == NULL) {
-                       if (ferror(input))
-                               err(2, "can't read %s", filename);
-                       else
-                               return (NULL);
-               }
+       linenum++;
+       if (fgets(tline, MAXLINE, input) == NULL) {
+               if (ferror(input))
+                       err(2, "can't read %s", filename);
+               else
+                       return (NULL);
        }
        cp = skipcomment(tline);
        if (linestate == LS_START && *cp == '#') {
@@ -1124,7 +1130,8 @@ skiphash(void)
 static const char *
 skipline(const char *cp)
 {
-       linestate = LS_DIRTY;
+       if (*cp != '\0')
+               linestate = LS_DIRTY;
        while (*cp != '\0')
                cp = skipcomment(cp + 1);
        return (cp);
index d57a866..276015c 100644 (file)
@@ -37,6 +37,7 @@
 /* Avoid err.h since this are non-standard BSD extensions */
 #define vwarnx(fmt, args)   ({ fprintf(stderr, "unifdef: "); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); })
 #define warnx(fmt, args...) fprintf(stderr, "unifdef: " fmt "\n", ## args)
+#define warn(fmt, args...)  warnx(fmt ": %s", ## args, strerror(errno))
 #define errx(exit_code, fmt, args...) ({ warnx(fmt, ## args); exit(exit_code); })
 #define err(exit_code, fmt, args...)  errx(exit_code, fmt ": %s", ## args, strerror(errno))
 
index ed3e7c0..5636b1b 100644 (file)
@@ -1,2 +1,2 @@
-"@(#) $Version: unifdef-2.9.5.55501a6 $\n"
-"@(#) $Date: 2013-06-12 15:50:39 +0100 $\n"
+"@(#) $Version: unifdef-2.10.4.1542ea4 $\n"
+"@(#) $Date: 2014-01-07 22:32:21 +0000 $\n"