summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-03-24 22:06:35 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-03-24 22:06:35 +0300
commit5e4b4e1c1142a747fa1ba6286639b4d82d80f4ce (patch)
tree5f561a35c72bd0c944a3df9ce216f071bf481f4a
parent030eb1cecb5bca5a5999dee1fd3f37639ab79a2d (diff)
downloadgunmake-5e4b4e1c1142a747fa1ba6286639b4d82d80f4ce.tar.gz
Eat trailing spaces in sun mode
-rw-r--r--read.c8
-rw-r--r--tests/scripts/features/sun-trailing-spaces31
2 files changed, 39 insertions, 0 deletions
diff --git a/read.c b/read.c
index 38cdbdd..eb049ba 100644
--- a/read.c
+++ b/read.c
@@ -2567,6 +2567,14 @@ readline (struct ebuffer *ebuf)
}
#endif
+ /* In SunOS mode strip trailing spaces. */
+ if (sun_flag)
+ {
+ while ((p - start) > 1 && (p[-2] == ' ' || p[-2] == '\t'))
+ --p;
+ p[-1] = '\n';
+ }
+
backslash = 0;
for (p2 = p - 2; p2 >= start; --p2)
{
diff --git a/tests/scripts/features/sun-trailing-spaces b/tests/scripts/features/sun-trailing-spaces
new file mode 100644
index 0000000..347e6ce
--- /dev/null
+++ b/tests/scripts/features/sun-trailing-spaces
@@ -0,0 +1,31 @@
+# -*-perl-*-
+$description = "In SunOS mode strip trailing spaces";
+
+$details = "";
+
+# !!! Note the spaces and tabs after hello !!!
+run_make_test('
+
+var_with_trailing_space = hello
+var_with_trailing_tab = hello
+var_with_trailing_tab_space_tab = hello
+
+space:
+ @echo "$(var_with_trailing_space)world"
+tab:
+ @echo "$(var_with_trailing_tab)world"
+tab_space_tab:
+ @echo "$(var_with_trailing_tab_space_tab)world"
+
+',
+'space',
+"hello world");
+
+run_make_test(undef, '--sun space', "helloworld");
+run_make_test(undef, '--sun tab', "helloworld");
+run_make_test(undef, '--sun tab_space_tab', "helloworld");
+run_make_test(undef, 'tab', "hello\tworld");
+run_make_test(undef, 'tab_space_tab', "hello\t \tworld");
+
+# This tells the test driver that the perl test script executed properly.
+1;