Fix Savannah bug # 1332: handle backslash-newline pairs in command scripts

according to POSIX rules.
This commit is contained in:
Paul Smith
2005-06-26 03:31:29 +00:00
parent f388233b03
commit d6a7894d3a
6 changed files with 370 additions and 67 deletions

View File

@@ -53,4 +53,261 @@ all: ; @:
',
'', 'true; true');
# TEST 4
# Check that backslashes in command scripts are handled according to POSIX.
# Checks Savannah bug # 1332.
# Test the fastpath / no quotes
run_make_test('
all:
@echo foo\
bar
@echo foo\
bar
@echo foo\
bar
@echo foo\
bar
@echo foo \
bar
@echo foo \
bar
@echo foo \
bar
@echo foo \
bar
',
'', 'foobar
foobar
foo bar
foo bar
foo bar
foo bar
foo bar
foo bar');
# Test the fastpath / single quotes
run_make_test("
all:
\@echo 'foo\\
bar'
\@echo 'foo\\
bar'
\@echo 'foo\\
bar'
\@echo 'foo\\
bar'
\@echo 'foo \\
bar'
\@echo 'foo \\
bar'
\@echo 'foo \\
bar'
\@echo 'foo \\
bar'
",
'', 'foo\
bar
foo\
bar
foo\
bar
foo\
bar
foo \
bar
foo \
bar
foo \
bar
foo \
bar');
# Test the fastpath / double quotes
run_make_test('
all:
@echo "foo\
bar"
@echo "foo\
bar"
@echo "foo\
bar"
@echo "foo\
bar"
@echo "foo \
bar"
@echo "foo \
bar"
@echo "foo \
bar"
@echo "foo \
bar"
',
'', 'foobar
foobar
foo bar
foo bar
foo bar
foo bar
foo bar
foo bar');
# Test the slow path / no quotes
run_make_test('
all:
@echo hi; echo foo\
bar
@echo hi; echo foo\
bar
@echo hi; echo foo\
bar
@echo hi; echo foo\
bar
@echo hi; echo foo \
bar
@echo hi; echo foo \
bar
@echo hi; echo foo \
bar
@echo hi; echo foo \
bar
',
'', 'hi
foobar
hi
foobar
hi
foo bar
hi
foo bar
hi
foo bar
hi
foo bar
hi
foo bar
hi
foo bar');
# Test the slow path / no quotes. This time we put the slow path
# determination _after_ the backslash-newline handling.
run_make_test('
all:
@echo foo\
bar; echo hi
@echo foo\
bar; echo hi
@echo foo\
bar; echo hi
@echo foo\
bar; echo hi
@echo foo \
bar; echo hi
@echo foo \
bar; echo hi
@echo foo \
bar; echo hi
@echo foo \
bar; echo hi
',
'', 'foobar
hi
foobar
hi
foo bar
hi
foo bar
hi
foo bar
hi
foo bar
hi
foo bar
hi
foo bar
hi');
# Test the slow path / single quotes
run_make_test("
all:
\@echo hi; echo 'foo\\
bar'
\@echo hi; echo 'foo\\
bar'
\@echo hi; echo 'foo\\
bar'
\@echo hi; echo 'foo\\
bar'
\@echo hi; echo 'foo \\
bar'
\@echo hi; echo 'foo \\
bar'
\@echo hi; echo 'foo \\
bar'
\@echo hi; echo 'foo \\
bar'
",
'', 'hi
foo\
bar
hi
foo\
bar
hi
foo\
bar
hi
foo\
bar
hi
foo \
bar
hi
foo \
bar
hi
foo \
bar
hi
foo \
bar');
# Test the slow path / double quotes
run_make_test('
all:
@echo hi; echo "foo\
bar"
@echo hi; echo "foo\
bar"
@echo hi; echo "foo\
bar"
@echo hi; echo "foo\
bar"
@echo hi; echo "foo \
bar"
@echo hi; echo "foo \
bar"
@echo hi; echo "foo \
bar"
@echo hi; echo "foo \
bar"
',
'', 'hi
foobar
hi
foobar
hi
foo bar
hi
foo bar
hi
foo bar
hi
foo bar
hi
foo bar
hi
foo bar');
1;