[BusyBox-cvs] busybox/editors sed.c,1.114,1.115
Glenn McGrath
bug1 at busybox.net
Fri Mar 28 14:11:37 UTC 2003
Update of /var/cvs/busybox/editors
In directory winder:/tmp/cvs-serv28159/editors
Modified Files:
sed.c
Log Message:
Still fine tunning the printing of the substitute command
Index: sed.c
===================================================================
RCS file: /var/cvs/busybox/editors/sed.c,v
retrieving revision 1.114
retrieving revision 1.115
diff -u -d -r1.114 -r1.115
--- sed.c 28 Mar 2003 08:36:52 -0000 1.114
+++ sed.c 28 Mar 2003 14:11:34 -0000 1.115
@@ -714,6 +714,7 @@
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 @@
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 @@
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 @@
/* 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);
More information about the busybox-cvs
mailing list