From 1075ca69b0ef393b78952c0de639252fb70d559d Mon Sep 17 00:00:00 2001 From: axel Date: Fri, 24 Feb 2006 22:18:29 +1000 Subject: [PATCH] Switch to standard syntax for octal escapes darcs-hash:20060224121829-ac50b-8e19f27857378e6456ae08269721138bd60f3464.gz --- common.c | 47 ++++++++++++++++++++++++++++++----------------- doc_src/doc.hdr | 2 +- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/common.c b/common.c index d1d2fe21a..76da6eba8 100644 --- a/common.c +++ b/common.c @@ -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 0) && (res <= max_val) ) + { + in[out_pos] = (byte?ENCODE_DIRECT_BASE:0)+res; + } + else + { + free(in); + return 0; + } + break; } diff --git a/doc_src/doc.hdr b/doc_src/doc.hdr index 8e31346db..9ceddfc5f 100644 --- a/doc_src/doc.hdr +++ b/doc_src/doc.hdr @@ -115,7 +115,7 @@ these characters, so called escape sequences are provided. These are: - '\\^', escapes the circumflex character - '\\xxx', where xx is a hexadecimal number, escapes the ascii character with the specified value - '\\Xxx', where xx 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. -- '\\oooo', where ooo is an octal number, escapes the ascii character with the specified value +- '\\ooo', where ooo is an octal number, escapes the ascii character with the specified value - '\\uxxxx', where xxxx is a hexadecimal number, escapes the 16-bit unicode character with the specified value - '\\Uxxxxxxxx', where xxxxxxxx is a hexadecimal number, escapes the 32-bit unicode character with the specified value