Correctly handle multiple backslashes at end of line w.r.t. multiline handling

darcs-hash:20061120021934-ac50b-20d953c16711a4959cac9d435217309fc78aab98.gz
This commit is contained in:
axel
2006-11-20 12:19:34 +10:00
parent c2e1d76400
commit 7b5649097f

View File

@@ -1985,6 +1985,27 @@ static int wchar_private( wchar_t c )
return ( (c >= 0xe000) && (c <= 0xf8ff ) );
}
/**
Test if the specified character in the specified string is
backslashed.
*/
static int is_backslashed( const wchar_t *str, int pos )
{
int count = 0;
int i;
for( i=pos-1; i>=0; i-- )
{
if( str[i] != L'\\' )
break;
count++;
}
return count %2;
}
wchar_t *reader_readline()
{
@@ -2366,7 +2387,7 @@ wchar_t *reader_readline()
/*
Allow backslash-escaped newlines
*/
if( data->buff_pos && data->buff[data->buff_pos-1]==L'\\' )
if( is_backslashed( data->buff, data->buff_pos ) )
{
insert_char( '\n' );
break;