summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2013-05-26 14:41:45 -0400
committerPaul Smith <psmith@gnu.org>2013-05-26 14:41:45 -0400
commit74d4cf5630f7028e2a615b8ff140f0b6e6d95ae1 (patch)
treef787d5b91d5ef0c3db9653d551bd55bfa4b8c22e
parent54ce9982f952a9c8f2a9a0935edaff51f962d339 (diff)
downloadmake-74d4cf5630f7028e2a615b8ff140f0b6e6d95ae1.tar.gz
[SV #38945] Copy the entire buffer back when overwriting CR
-rw-r--r--ChangeLog3
-rw-r--r--read.c2
-rw-r--r--tests/ChangeLog1
-rw-r--r--tests/scripts/misc/bs-nl9
4 files changed, 12 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index ff5bec59..498ad56f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
2013-05-26 Paul Smith <psmith@gnu.org>
+ * read.c (readline): To be safe, move the entire buffer if we
+ detect a CR. Fixes Savannah bug #38945.
+
* job.c (new_job): Compare OUT to the beginning of the OUT
var/function, not IN. Fixes Savannah bug #39035.
diff --git a/read.c b/read.c
index 36d3a8fa..d6e6fcb1 100644
--- a/read.c
+++ b/read.c
@@ -2542,7 +2542,7 @@ readline (struct ebuffer *ebuf)
if ((p - start) > 1 && p[-2] == '\r')
{
--p;
- p[-1] = '\n';
+ memmove (p-1, p, strlen (p) + 1);
}
#endif
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 1f93930f..7f1bd3cf 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,6 +1,7 @@
2013-05-26 Paul Smith <psmith@gnu.org>
* scripts/misc/bs-nl: Test for Savannah bug #39035.
+ Add a test for Savannah bug #38945.
2013-05-22 Paul Smith <psmith@gnu.org>
diff --git a/tests/scripts/misc/bs-nl b/tests/scripts/misc/bs-nl
index aa7661ea..4fc3f639 100644
--- a/tests/scripts/misc/bs-nl
+++ b/tests/scripts/misc/bs-nl
@@ -114,10 +114,15 @@ t:; @$(call f,"a \
my $m1 = get_tmpfile();
open(MAKEFILE, "> $m1");
binmode(MAKEFILE);
-print MAKEFILE "FOO = foo \\\r\nbar\nall: ; \@echo \$(FOO)\n";
+print MAKEFILE "FOO = foo \\\r\n";
close(MAKEFILE);
-run_make_with_options($m1, '', get_logfile());
+my $m2 = get_tmpfile();
+open(MAKEFILE, "> $m2");
+print MAKEFILE "include $m1\ndefine BAR\nall: ; \@echo \$(FOO) bar\nendef\n\$(eval \$(BAR))\n";
+close(MAKEFILE);
+
+run_make_with_options($m2, '', get_logfile());
compare_output("foo bar\n", get_logfile(1));