aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--editors/sed.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/editors/sed.c b/editors/sed.c
index ddd4780d3..b40aa8e02 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -265,6 +265,7 @@ static int parse_subst_cmd(sed_cmd_t * const sed_cmd, const char *substr)
265 case 'g': 265 case 'g':
266 sed_cmd->sub_g = 1; 266 sed_cmd->sub_g = 1;
267 break; 267 break;
268 /* Hmm, i dont see the I option mentioned in the standard */
268 case 'I': 269 case 'I':
269 cflags |= REG_ICASE; 270 cflags |= REG_ICASE;
270 break; 271 break;
@@ -381,7 +382,7 @@ static char *parse_cmd_str(sed_cmd_t * const sed_cmd, char *cmdstr)
381{ 382{
382 /* if it was a single-letter command that takes no arguments (such as 'p' 383 /* if it was a single-letter command that takes no arguments (such as 'p'
383 * or 'd') all we need to do is increment the index past that command */ 384 * or 'd') all we need to do is increment the index past that command */
384 if (strchr("pd=", sed_cmd->cmd)) { 385 if (strchr("pqd=", sed_cmd->cmd)) {
385 cmdstr++; 386 cmdstr++;
386 } 387 }
387 /* handle (s)ubstitution command */ 388 /* handle (s)ubstitution command */
@@ -400,7 +401,6 @@ static char *parse_cmd_str(sed_cmd_t * const sed_cmd, char *cmdstr)
400 error_msg_and_die("Command only uses one address"); 401 error_msg_and_die("Command only uses one address");
401 cmdstr += parse_file_cmd(sed_cmd, cmdstr); 402 cmdstr += parse_file_cmd(sed_cmd, cmdstr);
402 } 403 }
403 /* handle grouped commands */
404 else { 404 else {
405 error_msg_and_die("Unsupported command %c", sed_cmd->cmd); 405 error_msg_and_die("Unsupported command %c", sed_cmd->cmd);
406 } 406 }
@@ -794,16 +794,19 @@ static void process_file(FILE *file)
794 break; 794 break;
795 795
796 case 'r': { 796 case 'r': {
797 FILE *outfile; 797 FILE *outfile;
798 puts(line); 798 puts(line);
799 outfile = fopen(sed_cmd->filename, "r"); 799 outfile = fopen(sed_cmd->filename, "r");
800 if (outfile) 800 if (outfile)
801 print_file(outfile); 801 print_file(outfile);
802 /* else if we couldn't open the output file, 802 /* else if we couldn't open the output file,
803 * no biggie, just don't print anything */ 803 * no biggie, just don't print anything */
804 altered++; 804 altered++;
805 } 805 }
806 break; 806 break;
807 case 'q': /* Branch to end of script and quit */
808 free(line);
809 return;
807 } 810 }
808 } 811 }
809 812