Module Name:    src
Committed By:   rillig
Date:           Wed Sep 30 06:46:43 UTC 2020

Modified Files:
        src/usr.bin/make: var.c

Log Message:
make(1): extract ApplyModifier_Quote into separate function


To generate a diff of this commit:
cvs rdiff -u -r1.554 -r1.555 src/usr.bin/make/var.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.554 src/usr.bin/make/var.c:1.555
--- src/usr.bin/make/var.c:1.554	Wed Sep 30 05:58:22 2020
+++ src/usr.bin/make/var.c	Wed Sep 30 06:46:43 2020
@@ -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 @@ ApplyModifier_Regex(const char **pp, App
 }
 #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 @@ ApplyModifier(const char **pp, ApplyModi
 #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':

Reply via email to