aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/editors/sed.c b/editors/sed.c
index 7d6e7e79f..6cf54afe9 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -992,6 +992,8 @@ static void process_files(void)
992 } 992 }
993 993
994 /* actual sedding */ 994 /* actual sedding */
995 //bb_error_msg("pattern_space:'%s' next_line:'%s' cmd:%c",
996 //pattern_space, next_line, sed_cmd->cmd);
995 switch (sed_cmd->cmd) { 997 switch (sed_cmd->cmd) {
996 998
997 /* Print line number */ 999 /* Print line number */
@@ -1118,10 +1120,16 @@ static void process_files(void)
1118 { 1120 {
1119 int len; 1121 int len;
1120 /* If no next line, jump to end of script and exit. */ 1122 /* If no next line, jump to end of script and exit. */
1123 /* http://www.gnu.org/software/sed/manual/sed.html:
1124 * "Most versions of sed exit without printing anything
1125 * when the N command is issued on the last line of
1126 * a file. GNU sed prints pattern space before exiting
1127 * unless of course the -n command switch has been
1128 * specified. This choice is by design."
1129 */
1121 if (next_line == NULL) { 1130 if (next_line == NULL) {
1122 free(next_line); 1131 //goto discard_line;
1123 next_line = NULL; 1132 goto discard_commands; /* GNU behavior */
1124 goto discard_line;
1125 } 1133 }
1126 /* Append next_line, read new next_line. */ 1134 /* Append next_line, read new next_line. */
1127 len = strlen(pattern_space); 1135 len = strlen(pattern_space);