Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/config Allow abolute pathnames as prefixes.



details:   https://anonhg.NetBSD.org/src/rev/d9a97b1e5546
branches:  trunk
changeset: 480786:d9a97b1e5546
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Thu Jan 20 00:08:08 2000 +0000

description:
Allow abolute pathnames as prefixes.

diffstat:

 usr.sbin/config/mkmakefile.c |  33 +++++++++++++++++++++++++--------
 usr.sbin/config/util.c       |  25 ++++++++++++++++---------
 2 files changed, 41 insertions(+), 17 deletions(-)

diffs (131 lines):

diff -r 9a950a1fc2c1 -r d9a97b1e5546 usr.sbin/config/mkmakefile.c
--- a/usr.sbin/config/mkmakefile.c      Thu Jan 20 00:07:49 2000 +0000
+++ b/usr.sbin/config/mkmakefile.c      Thu Jan 20 00:08:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mkmakefile.c,v 1.42 1999/07/09 18:45:31 thorpej Exp $  */
+/*     $NetBSD: mkmakefile.c,v 1.43 2000/01/20 00:08:08 thorpej Exp $  */
 
 /*
  * Copyright (c) 1992, 1993
@@ -58,7 +58,9 @@
  */
 
 static const char *srcpath __P((struct files *)); 
-                        
+
+static const char *prefix_prologue __P((const char *));
+
 static int emitdefs __P((FILE *));
 static int emitfiles __P((FILE *, int));
 
@@ -176,6 +178,17 @@
 #endif
 }
 
+static const char *
+prefix_prologue(path)
+       const char *path;
+{
+
+       if (*path == '/')
+               return ("");
+       else
+               return ("$S/");
+}
+
 static int
 emitdefs(fp)
        FILE *fp;
@@ -266,8 +279,9 @@
                                return (1);
                } else {
                        if (oi->oi_prefix != NULL) {
-                               if (fprintf(fp, "%c$S/%s/%s", sp, oi->oi_prefix,
-                                   oi->oi_path) < 0)
+                               if (fprintf(fp, "%c%s%s/%s", sp,
+                                   prefix_prologue(oi->oi_prefix),
+                                   oi->oi_prefix, oi->oi_path) < 0)
                                        return (1);
                        } else {
                                if (fprintf(fp, "%c$S/%s", sp, oi->oi_path) < 0)
@@ -337,8 +351,9 @@
                                return (1);
                } else {
                        if (fi->fi_prefix != NULL) {
-                               if (fprintf(fp, "%c$S/%s/%s", sp, fi->fi_prefix,
-                                   fi->fi_path) < 0)
+                               if (fprintf(fp, "%c%s%s/%s", sp,
+                                   prefix_prologue(fi->fi_prefix),
+                                   fi->fi_prefix, fi->fi_path) < 0)
                                        return (1);
                        } else {
                                if (fprintf(fp, "%c$S/%s", sp, fi->fi_path) < 0)
@@ -396,7 +411,8 @@
                                return (1);
                } else {
                        if (fi->fi_prefix != NULL) {
-                               if (fprintf(fp, "%s.o: $S/%s/%s\n", fi->fi_base,
+                               if (fprintf(fp, "%s.o: %s%s/%s\n", fi->fi_base,
+                                   prefix_prologue(fi->fi_prefix),
                                    fi->fi_prefix, fpath) < 0)
                                        return (1);
                        } else {
@@ -477,7 +493,8 @@
        struct prefix *pf;
 
        for (pf = allprefixes; pf != NULL; pf = pf->pf_next) {
-               if (fprintf(fp, "INCLUDES+=\t-I$S/%s\n", pf->pf_prefix) < 0)
+               if (fprintf(fp, "INCLUDES+=\t-I%s%s\n",
+                   prefix_prologue(pf->pf_prefix), pf->pf_prefix) < 0)
                        return (1);
        }
 
diff -r 9a950a1fc2c1 -r d9a97b1e5546 usr.sbin/config/util.c
--- a/usr.sbin/config/util.c    Thu Jan 20 00:07:49 2000 +0000
+++ b/usr.sbin/config/util.c    Thu Jan 20 00:08:08 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.10 1999/07/09 18:46:09 thorpej Exp $        */
+/*     $NetBSD: util.c,v 1.11 2000/01/20 00:08:08 thorpej Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -124,7 +124,7 @@
 
        pf = emalloc(sizeof(struct prefix));
 
-       if (prefixes != NULL) {
+       if (prefixes != NULL && *path != '/') {
                cp = emalloc(strlen(prefixes->pf_prefix) + 1 +
                    strlen(path) + 1);
                (void) sprintf(cp, "%s/%s", prefixes->pf_prefix, path);
@@ -167,16 +167,23 @@
        size_t len;
        char *cp;
 
-       len = strlen(srcdir) + 1 + strlen(file) + 1;
-       if (prefixes != NULL)
-               len += strlen(prefixes->pf_prefix) + 1;
+       if (prefixes != NULL && *prefixes->pf_prefix == '/')
+               len = strlen(prefixes->pf_prefix) + 1 + strlen(file) + 1;
+       else {
+               len = strlen(srcdir) + 1 + strlen(file) + 1;
+               if (prefixes != NULL)
+                       len += strlen(prefixes->pf_prefix) + 1;
+       }
 
        cp = emalloc(len);
 
-       if (prefixes != NULL)
-               (void) sprintf(cp, "%s/%s/%s", srcdir,
-                   prefixes->pf_prefix, file);
-       else
+       if (prefixes != NULL) {
+               if (*prefixes->pf_prefix == '/')
+                       (void) sprintf(cp, "%s/%s", prefixes->pf_prefix, file);
+               else
+                       (void) sprintf(cp, "%s/%s/%s", srcdir,
+                           prefixes->pf_prefix, file);
+       } else
                (void) sprintf(cp, "%s/%s", srcdir, file);
        return (cp);
 }



Home | Main Index | Thread Index | Old Index