diff options
author | axel <axel@liljencrantz.se> | 2006-02-13 02:13:31 +1000 |
---|---|---|
committer | axel <axel@liljencrantz.se> | 2006-02-13 02:13:31 +1000 |
commit | 7eb3a5a17dbc1718b65e46e06ceef90db2307c34 (patch) | |
tree | d13ff2ec4b90f1a70a34b950a6a939855dda61dc /common.c | |
parent | b6cd723eb7cd6586063e7d5c35e63828c9310906 (diff) |
Allow backslash of quotes within quotes
darcs-hash:20060212161331-ac50b-c25affaa4b18e1654dab3d08debafa95017009ea.gz
Diffstat (limited to 'common.c')
-rw-r--r-- | common.c | 55 |
1 files changed, 51 insertions, 4 deletions
@@ -551,12 +551,34 @@ int my_wcswidth( const wchar_t *c ) return res; } -wchar_t *quote_end( const wchar_t *in ) +const wchar_t *quote_end( const wchar_t *pos ) { - return wcschr( in+1, *in ); -} + wchar_t c = *pos; + + while( 1 ) + { + pos++; + if( !*pos ) + return 0; + + if( *pos == L'\\') + { + pos++; + } + else + { + if( *pos == c ) + { + return pos; + } + } + } + return 0; + +} + const wchar_t *wsetlocale(int category, const wchar_t *locale) { @@ -1137,6 +1159,30 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special ) */ case 1: { + if( c == L'\\' ) + { + switch( in[++in_pos] ) + { + case L'\'': + { + in[out_pos]=in[in_pos]; + break; + } + + case 0: + { + free(in); + return 0; + } + + default: + { + in[out_pos++] = L'\\'; + in[out_pos]= in[in_pos]; + } + } + + } if( c == L'\'' ) { in[out_pos] = INTERNAL_SEPARATOR; @@ -1175,11 +1221,12 @@ wchar_t *unescape( const wchar_t * orig, int unescape_special ) } case L'$': + case '"': { in[out_pos]=in[in_pos]; break; } - + default: { in[out_pos++] = L'\\'; |