aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2003-04-26 07:40:07 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2003-04-26 07:40:07 +0000
commit91e1978ff0e46a57edaa74a1992ef24e801fc657 (patch)
tree502f9cc2e97d080ee0a8ae03bb9fdb6f24c2d288
parent69f28e7c0c2fb0f0efddad47310743d12a2b94d3 (diff)
downloadbusybox-w32-91e1978ff0e46a57edaa74a1992ef24e801fc657.tar.gz
busybox-w32-91e1978ff0e46a57edaa74a1992ef24e801fc657.tar.bz2
busybox-w32-91e1978ff0e46a57edaa74a1992ef24e801fc657.zip
New commands, 'G' and 'H'
-rw-r--r--editors/sed.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/editors/sed.c b/editors/sed.c
index bda359219..6beba0661 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -483,7 +483,7 @@ static char *parse_cmd_str(sed_cmd_t * sed_cmd, char *cmdstr)
483 /* if it wasnt a single-letter command that takes no arguments 483 /* if it wasnt a single-letter command that takes no arguments
484 * then it must be an invalid command. 484 * then it must be an invalid command.
485 */ 485 */
486 else if (strchr("dghnNpPqx={}", sed_cmd->cmd) == 0) { 486 else if (strchr("dgGhHnNpPqx={}", sed_cmd->cmd) == 0) {
487 bb_error_msg_and_die("Unsupported command %c", sed_cmd->cmd); 487 bb_error_msg_and_die("Unsupported command %c", sed_cmd->cmd);
488 } 488 }
489 489
@@ -1034,10 +1034,30 @@ static void process_file(FILE * file)
1034 free(pattern_space); 1034 free(pattern_space);
1035 pattern_space = strdup(hold_space); 1035 pattern_space = strdup(hold_space);
1036 break; 1036 break;
1037 case 'G': { /* Append newline and hold space to pattern space */
1038 int pattern_space_size = 0;
1039 if (pattern_space) {
1040 pattern_space_size = strlen(pattern_space);
1041 }
1042 pattern_space = xrealloc(pattern_space, pattern_space_size + strlen(hold_space) + 2);
1043 strcat(pattern_space, "\n");
1044 strcat(pattern_space, hold_space);
1045 break;
1046 }
1037 case 'h': /* Replace hold space with pattern space */ 1047 case 'h': /* Replace hold space with pattern space */
1038 free(hold_space); 1048 free(hold_space);
1039 hold_space = strdup(pattern_space); 1049 hold_space = strdup(pattern_space);
1040 break; 1050 break;
1051 case 'H': { /* Append newline and pattern space to hold space */
1052 int hold_space_size = 0;
1053 if (hold_space) {
1054 hold_space_size = strlen(hold_space);
1055 }
1056 hold_space = xrealloc(hold_space, hold_space_size + strlen(pattern_space) + 2);
1057 strcat(hold_space, "\n");
1058 strcat(hold_space, pattern_space);
1059 break;
1060 }
1041 case 'x':{ 1061 case 'x':{
1042 /* Swap hold and pattern space */ 1062 /* Swap hold and pattern space */
1043 char *tmp = pattern_space; 1063 char *tmp = pattern_space;