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): move variable modifier :sh into separa...



details:   https://anonhg.NetBSD.org/src/rev/8541ea1a3adf
branches:  trunk
changeset: 955423:8541ea1a3adf
user:      rillig <rillig%NetBSD.org@localhost>
date:      Mon Sep 28 21:01:53 2020 +0000

description:
make(1): move variable modifier :sh into separate function

diffstat:

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

diffs (66 lines):

diff -r 5c4679c366a0 -r 8541ea1a3adf usr.bin/make/var.c
--- a/usr.bin/make/var.c        Mon Sep 28 20:55:20 2020 +0000
+++ b/usr.bin/make/var.c        Mon Sep 28 21:01:53 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: var.c,v 1.547 2020/09/28 20:55:20 rillig Exp $ */
+/*     $NetBSD: var.c,v 1.548 2020/09/28 21:01:53 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.547 2020/09/28 20:55:20 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.548 2020/09/28 21:01:53 rillig Exp $");
 
 #define VAR_DEBUG1(fmt, arg1) DEBUG1(VAR, fmt, arg1)
 #define VAR_DEBUG2(fmt, arg1, arg2) DEBUG2(VAR, fmt, arg1, arg2)
@@ -2966,6 +2966,27 @@
 }
 #endif
 
+#ifdef SUNSHCMD
+/* :sh */
+static ApplyModifierResult
+ApplyModifier_SunShell(const char **pp, ApplyModifiersState *st)
+{
+    const char *p = *pp;
+    if (p[1] == 'h' && (p[2] == st->endc || p[2] == ':')) {
+       if (st->eflags & VARE_WANTRES) {
+           const char *errfmt;
+           st->newVal = Cmd_Exec(st->val, &errfmt);
+           if (errfmt)
+               Error(errfmt, st->val);
+       } else
+           st->newVal = emptyString;
+       *pp = p + 2;
+       return AMR_OK;
+    } else
+       return AMR_UNKNOWN;
+}
+#endif
+
 /* Apply any modifiers (such as :Mpattern or :@var@loop@ or :Q or ::=value). */
 static char *
 ApplyModifiers(
@@ -3165,18 +3186,7 @@
            break;
 #ifdef SUNSHCMD
        case 's':
-           if (p[1] == 'h' && (p[2] == st.endc || p[2] == ':')) {
-               if (st.eflags & VARE_WANTRES) {
-                   const char *errfmt;
-                   st.newVal = Cmd_Exec(st.val, &errfmt);
-                   if (errfmt)
-                       Error(errfmt, st.val);
-               } else
-                   st.newVal = emptyString;
-               p += 2;
-               res = AMR_OK;
-           } else
-               res = AMR_UNKNOWN;
+           res = ApplyModifier_SunShell(&p, &st);
            break;
 #endif
        default:



Home | Main Index | Thread Index | Old Index