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_Unique into sepa...



details:   https://anonhg.NetBSD.org/src/rev/7ddd0aa53f95
branches:  trunk
changeset: 1014789:7ddd0aa53f95
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Oct 03 12:46:52 2020 +0000

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

diffstat:

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

diffs (50 lines):

diff -r 0e90995d5d5b -r 7ddd0aa53f95 usr.bin/make/var.c
--- a/usr.bin/make/var.c        Sat Oct 03 12:30:17 2020 +0000
+++ b/usr.bin/make/var.c        Sat Oct 03 12:46:52 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.560 2020/10/03 12:30:17 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.561 2020/10/03 12:46:52 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.560 2020/10/03 12:30:17 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.561 2020/10/03 12:46:52 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2927,6 +2927,17 @@
     return AMR_OK;
 }
 
+static ApplyModifierResult
+ApplyModifier_Unique(const char **pp, ApplyModifiersState *st)
+{
+    if ((*pp)[1] == st->endc || (*pp)[1] == ':') {
+       st->newVal = VarUniq(st->val);
+       (*pp)++;
+       return AMR_OK;
+    } else
+       return AMR_UNKNOWN;
+}
+
 #ifdef SYSVVARSUB
 /* :from=to */
 static ApplyModifierResult
@@ -3110,12 +3121,7 @@
     case 'O':
        return ApplyModifier_Order(pp, st);
     case 'u':
-       if ((*pp)[1] == st->endc || (*pp)[1] == ':') {
-           st->newVal = VarUniq(st->val);
-           (*pp)++;
-           return AMR_OK;
-       } else
-           return AMR_UNKNOWN;
+        return ApplyModifier_Unique(pp, st);
 #ifdef SUNSHCMD
     case 's':
        return ApplyModifier_SunShell(pp, st);



Home | Main Index | Thread Index | Old Index