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): extract ApplyModifier_Quote into separ...



details:   https://anonhg.NetBSD.org/src/rev/cb850fe1a693
branches:  trunk
changeset: 976687:cb850fe1a693
user:      rillig <rillig%NetBSD.org@localhost>
date:      Wed Sep 30 06:46:43 2020 +0000

description:
make(1): extract ApplyModifier_Quote into separate function

diffstat:

 usr.bin/make/var.c |  23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diffs (51 lines):

diff -r f49e161b57c4 -r cb850fe1a693 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Wed Sep 30 06:27:02 2020 +0000
+++ b/usr.bin/make/var.c        Wed Sep 30 06:46:43 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.554 2020/09/30 05:58:22 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.555 2020/09/30 06:46:43 rillig Exp $ */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -121,7 +121,7 @@
 #include    "metachar.h"
 
 /*     "@(#)var.c      8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.554 2020/09/30 05:58:22 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.555 2020/09/30 06:46:43 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2426,6 +2426,18 @@
 }
 #endif
 
+/* :Q, :q */
+static ApplyModifierResult
+ApplyModifier_Quote(const char **pp, ApplyModifiersState *st)
+{
+    if ((*pp)[1] == st->endc || (*pp)[1] == ':') {
+       st->newVal = VarQuote(st->val, **pp == 'q');
+       (*pp)++;
+       return AMR_OK;
+    } else
+       return AMR_UNKNOWN;
+}
+
 static void
 ModifyWord_Copy(const char *word, SepBuf *buf, void *data MAKE_ATTR_UNUSED)
 {
@@ -3074,12 +3086,7 @@
 #endif
     case 'q':
     case 'Q':
-       if ((*pp)[1] == st->endc || (*pp)[1] == ':') {
-           st->newVal = VarQuote(st->val, **pp == 'q');
-           (*pp)++;
-           return AMR_OK;
-       } else
-           return AMR_UNKNOWN;
+        return ApplyModifier_Quote(pp, st);
     case 'T':
        return ApplyModifier_WordFunc(pp, st, ModifyWord_Tail);
     case 'H':



Home | Main Index | Thread Index | Old Index