diff options
Diffstat (limited to 'editors/awk.c')
-rw-r--r-- | editors/awk.c | 38 |
1 files changed, 14 insertions, 24 deletions
diff --git a/editors/awk.c b/editors/awk.c index 16c871f8c..5d43e1d9e 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -7,19 +7,9 @@ | |||
7 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. | 7 | * Licensed under the GPL v2 or later, see the file LICENSE in this tarball. |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #include <stdio.h> | ||
11 | #include <stdlib.h> | ||
12 | #include <unistd.h> | ||
13 | #include <errno.h> | ||
14 | #include <string.h> | ||
15 | #include <strings.h> | ||
16 | #include <time.h> | ||
17 | #include <math.h> | ||
18 | #include <ctype.h> | ||
19 | #include <getopt.h> | ||
20 | |||
21 | #include "xregex.h" | ||
22 | #include "busybox.h" | 10 | #include "busybox.h" |
11 | #include "xregex.h" | ||
12 | #include <math.h> | ||
23 | 13 | ||
24 | 14 | ||
25 | #define MAXVARFMT 240 | 15 | #define MAXVARFMT 240 |
@@ -610,7 +600,7 @@ static inline int isalnum_(int c) | |||
610 | 600 | ||
611 | static FILE *afopen(const char *path, const char *mode) | 601 | static FILE *afopen(const char *path, const char *mode) |
612 | { | 602 | { |
613 | return (*path == '-' && *(path+1) == '\0') ? stdin : bb_xfopen(path, mode); | 603 | return (*path == '-' && *(path+1) == '\0') ? stdin : xfopen(path, mode); |
614 | } | 604 | } |
615 | 605 | ||
616 | /* -------- working with variables (set/get/copy/etc) -------- */ | 606 | /* -------- working with variables (set/get/copy/etc) -------- */ |
@@ -672,7 +662,7 @@ static var *setvar_p(var *v, char *value) | |||
672 | /* same as setvar_p but make a copy of string */ | 662 | /* same as setvar_p but make a copy of string */ |
673 | static var *setvar_s(var *v, const char *value) | 663 | static var *setvar_s(var *v, const char *value) |
674 | { | 664 | { |
675 | return setvar_p(v, (value && *value) ? bb_xstrdup(value) : NULL); | 665 | return setvar_p(v, (value && *value) ? xstrdup(value) : NULL); |
676 | } | 666 | } |
677 | 667 | ||
678 | /* same as setvar_s but set USER flag */ | 668 | /* same as setvar_s but set USER flag */ |
@@ -709,7 +699,7 @@ static char *getvar_s(var *v) | |||
709 | /* if v is numeric and has no cached string, convert it to string */ | 699 | /* if v is numeric and has no cached string, convert it to string */ |
710 | if ((v->type & (VF_NUMBER | VF_CACHED)) == VF_NUMBER) { | 700 | if ((v->type & (VF_NUMBER | VF_CACHED)) == VF_NUMBER) { |
711 | fmt_num(buf, MAXVARFMT, getvar_s(V[CONVFMT]), v->number, TRUE); | 701 | fmt_num(buf, MAXVARFMT, getvar_s(V[CONVFMT]), v->number, TRUE); |
712 | v->string = bb_xstrdup(buf); | 702 | v->string = xstrdup(buf); |
713 | v->type |= VF_CACHED; | 703 | v->type |= VF_CACHED; |
714 | } | 704 | } |
715 | return (v->string == NULL) ? "" : v->string; | 705 | return (v->string == NULL) ? "" : v->string; |
@@ -744,7 +734,7 @@ static var *copyvar(var *dest, const var *src) | |||
744 | dest->type |= (src->type & ~VF_DONTTOUCH); | 734 | dest->type |= (src->type & ~VF_DONTTOUCH); |
745 | dest->number = src->number; | 735 | dest->number = src->number; |
746 | if (src->string) | 736 | if (src->string) |
747 | dest->string = bb_xstrdup(src->string); | 737 | dest->string = xstrdup(src->string); |
748 | } | 738 | } |
749 | handle_special(dest); | 739 | handle_special(dest); |
750 | return dest; | 740 | return dest; |
@@ -1144,7 +1134,7 @@ static node *chain_node(uint32_t info) | |||
1144 | if (seq->programname != programname) { | 1134 | if (seq->programname != programname) { |
1145 | seq->programname = programname; | 1135 | seq->programname = programname; |
1146 | n = chain_node(OC_NEWSOURCE); | 1136 | n = chain_node(OC_NEWSOURCE); |
1147 | n->l.s = bb_xstrdup(programname); | 1137 | n->l.s = xstrdup(programname); |
1148 | } | 1138 | } |
1149 | 1139 | ||
1150 | n = seq->last; | 1140 | n = seq->last; |
@@ -1433,7 +1423,7 @@ static int awk_split(char *s, node *spl, char **slist) | |||
1433 | regmatch_t pmatch[2]; | 1423 | regmatch_t pmatch[2]; |
1434 | 1424 | ||
1435 | /* in worst case, each char would be a separate field */ | 1425 | /* in worst case, each char would be a separate field */ |
1436 | *slist = s1 = bb_xstrndup(s, strlen(s) * 2 + 3); | 1426 | *slist = s1 = xstrndup(s, strlen(s) * 2 + 3); |
1437 | 1427 | ||
1438 | c[0] = c[1] = (char)spl->info; | 1428 | c[0] = c[1] = (char)spl->info; |
1439 | c[2] = c[3] = '\0'; | 1429 | c[2] = c[3] = '\0'; |
@@ -1747,7 +1737,7 @@ static char *awk_printf(node *n) | |||
1747 | var *v, *arg; | 1737 | var *v, *arg; |
1748 | 1738 | ||
1749 | v = nvalloc(1); | 1739 | v = nvalloc(1); |
1750 | fmt = f = bb_xstrdup(getvar_s(evaluate(nextarg(&n), v))); | 1740 | fmt = f = xstrdup(getvar_s(evaluate(nextarg(&n), v))); |
1751 | 1741 | ||
1752 | i = 0; | 1742 | i = 0; |
1753 | while (*f) { | 1743 | while (*f) { |
@@ -1941,7 +1931,7 @@ static var *exec_builtin(node *op, var *res) | |||
1941 | case B_up: | 1931 | case B_up: |
1942 | to_xxx = toupper; | 1932 | to_xxx = toupper; |
1943 | lo_cont: | 1933 | lo_cont: |
1944 | s1 = s = bb_xstrdup(as[0]); | 1934 | s1 = s = xstrdup(as[0]); |
1945 | while (*s1) { | 1935 | while (*s1) { |
1946 | *s1 = (*to_xxx)(*s1); | 1936 | *s1 = (*to_xxx)(*s1); |
1947 | s1++; | 1937 | s1++; |
@@ -2118,7 +2108,7 @@ static var *evaluate(node *op, var *res) | |||
2118 | bb_perror_msg_and_die("popen"); | 2108 | bb_perror_msg_and_die("popen"); |
2119 | X.rsm->is_pipe = 1; | 2109 | X.rsm->is_pipe = 1; |
2120 | } else { | 2110 | } else { |
2121 | X.rsm->F = bb_xfopen(R.s, opn=='w' ? "w" : "a"); | 2111 | X.rsm->F = xfopen(R.s, opn=='w' ? "w" : "a"); |
2122 | } | 2112 | } |
2123 | } | 2113 | } |
2124 | X.F = X.rsm->F; | 2114 | X.F = X.rsm->F; |
@@ -2272,7 +2262,7 @@ re_cont: | |||
2272 | X.rsm->F = popen(L.s, "r"); | 2262 | X.rsm->F = popen(L.s, "r"); |
2273 | X.rsm->is_pipe = TRUE; | 2263 | X.rsm->is_pipe = TRUE; |
2274 | } else { | 2264 | } else { |
2275 | X.rsm->F = fopen(L.s, "r"); /* not bb_xfopen! */ | 2265 | X.rsm->F = fopen(L.s, "r"); /* not xfopen! */ |
2276 | } | 2266 | } |
2277 | } | 2267 | } |
2278 | } else { | 2268 | } else { |
@@ -2564,7 +2554,7 @@ static int is_assignment(const char *expr) | |||
2564 | { | 2554 | { |
2565 | char *exprc, *s, *s0, *s1; | 2555 | char *exprc, *s, *s0, *s1; |
2566 | 2556 | ||
2567 | exprc = bb_xstrdup(expr); | 2557 | exprc = xstrdup(expr); |
2568 | if (!isalnum_(*exprc) || (s = strchr(exprc, '=')) == NULL) { | 2558 | if (!isalnum_(*exprc) || (s = strchr(exprc, '=')) == NULL) { |
2569 | free(exprc); | 2559 | free(exprc); |
2570 | return FALSE; | 2560 | return FALSE; |
@@ -2659,7 +2649,7 @@ int awk_main(int argc, char **argv) | |||
2659 | } | 2649 | } |
2660 | 2650 | ||
2661 | for (envp=environ; *envp; envp++) { | 2651 | for (envp=environ; *envp; envp++) { |
2662 | s = bb_xstrdup(*envp); | 2652 | s = xstrdup(*envp); |
2663 | s1 = strchr(s, '='); | 2653 | s1 = strchr(s, '='); |
2664 | if (!s1) { | 2654 | if (!s1) { |
2665 | goto keep_going; | 2655 | goto keep_going; |