diff options
author | Rob Landley <rob@landley.net> | 2006-05-07 20:20:34 +0000 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2006-05-07 20:20:34 +0000 |
commit | a3896511152cd5dcd64d2eb4aebcce65b29c6c0b (patch) | |
tree | 0058e653d90a3d2a961fca16f7c7afd57cd63715 /editors/awk.c | |
parent | f8a808426745ee5f4e5cc76ff1fb9c484c315195 (diff) | |
download | busybox-w32-a3896511152cd5dcd64d2eb4aebcce65b29c6c0b.tar.gz busybox-w32-a3896511152cd5dcd64d2eb4aebcce65b29c6c0b.tar.bz2 busybox-w32-a3896511152cd5dcd64d2eb4aebcce65b29c6c0b.zip |
Remove bb_strlen() in favor of -fno-builtin-strlen. Saves as many bytes
as the old optimization did (actually does slightly better under gcc 4.0), and
simplifies the code.
Diffstat (limited to 'editors/awk.c')
-rw-r--r-- | editors/awk.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/editors/awk.c b/editors/awk.c index e11c8350f..9c8bef53a 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -534,7 +534,7 @@ static void *hash_find(xhash *hash, const char *name) | |||
534 | if (++hash->nel / hash->csize > 10) | 534 | if (++hash->nel / hash->csize > 10) |
535 | hash_rebuild(hash); | 535 | hash_rebuild(hash); |
536 | 536 | ||
537 | l = bb_strlen(name) + 1; | 537 | l = strlen(name) + 1; |
538 | hi = xcalloc(sizeof(hash_item) + l, 1); | 538 | hi = xcalloc(sizeof(hash_item) + l, 1); |
539 | memcpy(hi->name, name, l); | 539 | memcpy(hi->name, name, l); |
540 | 540 | ||
@@ -559,7 +559,7 @@ static void hash_remove(xhash *hash, const char *name) | |||
559 | while (*phi) { | 559 | while (*phi) { |
560 | hi = *phi; | 560 | hi = *phi; |
561 | if (strcmp(hi->name, name) == 0) { | 561 | if (strcmp(hi->name, name) == 0) { |
562 | hash->glen -= (bb_strlen(name) + 1); | 562 | hash->glen -= (strlen(name) + 1); |
563 | hash->nel--; | 563 | hash->nel--; |
564 | *phi = hi->next; | 564 | *phi = hi->next; |
565 | free(hi); | 565 | free(hi); |
@@ -1364,7 +1364,7 @@ static node *mk_splitter(char *s, tsplitter *spl) | |||
1364 | regfree(re); | 1364 | regfree(re); |
1365 | regfree(ire); | 1365 | regfree(ire); |
1366 | } | 1366 | } |
1367 | if (bb_strlen(s) > 1) { | 1367 | if (strlen(s) > 1) { |
1368 | mk_re_node(s, n, re); | 1368 | mk_re_node(s, n, re); |
1369 | } else { | 1369 | } else { |
1370 | n->info = (uint32_t) *s; | 1370 | n->info = (uint32_t) *s; |
@@ -1432,7 +1432,7 @@ static int awk_split(char *s, node *spl, char **slist) | |||
1432 | regmatch_t pmatch[2]; | 1432 | regmatch_t pmatch[2]; |
1433 | 1433 | ||
1434 | /* in worst case, each char would be a separate field */ | 1434 | /* in worst case, each char would be a separate field */ |
1435 | *slist = s1 = bb_xstrndup(s, bb_strlen(s) * 2 + 3); | 1435 | *slist = s1 = bb_xstrndup(s, strlen(s) * 2 + 3); |
1436 | 1436 | ||
1437 | c[0] = c[1] = (char)spl->info; | 1437 | c[0] = c[1] = (char)spl->info; |
1438 | c[2] = c[3] = '\0'; | 1438 | c[2] = c[3] = '\0'; |
@@ -1527,12 +1527,12 @@ static void handle_special(var *v) | |||
1527 | 1527 | ||
1528 | /* recalculate $0 */ | 1528 | /* recalculate $0 */ |
1529 | sep = getvar_s(V[OFS]); | 1529 | sep = getvar_s(V[OFS]); |
1530 | sl = bb_strlen(sep); | 1530 | sl = strlen(sep); |
1531 | b = NULL; | 1531 | b = NULL; |
1532 | len = 0; | 1532 | len = 0; |
1533 | for (i=0; i<n; i++) { | 1533 | for (i=0; i<n; i++) { |
1534 | s = getvar_s(&Fields[i]); | 1534 | s = getvar_s(&Fields[i]); |
1535 | l = bb_strlen(s); | 1535 | l = strlen(s); |
1536 | if (b) { | 1536 | if (b) { |
1537 | memcpy(b+len, sep, sl); | 1537 | memcpy(b+len, sep, sl); |
1538 | len += sl; | 1538 | len += sl; |
@@ -1769,7 +1769,7 @@ static char *awk_printf(node *n) | |||
1769 | 1769 | ||
1770 | } else if (c == 's') { | 1770 | } else if (c == 's') { |
1771 | s1 = getvar_s(arg); | 1771 | s1 = getvar_s(arg); |
1772 | qrealloc(&b, incr+i+bb_strlen(s1), &bsize); | 1772 | qrealloc(&b, incr+i+strlen(s1), &bsize); |
1773 | i += sprintf(b+i, s, s1); | 1773 | i += sprintf(b+i, s, s1); |
1774 | 1774 | ||
1775 | } else { | 1775 | } else { |
@@ -1809,7 +1809,7 @@ static int awk_sub(node *rn, char *repl, int nm, var *src, var *dest, int ex) | |||
1809 | 1809 | ||
1810 | i = di = 0; | 1810 | i = di = 0; |
1811 | sp = getvar_s(src); | 1811 | sp = getvar_s(src); |
1812 | rl = bb_strlen(repl); | 1812 | rl = strlen(repl); |
1813 | while (regexec(re, sp, 10, pmatch, sp==getvar_s(src) ? 0:REG_NOTBOL) == 0) { | 1813 | while (regexec(re, sp, 10, pmatch, sp==getvar_s(src) ? 0:REG_NOTBOL) == 0) { |
1814 | so = pmatch[0].rm_so; | 1814 | so = pmatch[0].rm_so; |
1815 | eo = pmatch[0].rm_eo; | 1815 | eo = pmatch[0].rm_eo; |
@@ -1922,7 +1922,7 @@ static var *exec_builtin(node *op, var *res) | |||
1922 | break; | 1922 | break; |
1923 | 1923 | ||
1924 | case B_ss: | 1924 | case B_ss: |
1925 | l = bb_strlen(as[0]); | 1925 | l = strlen(as[0]); |
1926 | i = getvar_i(av[1]) - 1; | 1926 | i = getvar_i(av[1]) - 1; |
1927 | if (i>l) i=l; if (i<0) i=0; | 1927 | if (i>l) i=l; if (i<0) i=0; |
1928 | n = (nargs > 2) ? getvar_i(av[2]) : l-i; | 1928 | n = (nargs > 2) ? getvar_i(av[2]) : l-i; |
@@ -1950,8 +1950,8 @@ lo_cont: | |||
1950 | 1950 | ||
1951 | case B_ix: | 1951 | case B_ix: |
1952 | n = 0; | 1952 | n = 0; |
1953 | ll = bb_strlen(as[1]); | 1953 | ll = strlen(as[1]); |
1954 | l = bb_strlen(as[0]) - ll; | 1954 | l = strlen(as[0]) - ll; |
1955 | if (ll > 0 && l >= 0) { | 1955 | if (ll > 0 && l >= 0) { |
1956 | if (! icase) { | 1956 | if (! icase) { |
1957 | s = strstr(as[0], as[1]); | 1957 | s = strstr(as[0], as[1]); |
@@ -2353,7 +2353,7 @@ re_cont: | |||
2353 | case F_le: | 2353 | case F_le: |
2354 | if (! op1) | 2354 | if (! op1) |
2355 | L.s = getvar_s(V[F0]); | 2355 | L.s = getvar_s(V[F0]); |
2356 | R.d = bb_strlen(L.s); | 2356 | R.d = strlen(L.s); |
2357 | break; | 2357 | break; |
2358 | 2358 | ||
2359 | case F_sy: | 2359 | case F_sy: |
@@ -2441,12 +2441,12 @@ re_cont: | |||
2441 | /* concatenation (" ") and index joining (",") */ | 2441 | /* concatenation (" ") and index joining (",") */ |
2442 | case XC( OC_CONCAT ): | 2442 | case XC( OC_CONCAT ): |
2443 | case XC( OC_COMMA ): | 2443 | case XC( OC_COMMA ): |
2444 | opn = bb_strlen(L.s) + bb_strlen(R.s) + 2; | 2444 | opn = strlen(L.s) + strlen(R.s) + 2; |
2445 | X.s = (char *)xmalloc(opn); | 2445 | X.s = (char *)xmalloc(opn); |
2446 | strcpy(X.s, L.s); | 2446 | strcpy(X.s, L.s); |
2447 | if ((opinfo & OPCLSMASK) == OC_COMMA) { | 2447 | if ((opinfo & OPCLSMASK) == OC_COMMA) { |
2448 | L.s = getvar_s(V[SUBSEP]); | 2448 | L.s = getvar_s(V[SUBSEP]); |
2449 | X.s = (char *)xrealloc(X.s, opn + bb_strlen(L.s)); | 2449 | X.s = (char *)xrealloc(X.s, opn + strlen(L.s)); |
2450 | strcat(X.s, L.s); | 2450 | strcat(X.s, L.s); |
2451 | } | 2451 | } |
2452 | strcat(X.s, R.s); | 2452 | strcat(X.s, R.s); |