diff options
author | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-10-19 09:21:51 +0000 |
---|---|---|
committer | "Vladimir N. Oleynik" <dzo@simtreas.ru> | 2005-10-19 09:21:51 +0000 |
commit | 5cf9a03b3f7b9feb08f4aa4fc36f036b2f00614d (patch) | |
tree | 59c172d4dfecd04e30f11e741c78afc0f8666c56 /editors/awk.c | |
parent | bb20462cb34245037ecf92a0e7fc42b54b9e2d7b (diff) | |
download | busybox-w32-5cf9a03b3f7b9feb08f4aa4fc36f036b2f00614d.tar.gz busybox-w32-5cf9a03b3f7b9feb08f4aa4fc36f036b2f00614d.tar.bz2 busybox-w32-5cf9a03b3f7b9feb08f4aa4fc36f036b2f00614d.zip |
more const, attribute_noreturn saved 200 bytes
Diffstat (limited to 'editors/awk.c')
-rw-r--r-- | editors/awk.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/editors/awk.c b/editors/awk.c index d00fcafb1..cb54d2597 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -324,7 +324,7 @@ static char * const tokenlist = | |||
324 | "\3END" "\0" | 324 | "\3END" "\0" |
325 | ; | 325 | ; |
326 | 326 | ||
327 | static uint32_t tokeninfo[] = { | 327 | static const uint32_t tokeninfo[] = { |
328 | 328 | ||
329 | 0, | 329 | 0, |
330 | 0, | 330 | 0, |
@@ -420,14 +420,14 @@ static xhash *vhash, *ahash, *fdhash, *fnhash; | |||
420 | static char *programname; | 420 | static char *programname; |
421 | static short lineno; | 421 | static short lineno; |
422 | static int is_f0_split; | 422 | static int is_f0_split; |
423 | static int nfields = 0; | 423 | static int nfields; |
424 | static var *Fields = NULL; | 424 | static var *Fields; |
425 | static tsplitter fsplitter, rsplitter; | 425 | static tsplitter fsplitter, rsplitter; |
426 | static nvblock *cb = NULL; | 426 | static nvblock *cb; |
427 | static char *pos; | 427 | static char *pos; |
428 | static char *buf; | 428 | static char *buf; |
429 | static int icase = FALSE; | 429 | static int icase; |
430 | static int exiting = FALSE; | 430 | static int exiting; |
431 | 431 | ||
432 | static struct { | 432 | static struct { |
433 | uint32_t tclass; | 433 | uint32_t tclass; |
@@ -444,8 +444,8 @@ static node *parse_expr(uint32_t); | |||
444 | static void chain_group(void); | 444 | static void chain_group(void); |
445 | static var *evaluate(node *, var *); | 445 | static var *evaluate(node *, var *); |
446 | static rstream *next_input_file(void); | 446 | static rstream *next_input_file(void); |
447 | static int fmt_num(char *, int, char *, double, int); | 447 | static int fmt_num(char *, int, const char *, double, int); |
448 | static int awk_exit(int); | 448 | static int awk_exit(int) attribute_noreturn; |
449 | 449 | ||
450 | /* ---- error handling ---- */ | 450 | /* ---- error handling ---- */ |
451 | 451 | ||
@@ -462,10 +462,10 @@ static const char EMSG_UNDEF_FUNC[] = "Call to undefined function"; | |||
462 | static const char EMSG_NO_MATH[] = "Math support is not compiled in"; | 462 | static const char EMSG_NO_MATH[] = "Math support is not compiled in"; |
463 | #endif | 463 | #endif |
464 | 464 | ||
465 | static void syntax_error(const char * const message) attribute_noreturn; | ||
465 | static void syntax_error(const char * const message) | 466 | static void syntax_error(const char * const message) |
466 | { | 467 | { |
467 | bb_error_msg("%s:%i: %s", programname, lineno, message); | 468 | bb_error_msg_and_die("%s:%i: %s", programname, lineno, message); |
468 | exit(1); | ||
469 | } | 469 | } |
470 | 470 | ||
471 | #define runtime_error(x) syntax_error(x) | 471 | #define runtime_error(x) syntax_error(x) |
@@ -473,7 +473,7 @@ 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(const char *name) |
477 | { | 477 | { |
478 | register unsigned int idx=0; | 478 | register unsigned int idx=0; |
479 | 479 | ||
@@ -494,7 +494,7 @@ 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, const char *name) |
498 | { | 498 | { |
499 | hash_item *hi; | 499 | hash_item *hi; |
500 | 500 | ||
@@ -536,7 +536,7 @@ 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, const char *name) |
540 | { | 540 | { |
541 | hash_item *hi; | 541 | hash_item *hi; |
542 | unsigned int idx; | 542 | unsigned int idx; |
@@ -564,7 +564,7 @@ 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, const char *name) |
568 | { | 568 | { |
569 | hash_item *hi, **phi; | 569 | hash_item *hi, **phi; |
570 | 570 | ||
@@ -589,7 +589,7 @@ static void skip_spaces(char **s) | |||
589 | register char *p = *s; | 589 | register char *p = *s; |
590 | 590 | ||
591 | while(*p == ' ' || *p == '\t' || | 591 | while(*p == ' ' || *p == '\t' || |
592 | (*p == '\\' && *(p+1) == '\n' && (++p, ++t.lineno))) { | 592 | (*p == '\\' && *(p+1) == '\n' && (++p, ++t.lineno))) { |
593 | p++; | 593 | p++; |
594 | } | 594 | } |
595 | *s = p; | 595 | *s = p; |
@@ -682,13 +682,13 @@ 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, const 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, const char *value) |
692 | { | 692 | { |
693 | setvar_s(v, value); | 693 | setvar_s(v, value); |
694 | v->type |= VF_USER; | 694 | v->type |= VF_USER; |
@@ -696,7 +696,7 @@ static var *setvar_u(var *v, char *value) | |||
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, const char *s) |
700 | { | 700 | { |
701 | register var *v; | 701 | register var *v; |
702 | static char sidx[12]; | 702 | static char sidx[12]; |
@@ -749,7 +749,7 @@ 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, const var *src) |
753 | { | 753 | { |
754 | if (dest != src) { | 754 | if (dest != src) { |
755 | clrvar(dest); | 755 | clrvar(dest); |
@@ -852,9 +852,10 @@ static uint32_t next_token(uint32_t expected) | |||
852 | { | 852 | { |
853 | char *p, *pp, *s; | 853 | char *p, *pp, *s; |
854 | char *tl; | 854 | char *tl; |
855 | uint32_t tc, *ti; | 855 | uint32_t tc; |
856 | const uint32_t *ti; | ||
856 | int l; | 857 | int l; |
857 | static int concat_inserted = FALSE; | 858 | static int concat_inserted; |
858 | static uint32_t save_tclass, save_info; | 859 | static uint32_t save_tclass, save_info; |
859 | static uint32_t ltclass = TC_OPTERM; | 860 | static uint32_t ltclass = TC_OPTERM; |
860 | 861 | ||
@@ -1725,10 +1726,11 @@ static int awk_getline(rstream *rsm, var *v) | |||
1725 | return r; | 1726 | return r; |
1726 | } | 1727 | } |
1727 | 1728 | ||
1728 | static int fmt_num(char *b, int size, char *format, double n, int int_as_int) | 1729 | static int fmt_num(char *b, int size, const char *format, double n, int int_as_int) |
1729 | { | 1730 | { |
1730 | int r=0; | 1731 | int r=0; |
1731 | char c, *s=format; | 1732 | char c; |
1733 | const char *s=format; | ||
1732 | 1734 | ||
1733 | if (int_as_int && n == (int)n) { | 1735 | if (int_as_int && n == (int)n) { |
1734 | r = snprintf(b, size, "%d", (int)n); | 1736 | r = snprintf(b, size, "%d", (int)n); |
@@ -2569,7 +2571,7 @@ static int awk_exit(int r) | |||
2569 | 2571 | ||
2570 | /* if expr looks like "var=value", perform assignment and return 1, | 2572 | /* if expr looks like "var=value", perform assignment and return 1, |
2571 | * otherwise return 0 */ | 2573 | * otherwise return 0 */ |
2572 | static int is_assignment(char *expr) | 2574 | static int is_assignment(const char *expr) |
2573 | { | 2575 | { |
2574 | char *exprc, *s, *s0, *s1; | 2576 | char *exprc, *s, *s0, *s1; |
2575 | 2577 | ||