diff options
author | Rob Landley <rob@landley.net> | 2006-08-03 15:41:12 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-08-03 15:41:12 +0000 |
commit | d921b2ecc0d294ad4bf8c7458fc52a60c28727d2 (patch) | |
tree | e4a2769349867c441cf2983d83097bb66701a733 /editors/sed.c | |
parent | 6dce0b6fa79f2d4bb7e9d90e1fbc0f6beb25f855 (diff) | |
download | busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.gz busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.tar.bz2 busybox-w32-d921b2ecc0d294ad4bf8c7458fc52a60c28727d2.zip |
Remove bb_ prefixes from xfuncs.c (and a few other places), consolidate
things like xasprintf() into xfuncs.c, remove xprint_file_by_name() (it only
had one user), clean up lots of #includes... General cleanup pass. What I've
been doing for the last couple days.
And it conflicts! I've removed httpd.c from this checkin due to somebody else
touching that file. It builds for me. I have to catch a bus. (Now you know
why I'm looking forward to Mercurial.)
Diffstat (limited to 'editors/sed.c')
-rw-r--r-- | editors/sed.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/editors/sed.c b/editors/sed.c index 89b8dd72c..d5cf3f219 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -132,7 +132,7 @@ void sed_free_and_close_stuff(void) | |||
132 | sed_cmd_t *sed_cmd_next = sed_cmd->next; | 132 | sed_cmd_t *sed_cmd_next = sed_cmd->next; |
133 | 133 | ||
134 | if(sed_cmd->file) | 134 | if(sed_cmd->file) |
135 | bb_xprint_and_close_file(sed_cmd->file); | 135 | xprint_and_close_file(sed_cmd->file); |
136 | 136 | ||
137 | if (sed_cmd->beg_match) { | 137 | if (sed_cmd->beg_match) { |
138 | regfree(sed_cmd->beg_match); | 138 | regfree(sed_cmd->beg_match); |
@@ -300,7 +300,7 @@ static int parse_file_cmd(sed_cmd_t *sed_cmd, char *filecmdstr, char **retval) | |||
300 | /* If lines glued together, put backslash back. */ | 300 | /* If lines glued together, put backslash back. */ |
301 | if(filecmdstr[idx]=='\n') hack=1; | 301 | if(filecmdstr[idx]=='\n') hack=1; |
302 | if(idx==start) bb_error_msg_and_die("Empty filename"); | 302 | if(idx==start) bb_error_msg_and_die("Empty filename"); |
303 | *retval = bb_xstrndup(filecmdstr+start, idx-start+hack+1); | 303 | *retval = xstrndup(filecmdstr+start, idx-start+hack+1); |
304 | if(hack) *(idx+*retval)='\\'; | 304 | if(hack) *(idx+*retval)='\\'; |
305 | 305 | ||
306 | return idx; | 306 | return idx; |
@@ -406,7 +406,7 @@ static char *parse_cmd_args(sed_cmd_t *sed_cmd, char *cmdstr) | |||
406 | } else if(isspace(*cmdstr)) cmdstr++; | 406 | } else if(isspace(*cmdstr)) cmdstr++; |
407 | else break; | 407 | else break; |
408 | } | 408 | } |
409 | sed_cmd->string = bb_xstrdup(cmdstr); | 409 | sed_cmd->string = xstrdup(cmdstr); |
410 | parse_escapes(sed_cmd->string,sed_cmd->string,strlen(cmdstr),0,0); | 410 | parse_escapes(sed_cmd->string,sed_cmd->string,strlen(cmdstr),0,0); |
411 | cmdstr += strlen(cmdstr); | 411 | cmdstr += strlen(cmdstr); |
412 | /* handle file cmds: (r)ead */ | 412 | /* handle file cmds: (r)ead */ |
@@ -415,7 +415,7 @@ static char *parse_cmd_args(sed_cmd_t *sed_cmd, char *cmdstr) | |||
415 | bb_error_msg_and_die("Command only uses one address"); | 415 | bb_error_msg_and_die("Command only uses one address"); |
416 | cmdstr += parse_file_cmd(sed_cmd, cmdstr, &sed_cmd->string); | 416 | cmdstr += parse_file_cmd(sed_cmd, cmdstr, &sed_cmd->string); |
417 | if(sed_cmd->cmd=='w') | 417 | if(sed_cmd->cmd=='w') |
418 | sed_cmd->file=bb_xfopen(sed_cmd->string,"w"); | 418 | sed_cmd->file=xfopen(sed_cmd->string,"w"); |
419 | /* handle branch commands */ | 419 | /* handle branch commands */ |
420 | } else if (strchr(":btT", sed_cmd->cmd)) { | 420 | } else if (strchr(":btT", sed_cmd->cmd)) { |
421 | int length; | 421 | int length; |
@@ -423,7 +423,7 @@ static char *parse_cmd_args(sed_cmd_t *sed_cmd, char *cmdstr) | |||
423 | while(isspace(*cmdstr)) cmdstr++; | 423 | while(isspace(*cmdstr)) cmdstr++; |
424 | length = strcspn(cmdstr, semicolon_whitespace); | 424 | length = strcspn(cmdstr, semicolon_whitespace); |
425 | if (length) { | 425 | if (length) { |
426 | sed_cmd->string = bb_xstrndup(cmdstr, length); | 426 | sed_cmd->string = xstrndup(cmdstr, length); |
427 | cmdstr += length; | 427 | cmdstr += length; |
428 | } | 428 | } |
429 | } | 429 | } |
@@ -466,7 +466,7 @@ static void add_cmd(char *cmdstr) | |||
466 | 466 | ||
467 | /* Append this line to any unfinished line from last time. */ | 467 | /* Append this line to any unfinished line from last time. */ |
468 | if (bbg.add_cmd_line) { | 468 | if (bbg.add_cmd_line) { |
469 | cmdstr = bb_xasprintf("%s\n%s", bbg.add_cmd_line, cmdstr); | 469 | cmdstr = xasprintf("%s\n%s", bbg.add_cmd_line, cmdstr); |
470 | free(bbg.add_cmd_line); | 470 | free(bbg.add_cmd_line); |
471 | bbg.add_cmd_line = cmdstr; | 471 | bbg.add_cmd_line = cmdstr; |
472 | } | 472 | } |
@@ -474,7 +474,7 @@ static void add_cmd(char *cmdstr) | |||
474 | /* If this line ends with backslash, request next line. */ | 474 | /* If this line ends with backslash, request next line. */ |
475 | temp=strlen(cmdstr); | 475 | temp=strlen(cmdstr); |
476 | if(temp && cmdstr[temp-1]=='\\') { | 476 | if(temp && cmdstr[temp-1]=='\\') { |
477 | if (!bbg.add_cmd_line) bbg.add_cmd_line = bb_xstrdup(cmdstr); | 477 | if (!bbg.add_cmd_line) bbg.add_cmd_line = xstrdup(cmdstr); |
478 | bbg.add_cmd_line[temp-1] = 0; | 478 | bbg.add_cmd_line[temp-1] = 0; |
479 | return; | 479 | return; |
480 | } | 480 | } |
@@ -671,7 +671,7 @@ static sed_cmd_t *branch_to(char *label) | |||
671 | 671 | ||
672 | static void append(char *s) | 672 | static void append(char *s) |
673 | { | 673 | { |
674 | llist_add_to_end(&bbg.append_head, bb_xstrdup(s)); | 674 | llist_add_to_end(&bbg.append_head, xstrdup(s)); |
675 | } | 675 | } |
676 | 676 | ||
677 | static void flush_append(void) | 677 | static void flush_append(void) |
@@ -852,7 +852,7 @@ restart: | |||
852 | char *tmp = strchr(pattern_space,'\n'); | 852 | char *tmp = strchr(pattern_space,'\n'); |
853 | 853 | ||
854 | if(tmp) { | 854 | if(tmp) { |
855 | tmp=bb_xstrdup(tmp+1); | 855 | tmp=xstrdup(tmp+1); |
856 | free(pattern_space); | 856 | free(pattern_space); |
857 | pattern_space=tmp; | 857 | pattern_space=tmp; |
858 | goto restart; | 858 | goto restart; |
@@ -907,7 +907,7 @@ restart: | |||
907 | while ((line = bb_get_chomped_line_from_file(rfile)) | 907 | while ((line = bb_get_chomped_line_from_file(rfile)) |
908 | != NULL) | 908 | != NULL) |
909 | append(line); | 909 | append(line); |
910 | bb_xprint_and_close_file(rfile); | 910 | xprint_and_close_file(rfile); |
911 | } | 911 | } |
912 | 912 | ||
913 | break; | 913 | break; |
@@ -996,7 +996,7 @@ restart: | |||
996 | } | 996 | } |
997 | case 'g': /* Replace pattern space with hold space */ | 997 | case 'g': /* Replace pattern space with hold space */ |
998 | free(pattern_space); | 998 | free(pattern_space); |
999 | pattern_space = bb_xstrdup(bbg.hold_space ? bbg.hold_space : ""); | 999 | pattern_space = xstrdup(bbg.hold_space ? bbg.hold_space : ""); |
1000 | break; | 1000 | break; |
1001 | case 'G': /* Append newline and hold space to pattern space */ | 1001 | case 'G': /* Append newline and hold space to pattern space */ |
1002 | { | 1002 | { |
@@ -1019,7 +1019,7 @@ restart: | |||
1019 | } | 1019 | } |
1020 | case 'h': /* Replace hold space with pattern space */ | 1020 | case 'h': /* Replace hold space with pattern space */ |
1021 | free(bbg.hold_space); | 1021 | free(bbg.hold_space); |
1022 | bbg.hold_space = bb_xstrdup(pattern_space); | 1022 | bbg.hold_space = xstrdup(pattern_space); |
1023 | break; | 1023 | break; |
1024 | case 'H': /* Append newline and pattern space to hold space */ | 1024 | case 'H': /* Append newline and pattern space to hold space */ |
1025 | { | 1025 | { |
@@ -1072,7 +1072,7 @@ discard_line: | |||
1072 | static void add_cmd_block(char *cmdstr) | 1072 | static void add_cmd_block(char *cmdstr) |
1073 | { | 1073 | { |
1074 | int go=1; | 1074 | int go=1; |
1075 | char *temp=bb_xstrdup(cmdstr),*temp2=temp; | 1075 | char *temp=xstrdup(cmdstr),*temp2=temp; |
1076 | 1076 | ||
1077 | while(go) { | 1077 | while(go) { |
1078 | int len=strcspn(temp2,"\n"); | 1078 | int len=strcspn(temp2,"\n"); |
@@ -1121,14 +1121,14 @@ int sed_main(int argc, char **argv) | |||
1121 | FILE *cmdfile; | 1121 | FILE *cmdfile; |
1122 | char *line; | 1122 | char *line; |
1123 | 1123 | ||
1124 | cmdfile = bb_xfopen(optarg, "r"); | 1124 | cmdfile = xfopen(optarg, "r"); |
1125 | 1125 | ||
1126 | while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) { | 1126 | while ((line = bb_get_chomped_line_from_file(cmdfile)) != NULL) { |
1127 | add_cmd(line); | 1127 | add_cmd(line); |
1128 | getpat=0; | 1128 | getpat=0; |
1129 | free(line); | 1129 | free(line); |
1130 | } | 1130 | } |
1131 | bb_xprint_and_close_file(cmdfile); | 1131 | xprint_and_close_file(cmdfile); |
1132 | 1132 | ||
1133 | break; | 1133 | break; |
1134 | } | 1134 | } |
@@ -1172,7 +1172,7 @@ int sed_main(int argc, char **argv) | |||
1172 | struct stat statbuf; | 1172 | struct stat statbuf; |
1173 | int nonstdoutfd; | 1173 | int nonstdoutfd; |
1174 | 1174 | ||
1175 | bbg.outname=bb_xstrndup(argv[i],strlen(argv[i])+6); | 1175 | bbg.outname=xstrndup(argv[i],strlen(argv[i])+6); |
1176 | strcat(bbg.outname,"XXXXXX"); | 1176 | strcat(bbg.outname,"XXXXXX"); |
1177 | if(-1==(nonstdoutfd=mkstemp(bbg.outname))) | 1177 | if(-1==(nonstdoutfd=mkstemp(bbg.outname))) |
1178 | bb_error_msg_and_die("no temp file"); | 1178 | bb_error_msg_and_die("no temp file"); |