summaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorGlenn L McGrath2003-03-28 14:11:34 +0000
committerGlenn L McGrath2003-03-28 14:11:34 +0000
commita0f0f0cf76458ed2e2cb6cb5fe5425bd7322775d (patch)
tree387dfe73041ad5d14af4aca0e71c5d3716b3bf54 /editors
parent595a6a419933eb08a05102e15c594d6d303b9e6f (diff)
downloadbusybox-a0f0f0cf76458ed2e2cb6cb5fe5425bd7322775d.zip
busybox-a0f0f0cf76458ed2e2cb6cb5fe5425bd7322775d.tar.gz
Still fine tunning the printing of the substitute command
Diffstat (limited to 'editors')
-rw-r--r--editors/sed.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/editors/sed.c b/editors/sed.c
index d1db5fa..1cbf974 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -714,6 +714,7 @@ static void process_file(FILE *file)
static int linenum = 0; /* GNU sed does not restart counting lines at EOF */
unsigned int still_in_range = 0;
int altered;
+ int force_print;
line = bb_get_chomped_line_from_file(file);
if (line == NULL) {
@@ -731,6 +732,7 @@ static void process_file(FILE *file)
linenum++;
altered = 0;
+ force_print = 0;
/* for every line, go through all the commands */
for (sed_cmd = sed_cmd_head.linear; sed_cmd; sed_cmd = sed_cmd->linear) {
@@ -797,7 +799,7 @@ static void process_file(FILE *file)
substituted = do_subst_command(sed_cmd, &line);
altered |= substituted;
if (!be_quiet && altered && ((sed_cmd->linear == NULL) || (sed_cmd->linear->cmd != 's'))) {
- puts(line);
+ force_print = 1;
}
/* we also print the line if we were given the 'p' flag
@@ -908,9 +910,9 @@ static void process_file(FILE *file)
/* we will print the line unless we were told to be quiet or if the
* line was altered (via a 'd'elete or 's'ubstitution), in which case
* the altered line was already printed */
- if (!be_quiet && !altered)
+ if ((!be_quiet && !altered) || force_print){
puts(line);
-
+ }
free(line);
line = next_line;
} while (line);