+
+ /*
+ * Some special cases for 's' printing to make it compliant with
+ * GNU sed printing behavior (aka "The -n | s///p Matrix"):
+ *
+ * -n ONLY = never print anything regardless of any successful
+ * substitution
+ *
+ * s///p ONLY = always print successful substitutions, even if
+ * the line is going to be printed anyway (line will be printed
+ * twice).
+ *
+ * -n AND s///p = print ONLY a successful substitution ONE TIME;
+ * no other lines are printed - this is the reason why the 'p'
+ * 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)
+ altered = do_subst_command(sed_cmd, 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)
+ altered = do_subst_command(sed_cmd, line);
+