about summary refs log tree commit diff
path: root/Src/utils.c
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-07-12 17:02:40 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-07-12 17:02:40 +0000
commit1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1 (patch)
tree608d6471d477e8d4d9eafa62f521be50c3248f6e /Src/utils.c
parent7c670f1e6a0e154f0b1a2d4b6eed0e71c9404b56 (diff)
downloadzsh-1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1.tar.gz
zsh-1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1.tar.xz
zsh-1f6786ef7ae24ff858f52c6d4ac2bc23d529c0c1.zip
zsh-3.1.6-test-1 zsh-3.1.6-test-1
Diffstat (limited to 'Src/utils.c')
-rw-r--r--Src/utils.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/Src/utils.c b/Src/utils.c
index a409ab03c..d82f62694 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1735,10 +1735,11 @@ findsep(char **s, char *sep)
 	if (!*t)
 	    return i;
 	if (*(*s)++ == Meta) {
-	    (*s)++;
 #ifdef DEBUG
-	    if (! **s)
+	    if (! *(*s)++)
 		fprintf(stderr, "BUG: unexpected end of string in findsep()\n");
+#else
+	    (*s)++;
 #endif
 	}
     }
@@ -3187,24 +3188,28 @@ dquotedzputs(char const *s, FILE *stream)
  *   4:  Do $'...' quoting.  Overwrites the existing string instead of
  *       zhalloc'ing 
  *   5:  As 2, but \- is special.  Expects misc to be defined.
+ *   6:  As 2, but parses only one character and returns end-pointer
+ *       and parsed character in *misc
  */
 
 /**/
 char *
 getkeystring(char *s, int *len, int fromwhere, int *misc)
 {
-    char *buf;
+    char *buf, tmp[1];
     char *t, *u = NULL;
     char svchar = '\0';
     int meta = 0, control = 0;
 
-    if (fromwhere != 4)
-	buf = zhalloc(strlen(s) + 1);
+    if (fromwhere == 6)
+	t = tmp;
+    else if (fromwhere != 4)
+	t = buf = zhalloc(strlen(s) + 1);
     else {
-	buf = s;
+	t = buf = s;
 	s += 2;
     }
-    for (t = buf; *s; s++) {
+    for (; *s; s++) {
 	if (*s == '\\' && s[1]) {
 	    switch (*++s) {
 	    case 'a':
@@ -3303,7 +3308,8 @@ getkeystring(char *s, int *len, int fromwhere, int *misc)
 	} else if (fromwhere == 4 && *s == Snull) {
 	    for (u = t; (*u++ = *s++););
 	    return t + 1;
-	} else if (*s == '^' && (fromwhere == 2 || fromwhere == 5)) {
+	} else if (*s == '^' &&
+		   (fromwhere == 2 || fromwhere == 5 || fromwhere == 6)) {
 	    control = 1;
 	    continue;
 	} else if (*s == Meta)
@@ -3330,6 +3336,10 @@ getkeystring(char *s, int *len, int fromwhere, int *misc)
 	    t[-1] = Meta;
 	    t++;
 	}
+	if (fromwhere == 6 && t != tmp) {
+	    *misc = (int) tmp[0];
+	    return s + 1;
+	}
     }
     DPUTS(fromwhere == 4, "BUG: unterminated $' substitution");
     *t = '\0';