aboutsummaryrefslogtreecommitdiffhomepage
path: root/common.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-02-13 02:13:31 +1000
committerGravatar axel <axel@liljencrantz.se>2006-02-13 02:13:31 +1000
commit7eb3a5a17dbc1718b65e46e06ceef90db2307c34 (patch)
treed13ff2ec4b90f1a70a34b950a6a939855dda61dc /common.c
parentb6cd723eb7cd6586063e7d5c35e63828c9310906 (diff)
Allow backslash of quotes within quotes
darcs-hash:20060212161331-ac50b-c25affaa4b18e1654dab3d08debafa95017009ea.gz
Diffstat (limited to 'common.c')
-rw-r--r--common.c55
1 files changed, 51 insertions, 4 deletions
diff --git a/common.c b/common.c
index e743f632..a3d53667 100644
--- a/common.c
+++ b/common.c
@@ -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'\\';