diff options
author | 2006-02-24 22:18:29 +1000 | |
---|---|---|
committer | 2006-02-24 22:18:29 +1000 | |
commit | 1075ca69b0ef393b78952c0de639252fb70d559d (patch) | |
tree | 3a39e680d379361071bfb25559d817d271251eaf /common.c | |
parent | e29f5c5474ab59a2487cd5216810b090cd2b13f6 (diff) |
Switch to standard syntax for octal escapes
darcs-hash:20060224121829-ac50b-8e19f27857378e6456ae08269721138bd60f3464.gz
Diffstat (limited to 'common.c')
-rw-r--r-- | common.c | 47 |
1 files changed, 30 insertions, 17 deletions
@@ -917,74 +917,87 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special ) break; } - case L'X': case L'u': case L'U': 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; - wchar_t res=0; + long long res=0; int chars=2; int base=16; int byte = 0; + int max_val = 127; switch( in[in_pos] ) { case L'u': { - base=16; chars=4; + max_val = 35535; break; } case L'U': { - base=16; chars=8; + max_val = WCHAR_MAX; break; } case L'x': { - base=16; - chars=2; break; } case L'X': { byte=1; - base=16; - chars=2; + max_val = 255; break; } - case L'o': + default: { base=8; chars=3; + in_pos--; break; - } - + } } for( i=0; i<chars; i++ ) { int d = convert_digit( in[++in_pos],base); + if( d < 0 ) { in_pos--; break; } - + 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; } |