diff options
author | Glenn L McGrath <bug1@ihug.co.nz> | 2003-09-15 12:07:48 +0000 |
---|---|---|
committer | Glenn L McGrath <bug1@ihug.co.nz> | 2003-09-15 12:07:48 +0000 |
commit | 977451ef446fc27d7d6e40a9ba01fce5ee0e25b6 (patch) | |
tree | 6636a19bb0c4433f719ba54dd5de699bd024468f | |
parent | 47e5ca1ecb2a86b29c8a52ee3ed276d8b27147cf (diff) | |
download | busybox-w32-977451ef446fc27d7d6e40a9ba01fce5ee0e25b6.tar.gz busybox-w32-977451ef446fc27d7d6e40a9ba01fce5ee0e25b6.tar.bz2 busybox-w32-977451ef446fc27d7d6e40a9ba01fce5ee0e25b6.zip |
Fix a simple mistake with pattern space, and add a test for it
-rw-r--r-- | editors/sed.c | 4 | ||||
-rw-r--r-- | testsuite/sed/sed-append-hold-space-to-pattern-space | 13 |
2 files changed, 15 insertions, 2 deletions
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) | |||
1070 | } | 1070 | } |
1071 | pattern_space = xrealloc(pattern_space, pattern_space_size + hold_space_size); | 1071 | pattern_space = xrealloc(pattern_space, pattern_space_size + hold_space_size); |
1072 | if (pattern_space_size == 2) { | 1072 | if (pattern_space_size == 2) { |
1073 | strcat(pattern_space, "\n"); | ||
1074 | } else { | ||
1075 | strcpy(pattern_space, "\n"); | 1073 | strcpy(pattern_space, "\n"); |
1074 | } else { | ||
1075 | strcat(pattern_space, "\n"); | ||
1076 | } | 1076 | } |
1077 | if (hold_space) { | 1077 | if (hold_space) { |
1078 | strcat(pattern_space, hold_space); | 1078 | 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 @@ | |||
1 | busybox sed 'G'>output <<EOF | ||
2 | a | ||
3 | b | ||
4 | c | ||
5 | EOF | ||
6 | cmp -s output - <<EOF | ||
7 | a | ||
8 | |||
9 | b | ||
10 | |||
11 | c | ||
12 | |||
13 | EOF | ||