diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-12 21:04:47 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-03-12 21:04:47 +0100 |
commit | 7b81db13791c4dc56f1a04737c5a5a47f4965738 (patch) | |
tree | d522f8e7fdc80764b9ff1adfd1ccbb39989188ef | |
parent | 39fe4d159920f9b1b4ee537479216dc331d73b9c (diff) | |
download | busybox-w32-7b81db13791c4dc56f1a04737c5a5a47f4965738.tar.gz busybox-w32-7b81db13791c4dc56f1a04737c5a5a47f4965738.tar.bz2 busybox-w32-7b81db13791c4dc56f1a04737c5a5a47f4965738.zip |
awk: style fixes
function old new delta
hash_find 234 233 -1
awk_printf 457 453 -4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | editors/awk.c | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/editors/awk.c b/editors/awk.c index 2510192a6..d022b7915 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -110,15 +110,14 @@ typedef struct node_s { | |||
110 | union { | 110 | union { |
111 | struct node_s *n; | 111 | struct node_s *n; |
112 | var *v; | 112 | var *v; |
113 | int i; | 113 | int aidx; |
114 | char *s; | 114 | char *new_progname; |
115 | regex_t *re; | 115 | regex_t *re; |
116 | } l; | 116 | } l; |
117 | union { | 117 | union { |
118 | struct node_s *n; | 118 | struct node_s *n; |
119 | regex_t *ire; | 119 | regex_t *ire; |
120 | func *f; | 120 | func *f; |
121 | int argno; | ||
122 | } r; | 121 | } r; |
123 | union { | 122 | union { |
124 | struct node_s *n; | 123 | struct node_s *n; |
@@ -575,7 +574,7 @@ static void *hash_search(xhash *hash, const char *name) | |||
575 | hi = hash->items[hashidx(name) % hash->csize]; | 574 | hi = hash->items[hashidx(name) % hash->csize]; |
576 | while (hi) { | 575 | while (hi) { |
577 | if (strcmp(hi->name, name) == 0) | 576 | if (strcmp(hi->name, name) == 0) |
578 | return &(hi->data); | 577 | return &hi->data; |
579 | hi = hi->next; | 578 | hi = hi->next; |
580 | } | 579 | } |
581 | return NULL; | 580 | return NULL; |
@@ -630,7 +629,7 @@ static void *hash_find(xhash *hash, const char *name) | |||
630 | hash->items[idx] = hi; | 629 | hash->items[idx] = hi; |
631 | hash->glen += l; | 630 | hash->glen += l; |
632 | } | 631 | } |
633 | return &(hi->data); | 632 | return &hi->data; |
634 | } | 633 | } |
635 | 634 | ||
636 | #define findvar(hash, name) ((var*) hash_find((hash), (name))) | 635 | #define findvar(hash, name) ((var*) hash_find((hash), (name))) |
@@ -642,7 +641,7 @@ static void hash_remove(xhash *hash, const char *name) | |||
642 | { | 641 | { |
643 | hash_item *hi, **phi; | 642 | hash_item *hi, **phi; |
644 | 643 | ||
645 | phi = &(hash->items[hashidx(name) % hash->csize]); | 644 | phi = &hash->items[hashidx(name) % hash->csize]; |
646 | while (*phi) { | 645 | while (*phi) { |
647 | hi = *phi; | 646 | hi = *phi; |
648 | if (strcmp(hi->name, name) == 0) { | 647 | if (strcmp(hi->name, name) == 0) { |
@@ -652,7 +651,7 @@ static void hash_remove(xhash *hash, const char *name) | |||
652 | free(hi); | 651 | free(hi); |
653 | break; | 652 | break; |
654 | } | 653 | } |
655 | phi = &(hi->next); | 654 | phi = &hi->next; |
656 | } | 655 | } |
657 | } | 656 | } |
658 | 657 | ||
@@ -1221,7 +1220,7 @@ static node *parse_expr(uint32_t iexp) | |||
1221 | v = hash_search(ahash, t_string); | 1220 | v = hash_search(ahash, t_string); |
1222 | if (v != NULL) { | 1221 | if (v != NULL) { |
1223 | cn->info = OC_FNARG; | 1222 | cn->info = OC_FNARG; |
1224 | cn->l.i = v->x.aidx; | 1223 | cn->l.aidx = v->x.aidx; |
1225 | } else { | 1224 | } else { |
1226 | cn->l.v = newvar(t_string); | 1225 | cn->l.v = newvar(t_string); |
1227 | } | 1226 | } |
@@ -1282,7 +1281,7 @@ static node *chain_node(uint32_t info) | |||
1282 | if (seq->programname != g_progname) { | 1281 | if (seq->programname != g_progname) { |
1283 | seq->programname = g_progname; | 1282 | seq->programname = g_progname; |
1284 | n = chain_node(OC_NEWSOURCE); | 1283 | n = chain_node(OC_NEWSOURCE); |
1285 | n->l.s = xstrdup(g_progname); | 1284 | n->l.new_progname = xstrdup(g_progname); |
1286 | } | 1285 | } |
1287 | 1286 | ||
1288 | n = seq->last; | 1287 | n = seq->last; |
@@ -1460,12 +1459,12 @@ static void parse_program(char *p) | |||
1460 | f->nargs = 0; | 1459 | f->nargs = 0; |
1461 | while (next_token(TC_VARIABLE | TC_SEQTERM) & TC_VARIABLE) { | 1460 | while (next_token(TC_VARIABLE | TC_SEQTERM) & TC_VARIABLE) { |
1462 | v = findvar(ahash, t_string); | 1461 | v = findvar(ahash, t_string); |
1463 | v->x.aidx = (f->nargs)++; | 1462 | v->x.aidx = f->nargs++; |
1464 | 1463 | ||
1465 | if (next_token(TC_COMMA | TC_SEQTERM) & TC_SEQTERM) | 1464 | if (next_token(TC_COMMA | TC_SEQTERM) & TC_SEQTERM) |
1466 | break; | 1465 | break; |
1467 | } | 1466 | } |
1468 | seq = &(f->body); | 1467 | seq = &f->body; |
1469 | chain_group(); | 1468 | chain_group(); |
1470 | clear_array(ahash); | 1469 | clear_array(ahash); |
1471 | 1470 | ||
@@ -1812,7 +1811,7 @@ static int awk_getline(rstream *rsm, var *v) | |||
1812 | { | 1811 | { |
1813 | char *b; | 1812 | char *b; |
1814 | regmatch_t pmatch[2]; | 1813 | regmatch_t pmatch[2]; |
1815 | int a, p, pp=0, size; | 1814 | int size, a, p, pp = 0; |
1816 | int fd, so, eo, r, rp; | 1815 | int fd, so, eo, r, rp; |
1817 | char c, *m, *s; | 1816 | char c, *m, *s; |
1818 | 1817 | ||
@@ -1829,6 +1828,7 @@ static int awk_getline(rstream *rsm, var *v) | |||
1829 | 1828 | ||
1830 | if (!m) | 1829 | if (!m) |
1831 | m = qrealloc(m, 256, &size); | 1830 | m = qrealloc(m, 256, &size); |
1831 | |||
1832 | do { | 1832 | do { |
1833 | b = m + a; | 1833 | b = m + a; |
1834 | so = eo = p; | 1834 | so = eo = p; |
@@ -1857,7 +1857,8 @@ static int awk_getline(rstream *rsm, var *v) | |||
1857 | s = strstr(b+rp, "\n\n"); | 1857 | s = strstr(b+rp, "\n\n"); |
1858 | if (s) { | 1858 | if (s) { |
1859 | so = eo = s-b; | 1859 | so = eo = s-b; |
1860 | while (b[eo] == '\n') eo++; | 1860 | while (b[eo] == '\n') |
1861 | eo++; | ||
1861 | if (b[eo] != '\0') | 1862 | if (b[eo] != '\0') |
1862 | break; | 1863 | break; |
1863 | } | 1864 | } |
@@ -1865,7 +1866,7 @@ static int awk_getline(rstream *rsm, var *v) | |||
1865 | } | 1866 | } |
1866 | 1867 | ||
1867 | if (a > 0) { | 1868 | if (a > 0) { |
1868 | memmove(m, (const void *)(m+a), p+1); | 1869 | memmove(m, m+a, p+1); |
1869 | b = m; | 1870 | b = m; |
1870 | a = 0; | 1871 | a = 0; |
1871 | } | 1872 | } |
@@ -1975,9 +1976,9 @@ static char *awk_printf(node *n) | |||
1975 | i = j; | 1976 | i = j; |
1976 | } | 1977 | } |
1977 | 1978 | ||
1978 | b = xrealloc(b, i + 1); | ||
1979 | free(fmt); | 1979 | free(fmt); |
1980 | nvfree(v); | 1980 | nvfree(v); |
1981 | b = xrealloc(b, i + 1); | ||
1981 | b[i] = '\0'; | 1982 | b[i] = '\0'; |
1982 | return b; | 1983 | return b; |
1983 | } | 1984 | } |
@@ -2361,7 +2362,7 @@ static var *evaluate(node *op, var *res) | |||
2361 | op = op->r.n; | 2362 | op = op->r.n; |
2362 | } | 2363 | } |
2363 | } else { | 2364 | } else { |
2364 | op = (ptest(op1)) ? op->a.n : op->r.n; | 2365 | op = ptest(op1) ? op->a.n : op->r.n; |
2365 | } | 2366 | } |
2366 | break; | 2367 | break; |
2367 | 2368 | ||
@@ -2435,7 +2436,7 @@ static var *evaluate(node *op, var *res) | |||
2435 | if (X.info == OC_VAR) { | 2436 | if (X.info == OC_VAR) { |
2436 | R.v = op1->l.v; | 2437 | R.v = op1->l.v; |
2437 | } else if (X.info == OC_FNARG) { | 2438 | } else if (X.info == OC_FNARG) { |
2438 | R.v = &fnargs[op1->l.i]; | 2439 | R.v = &fnargs[op1->l.aidx]; |
2439 | } else { | 2440 | } else { |
2440 | syntax_error(EMSG_NOT_ARRAY); | 2441 | syntax_error(EMSG_NOT_ARRAY); |
2441 | } | 2442 | } |
@@ -2450,7 +2451,7 @@ static var *evaluate(node *op, var *res) | |||
2450 | break; | 2451 | break; |
2451 | 2452 | ||
2452 | case XC( OC_NEWSOURCE ): | 2453 | case XC( OC_NEWSOURCE ): |
2453 | g_progname = op->l.s; | 2454 | g_progname = op->l.new_progname; |
2454 | break; | 2455 | break; |
2455 | 2456 | ||
2456 | case XC( OC_RETURN ): | 2457 | case XC( OC_RETURN ): |
@@ -2477,7 +2478,7 @@ static var *evaluate(node *op, var *res) | |||
2477 | goto v_cont; | 2478 | goto v_cont; |
2478 | 2479 | ||
2479 | case XC( OC_FNARG ): | 2480 | case XC( OC_FNARG ): |
2480 | L.v = &fnargs[op->l.i]; | 2481 | L.v = &fnargs[op->l.aidx]; |
2481 | v_cont: | 2482 | v_cont: |
2482 | res = op->r.n ? findvar(iamarray(L.v), R.s) : L.v; | 2483 | res = op->r.n ? findvar(iamarray(L.v), R.s) : L.v; |
2483 | break; | 2484 | break; |