diff options
| author | Glenn L McGrath <bug1@ihug.co.nz> | 2003-03-10 02:21:14 +0000 |
|---|---|---|
| committer | Glenn L McGrath <bug1@ihug.co.nz> | 2003-03-10 02:21:14 +0000 |
| commit | bed4033e968274de997f265313738952b754fb3e (patch) | |
| tree | a03e2510ab9467c29b44909a03089e9a770190e5 | |
| parent | f3bd7c4631b0489f93069bf4de127f74a88f90c9 (diff) | |
| download | busybox-w32-bed4033e968274de997f265313738952b754fb3e.tar.gz busybox-w32-bed4033e968274de997f265313738952b754fb3e.tar.bz2 busybox-w32-bed4033e968274de997f265313738952b754fb3e.zip | |
Add the q (quit) option
| -rw-r--r-- | editors/sed.c | 27 |
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 | ||
