mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-03 06:41:14 -03:00
Correctly handle multiple backslashes at end of line w.r.t. multiline handling
darcs-hash:20061120021934-ac50b-20d953c16711a4959cac9d435217309fc78aab98.gz
This commit is contained in:
23
reader.c
23
reader.c
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user