Fix a bug in completion insertion code on string with escaped quotes. This bug was reported by David Benbennick.

darcs-hash:20060914151821-ac50b-c6628fc01a90865e0aec6e93b39b77c3877606fc.gz
This commit is contained in:
axel 2006-09-15 01:18:21 +10:00
parent 06b5fdc6e8
commit 4399503f4e

View File

@ -1274,28 +1274,36 @@ static wchar_t get_quote( wchar_t *cmd, int l )
int i=0;
wchar_t res=0;
// fwprintf( stderr, L"Woot %ls\n", cmd );
while( 1 )
{
if( !cmd[i] )
break;
if( cmd[i] == L'\'' || cmd[i] == L'\"' )
if( cmd[i] == L'\\' )
{
const wchar_t *end = quote_end( &cmd[i] );
//fwprintf( stderr, L"Jump %d\n", end-cmd );
if(( end == 0 ) || (!*end) || (end-cmd > l))
{
res = cmd[i];
i++;
if( !cmd[i] )
break;
}
i = end-cmd+1;
i++;
}
else
i++;
{
if( cmd[i] == L'\'' || cmd[i] == L'\"' )
{
const wchar_t *end = quote_end( &cmd[i] );
//fwprintf( stderr, L"Jump %d\n", end-cmd );
if(( end == 0 ) || (!*end) || (end-cmd > l))
{
res = cmd[i];
break;
}
i = end-cmd+1;
}
else
i++;
}
}
return res;
}