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): constify VarModify parameter



details:   https://anonhg.NetBSD.org/src/rev/2b475d83569b
branches:  trunk
changeset: 1011611:2b475d83569b
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jul 04 16:30:47 2020 +0000

description:
make(1): constify VarModify parameter

Since var.c r1.238 and r1.239, the callbacks for the :H :T :E :R modifiers
don't modify the word anymore, and the others didn't modify it at all.

diffstat:

 usr.bin/make/var.c |  36 ++++++++++++++++++------------------
 1 files changed, 18 insertions(+), 18 deletions(-)

diffs (153 lines):

diff -r 36978559ceab -r 2b475d83569b usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Jul 04 16:15:21 2020 +0000
+++ b/usr.bin/make/var.c        Sat Jul 04 16:30:47 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.252 2020/07/04 15:44:07 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.253 2020/07/04 16:30:47 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.252 2020/07/04 15:44:07 rillig Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.253 2020/07/04 16:30:47 rillig 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.252 2020/07/04 15:44:07 rillig Exp $");
+__RCSID("$NetBSD: var.c,v 1.253 2020/07/04 16:30:47 rillig Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -1125,14 +1125,14 @@
  * It returns the addSpace value for the next call of this callback. Typical
  * return values are the current addSpaces or TRUE. */
 typedef Boolean (*VarModifyCallback)(GNode *ctxt, Var_Parse_State *vpstate,
-    char *word, Boolean addSpace, Buffer *buf, void *data);
+    const char *word, Boolean addSpace, Buffer *buf, void *data);
 
 
 /* Callback function for VarModify to implement the :H modifier.
  * Add the dirname of the given word to the buffer. */
 static Boolean
 VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
-       char *word, Boolean addSpace, Buffer *buf,
+       const char *word, Boolean addSpace, Buffer *buf,
        void *dummy MAKE_ATTR_UNUSED)
 {
     const char *slash = strrchr(word, '/');
@@ -1151,7 +1151,7 @@
  * Add the basename of the given word to the buffer. */
 static Boolean
 VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
-       char *word, Boolean addSpace, Buffer *buf,
+       const char *word, Boolean addSpace, Buffer *buf,
        void *dummy MAKE_ATTR_UNUSED)
 {
     const char *slash = strrchr(word, '/');
@@ -1167,7 +1167,7 @@
  * Add the filename suffix of the given word to the buffer, if it exists. */
 static Boolean
 VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
-         char *word, Boolean addSpace, Buffer *buf,
+         const char *word, Boolean addSpace, Buffer *buf,
          void *dummy MAKE_ATTR_UNUSED)
 {
     const char *dot = strrchr(word, '.');
@@ -1184,7 +1184,7 @@
  * Add the filename basename of the given word to the buffer. */
 static Boolean
 VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
-       char *word, Boolean addSpace, Buffer *buf,
+       const char *word, Boolean addSpace, Buffer *buf,
        void *dummy MAKE_ATTR_UNUSED)
 {
     char *dot = strrchr(word, '.');
@@ -1200,7 +1200,7 @@
  * Place the word in the buffer if it matches the given pattern. */
 static Boolean
 VarMatch(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
-        char *word, Boolean addSpace, Buffer *buf,
+        const char *word, Boolean addSpace, Buffer *buf,
         void *data)
 {
     const char *pattern = data;
@@ -1218,7 +1218,7 @@
 /* Callback function for VarModify to implement the :%.from=%.to modifier. */
 static Boolean
 VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate,
-            char *word, Boolean addSpace, Buffer *buf,
+            const char *word, Boolean addSpace, Buffer *buf,
             void *data)
 {
     size_t len;
@@ -1245,7 +1245,7 @@
  * Place the word in the buffer if it doesn't match the given pattern. */
 static Boolean
 VarNoMatch(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
-          char *word, Boolean addSpace, Buffer *buf,
+          const char *word, Boolean addSpace, Buffer *buf,
           void *data)
 {
     const char *pattern = data;
@@ -1261,11 +1261,11 @@
  * Perform a string substitution on the given word. */
 static Boolean
 VarSubstitute(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
-             char *word, Boolean addSpace, Buffer *buf,
+             const char *word, Boolean addSpace, Buffer *buf,
              void *data)
 {
     int wordLen = strlen(word);
-    char *cp;                  /* General pointer */
+    const char *cp;            /* General pointer */
     VarPattern *pattern = data;
 
     if ((pattern->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) !=
@@ -1374,7 +1374,7 @@
                        Buf_AddByte(buf, vpstate->varSpace);
                        addSpace = FALSE;
                    }
-                   Buf_AddBytes(buf, cp-word, word);
+                   Buf_AddBytes(buf, cp - word, word);
                    Buf_AddBytes(buf, pattern->rightLen, pattern->rhs);
                    wordLen -= (cp - word) + pattern->leftLen;
                    word = cp + pattern->leftLen;
@@ -1441,12 +1441,12 @@
 static Boolean
 VarRESubstitute(GNode *ctx MAKE_ATTR_UNUSED,
                Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
-               char *word, Boolean addSpace, Buffer *buf,
+               const char *word, Boolean addSpace, Buffer *buf,
                void *data)
 {
     VarREPattern *pat = data;
     int xrv;
-    char *wp = word;
+    const char *wp = word;
     char *rp;
     int added = 0;
     int flags = 0;
@@ -1557,7 +1557,7 @@
 static Boolean
 VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSED,
              Var_Parse_State *vpstate MAKE_ATTR_UNUSED,
-             char *word, Boolean addSpace, Buffer *buf,
+             const char *word, Boolean addSpace, Buffer *buf,
              void *data)
 {
     VarLoop *loop = data;
@@ -1672,7 +1672,7 @@
  * Replace each word with the result of realpath() if successful. */
 static Boolean
 VarRealpath(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate,
-           char *word, Boolean addSpace, Buffer *buf,
+           const char *word, Boolean addSpace, Buffer *buf,
            void *patternp MAKE_ATTR_UNUSED)
 {
     struct stat st;



Home | Main Index | Thread Index | Old Index