Source-Changes-HG archive

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

[src/netbsd-1-5]: src/usr.bin/make Pull up revision 1.61 (requested by explor...



details:   https://anonhg.NetBSD.org/src/rev/a2b912e46a4d
branches:  netbsd-1-5
changeset: 491859:a2b912e46a4d
user:      he <he%NetBSD.org@localhost>
date:      Thu Jun 07 19:53:06 2001 +0000

description:
Pull up revision 1.61 (requested by explorer):
  Expand variables in SysV patterns, as in ``${SRCS:.c=.${O}}''.

diffstat:

 usr.bin/make/var.c |  109 ++++++++++++++++++++++++++++++++--------------------
 1 files changed, 66 insertions(+), 43 deletions(-)

diffs (truncated from 330 to 300 lines):

diff -r 6b99fd62f512 -r a2b912e46a4d usr.bin/make/var.c
--- a/usr.bin/make/var.c        Thu Jun 07 17:00:32 2001 +0000
+++ b/usr.bin/make/var.c        Thu Jun 07 19:53:06 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.53 2000/06/10 05:54:29 sjg Exp $     */
+/*     $NetBSD: var.c,v 1.53.2.1 2001/06/07 19:53:06 he Exp $  */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -39,14 +39,14 @@
  */
 
 #ifdef MAKE_BOOTSTRAP
-static char rcsid[] = "$NetBSD: var.c,v 1.53 2000/06/10 05:54:29 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.53.2.1 2001/06/07 19:53:06 he Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)var.c      8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: var.c,v 1.53 2000/06/10 05:54:29 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.53.2.1 2001/06/07 19:53:06 he Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -193,26 +193,31 @@
 
 static Var *VarFind __P((char *, GNode *, int));
 static void VarAdd __P((char *, char *, GNode *));
-static Boolean VarHead __P((char *, Boolean, Buffer, ClientData));
-static Boolean VarTail __P((char *, Boolean, Buffer, ClientData));
-static Boolean VarSuffix __P((char *, Boolean, Buffer, ClientData));
-static Boolean VarRoot __P((char *, Boolean, Buffer, ClientData));
-static Boolean VarMatch __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarHead __P((GNode *, char *, Boolean, Buffer, ClientData));
+static Boolean VarTail __P((GNode *, char *, Boolean, Buffer, ClientData));
+static Boolean VarSuffix __P((GNode *, char *, Boolean, Buffer, ClientData));
+static Boolean VarRoot __P((GNode *, char *, Boolean, Buffer, ClientData));
+static Boolean VarMatch __P((GNode *, char *, Boolean, Buffer, ClientData));
 #ifdef SYSVVARSUB
-static Boolean VarSYSVMatch __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarSYSVMatch __P((GNode *, char *, Boolean, Buffer,
+                                ClientData));
 #endif
-static Boolean VarNoMatch __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarNoMatch __P((GNode *, char *, Boolean, Buffer, ClientData));
 #ifndef NO_REGEX
 static void VarREError __P((int, regex_t *, const char *));
-static Boolean VarRESubstitute __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarRESubstitute __P((GNode *, char *, Boolean, Buffer,
+                                   ClientData));
 #endif
-static Boolean VarSubstitute __P((char *, Boolean, Buffer, ClientData));
-static Boolean VarLoopExpand __P((char *, Boolean, Buffer, ClientData));
+static Boolean VarSubstitute __P((GNode *, char *, Boolean, Buffer,
+                                 ClientData));
+static Boolean VarLoopExpand __P((GNode *, char *, Boolean, Buffer,
+                                 ClientData));
 static char *VarGetPattern __P((GNode *, int, char **, int, int *, int *,
                                VarPattern *));
 static char *VarQuote __P((char *));
-static char *VarModify __P((char *, Boolean (*)(char *, Boolean, Buffer,
-                                               ClientData),
+static char *VarModify __P((GNode *, char *, Boolean (*)(GNode *, char *,
+                                                        Boolean, Buffer,
+                                                        ClientData),
                            ClientData));
 static char *VarSort __P((char *));
 static int VarWordCompare __P((const void *, const void *));
@@ -618,7 +623,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarHead (word, addSpace, buf, dummy)
+VarHead (ctx, word, addSpace, buf, dummy)
+    GNode        *ctx;
     char         *word;        /* Word to trim */
     Boolean      addSpace;     /* True if need to add a space to the buffer
                                 * before sticking in the head */
@@ -665,7 +671,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarTail (word, addSpace, buf, dummy)
+VarTail (ctx, word, addSpace, buf, dummy)
+    GNode        *ctx;
     char         *word;        /* Word to trim */
     Boolean      addSpace;     /* TRUE if need to stick a space in the
                                 * buffer before adding the tail */
@@ -704,7 +711,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarSuffix (word, addSpace, buf, dummy)
+VarSuffix (ctx, word, addSpace, buf, dummy)
+    GNode        *ctx;
     char         *word;        /* Word to trim */
     Boolean      addSpace;     /* TRUE if need to add a space before placing
                                 * the suffix in the buffer */
@@ -742,7 +750,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarRoot (word, addSpace, buf, dummy)
+VarRoot (ctx, word, addSpace, buf, dummy)
+    GNode        *ctx;
     char         *word;        /* Word to trim */
     Boolean      addSpace;     /* TRUE if need to add a space to the buffer
                                 * before placing the root in it */
@@ -782,7 +791,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarMatch (word, addSpace, buf, pattern)
+VarMatch (ctx, word, addSpace, buf, pattern)
+    GNode        *ctx;
     char         *word;        /* Word to examine */
     Boolean      addSpace;     /* TRUE if need to add a space to the
                                 * buffer before adding the word, if it
@@ -818,7 +828,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarSYSVMatch (word, addSpace, buf, patp)
+VarSYSVMatch (ctx, word, addSpace, buf, patp)
+    GNode        *ctx;
     char         *word;        /* Word to examine */
     Boolean      addSpace;     /* TRUE if need to add a space to the
                                 * buffer before adding the word, if it
@@ -829,16 +840,20 @@
     int len;
     char *ptr;
     VarPattern           *pat = (VarPattern *) patp;
+    char *varexp;
 
     if (addSpace)
        Buf_AddByte(buf, (Byte)' ');
 
     addSpace = TRUE;
 
-    if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL)
-       Str_SYSVSubst(buf, pat->rhs, ptr, len);
-    else
+    if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL) {
+        varexp = Var_Subst(NULL, pat->rhs, ctx, 0);
+       Str_SYSVSubst(buf, varexp, ptr, len);
+       free(varexp);
+    } else {
        Buf_AddBytes(buf, strlen(word), (Byte *) word);
+    }
 
     return(addSpace);
 }
@@ -861,7 +876,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarNoMatch (word, addSpace, buf, pattern)
+VarNoMatch (ctx, word, addSpace, buf, pattern)
+    GNode        *ctx;
     char         *word;        /* Word to examine */
     Boolean      addSpace;     /* TRUE if need to add a space to the
                                 * buffer before adding the word, if it
@@ -895,7 +911,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarSubstitute (word, addSpace, buf, patternp)
+VarSubstitute (ctx, word, addSpace, buf, patternp)
+    GNode              *ctx;
     char               *word;      /* Word to modify */
     Boolean            addSpace;   /* True if space should be added before
                                     * other characters */
@@ -1098,7 +1115,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarRESubstitute(word, addSpace, buf, patternp)
+VarRESubstitute(ctx, word, addSpace, buf, patternp)
+    GNode *ctx;
     char *word;
     Boolean addSpace;
     Buffer buf;
@@ -1233,7 +1251,8 @@
  *-----------------------------------------------------------------------
  */
 static Boolean
-VarLoopExpand (word, addSpace, buf, loopp)
+VarLoopExpand (ctx, word, addSpace, buf, loopp)
+    GNode              *ctx;
     char               *word;      /* Word to modify */
     Boolean            addSpace;   /* True if space should be added before
                                     * other characters */
@@ -1270,10 +1289,12 @@
  *-----------------------------------------------------------------------
  */
 static char *
-VarModify (str, modProc, datum)
+VarModify (ctx, str, modProc, datum)
+    GNode        *ctx;
     char         *str;             /* String whose words should be trimmed */
                                    /* Function to use to modify them */
-    Boolean              (*modProc) __P((char *, Boolean, Buffer, ClientData));
+    Boolean              (*modProc) __P((GNode *, char *, Boolean, Buffer,
+                                 ClientData));
     ClientData   datum;            /* Datum to pass it */
 {
     Buffer       buf;              /* Buffer for the new string */
@@ -1290,7 +1311,7 @@
     av = brk_string(str, &ac, FALSE, &as);
 
     for (i = 0; i < ac; i++)
-       addSpace = (*modProc)(av[i], addSpace, buf, datum);
+       addSpace = (*modProc)(ctx, av[i], addSpace, buf, datum);
 
     free(as);
     free(av);
@@ -1700,9 +1721,9 @@
                        val = (char *)Buf_GetAll(v->val, (int *)NULL);
 
                        if (str[1] == 'D') {
-                           val = VarModify(val, VarHead, (ClientData)0);
+                           val = VarModify(ctxt, val, VarHead, (ClientData)0);
                        } else {
-                           val = VarModify(val, VarTail, (ClientData)0);
+                           val = VarModify(ctxt, val, VarTail, (ClientData)0);
                        }
                        /*
                         * Resulting string is dynamically allocated, so
@@ -1991,7 +2012,7 @@
 
                    loop.err = err;
                    loop.ctxt = ctxt;
-                   newStr = VarModify(str, VarLoopExpand,
+                   newStr = VarModify(ctxt, str, VarLoopExpand,
                                       (ClientData)&loop);
                    free(loop.tvar);
                    free(loop.str);
@@ -2168,9 +2189,9 @@
                        copy = TRUE;
                    }
                    if (*tstr == 'M' || *tstr == 'm') {
-                       newStr = VarModify(str, VarMatch, (ClientData)pattern);
+                       newStr = VarModify(ctxt, str, VarMatch, (ClientData)pattern);
                    } else {
-                       newStr = VarModify(str, VarNoMatch,
+                       newStr = VarModify(ctxt, str, VarNoMatch,
                                           (ClientData)pattern);
                    }
                    if (copy) {
@@ -2222,7 +2243,7 @@
                    }
 
                    termc = *cp;
-                   newStr = VarModify(str, VarSubstitute,
+                   newStr = VarModify(ctxt, str, VarSubstitute,
                                       (ClientData)&pattern);
 
                    /*
@@ -2322,7 +2343,7 @@
                        pattern.nsub = 10;
                    pattern.matches = emalloc(pattern.nsub *
                                              sizeof(regmatch_t));
-                   newStr = VarModify(str, VarRESubstitute,
+                   newStr = VarModify(ctxt, str, VarRESubstitute,
                                       (ClientData) &pattern);
                    regfree(&pattern.re);
                    free(pattern.replace);
@@ -2340,7 +2361,7 @@
                    /*FALLTHRU*/
                case 'T':
                    if (tstr[1] == endc || tstr[1] == ':') {
-                       newStr = VarModify (str, VarTail, (ClientData)0);
+                       newStr = VarModify(ctxt, str, VarTail, (ClientData)0);
                        cp = tstr + 1;
                        termc = *cp;
                        break;
@@ -2348,7 +2369,7 @@
                    /*FALLTHRU*/
                case 'H':
                    if (tstr[1] == endc || tstr[1] == ':') {
-                       newStr = VarModify (str, VarHead, (ClientData)0);
+                       newStr = VarModify(ctxt, str, VarHead, (ClientData)0);
                        cp = tstr + 1;
                        termc = *cp;
                        break;
@@ -2356,7 +2377,7 @@
                    /*FALLTHRU*/
                case 'E':
                    if (tstr[1] == endc || tstr[1] == ':') {
-                       newStr = VarModify (str, VarSuffix, (ClientData)0);
+                       newStr = VarModify(ctxt, str, VarSuffix, (ClientData)0);
                        cp = tstr + 1;
                        termc = *cp;
                        break;
@@ -2364,7 +2385,7 @@
                    /*FALLTHRU*/
                case 'R':
                    if (tstr[1] == endc || tstr[1] == ':') {



Home | Main Index | Thread Index | Old Index