Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make make(1): replace %zu with %u in printf calls



details:   https://anonhg.NetBSD.org/src/rev/77fa9e22564a
branches:  trunk
changeset: 979111:77fa9e22564a
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Dec 13 21:27:45 2020 +0000

description:
make(1): replace %zu with %u in printf calls

This is needed to compile bmake with GCC 2.8.1 on SunOS 5.9.

To support ancient systems like this, the whole code of usr.bin/make is
supposed to use only ISO C90 features, except for filemon, which is not
used on these systems.

diffstat:

 usr.bin/make/for.c   |   9 +++++----
 usr.bin/make/meta.c  |   5 +++--
 usr.bin/make/parse.c |   8 ++++----
 usr.bin/make/var.c   |  15 ++++++++-------
 4 files changed, 20 insertions(+), 17 deletions(-)

diffs (130 lines):

diff -r e766d5a0c795 -r 77fa9e22564a usr.bin/make/for.c
--- a/usr.bin/make/for.c        Sun Dec 13 20:57:17 2020 +0000
+++ b/usr.bin/make/for.c        Sun Dec 13 21:27:45 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: for.c,v 1.116 2020/12/12 00:33:25 rillig Exp $ */
+/*     $NetBSD: for.c,v 1.117 2020/12/13 21:27:45 rillig Exp $ */
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -60,7 +60,7 @@
 #include "make.h"
 
 /*     "@(#)for.c      8.1 (Berkeley) 6/6/93"  */
-MAKE_RCSID("$NetBSD: for.c,v 1.116 2020/12/12 00:33:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: for.c,v 1.117 2020/12/13 21:27:45 rillig Exp $");
 
 static int forLevel = 0;       /* Nesting level */
 
@@ -217,8 +217,9 @@
 
        if ((nitems = f->items.len) > 0 && nitems % (nvars = f->vars.len)) {
            Parse_Error(PARSE_FATAL,
-                       "Wrong number of words (%zu) in .for substitution list"
-                       " with %zu variables", nitems, nvars);
+                       "Wrong number of words (%u) in .for substitution list"
+                       " with %u variables",
+                       (unsigned)nitems, (unsigned)nvars);
            /*
             * Return 'success' so that the body of the .for loop is
             * accumulated.
diff -r e766d5a0c795 -r 77fa9e22564a usr.bin/make/meta.c
--- a/usr.bin/make/meta.c       Sun Dec 13 20:57:17 2020 +0000
+++ b/usr.bin/make/meta.c       Sun Dec 13 21:27:45 2020 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: meta.c,v 1.159 2020/12/13 20:14:48 rillig Exp $ */
+/*      $NetBSD: meta.c,v 1.160 2020/12/13 21:27:45 rillig Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -924,7 +924,8 @@
                newsz = ROUNDUP((size_t)fs.st_size, BUFSIZ);
            if (newsz <= bufsz)
                return x;               /* truncated */
-           DEBUG2(META, "growing buffer %zu -> %zu\n", bufsz, newsz);
+           DEBUG2(META, "growing buffer %u -> %u\n",
+                  (unsigned)bufsz, (unsigned)newsz);
            p = bmake_realloc(buf, newsz);
            *bufp = buf = p;
            *szp = bufsz = newsz;
diff -r e766d5a0c795 -r 77fa9e22564a usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Sun Dec 13 20:57:17 2020 +0000
+++ b/usr.bin/make/parse.c      Sun Dec 13 21:27:45 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.480 2020/12/13 20:14:48 rillig Exp $       */
+/*     $NetBSD: parse.c,v 1.481 2020/12/13 21:27:45 rillig Exp $       */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -117,7 +117,7 @@
 #include "pathnames.h"
 
 /*     "@(#)parse.c    8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: parse.c,v 1.480 2020/12/13 20:14:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.481 2020/12/13 21:27:45 rillig Exp $");
 
 /* types and constants */
 
@@ -618,7 +618,7 @@
        void *dir_freeIt, *base_freeIt;
 
        if (*fname == '/' || strcmp(fname, "(stdin)") == 0) {
-               (void)fprintf(f, "\"%s\" line %zu: ", fname, lineno);
+               (void)fprintf(f, "\"%s\" line %u: ", fname, (unsigned)lineno);
                return;
        }
 
@@ -635,7 +635,7 @@
        if (base == NULL)
                base = str_basename(fname);
 
-       (void)fprintf(f, "\"%s/%s\" line %zu: ", dir, base, lineno);
+       (void)fprintf(f, "\"%s/%s\" line %u: ", dir, base, (unsigned)lineno);
        bmake_free(base_freeIt);
        bmake_free(dir_freeIt);
 }
diff -r e766d5a0c795 -r 77fa9e22564a usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sun Dec 13 20:57:17 2020 +0000
+++ b/usr.bin/make/var.c        Sun Dec 13 21:27:45 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.733 2020/12/13 20:14:48 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.734 2020/12/13 21:27:45 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -131,7 +131,7 @@
 #include "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.733 2020/12/13 20:14:48 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.734 2020/12/13 21:27:45 rillig Exp $");
 
 /* A string that may need to be freed after use. */
 typedef struct FStr {
@@ -1467,11 +1467,12 @@
                                rp++;
 
                                if (n >= args->nsub) {
-                                       Error("No subexpression \\%zu", n);
+                                       Error("No subexpression \\%u",
+                                           (unsigned)n);
                                } else if (m[n].rm_so == -1) {
                                        Error(
-                                           "No match for subexpression \\%zu",
-                                           n);
+                                           "No match for subexpression \\%u",
+                                           (unsigned)n);
                                } else {
                                        SepBuf_AddBytesBetween(buf,
                                            wp + m[n].rm_so, wp + m[n].rm_eo);
@@ -1640,8 +1641,8 @@
 
        words = Str_Words(str, FALSE);
 
-       DEBUG2(VAR, "ModifyWords: split \"%s\" into %zu words\n",
-           str, words.len);
+       DEBUG2(VAR, "ModifyWords: split \"%s\" into %u words\n",
+           str, (unsigned)words.len);
 
        for (i = 0; i < words.len; i++) {
                modifyWord(words.words[i], &result, modifyWord_args);



Home | Main Index | Thread Index | Old Index