From 95af0ef9c4639763c8094d6e8cd5d8ec01a32f96 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Tue, 9 Nov 1999 09:01:23 +0000 Subject: zsh-workers/8599 --- Src/Zle/compcore.c | 52 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c index 3ea884f53..c3de9c564 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -923,34 +923,40 @@ makecomplist(char *s, int incmd, int lst) char * multiquote(char *s, int ign) { - char *os = s, *p = compqstack; - - if (p && *p && (ign < 1 || p[ign])) { - if (ign > 0) - p += ign; - while (*p) { - if (ign >= 0 || p[1]) - s = bslashquote(s, NULL, - (*p == '\'' ? 1 : (*p == '"' ? 2 : 0))); - p++; + if (s) { + char *os = s, *p = compqstack; + + if (p && *p && (ign < 1 || p[ign])) { + if (ign > 0) + p += ign; + while (*p) { + if (ign >= 0 || p[1]) + s = bslashquote(s, NULL, + (*p == '\'' ? 1 : (*p == '"' ? 2 : 0))); + p++; + } } + return (s == os ? dupstring(s) : s); } - return (s == os ? dupstring(s) : s); + return NULL; } /**/ char * tildequote(char *s, int ign) { - int tilde; + if (s) { + int tilde; - if ((tilde = (*s == '~'))) - *s = 'x'; - s = multiquote(s, ign); - if (tilde) - *s = '~'; + if ((tilde = (*s == '~'))) + *s = 'x'; + s = multiquote(s, ign); + if (tilde) + *s = '~'; - return s; + return s; + } + return NULL; } /* Check if we have to complete a parameter name. */ @@ -1708,10 +1714,12 @@ addmatches(Cadata dat, char **argv) } else if (dat->rems) dat->rems = dupstring(dat->rems); - lpre = ((!(dat->aflags & CAF_QUOTE) && - (!dat->ppre && (dat->flags & CMF_FILE))) ? - tildequote(lpre, 1) : multiquote(lpre, 1)); - lsuf = multiquote(lsuf, 1); + if (lpre) + lpre = ((!(dat->aflags & CAF_QUOTE) && + (!dat->ppre && (dat->flags & CMF_FILE))) ? + tildequote(lpre, 1) : multiquote(lpre, 1)); + if (lsuf) + lsuf = multiquote(lsuf, 1); } /* Walk through the matches given. */ obpl = bpl; -- cgit 1.4.1