diff options
author | Mike Frysinger <vapier@gentoo.org> | 2005-09-27 02:23:02 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2005-09-27 02:23:02 +0000 |
commit | 10a11e23ba9b03ae1827959539b12a281fe8e2a4 (patch) | |
tree | b7a89927946b3a269478f4148a8c18dd3fd4acae /editors | |
parent | 1c943eb88af4782f02001ced33f0b07e892bdb22 (diff) | |
download | busybox-w32-10a11e23ba9b03ae1827959539b12a281fe8e2a4.tar.gz busybox-w32-10a11e23ba9b03ae1827959539b12a281fe8e2a4.tar.bz2 busybox-w32-10a11e23ba9b03ae1827959539b12a281fe8e2a4.zip |
uncuddle function scope brackets
Diffstat (limited to 'editors')
-rw-r--r-- | editors/awk.c | 232 |
1 files changed, 116 insertions, 116 deletions
diff --git a/editors/awk.c b/editors/awk.c index 6e81e23a9..83ad9b6ee 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -473,8 +473,8 @@ static void syntax_error(const char * const message) | |||
473 | 473 | ||
474 | /* ---- hash stuff ---- */ | 474 | /* ---- hash stuff ---- */ |
475 | 475 | ||
476 | static unsigned int hashidx(char *name) { | 476 | static unsigned int hashidx(char *name) |
477 | 477 | { | |
478 | register unsigned int idx=0; | 478 | register unsigned int idx=0; |
479 | 479 | ||
480 | while (*name) idx = *name++ + (idx << 6) - idx; | 480 | while (*name) idx = *name++ + (idx << 6) - idx; |
@@ -482,8 +482,8 @@ static unsigned int hashidx(char *name) { | |||
482 | } | 482 | } |
483 | 483 | ||
484 | /* create new hash */ | 484 | /* create new hash */ |
485 | static xhash *hash_init(void) { | 485 | static xhash *hash_init(void) |
486 | 486 | { | |
487 | xhash *newhash; | 487 | xhash *newhash; |
488 | 488 | ||
489 | newhash = (xhash *)xcalloc(1, sizeof(xhash)); | 489 | newhash = (xhash *)xcalloc(1, sizeof(xhash)); |
@@ -494,8 +494,8 @@ static xhash *hash_init(void) { | |||
494 | } | 494 | } |
495 | 495 | ||
496 | /* find item in hash, return ptr to data, NULL if not found */ | 496 | /* find item in hash, return ptr to data, NULL if not found */ |
497 | static void *hash_search(xhash *hash, char *name) { | 497 | static void *hash_search(xhash *hash, char *name) |
498 | 498 | { | |
499 | hash_item *hi; | 499 | hash_item *hi; |
500 | 500 | ||
501 | hi = hash->items [ hashidx(name) % hash->csize ]; | 501 | hi = hash->items [ hashidx(name) % hash->csize ]; |
@@ -508,8 +508,8 @@ static void *hash_search(xhash *hash, char *name) { | |||
508 | } | 508 | } |
509 | 509 | ||
510 | /* grow hash if it becomes too big */ | 510 | /* grow hash if it becomes too big */ |
511 | static void hash_rebuild(xhash *hash) { | 511 | static void hash_rebuild(xhash *hash) |
512 | 512 | { | |
513 | unsigned int newsize, i, idx; | 513 | unsigned int newsize, i, idx; |
514 | hash_item **newitems, *hi, *thi; | 514 | hash_item **newitems, *hi, *thi; |
515 | 515 | ||
@@ -536,8 +536,8 @@ static void hash_rebuild(xhash *hash) { | |||
536 | } | 536 | } |
537 | 537 | ||
538 | /* find item in hash, add it if necessary. Return ptr to data */ | 538 | /* find item in hash, add it if necessary. Return ptr to data */ |
539 | static void *hash_find(xhash *hash, char *name) { | 539 | static void *hash_find(xhash *hash, char *name) |
540 | 540 | { | |
541 | hash_item *hi; | 541 | hash_item *hi; |
542 | unsigned int idx; | 542 | unsigned int idx; |
543 | int l; | 543 | int l; |
@@ -564,8 +564,8 @@ static void *hash_find(xhash *hash, char *name) { | |||
564 | #define newfile(name) (rstream *) hash_find ( fdhash , (name) ) | 564 | #define newfile(name) (rstream *) hash_find ( fdhash , (name) ) |
565 | #define newfunc(name) (func *) hash_find ( fnhash , (name) ) | 565 | #define newfunc(name) (func *) hash_find ( fnhash , (name) ) |
566 | 566 | ||
567 | static void hash_remove(xhash *hash, char *name) { | 567 | static void hash_remove(xhash *hash, char *name) |
568 | 568 | { | |
569 | hash_item *hi, **phi; | 569 | hash_item *hi, **phi; |
570 | 570 | ||
571 | phi = &(hash->items[ hashidx(name) % hash->csize ]); | 571 | phi = &(hash->items[ hashidx(name) % hash->csize ]); |
@@ -584,8 +584,8 @@ static void hash_remove(xhash *hash, char *name) { | |||
584 | 584 | ||
585 | /* ------ some useful functions ------ */ | 585 | /* ------ some useful functions ------ */ |
586 | 586 | ||
587 | static void skip_spaces(char **s) { | 587 | static void skip_spaces(char **s) |
588 | 588 | { | |
589 | register char *p = *s; | 589 | register char *p = *s; |
590 | 590 | ||
591 | while(*p == ' ' || *p == '\t' || | 591 | while(*p == ' ' || *p == '\t' || |
@@ -595,8 +595,8 @@ static void skip_spaces(char **s) { | |||
595 | *s = p; | 595 | *s = p; |
596 | } | 596 | } |
597 | 597 | ||
598 | static char *nextword(char **s) { | 598 | static char *nextword(char **s) |
599 | 599 | { | |
600 | register char *p = *s; | 600 | register char *p = *s; |
601 | 601 | ||
602 | while (*(*s)++) ; | 602 | while (*(*s)++) ; |
@@ -604,8 +604,8 @@ static char *nextword(char **s) { | |||
604 | return p; | 604 | return p; |
605 | } | 605 | } |
606 | 606 | ||
607 | static char nextchar(char **s) { | 607 | static char nextchar(char **s) |
608 | 608 | { | |
609 | register char c, *pps; | 609 | register char c, *pps; |
610 | 610 | ||
611 | c = *((*s)++); | 611 | c = *((*s)++); |
@@ -615,20 +615,20 @@ static char nextchar(char **s) { | |||
615 | return c; | 615 | return c; |
616 | } | 616 | } |
617 | 617 | ||
618 | static inline int isalnum_(int c) { | 618 | static inline int isalnum_(int c) |
619 | 619 | { | |
620 | return (isalnum(c) || c == '_'); | 620 | return (isalnum(c) || c == '_'); |
621 | } | 621 | } |
622 | 622 | ||
623 | static FILE *afopen(const char *path, const char *mode) { | 623 | static FILE *afopen(const char *path, const char *mode) |
624 | 624 | { | |
625 | return (*path == '-' && *(path+1) == '\0') ? stdin : bb_xfopen(path, mode); | 625 | return (*path == '-' && *(path+1) == '\0') ? stdin : bb_xfopen(path, mode); |
626 | } | 626 | } |
627 | 627 | ||
628 | /* -------- working with variables (set/get/copy/etc) -------- */ | 628 | /* -------- working with variables (set/get/copy/etc) -------- */ |
629 | 629 | ||
630 | static xhash *iamarray(var *v) { | 630 | static xhash *iamarray(var *v) |
631 | 631 | { | |
632 | var *a = v; | 632 | var *a = v; |
633 | 633 | ||
634 | while (a->type & VF_CHILD) | 634 | while (a->type & VF_CHILD) |
@@ -641,8 +641,8 @@ static xhash *iamarray(var *v) { | |||
641 | return a->x.array; | 641 | return a->x.array; |
642 | } | 642 | } |
643 | 643 | ||
644 | static void clear_array(xhash *array) { | 644 | static void clear_array(xhash *array) |
645 | 645 | { | |
646 | unsigned int i; | 646 | unsigned int i; |
647 | hash_item *hi, *thi; | 647 | hash_item *hi, *thi; |
648 | 648 | ||
@@ -660,8 +660,8 @@ static void clear_array(xhash *array) { | |||
660 | } | 660 | } |
661 | 661 | ||
662 | /* clear a variable */ | 662 | /* clear a variable */ |
663 | static var *clrvar(var *v) { | 663 | static var *clrvar(var *v) |
664 | 664 | { | |
665 | if (!(v->type & VF_FSTR)) | 665 | if (!(v->type & VF_FSTR)) |
666 | free(v->string); | 666 | free(v->string); |
667 | 667 | ||
@@ -672,8 +672,8 @@ static var *clrvar(var *v) { | |||
672 | } | 672 | } |
673 | 673 | ||
674 | /* assign string value to variable */ | 674 | /* assign string value to variable */ |
675 | static var *setvar_p(var *v, char *value) { | 675 | static var *setvar_p(var *v, char *value) |
676 | 676 | { | |
677 | clrvar(v); | 677 | clrvar(v); |
678 | v->string = value; | 678 | v->string = value; |
679 | handle_special(v); | 679 | handle_special(v); |
@@ -682,22 +682,22 @@ static var *setvar_p(var *v, char *value) { | |||
682 | } | 682 | } |
683 | 683 | ||
684 | /* same as setvar_p but make a copy of string */ | 684 | /* same as setvar_p but make a copy of string */ |
685 | static var *setvar_s(var *v, char *value) { | 685 | static var *setvar_s(var *v, char *value) |
686 | 686 | { | |
687 | return setvar_p(v, (value && *value) ? bb_xstrdup(value) : NULL); | 687 | return setvar_p(v, (value && *value) ? bb_xstrdup(value) : NULL); |
688 | } | 688 | } |
689 | 689 | ||
690 | /* same as setvar_s but set USER flag */ | 690 | /* same as setvar_s but set USER flag */ |
691 | static var *setvar_u(var *v, char *value) { | 691 | static var *setvar_u(var *v, char *value) |
692 | 692 | { | |
693 | setvar_s(v, value); | 693 | setvar_s(v, value); |
694 | v->type |= VF_USER; | 694 | v->type |= VF_USER; |
695 | return v; | 695 | return v; |
696 | } | 696 | } |
697 | 697 | ||
698 | /* set array element to user string */ | 698 | /* set array element to user string */ |
699 | static void setari_u(var *a, int idx, char *s) { | 699 | static void setari_u(var *a, int idx, char *s) |
700 | 700 | { | |
701 | register var *v; | 701 | register var *v; |
702 | static char sidx[12]; | 702 | static char sidx[12]; |
703 | 703 | ||
@@ -707,8 +707,8 @@ static void setari_u(var *a, int idx, char *s) { | |||
707 | } | 707 | } |
708 | 708 | ||
709 | /* assign numeric value to variable */ | 709 | /* assign numeric value to variable */ |
710 | static var *setvar_i(var *v, double value) { | 710 | static var *setvar_i(var *v, double value) |
711 | 711 | { | |
712 | clrvar(v); | 712 | clrvar(v); |
713 | v->type |= VF_NUMBER; | 713 | v->type |= VF_NUMBER; |
714 | v->number = value; | 714 | v->number = value; |
@@ -716,8 +716,8 @@ static var *setvar_i(var *v, double value) { | |||
716 | return v; | 716 | return v; |
717 | } | 717 | } |
718 | 718 | ||
719 | static char *getvar_s(var *v) { | 719 | static char *getvar_s(var *v) |
720 | 720 | { | |
721 | /* if v is numeric and has no cached string, convert it to string */ | 721 | /* if v is numeric and has no cached string, convert it to string */ |
722 | if ((v->type & (VF_NUMBER | VF_CACHED)) == VF_NUMBER) { | 722 | if ((v->type & (VF_NUMBER | VF_CACHED)) == VF_NUMBER) { |
723 | fmt_num(buf, MAXVARFMT, getvar_s(V[CONVFMT]), v->number, TRUE); | 723 | fmt_num(buf, MAXVARFMT, getvar_s(V[CONVFMT]), v->number, TRUE); |
@@ -727,8 +727,8 @@ static char *getvar_s(var *v) { | |||
727 | return (v->string == NULL) ? "" : v->string; | 727 | return (v->string == NULL) ? "" : v->string; |
728 | } | 728 | } |
729 | 729 | ||
730 | static double getvar_i(var *v) { | 730 | static double getvar_i(var *v) |
731 | 731 | { | |
732 | char *s; | 732 | char *s; |
733 | 733 | ||
734 | if ((v->type & (VF_NUMBER | VF_CACHED)) == 0) { | 734 | if ((v->type & (VF_NUMBER | VF_CACHED)) == 0) { |
@@ -749,8 +749,8 @@ static double getvar_i(var *v) { | |||
749 | return v->number; | 749 | return v->number; |
750 | } | 750 | } |
751 | 751 | ||
752 | static var *copyvar(var *dest, var *src) { | 752 | static var *copyvar(var *dest, var *src) |
753 | 753 | { | |
754 | if (dest != src) { | 754 | if (dest != src) { |
755 | clrvar(dest); | 755 | clrvar(dest); |
756 | dest->type |= (src->type & ~VF_DONTTOUCH); | 756 | dest->type |= (src->type & ~VF_DONTTOUCH); |
@@ -762,21 +762,21 @@ static var *copyvar(var *dest, var *src) { | |||
762 | return dest; | 762 | return dest; |
763 | } | 763 | } |
764 | 764 | ||
765 | static var *incvar(var *v) { | 765 | static var *incvar(var *v) |
766 | 766 | { | |
767 | return setvar_i(v, getvar_i(v)+1.); | 767 | return setvar_i(v, getvar_i(v)+1.); |
768 | } | 768 | } |
769 | 769 | ||
770 | /* return true if v is number or numeric string */ | 770 | /* return true if v is number or numeric string */ |
771 | static int is_numeric(var *v) { | 771 | static int is_numeric(var *v) |
772 | 772 | { | |
773 | getvar_i(v); | 773 | getvar_i(v); |
774 | return ((v->type ^ VF_DIRTY) & (VF_NUMBER | VF_USER | VF_DIRTY)); | 774 | return ((v->type ^ VF_DIRTY) & (VF_NUMBER | VF_USER | VF_DIRTY)); |
775 | } | 775 | } |
776 | 776 | ||
777 | /* return 1 when value of v corresponds to true, 0 otherwise */ | 777 | /* return 1 when value of v corresponds to true, 0 otherwise */ |
778 | static int istrue(var *v) { | 778 | static int istrue(var *v) |
779 | 779 | { | |
780 | if (is_numeric(v)) | 780 | if (is_numeric(v)) |
781 | return (v->number == 0) ? 0 : 1; | 781 | return (v->number == 0) ? 0 : 1; |
782 | else | 782 | else |
@@ -784,8 +784,8 @@ static int istrue(var *v) { | |||
784 | } | 784 | } |
785 | 785 | ||
786 | /* temporary variables allocator. Last allocated should be first freed */ | 786 | /* temporary variables allocator. Last allocated should be first freed */ |
787 | static var *nvalloc(int n) { | 787 | static var *nvalloc(int n) |
788 | 788 | { | |
789 | nvblock *pb = NULL; | 789 | nvblock *pb = NULL; |
790 | var *v, *r; | 790 | var *v, *r; |
791 | int size; | 791 | int size; |
@@ -818,8 +818,8 @@ static var *nvalloc(int n) { | |||
818 | return r; | 818 | return r; |
819 | } | 819 | } |
820 | 820 | ||
821 | static void nvfree(var *v) { | 821 | static void nvfree(var *v) |
822 | 822 | { | |
823 | var *p; | 823 | var *p; |
824 | 824 | ||
825 | if (v < cb->nv || v >= cb->pos) | 825 | if (v < cb->nv || v >= cb->pos) |
@@ -848,8 +848,8 @@ static void nvfree(var *v) { | |||
848 | /* Parse next token pointed by global pos, place results into global t. | 848 | /* Parse next token pointed by global pos, place results into global t. |
849 | * If token isn't expected, give away. Return token class | 849 | * If token isn't expected, give away. Return token class |
850 | */ | 850 | */ |
851 | static unsigned long next_token(unsigned long expected) { | 851 | static unsigned long next_token(unsigned long expected) |
852 | 852 | { | |
853 | char *p, *pp, *s; | 853 | char *p, *pp, *s; |
854 | char *tl; | 854 | char *tl; |
855 | unsigned long tc, *ti; | 855 | unsigned long tc, *ti; |
@@ -999,8 +999,8 @@ static unsigned long next_token(unsigned long expected) { | |||
999 | 999 | ||
1000 | static void rollback_token(void) { t.rollback = TRUE; } | 1000 | static void rollback_token(void) { t.rollback = TRUE; } |
1001 | 1001 | ||
1002 | static node *new_node(unsigned long info) { | 1002 | static node *new_node(unsigned long info) |
1003 | 1003 | { | |
1004 | register node *n; | 1004 | register node *n; |
1005 | 1005 | ||
1006 | n = (node *)xcalloc(sizeof(node), 1); | 1006 | n = (node *)xcalloc(sizeof(node), 1); |
@@ -1009,8 +1009,8 @@ static node *new_node(unsigned long info) { | |||
1009 | return n; | 1009 | return n; |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | static node *mk_re_node(char *s, node *n, regex_t *re) { | 1012 | static node *mk_re_node(char *s, node *n, regex_t *re) |
1013 | 1013 | { | |
1014 | n->info = OC_REGEXP; | 1014 | n->info = OC_REGEXP; |
1015 | n->l.re = re; | 1015 | n->l.re = re; |
1016 | n->r.ire = re + 1; | 1016 | n->r.ire = re + 1; |
@@ -1020,16 +1020,16 @@ static node *mk_re_node(char *s, node *n, regex_t *re) { | |||
1020 | return n; | 1020 | return n; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | static node *condition(void) { | 1023 | static node *condition(void) |
1024 | 1024 | { | |
1025 | next_token(TC_SEQSTART); | 1025 | next_token(TC_SEQSTART); |
1026 | return parse_expr(TC_SEQTERM); | 1026 | return parse_expr(TC_SEQTERM); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | /* parse expression terminated by given argument, return ptr | 1029 | /* parse expression terminated by given argument, return ptr |
1030 | * to built subtree. Terminator is eaten by parse_expr */ | 1030 | * to built subtree. Terminator is eaten by parse_expr */ |
1031 | static node *parse_expr(unsigned long iexp) { | 1031 | static node *parse_expr(unsigned long iexp) |
1032 | 1032 | { | |
1033 | node sn; | 1033 | node sn; |
1034 | node *cn = &sn; | 1034 | node *cn = &sn; |
1035 | node *vn, *glptr; | 1035 | node *vn, *glptr; |
@@ -1144,8 +1144,8 @@ static node *parse_expr(unsigned long iexp) { | |||
1144 | } | 1144 | } |
1145 | 1145 | ||
1146 | /* add node to chain. Return ptr to alloc'd node */ | 1146 | /* add node to chain. Return ptr to alloc'd node */ |
1147 | static node *chain_node(unsigned long info) { | 1147 | static node *chain_node(unsigned long info) |
1148 | 1148 | { | |
1149 | register node *n; | 1149 | register node *n; |
1150 | 1150 | ||
1151 | if (! seq->first) | 1151 | if (! seq->first) |
@@ -1164,8 +1164,8 @@ static node *chain_node(unsigned long info) { | |||
1164 | return n; | 1164 | return n; |
1165 | } | 1165 | } |
1166 | 1166 | ||
1167 | static void chain_expr(unsigned long info) { | 1167 | static void chain_expr(unsigned long info) |
1168 | 1168 | { | |
1169 | node *n; | 1169 | node *n; |
1170 | 1170 | ||
1171 | n = chain_node(info); | 1171 | n = chain_node(info); |
@@ -1174,8 +1174,8 @@ static void chain_expr(unsigned long info) { | |||
1174 | rollback_token(); | 1174 | rollback_token(); |
1175 | } | 1175 | } |
1176 | 1176 | ||
1177 | static node *chain_loop(node *nn) { | 1177 | static node *chain_loop(node *nn) |
1178 | 1178 | { | |
1179 | node *n, *n2, *save_brk, *save_cont; | 1179 | node *n, *n2, *save_brk, *save_cont; |
1180 | 1180 | ||
1181 | save_brk = break_ptr; | 1181 | save_brk = break_ptr; |
@@ -1198,8 +1198,8 @@ static node *chain_loop(node *nn) { | |||
1198 | } | 1198 | } |
1199 | 1199 | ||
1200 | /* parse group and attach it to chain */ | 1200 | /* parse group and attach it to chain */ |
1201 | static void chain_group(void) { | 1201 | static void chain_group(void) |
1202 | 1202 | { | |
1203 | unsigned long c; | 1203 | unsigned long c; |
1204 | node *n, *n2, *n3; | 1204 | node *n, *n2, *n3; |
1205 | 1205 | ||
@@ -1300,8 +1300,8 @@ static void chain_group(void) { | |||
1300 | } | 1300 | } |
1301 | } | 1301 | } |
1302 | 1302 | ||
1303 | static void parse_program(char *p) { | 1303 | static void parse_program(char *p) |
1304 | 1304 | { | |
1305 | unsigned long tclass; | 1305 | unsigned long tclass; |
1306 | node *cn; | 1306 | node *cn; |
1307 | func *f; | 1307 | func *f; |
@@ -1363,8 +1363,8 @@ static void parse_program(char *p) { | |||
1363 | 1363 | ||
1364 | /* -------- program execution part -------- */ | 1364 | /* -------- program execution part -------- */ |
1365 | 1365 | ||
1366 | static node *mk_splitter(char *s, tsplitter *spl) { | 1366 | static node *mk_splitter(char *s, tsplitter *spl) |
1367 | 1367 | { | |
1368 | register regex_t *re, *ire; | 1368 | register regex_t *re, *ire; |
1369 | node *n; | 1369 | node *n; |
1370 | 1370 | ||
@@ -1388,8 +1388,8 @@ static node *mk_splitter(char *s, tsplitter *spl) { | |||
1388 | * storage space. Return ptr to regex (if result points to preg, it should | 1388 | * storage space. Return ptr to regex (if result points to preg, it should |
1389 | * be later regfree'd manually | 1389 | * be later regfree'd manually |
1390 | */ | 1390 | */ |
1391 | static regex_t *as_regex(node *op, regex_t *preg) { | 1391 | static regex_t *as_regex(node *op, regex_t *preg) |
1392 | 1392 | { | |
1393 | var *v; | 1393 | var *v; |
1394 | char *s; | 1394 | char *s; |
1395 | 1395 | ||
@@ -1405,15 +1405,15 @@ static regex_t *as_regex(node *op, regex_t *preg) { | |||
1405 | } | 1405 | } |
1406 | 1406 | ||
1407 | /* gradually increasing buffer */ | 1407 | /* gradually increasing buffer */ |
1408 | static void qrealloc(char **b, int n, int *size) { | 1408 | static void qrealloc(char **b, int n, int *size) |
1409 | 1409 | { | |
1410 | if (! *b || n >= *size) | 1410 | if (! *b || n >= *size) |
1411 | *b = xrealloc(*b, *size = n + (n>>1) + 80); | 1411 | *b = xrealloc(*b, *size = n + (n>>1) + 80); |
1412 | } | 1412 | } |
1413 | 1413 | ||
1414 | /* resize field storage space */ | 1414 | /* resize field storage space */ |
1415 | static void fsrealloc(int size) { | 1415 | static void fsrealloc(int size) |
1416 | 1416 | { | |
1417 | static int maxfields = 0; | 1417 | static int maxfields = 0; |
1418 | int i; | 1418 | int i; |
1419 | 1419 | ||
@@ -1435,8 +1435,8 @@ static void fsrealloc(int size) { | |||
1435 | nfields = size; | 1435 | nfields = size; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | static int awk_split(char *s, node *spl, char **slist) { | 1438 | static int awk_split(char *s, node *spl, char **slist) |
1439 | 1439 | { | |
1440 | int l, n=0; | 1440 | int l, n=0; |
1441 | char c[4]; | 1441 | char c[4]; |
1442 | char *s1; | 1442 | char *s1; |
@@ -1496,8 +1496,8 @@ static int awk_split(char *s, node *spl, char **slist) { | |||
1496 | return n; | 1496 | return n; |
1497 | } | 1497 | } |
1498 | 1498 | ||
1499 | static void split_f0(void) { | 1499 | static void split_f0(void) |
1500 | 1500 | { | |
1501 | static char *fstrings = NULL; | 1501 | static char *fstrings = NULL; |
1502 | int i, n; | 1502 | int i, n; |
1503 | char *s; | 1503 | char *s; |
@@ -1523,8 +1523,8 @@ static void split_f0(void) { | |||
1523 | } | 1523 | } |
1524 | 1524 | ||
1525 | /* perform additional actions when some internal variables changed */ | 1525 | /* perform additional actions when some internal variables changed */ |
1526 | static void handle_special(var *v) { | 1526 | static void handle_special(var *v) |
1527 | 1527 | { | |
1528 | int n; | 1528 | int n; |
1529 | char *b, *sep, *s; | 1529 | char *b, *sep, *s; |
1530 | int sl, l, len, i, bsize; | 1530 | int sl, l, len, i, bsize; |
@@ -1576,8 +1576,8 @@ static void handle_special(var *v) { | |||
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | /* step through func/builtin/etc arguments */ | 1578 | /* step through func/builtin/etc arguments */ |
1579 | static node *nextarg(node **pn) { | 1579 | static node *nextarg(node **pn) |
1580 | 1580 | { | |
1581 | node *n; | 1581 | node *n; |
1582 | 1582 | ||
1583 | n = *pn; | 1583 | n = *pn; |
@@ -1590,8 +1590,8 @@ static node *nextarg(node **pn) { | |||
1590 | return n; | 1590 | return n; |
1591 | } | 1591 | } |
1592 | 1592 | ||
1593 | static void hashwalk_init(var *v, xhash *array) { | 1593 | static void hashwalk_init(var *v, xhash *array) |
1594 | 1594 | { | |
1595 | char **w; | 1595 | char **w; |
1596 | hash_item *hi; | 1596 | hash_item *hi; |
1597 | int i; | 1597 | int i; |
@@ -1612,8 +1612,8 @@ static void hashwalk_init(var *v, xhash *array) { | |||
1612 | } | 1612 | } |
1613 | } | 1613 | } |
1614 | 1614 | ||
1615 | static int hashwalk_next(var *v) { | 1615 | static int hashwalk_next(var *v) |
1616 | 1616 | { | |
1617 | char **w; | 1617 | char **w; |
1618 | 1618 | ||
1619 | w = v->x.walker; | 1619 | w = v->x.walker; |
@@ -1625,15 +1625,15 @@ static int hashwalk_next(var *v) { | |||
1625 | } | 1625 | } |
1626 | 1626 | ||
1627 | /* evaluate node, return 1 when result is true, 0 otherwise */ | 1627 | /* evaluate node, return 1 when result is true, 0 otherwise */ |
1628 | static int ptest(node *pattern) { | 1628 | static int ptest(node *pattern) |
1629 | { | ||
1629 | static var v; | 1630 | static var v; |
1630 | |||
1631 | return istrue(evaluate(pattern, &v)); | 1631 | return istrue(evaluate(pattern, &v)); |
1632 | } | 1632 | } |
1633 | 1633 | ||
1634 | /* read next record from stream rsm into a variable v */ | 1634 | /* read next record from stream rsm into a variable v */ |
1635 | static int awk_getline(rstream *rsm, var *v) { | 1635 | static int awk_getline(rstream *rsm, var *v) |
1636 | 1636 | { | |
1637 | char *b; | 1637 | char *b; |
1638 | regmatch_t pmatch[2]; | 1638 | regmatch_t pmatch[2]; |
1639 | int a, p, pp=0, size; | 1639 | int a, p, pp=0, size; |
@@ -1724,8 +1724,8 @@ static int awk_getline(rstream *rsm, var *v) { | |||
1724 | return r; | 1724 | return r; |
1725 | } | 1725 | } |
1726 | 1726 | ||
1727 | static int fmt_num(char *b, int size, char *format, double n, int int_as_int) { | 1727 | static int fmt_num(char *b, int size, char *format, double n, int int_as_int) |
1728 | 1728 | { | |
1729 | int r=0; | 1729 | int r=0; |
1730 | char c, *s=format; | 1730 | char c, *s=format; |
1731 | 1731 | ||
@@ -1746,8 +1746,8 @@ static int fmt_num(char *b, int size, char *format, double n, int int_as_int) { | |||
1746 | 1746 | ||
1747 | 1747 | ||
1748 | /* formatted output into an allocated buffer, return ptr to buffer */ | 1748 | /* formatted output into an allocated buffer, return ptr to buffer */ |
1749 | static char *awk_printf(node *n) { | 1749 | static char *awk_printf(node *n) |
1750 | 1750 | { | |
1751 | char *b = NULL; | 1751 | char *b = NULL; |
1752 | char *fmt, *s, *s1, *f; | 1752 | char *fmt, *s, *s1, *f; |
1753 | int i, j, incr, bsize; | 1753 | int i, j, incr, bsize; |
@@ -1804,8 +1804,8 @@ static char *awk_printf(node *n) { | |||
1804 | * all matches. If src or dst is NULL, use $0. If ex=TRUE, enable | 1804 | * all matches. If src or dst is NULL, use $0. If ex=TRUE, enable |
1805 | * subexpression matching (\1-\9) | 1805 | * subexpression matching (\1-\9) |
1806 | */ | 1806 | */ |
1807 | static int awk_sub(node *rn, char *repl, int nm, var *src, var *dest, int ex) { | 1807 | static int awk_sub(node *rn, char *repl, int nm, var *src, var *dest, int ex) |
1808 | 1808 | { | |
1809 | char *ds = NULL; | 1809 | char *ds = NULL; |
1810 | char *sp, *s; | 1810 | char *sp, *s; |
1811 | int c, i, j, di, rl, so, eo, nbs, n, dssize; | 1811 | int c, i, j, di, rl, so, eo, nbs, n, dssize; |
@@ -1870,8 +1870,8 @@ static int awk_sub(node *rn, char *repl, int nm, var *src, var *dest, int ex) { | |||
1870 | return i; | 1870 | return i; |
1871 | } | 1871 | } |
1872 | 1872 | ||
1873 | static var *exec_builtin(node *op, var *res) { | 1873 | static var *exec_builtin(node *op, var *res) |
1874 | 1874 | { | |
1875 | int (*to_xxx)(int); | 1875 | int (*to_xxx)(int); |
1876 | var *tv; | 1876 | var *tv; |
1877 | node *an[4]; | 1877 | node *an[4]; |
@@ -2030,8 +2030,8 @@ lo_cont: | |||
2030 | */ | 2030 | */ |
2031 | #define XC(n) ((n) >> 8) | 2031 | #define XC(n) ((n) >> 8) |
2032 | 2032 | ||
2033 | static var *evaluate(node *op, var *res) { | 2033 | static var *evaluate(node *op, var *res) |
2034 | 2034 | { | |
2035 | /* This procedure is recursive so we should count every byte */ | 2035 | /* This procedure is recursive so we should count every byte */ |
2036 | static var *fnargs = NULL; | 2036 | static var *fnargs = NULL; |
2037 | static unsigned int seed = 1; | 2037 | static unsigned int seed = 1; |
@@ -2541,8 +2541,8 @@ re_cont: | |||
2541 | 2541 | ||
2542 | /* -------- main & co. -------- */ | 2542 | /* -------- main & co. -------- */ |
2543 | 2543 | ||
2544 | static int awk_exit(int r) { | 2544 | static int awk_exit(int r) |
2545 | 2545 | { | |
2546 | unsigned int i; | 2546 | unsigned int i; |
2547 | hash_item *hi; | 2547 | hash_item *hi; |
2548 | static var tv; | 2548 | static var tv; |
@@ -2568,8 +2568,8 @@ static int awk_exit(int r) { | |||
2568 | 2568 | ||
2569 | /* if expr looks like "var=value", perform assignment and return 1, | 2569 | /* if expr looks like "var=value", perform assignment and return 1, |
2570 | * otherwise return 0 */ | 2570 | * otherwise return 0 */ |
2571 | static int is_assignment(char *expr) { | 2571 | static int is_assignment(char *expr) |
2572 | 2572 | { | |
2573 | char *exprc, *s, *s0, *s1; | 2573 | char *exprc, *s, *s0, *s1; |
2574 | 2574 | ||
2575 | exprc = bb_xstrdup(expr); | 2575 | exprc = bb_xstrdup(expr); |
@@ -2590,8 +2590,8 @@ static int is_assignment(char *expr) { | |||
2590 | } | 2590 | } |
2591 | 2591 | ||
2592 | /* switch to next input file */ | 2592 | /* switch to next input file */ |
2593 | static rstream *next_input_file(void) { | 2593 | static rstream *next_input_file(void) |
2594 | 2594 | { | |
2595 | static rstream rsm; | 2595 | static rstream rsm; |
2596 | FILE *F = NULL; | 2596 | FILE *F = NULL; |
2597 | char *fname, *ind; | 2597 | char *fname, *ind; |
@@ -2621,8 +2621,8 @@ static rstream *next_input_file(void) { | |||
2621 | return &rsm; | 2621 | return &rsm; |
2622 | } | 2622 | } |
2623 | 2623 | ||
2624 | extern int awk_main(int argc, char **argv) { | 2624 | extern int awk_main(int argc, char **argv) |
2625 | 2625 | { | |
2626 | char *s, *s1; | 2626 | char *s, *s1; |
2627 | int i, j, c; | 2627 | int i, j, c; |
2628 | var *v; | 2628 | var *v; |