Skip to content

Commit

Permalink
Further fixes to newline escaping
Browse files Browse the repository at this point in the history
Addresses issue described in #347 (comment)
  • Loading branch information
ridiculousfish committed Nov 23, 2012
1 parent 654010f commit bf27cb1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
6 changes: 6 additions & 0 deletions tests/test1.in
Expand Up @@ -24,6 +24,12 @@ bar"
echo 'foo\
bar'

for i in \
a b c
echo $i
end


# Simple alias tests

function foo
Expand Down
3 changes: 3 additions & 0 deletions tests/test1.out
Expand Up @@ -10,6 +10,9 @@ foobar
foobar
foo\
bar
a
b
c
Test 2 pass
Test pass
Test 3 pass
Expand Down
20 changes: 7 additions & 13 deletions tokenizer.cpp
Expand Up @@ -491,12 +491,9 @@ wchar_t tok_last_quote(tokenizer_t *tok)
Test if a character is whitespace. Differs from iswspace in that it
does not consider a newline to be whitespace.
*/
static int my_iswspace(wchar_t c)
static bool my_iswspace(wchar_t c)
{
if (c == L'\n')
return 0;
else
return iswspace(c);
return c != L'\n' && iswspace(c);
}


Expand Down Expand Up @@ -531,19 +528,16 @@ void tok_next(tokenizer_t *tok)

while (1)
{
if (my_iswspace(*(tok->buff)))
if (tok->buff[0] == L'\\' && tok->buff[1] == L'\n')
{
tok->buff += 2;
}
else if (my_iswspace(tok->buff[0]))
{
tok->buff++;
}
else
{
if ((*(tok->buff) == L'\\') &&(*(tok->buff+1) == L'\n'))
{
tok->last_pos = tok->buff - tok->orig_buff;
tok->buff+=2;
tok->last_type = TOK_END;
return;
}
break;
}
}
Expand Down

0 comments on commit bf27cb1

Please sign in to comment.