1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-03 10:21:46 +02:00

23138: further tweak to backslashes in $'...'

This commit is contained in:
Peter Stephenson 2007-01-27 23:52:13 +00:00
parent df54eeed2c
commit 2b948e6c37
3 changed files with 43 additions and 10 deletions

View file

@ -1,7 +1,8 @@
2007-01-27 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 23136: Src/utils.c, Test/A03quoting.ztst: 23097 added Bnulls
for backslashes in $'...' strings but then didn't handle them.
* 23136, 23138: Src/utils.c, Test/A03quoting.ztst: 23097 added
Bnulls for backslashes in $'...' strings but then didn't handle
them.
2007-01-26 Wayne Davison <wayned@users.sourceforge.net>

View file

@ -4915,27 +4915,45 @@ getkeystring(char *s, int *len, int how, int *misc)
*t++ = *++s ^ 32;
else {
if (itok(*s)) {
/*
* We need to be quite careful here. We haven't
* necessarily got an input stream with all tokens
* removed, so the majority of tokens need passing
* through untouched and without Meta handling.
* However, me may need to handle tokenized
* backslashes.
*/
if (meta || control) {
/*
* Presumably we should be using meta or control
* on the character representing the token.
*
* Special case: $'\M-\\' where the token is a Bnull.
* This time we dump the Bnull since we're
* replacing the whole thing. The lexer
* doesn't know about the meta or control modifiers.
*/
*t++ = ztokens[*s - Pound];
if ((how & GETKEY_DOLLAR_QUOTE) && *s == Bnull)
*t++ = *++s;
else
*t++ = ztokens[*s - Pound];
} else if (how & GETKEY_DOLLAR_QUOTE) {
/*
* We don't want to metafy this, it's a real
* token.
*/
*tdest++ = *s;
if (*s == Bnull) {
/*
* Bnull is a backslash which quotes a couple
* of special characters that always appear
* literally next. See strquote handling
* in gettokstr() in lex.c.
* in gettokstr() in lex.c. We need
* to retain the Bnull (as above) so that quote
* handling in completion can tell where the
* backslash was.
*/
*tdest++ = *++s;
} else {
/*
* We don't want to metafy this, it's a real
* token.
*/
*tdest++ = *s;
}
continue;
} else

View file

@ -17,6 +17,20 @@
0:$'-style quotes with backslashed backslashes
>'a \' is 'a backslash' is 'a \'
chars=$(print -r $'BS\\MBS\M-\\')
for (( i = 1; i <= $#chars; i++ )); do
char=$chars[$i]
print $(( [#16] #char ))
done
0:$'-style quote with metafied backslash
>16#42
>16#53
>16#5C
>16#4D
>16#42
>16#53
>16#DC
print -r ''''
setopt rcquotes
# We need to set rcquotes here for the next example since it is