Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/config Global paths looked up at output stage (mk*()...



details:   https://anonhg.NetBSD.org/src/rev/469da45573bb
branches:  trunk
changeset: 340218:469da45573bb
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Fri Aug 28 03:55:15 2015 +0000

description:
Global paths looked up at output stage (mk*()) are relative to `srcdir'.
Ignore "prefix" by not calling sourcepath().

diffstat:

 usr.bin/config/main.c       |  20 ++++++++------------
 usr.bin/config/mkioconf.c   |  10 +++++-----
 usr.bin/config/mkmakefile.c |  25 ++++++++++---------------
 3 files changed, 23 insertions(+), 32 deletions(-)

diffs (172 lines):

diff -r 453f5f077496 -r 469da45573bb usr.bin/config/main.c
--- a/usr.bin/config/main.c     Fri Aug 28 02:59:09 2015 +0000
+++ b/usr.bin/config/main.c     Fri Aug 28 03:55:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.76 2015/08/08 15:52:41 shm Exp $    */
+/*     $NetBSD: main.c,v 1.77 2015/08/28 03:55:15 uebayasi Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.76 2015/08/08 15:52:41 shm Exp $");
+__RCSID("$NetBSD: main.c,v 1.77 2015/08/28 03:55:15 uebayasi Exp $");
 
 #ifndef MAKE_BOOTSTRAP
 #include <sys/cdefs.h>
@@ -616,30 +616,26 @@
        const char *q;
        struct nvlist *nv;
 
-       snprintf(buf, sizeof(buf), "arch/%s/include", machine);
-       p = sourcepath(buf);
+       p = buf;
+
+       snprintf(buf, sizeof(buf), "%s/arch/%s/include", srcdir, machine);
        ret = recreate(p, "machine");
        ret = recreate(p, machine);
-       free(p);
 
        if (machinearch != NULL) {
-               snprintf(buf, sizeof(buf), "arch/%s/include", machinearch);
-               p = sourcepath(buf);
+               snprintf(buf, sizeof(buf), "%s/arch/%s/include", srcdir, machinearch);
                q = machinearch;
        } else {
-               p = estrdup("machine");
+               snprintf(buf, sizeof(buf), "machine");
                q = machine;
        }
 
        ret = recreate(p, q);
-       free(p);
 
        for (nv = machinesubarches; nv != NULL; nv = nv->nv_next) {
                q = nv->nv_name;
-               snprintf(buf, sizeof(buf), "arch/%s/include", q);
-               p = sourcepath(buf);
+               snprintf(buf, sizeof(buf), "%s/arch/%s/include", srcdir, q);
                ret = recreate(p, q);
-               free(p);
        }
 
        return (ret);
diff -r 453f5f077496 -r 469da45573bb usr.bin/config/mkioconf.c
--- a/usr.bin/config/mkioconf.c Fri Aug 28 02:59:09 2015 +0000
+++ b/usr.bin/config/mkioconf.c Fri Aug 28 03:55:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkioconf.c,v 1.29 2015/08/20 09:44:24 christos Exp $   */
+/*     $NetBSD: mkioconf.c,v 1.30 2015/08/28 03:55:15 uebayasi Exp $   */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: mkioconf.c,v 1.29 2015/08/20 09:44:24 christos Exp $");
+__RCSID("$NetBSD: mkioconf.c,v 1.30 2015/08/28 03:55:15 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <err.h>
@@ -147,9 +147,10 @@
 
        autogen_comment(ofp, "ioconf.c");
 
-       (void)snprintf(ifnbuf, sizeof(ifnbuf), "arch/%s/conf/ioconf.incl.%s",
+       (void)snprintf(ifnbuf, sizeof(ifnbuf), "%s/arch/%s/conf/ioconf.incl.%s",
+           srcdir,
            machine ? machine : "(null)", machine ? machine : "(null)");
-       ifn = sourcepath(ifnbuf);
+       ifn = ifnbuf;
        if ((ifp = fopen(ifn, "r")) != NULL) {
                while ((n = fread(buf, 1, sizeof(buf), ifp)) > 0)
                        (void)fwrite(buf, 1, n, ofp);
@@ -162,7 +163,6 @@
                        "#include <sys/device.h>\n"
                        "#include <sys/mount.h>\n", ofp);
        }
-       free(ifn);
 }
 
 /*
diff -r 453f5f077496 -r 469da45573bb usr.bin/config/mkmakefile.c
--- a/usr.bin/config/mkmakefile.c       Fri Aug 28 02:59:09 2015 +0000
+++ b/usr.bin/config/mkmakefile.c       Fri Aug 28 03:55:15 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkmakefile.c,v 1.37 2014/12/15 15:49:25 uebayasi Exp $ */
+/*     $NetBSD: mkmakefile.c,v 1.38 2015/08/28 03:55:15 uebayasi Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -45,7 +45,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: mkmakefile.c,v 1.37 2014/12/15 15:49:25 uebayasi Exp $");
+__RCSID("$NetBSD: mkmakefile.c,v 1.38 2015/08/28 03:55:15 uebayasi Exp $");
 
 #include <sys/param.h>
 #include <ctype.h>
@@ -94,8 +94,7 @@
        FILE *ifp, *ofp;
        int lineno;
        void (*fn)(FILE *);
-       char *ifname;
-       char line[BUFSIZ], buf[200];
+       char line[BUFSIZ], ifname[200];
 
        /*
         * Check if conf/Makefile.kern.inc defines "build_kernel".
@@ -104,8 +103,8 @@
         * unfortunately the "build_kernel" change done around 2014 Aug didn't
         * bump that version.  Thus this hack.)
         */
-       (void)snprintf(buf, sizeof(buf), "conf/Makefile.kern.inc");
-       ifname = sourcepath(buf);
+       (void)snprintf(ifname, sizeof(ifname), "%s/conf/Makefile.kern.inc",
+           srcdir);
        if ((ifp = fopen(ifname, "r")) == NULL) {
                warn("cannot read %s", ifname);
                goto bad2;
@@ -121,17 +120,15 @@
        /*
         * Try a makefile for the port first.
         */
-       (void)snprintf(buf, sizeof(buf), "arch/%s/conf/Makefile.%s",
-           machine, machine);
-       ifname = sourcepath(buf);
+       (void)snprintf(ifname, sizeof(ifname), "%s/arch/%s/conf/Makefile.%s",
+           srcdir, machine, machine);
        if ((ifp = fopen(ifname, "r")) == NULL) {
                /*
                 * Try a makefile for the architecture second.
                 */
-               (void)snprintf(buf, sizeof(buf), "arch/%s/conf/Makefile.%s",
-                   machinearch, machinearch);
-               free(ifname);
-               ifname = sourcepath(buf);
+               (void)snprintf(ifname, sizeof(ifname),
+                   "%s/arch/%s/conf/Makefile.%s",
+                   srcdir, machinearch, machinearch);
                ifp = fopen(ifname, "r");
        }
        if (ifp == NULL) {
@@ -205,7 +202,6 @@
                warn("error renaming Makefile");
                goto bad2;
        }
-       free(ifname);
        return (0);
 
  wrerror:
@@ -217,7 +213,6 @@
        (void)fclose(ifp);
        /* (void)unlink("Makefile.tmp"); */
  bad2:
-       free(ifname);
        return (1);
 }
 



Home | Main Index | Thread Index | Old Index