[BusyBox-cvs] busybox/editors sed.c,1.112,1.113

Glenn McGrath bug1 at busybox.net
Fri Mar 28 07:44:07 UTC 2003


Update of /var/cvs/busybox/editors
In directory winder:/tmp/cvs-serv25202/editors

Modified Files:
	sed.c 
Log Message:
Fix sed 's' command's 'p' flag, so it can print line twice


Index: sed.c
===================================================================
RCS file: /var/cvs/busybox/editors/sed.c,v
retrieving revision 1.112
retrieving revision 1.113
diff -u -d -r1.112 -r1.113
--- sed.c	28 Mar 2003 04:57:52 -0000	1.112
+++ sed.c	28 Mar 2003 07:44:03 -0000	1.113
@@ -792,25 +792,23 @@
 						 *    flag exists in the first place.
 						 */
 
-						/* if the user specified that they didn't want anything printed (i.e., a -n
-						 * flag and no 'p' flag after the s///), then there's really no point doing
-						 * anything here. */
-						if (be_quiet && !sed_cmd->sub_p)
-							break;
-
 						/* we print the line once, unless we were told to be quiet */
-						if (!be_quiet)
+						if (!be_quiet) {
 							altered |= do_subst_command(sed_cmd, &line);
+							if (altered && ((sed_cmd->linear == NULL) || (sed_cmd->linear->cmd != 's'))) {
+								puts(line);
+							}
+						}
 
 						/* we also print the line if we were given the 'p' flag
 						 * (this is quite possibly the second printing) */
-						if (sed_cmd->sub_p)
+						if (sed_cmd->sub_p) {
 							altered |= do_subst_command(sed_cmd, &line);
-						if (altered && ((sed_cmd->linear == NULL) || (sed_cmd->linear->cmd != 's')))
-							puts(line);
-
+							if (altered) {
+								puts(line);
+							}
+						}
 						break;
-
 					case 'a':
 						puts(line);
 						fputs(sed_cmd->editline, stdout);




More information about the busybox-cvs mailing list