From 977451ef446fc27d7d6e40a9ba01fce5ee0e25b6 Mon Sep 17 00:00:00 2001 From: Glenn L McGrath Date: Mon, 15 Sep 2003 12:07:48 +0000 Subject: [PATCH] Fix a simple mistake with pattern space, and add a test for it --- editors/sed.c | 4 ++-- .../sed/sed-append-hold-space-to-pattern-space | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 testsuite/sed/sed-append-hold-space-to-pattern-space diff --git a/editors/sed.c b/editors/sed.c index 05eb744a4..da15c4d06 100644 --- a/editors/sed.c +++ b/editors/sed.c @@ -1070,9 +1070,9 @@ static void process_file(FILE * file) } pattern_space = xrealloc(pattern_space, pattern_space_size + hold_space_size); if (pattern_space_size == 2) { - strcat(pattern_space, "\n"); - } else { strcpy(pattern_space, "\n"); + } else { + strcat(pattern_space, "\n"); } if (hold_space) { strcat(pattern_space, hold_space); diff --git a/testsuite/sed/sed-append-hold-space-to-pattern-space b/testsuite/sed/sed-append-hold-space-to-pattern-space new file mode 100644 index 000000000..6dda80fee --- /dev/null +++ b/testsuite/sed/sed-append-hold-space-to-pattern-space @@ -0,0 +1,13 @@ +busybox sed 'G'>output <