summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
authorMark Lumsden <lum@cvs.openbsd.org>2021-05-03 13:28:04 +0000
committerMark Lumsden <lum@cvs.openbsd.org>2021-05-03 13:28:04 +0000
commita9233f12975f549c2b68d2286a02f6033908bf6a (patch)
tree65186316061084e5f1e8d63d8b3008a828bab73b /usr.bin/mg
parent518982d622d2994873279f54c7c550d3b51030b1 (diff)
When parsing a variable value within double quotes, allow parenthesis
to be accomodated for.
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/interpreter.c70
1 files changed, 37 insertions, 33 deletions
diff --git a/usr.bin/mg/interpreter.c b/usr.bin/mg/interpreter.c
index d958cb5107f..1b99318ab5e 100644
--- a/usr.bin/mg/interpreter.c
+++ b/usr.bin/mg/interpreter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interpreter.c,v 1.23 2021/05/03 12:18:43 lum Exp $ */
+/* $OpenBSD: interpreter.c,v 1.24 2021/05/03 13:28:03 lum Exp $ */
/*
* This file is in the public domain.
*
@@ -158,48 +158,52 @@ foundparen(char *funstr, int llen)
if (*p == '\\') {
esc = 1;
} else if (*p == '(') {
- if (inquote != 0) {
+ if (inquote == 0) {
+ if (begp != NULL) {
+ if (endp == NULL)
+ *p = '\0';
+ else
+ *endp = '\0';
+
+ ret = parse(begp, lrp, &lp, blkid,
+ ++expctr);
+ if (!ret) {
+ cleanup();
+ return(ret);
+ }
+ }
+ lrp = &lp;
+ begp = endp = NULL;
+ pctr++;
+ } else if (inquote != 1) {
cleanup();
return(dobeep_msg("Opening and closing quote "\
"char error"));
}
- if (begp != NULL) {
- if (endp == NULL)
- *p = '\0';
- else
- *endp = '\0';
-
- ret = parse(begp, lrp, &lp, blkid, ++expctr);
- if (!ret) {
- cleanup();
- return(ret);
- }
- }
- lrp = &lp;
- begp = endp = NULL;
- pctr++;
esc = 0;
} else if (*p == ')') {
- if (inquote != 0) {
+ if (inquote == 0) {
+ if (begp != NULL) {
+ if (endp == NULL)
+ *p = '\0';
+ else
+ *endp = '\0';
+
+ ret = parse(begp, lrp, &rp, blkid,
+ ++expctr);
+ if (!ret) {
+ cleanup();
+ return(ret);
+ }
+ }
+ lrp = &rp;
+ begp = endp = NULL;
+ pctr--;
+ } else if (inquote != 1) {
cleanup();
return(dobeep_msg("Opening and closing quote "\
"char error"));
}
- if (begp != NULL) {
- if (endp == NULL)
- *p = '\0';
- else
- *endp = '\0';
-
- ret = parse(begp, lrp, &rp, blkid, ++expctr);
- if (!ret) {
- cleanup();
- return(ret);
- }
- }
- lrp = &rp;
- begp = endp = NULL;
- pctr--;
esc = 0;
} else if (*p != ' ' && *p != '\t') {
if (begp == NULL)