Module Name:    src
Committed By:   rillig
Date:           Mon Sep 28 21:01:53 UTC 2020

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

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


To generate a diff of this commit:
cvs rdiff -u -r1.547 -r1.548 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.547 src/usr.bin/make/var.c:1.548
--- src/usr.bin/make/var.c:1.547	Mon Sep 28 20:55:20 2020
+++ src/usr.bin/make/var.c	Mon Sep 28 21:01:53 2020
@@ -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 @@ ApplyModifier_SysV(const char **pp, Appl
 }
 #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 @@ ApplyModifiers(
 	    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:

Reply via email to