Allow to use \\$ to input \$.
authorDaniel Carl <danielcarl@gmx.de>
Wed, 4 Jun 2014 21:46:12 +0000 (23:46 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Wed, 4 Jun 2014 21:46:48 +0000 (23:46 +0200)
Also fixed uninitialized expansion flags.

src/ex.c
src/util.c

index b34a7e0..5ad6d42 100644 (file)
--- a/src/ex.c
+++ b/src/ex.c
@@ -645,21 +645,27 @@ static gboolean parse_lhs(const char **input, ExArg *arg)
 static gboolean parse_rhs(const char **input, ExArg *arg)
 {
     int expflags, flags;
+    const char *quoteable;
 
     if (!*input || !**input) {
         return false;
     }
 
-    flags = expflags = (arg->flags & EX_FLAG_EXP)
-        ? UTIL_EXP_TILDE|UTIL_EXP_DOLLAR|UTIL_EXP_SPECIAL
-        : 0;
+    if (arg->flags & EX_FLAG_EXP) {
+        expflags  = UTIL_EXP_TILDE|UTIL_EXP_DOLLAR|UTIL_EXP_SPECIAL;
+        quoteable = "|~$%\\";
+    } else {
+        expflags  = 0;
+        quoteable = "|\\";
+    }
+    flags = expflags;
 
     /* get char until the end of command */
     while (**input && **input != '\n' && **input != '|') {
         /* check for expansion placeholder */
-        util_parse_expansion(input, arg->rhs, flags, "|~$%");
+        util_parse_expansion(input, arg->rhs, flags, "|~$%\\");
 
-        if (VB_IS_SPACE(**input)) {
+        if (VB_IS_SEPARATOR(**input)) {
             /* add tilde expansion for next loop needs to be first char or to
              * be after a space */
             flags = expflags;
index 404d205..078b718 100644 (file)
@@ -352,7 +352,7 @@ char *util_expand(const char *src, int expflags)
     int flags    = expflags;
 
     while (**input) {
-        util_parse_expansion(input, dst, flags, "~$%");
+        util_parse_expansion(input, dst, flags, "~$%\\");
         if (VB_IS_SEPARATOR(**input)) {
             /* after space the tilde expansion is allowed */
             flags = expflags;