mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Switch to standard syntax for octal escapes
darcs-hash:20060224121829-ac50b-8e19f27857378e6456ae08269721138bd60f3464.gz
This commit is contained in:
parent
e29f5c5474
commit
1075ca69b0
2 changed files with 31 additions and 18 deletions
39
common.c
39
common.c
|
@ -917,62 +917,68 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case L'X':
|
|
||||||
case L'u':
|
case L'u':
|
||||||
case L'U':
|
case L'U':
|
||||||
case L'x':
|
case L'x':
|
||||||
case L'o':
|
case L'X':
|
||||||
|
case L'0':
|
||||||
|
case L'1':
|
||||||
|
case L'2':
|
||||||
|
case L'3':
|
||||||
|
case L'4':
|
||||||
|
case L'5':
|
||||||
|
case L'6':
|
||||||
|
case L'7':
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
wchar_t res=0;
|
long long res=0;
|
||||||
int chars=2;
|
int chars=2;
|
||||||
int base=16;
|
int base=16;
|
||||||
|
|
||||||
int byte = 0;
|
int byte = 0;
|
||||||
|
int max_val = 127;
|
||||||
|
|
||||||
switch( in[in_pos] )
|
switch( in[in_pos] )
|
||||||
{
|
{
|
||||||
case L'u':
|
case L'u':
|
||||||
{
|
{
|
||||||
base=16;
|
|
||||||
chars=4;
|
chars=4;
|
||||||
|
max_val = 35535;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case L'U':
|
case L'U':
|
||||||
{
|
{
|
||||||
base=16;
|
|
||||||
chars=8;
|
chars=8;
|
||||||
|
max_val = WCHAR_MAX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case L'x':
|
case L'x':
|
||||||
{
|
{
|
||||||
base=16;
|
|
||||||
chars=2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case L'X':
|
case L'X':
|
||||||
{
|
{
|
||||||
byte=1;
|
byte=1;
|
||||||
base=16;
|
max_val = 255;
|
||||||
chars=2;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case L'o':
|
default:
|
||||||
{
|
{
|
||||||
base=8;
|
base=8;
|
||||||
chars=3;
|
chars=3;
|
||||||
|
in_pos--;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i=0; i<chars; i++ )
|
for( i=0; i<chars; i++ )
|
||||||
{
|
{
|
||||||
int d = convert_digit( in[++in_pos],base);
|
int d = convert_digit( in[++in_pos],base);
|
||||||
|
|
||||||
if( d < 0 )
|
if( d < 0 )
|
||||||
{
|
{
|
||||||
in_pos--;
|
in_pos--;
|
||||||
|
@ -980,10 +986,17 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special )
|
||||||
}
|
}
|
||||||
|
|
||||||
res=(res*base)|d;
|
res=(res*base)|d;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
in[out_pos] = (byte?ENCODE_DIRECT_BASE:0)+res;
|
if( (res > 0) && (res <= max_val) )
|
||||||
|
{
|
||||||
|
in[out_pos] = (byte?ENCODE_DIRECT_BASE:0)+res;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(in);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,7 @@ these characters, so called escape sequences are provided. These are:
|
||||||
- <code>'\\^'</code>, escapes the circumflex character
|
- <code>'\\^'</code>, escapes the circumflex character
|
||||||
- <code>'\\x<i>xx</i>'</code>, where <code><i>xx</i></code> is a hexadecimal number, escapes the ascii character with the specified value
|
- <code>'\\x<i>xx</i>'</code>, where <code><i>xx</i></code> is a hexadecimal number, escapes the ascii character with the specified value
|
||||||
- <code>'\\X<i>xx</i>'</code>, where <code><i>xx</i></code> is a hexadecimal number, escapes a byte of data with the specified value. If you are using a mutibyte encoding, this can be used to enter invalid strings. Only use this if you know what you are doing.
|
- <code>'\\X<i>xx</i>'</code>, where <code><i>xx</i></code> is a hexadecimal number, escapes a byte of data with the specified value. If you are using a mutibyte encoding, this can be used to enter invalid strings. Only use this if you know what you are doing.
|
||||||
- <code>'\\o<i>ooo</i>'</code>, where <code><i>ooo</i></code> is an octal number, escapes the ascii character with the specified value
|
- <code>'\\<i>ooo</i>'</code>, where <code><i>ooo</i></code> is an octal number, escapes the ascii character with the specified value
|
||||||
- <code>'\\u<i>xxxx</i>'</code>, where <code><i>xxxx</i></code> is a hexadecimal number, escapes the 16-bit unicode character with the specified value
|
- <code>'\\u<i>xxxx</i>'</code>, where <code><i>xxxx</i></code> is a hexadecimal number, escapes the 16-bit unicode character with the specified value
|
||||||
- <code>'\\U<i>xxxxxxxx</i>'</code>, where <code><i>xxxxxxxx</i></code> is a hexadecimal number, escapes the 32-bit unicode character with the specified value
|
- <code>'\\U<i>xxxxxxxx</i>'</code>, where <code><i>xxxxxxxx</i></code> is a hexadecimal number, escapes the 32-bit unicode character with the specified value
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue