From 7b5649097f182a1f5f6270cb3d6719d13aa3f34f Mon Sep 17 00:00:00 2001 From: axel Date: Mon, 20 Nov 2006 12:19:34 +1000 Subject: [PATCH] Correctly handle multiple backslashes at end of line w.r.t. multiline handling darcs-hash:20061120021934-ac50b-20d953c16711a4959cac9d435217309fc78aab98.gz --- reader.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/reader.c b/reader.c index c9663f156..2a2b7cf59 100644 --- a/reader.c +++ b/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;