From ead30e83239251cba3bf2fd08387ab9e4963dbe7 Mon Sep 17 00:00:00 2001 From: sheldonh Date: Tue, 15 Aug 2000 10:20:01 +0000 Subject: Merge the vendor release of gawk-3.0.6 onto HEAD. This addresses one known problem in the PR database. PR: 13921 Reported by: Jin Guojun --- contrib/awk/awk.h | 12 ++++- contrib/awk/builtin.c | 5 +- contrib/awk/eval.c | 147 ++++++++++++++++++++++++++++++++------------------ contrib/awk/field.c | 33 +++++++++++- contrib/awk/io.c | 37 ++++++++++--- contrib/awk/main.c | 30 +++++++---- contrib/awk/node.c | 18 ++++++- 7 files changed, 206 insertions(+), 76 deletions(-) (limited to 'contrib/awk') diff --git a/contrib/awk/awk.h b/contrib/awk/awk.h index 621a981..8b3bb1e 100644 --- a/contrib/awk/awk.h +++ b/contrib/awk/awk.h @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-1999 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2000 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -299,6 +299,7 @@ typedef enum nodevals { Node_K_do, /* lnode is conditional, rnode stuff to run */ Node_K_return, /* lnode is return value */ Node_K_delete, /* lnode is array, rnode is subscript */ + Node_K_delete_loop, /* lnode is array, rnode is subscript */ Node_K_getline, /* lnode is opt var, rnode is redirection */ Node_K_function, /* lnode is statement list, rnode is params */ Node_K_nextfile, /* no subs */ @@ -338,6 +339,7 @@ typedef enum nodevals { Node_regex, /* a regexp, text, compiled, flags, etc */ Node_hashnode, /* an identifier in the symbol table */ Node_ahash, /* an array element */ + Node_array_ref, /* array passed by ref as parameter */ Node_NF, /* variables recognized in the grammar */ Node_NR, Node_FNR, @@ -463,6 +465,8 @@ typedef struct exp_node { #define array_size sub.nodep.l.ll #define table_size sub.nodep.x.xl +#define orig_array sub.nodep.x.extra + #define condpair lnode #define triggered sub.nodep.r.r_ent @@ -721,16 +725,19 @@ extern unsigned int hash P((const char *s, size_t len, unsigned long hsize)); extern int in_array P((NODE *symbol, NODE *subs)); extern NODE **assoc_lookup P((NODE *symbol, NODE *subs)); extern void do_delete P((NODE *symbol, NODE *tree)); +extern void do_delete_loop P((NODE *symbol, NODE *tree)); extern void assoc_scan P((NODE *symbol, struct search *lookat)); extern void assoc_next P((struct search *lookat)); +extern NODE *assoc_dump P((NODE *symbol)); +extern NODE *do_adump P((NODE *tree)); /* awktab.c */ extern char *tokexpand P((void)); -extern char nextc P((void)); extern NODE *node P((NODE *left, NODETYPE op, NODE *right)); extern NODE *install P((char *name, NODE *value)); extern NODE *lookup P((const char *name)); extern NODE *variable P((char *name, int can_free, NODETYPE type)); extern int yyparse P((void)); +extern NODE *stopme P((NODE *tree)); /* builtin.c */ extern double double_to_int P((double d)); extern NODE *do_exp P((NODE *tree)); @@ -781,6 +788,7 @@ void set_OFS P((void)); void set_ORS P((void)); void set_OFMT P((void)); void set_CONVFMT P((void)); +extern char *flags2str P((int)); /* field.c */ extern void init_fields P((void)); extern void set_record P((char *buf, int cnt, int freeold)); diff --git a/contrib/awk/builtin.c b/contrib/awk/builtin.c index 3de6f2e..89babb3 100644 --- a/contrib/awk/builtin.c +++ b/contrib/awk/builtin.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-1999 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2000 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -815,7 +815,8 @@ check_pos: *cp++ = '#'; if (zero_flag) *cp++ = '0'; - cp = strcpy(cp, "*.*") + 3; + strcpy(cp, "*.*"); + cp += 3; *cp++ = cs1; *cp = '\0'; #ifndef GFMT_WORKAROUND diff --git a/contrib/awk/eval.c b/contrib/awk/eval.c index 37c5fef..3d5e568 100644 --- a/contrib/awk/eval.c +++ b/contrib/awk/eval.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-1999 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2000 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -68,6 +68,11 @@ static int func_tag_valid = FALSE; static jmp_buf func_tag; extern int exiting, exit_val; +/* This rather ugly macro is for VMS C */ +#ifdef C +#undef C +#endif +#define C(c) ((char)c) /* * This table is used by the regexp routines to do case independant * matching. Basically, every ascii character maps to itself, except @@ -110,45 +115,47 @@ char casetable[] = { /* 'x' 'y' 'z' '{' '|' '}' '~' */ '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', #ifndef USE_PURE_ASCII - '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', - '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', - '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', - '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', - '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', - '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', - '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', - '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', - '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', - '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', - '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\327', - '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\337', - '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', - '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', - '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', - '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', + C('\200'), C('\201'), C('\202'), C('\203'), C('\204'), C('\205'), C('\206'), C('\207'), + C('\210'), C('\211'), C('\212'), C('\213'), C('\214'), C('\215'), C('\216'), C('\217'), + C('\220'), C('\221'), C('\222'), C('\223'), C('\224'), C('\225'), C('\226'), C('\227'), + C('\230'), C('\231'), C('\232'), C('\233'), C('\234'), C('\235'), C('\236'), C('\237'), + C('\240'), C('\241'), C('\242'), C('\243'), C('\244'), C('\245'), C('\246'), C('\247'), + C('\250'), C('\251'), C('\252'), C('\253'), C('\254'), C('\255'), C('\256'), C('\257'), + C('\260'), C('\261'), C('\262'), C('\263'), C('\264'), C('\265'), C('\266'), C('\267'), + C('\270'), C('\271'), C('\272'), C('\273'), C('\274'), C('\275'), C('\276'), C('\277'), + C('\340'), C('\341'), C('\342'), C('\343'), C('\344'), C('\345'), C('\346'), C('\347'), + C('\350'), C('\351'), C('\352'), C('\353'), C('\354'), C('\355'), C('\356'), C('\357'), + C('\360'), C('\361'), C('\362'), C('\363'), C('\364'), C('\365'), C('\366'), C('\327'), + C('\370'), C('\371'), C('\372'), C('\373'), C('\374'), C('\375'), C('\376'), C('\337'), + C('\340'), C('\341'), C('\342'), C('\343'), C('\344'), C('\345'), C('\346'), C('\347'), + C('\350'), C('\351'), C('\352'), C('\353'), C('\354'), C('\355'), C('\356'), C('\357'), + C('\360'), C('\361'), C('\362'), C('\363'), C('\364'), C('\365'), C('\366'), C('\367'), + C('\370'), C('\371'), C('\372'), C('\373'), C('\374'), C('\375'), C('\376'), C('\377'), #else - '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', - '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', - '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', - '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', - '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', - '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', - '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', - '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', - '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', - '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', - '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', - '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', - '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', - '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', - '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', - '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', + C('\200'), C('\201'), C('\202'), C('\203'), C('\204'), C('\205'), C('\206'), C('\207'), + C('\210'), C('\211'), C('\212'), C('\213'), C('\214'), C('\215'), C('\216'), C('\217'), + C('\220'), C('\221'), C('\222'), C('\223'), C('\224'), C('\225'), C('\226'), C('\227'), + C('\230'), C('\231'), C('\232'), C('\233'), C('\234'), C('\235'), C('\236'), C('\237'), + C('\240'), C('\241'), C('\242'), C('\243'), C('\244'), C('\245'), C('\246'), C('\247'), + C('\250'), C('\251'), C('\252'), C('\253'), C('\254'), C('\255'), C('\256'), C('\257'), + C('\260'), C('\261'), C('\262'), C('\263'), C('\264'), C('\265'), C('\266'), C('\267'), + C('\270'), C('\271'), C('\272'), C('\273'), C('\274'), C('\275'), C('\276'), C('\277'), + C('\300'), C('\301'), C('\302'), C('\303'), C('\304'), C('\305'), C('\306'), C('\307'), + C('\310'), C('\311'), C('\312'), C('\313'), C('\314'), C('\315'), C('\316'), C('\317'), + C('\320'), C('\321'), C('\322'), C('\323'), C('\324'), C('\325'), C('\326'), C('\327'), + C('\330'), C('\331'), C('\332'), C('\333'), C('\334'), C('\335'), C('\336'), C('\337'), + C('\340'), C('\341'), C('\342'), C('\343'), C('\344'), C('\345'), C('\346'), C('\347'), + C('\350'), C('\351'), C('\352'), C('\353'), C('\354'), C('\355'), C('\356'), C('\357'), + C('\360'), C('\361'), C('\362'), C('\363'), C('\364'), C('\365'), C('\366'), C('\367'), + C('\370'), C('\371'), C('\372'), C('\373'), C('\374'), C('\375'), C('\376'), C('\377'), #endif }; #else #include "You lose. You will need a translation table for your character set." #endif +#undef C + /* * This table maps node types to strings for debugging. * KEEP IN SYNC WITH awk.h!!!! @@ -207,6 +214,7 @@ static char *nodetypes[] = { "Node_K_do", "Node_K_return", "Node_K_delete", + "Node_K_delete_loop", "Node_K_getline", "Node_K_function", "Node_K_nextfile", @@ -227,6 +235,7 @@ static char *nodetypes[] = { "Node_regex", "Node_hashnode", "Node_ahash", + "Node_array_ref", "Node_NF", "Node_NR", "Node_FNR", @@ -482,6 +491,8 @@ register NODE *volatile tree; t = tree->arrvar; if (t->type == Node_param_list) t = stack_ptr[t->param_cnt]; + if (t->type == Node_array_ref) + t = t->orig_array; stable_tree = tree; if ((t->flags & SCALAR) != 0) fatal("attempt to use scalar as array"); @@ -565,6 +576,10 @@ register NODE *volatile tree; do_delete(tree->lnode, tree->rnode); break; + case Node_K_delete_loop: + do_delete_loop(tree->lnode, tree->rnode); + break; + case Node_K_next: if (in_begin_rule) fatal("`next' cannot be called from a BEGIN rule"); @@ -661,12 +676,18 @@ int iscond; if (tree->type == Node_param_list) { int paramnum = tree->param_cnt + 1; + if ((tree->flags & FUNC) != 0) + fatal("can't use function name `%s' as variable or array", + tree->vname); + tree = stack_ptr[tree->param_cnt]; if (tree == NULL) return Nnull_string; sprintf(namebuf, "parameter #%d", paramnum); tree->vname = namebuf; - } + } + if (tree->type == Node_array_ref) + tree = tree->orig_array; switch (tree->type) { case Node_var: @@ -986,11 +1007,12 @@ register NODE *tree; * able to begin and end on a single input record, so this * isn't an ELSE IF, as noted above. */ - if (! tree->triggered) + if (! tree->triggered) { if (! eval_condition(tree->condpair->lnode)) return FALSE; else tree->triggered = TRUE; + } /* Else we are triggered */ if (eval_condition(tree->condpair->rnode)) tree->triggered = FALSE; @@ -1071,16 +1093,17 @@ register NODE *tree; NODE *tmp; Func_ptr after_assign = NULL; - lhs = get_lhs(tree->lnode, &after_assign); - lval = force_number(*lhs); - /* - * Can't unref *lhs until we know the type; doing so - * too early breaks x += x sorts of things. + * For ++ and --, get the lhs when doing the op and then + * return. For += etc, do the rhs first, since it can + * rearrange things, and *then* get the lhs. */ + switch(tree->type) { case Node_preincrement: case Node_predecrement: + lhs = get_lhs(tree->lnode, &after_assign); + lval = force_number(*lhs); unref(*lhs); *lhs = make_number(lval + (tree->type == Node_preincrement ? 1.0 : -1.0)); @@ -1091,6 +1114,8 @@ register NODE *tree; case Node_postincrement: case Node_postdecrement: + lhs = get_lhs(tree->lnode, &after_assign); + lval = force_number(*lhs); unref(*lhs); *lhs = make_number(lval + (tree->type == Node_postincrement ? 1.0 : -1.0)); @@ -1102,16 +1127,16 @@ register NODE *tree; break; /* handled below */ } + /* + * It's a += kind of thing. Do the rhs, then the lhs. + */ + tmp = tree_eval(tree->rnode); rval = force_number(tmp); free_temp(tmp); - /* - * Do this again; the lhs and the rhs could both be fields. - * Accessing the rhs could cause the lhs to have moved around. - * (Yet another special case. Gack.) - */ lhs = get_lhs(tree->lnode, &after_assign); + lval = force_number(*lhs); unref(*lhs); switch(tree->type) { @@ -1227,7 +1252,7 @@ pop_fcall() if (arg->type == Node_param_list) arg = stack_ptr[arg->param_cnt]; n = *sp++; - if ((arg->type == Node_var || arg->type == Node_var_array) + if ((arg->type == Node_var /* || arg->type == Node_var_array */) && n->type == Node_var_array) { /* should we free arg->var_value ? */ arg->var_array = n->var_array; @@ -1237,7 +1262,7 @@ pop_fcall() arg->flags = n->flags; } /* n->lnode overlays the array size, don't unref it if array */ - if (n->type != Node_var_array) + if (n->type != Node_var_array && n->type != Node_array_ref) unref(n->lnode); freenode(n); count--; @@ -1247,7 +1272,9 @@ pop_fcall() /* if n is a local array, all the elements should be freed */ if (n->type == Node_var_array) assoc_clear(n); - unref(n->lnode); + /* n->lnode overlays the array size, don't unref it if array */ + if (n->type != Node_var_array && n->type != Node_array_ref) + unref(n->lnode); freenode(n); } if (f->stack) @@ -1307,11 +1334,19 @@ char *func_name; r->type = Node_var; /* call by reference for arrays; see below also */ - if (arg->type == Node_param_list) + if (arg->type == Node_param_list) { + /* we must also reassign f here; see below */ + f = & fcall_list[curfcall]; arg = f->prevstack[arg->param_cnt]; - if (arg->type == Node_var_array) + } + if (arg->type == Node_var_array) { + r->type = Node_array_ref; + r->flags &= ~SCALAR; + r->orig_array = arg; + r->vname = arg->vname; + } else if (arg->type == Node_array_ref) { *r = *arg; - else { + } else { n = tree_eval(arg); r->lnode = dupnode(n); r->rnode = (NODE *) NULL; @@ -1445,6 +1480,7 @@ Func_ptr *assign; } switch (ptr->type) { + case Node_array_ref: case Node_var_array: fatal("attempt to use array `%s' in a scalar context", ptr->vname); @@ -1567,7 +1603,12 @@ Func_ptr *assign; n = stack_ptr[n->param_cnt]; if ((n->flags & SCALAR) != 0) fatal("attempt to use scalar parameter %d as an array", i); - } else if (n->type == Node_func) { + } + if (n->type == Node_array_ref) { + n = n->orig_array; + assert(n->type == Node_var_array || n->type == Node_var); + } + if (n->type == Node_func) { fatal("attempt to use function `%s' as array", n->lnode->param); } @@ -1581,6 +1622,8 @@ Func_ptr *assign; case Node_builtin: fatal("assignment is not allowed to result of builtin function"); default: + fprintf(stderr, "type = %s\n", nodetype2str(ptr->type)); + fflush(stderr); cant_happen(); } return aptr; diff --git a/contrib/awk/field.c b/contrib/awk/field.c index 72cbd78..bd038a0 100644 --- a/contrib/awk/field.c +++ b/contrib/awk/field.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-1999 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2000 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -221,6 +221,11 @@ rebuild_record() * set_record: * setup $0, but defer parsing rest of line until reference is made to $(>0) * or to NF. At that point, parse only as much as necessary. + * + * Manage a private buffer for the contents of $0. Doing so keeps us safe + * if `getline var' decides to rearrange the contents of the IOBUF that + * $0 might have been pointing into. The cost is the copying of the buffer; + * but better correct than fast. */ void set_record(buf, cnt, freeold) @@ -230,6 +235,10 @@ int freeold; { register int i; NODE *n; + static char *databuf; + static unsigned long databuf_size; +#define INITIAL_SIZE 512 +#define MAX_SIZE ((unsigned long) ~0) /* maximally portable ... */ NF = -1; for (i = 1; i <= parse_high_water; i++) { @@ -250,9 +259,24 @@ int freeold; save_FS = dupnode(FS_node->var_value); } if (freeold) { + /* buffer management: */ + if (databuf_size == 0) { /* first time */ + emalloc(databuf, char *, INITIAL_SIZE, "set_record"); + databuf_size = INITIAL_SIZE; + } + /* make sure there's enough room */ + if (cnt > databuf_size) { + while (cnt > databuf_size && databuf_size <= MAX_SIZE) + databuf_size *= 2; + erealloc(databuf, char *, databuf_size, "set_record"); + } + /* copy the data */ + memcpy(databuf, buf, cnt); + + /* manage field 0: */ unref(fields_arr[0]); getnode(n); - n->stptr = buf; + n->stptr = databuf; n->stlen = cnt; n->stref = 1; n->type = Node_val; @@ -262,6 +286,9 @@ int freeold; } fields_arr[0]->flags |= MAYBE_NUM; field0_valid = TRUE; + +#undef INITIAL_SIZE +#undef MAX_SIZE } /* reset_record --- start over again with current $0 */ @@ -761,6 +788,8 @@ NODE *tree; if (arr->type == Node_param_list) arr = stack_ptr[arr->param_cnt]; + if (arr->type == Node_array_ref) + arr = arr->orig_array; if (arr->type != Node_var && arr->type != Node_var_array) fatal("second argument of split is not an array"); arr->type = Node_var_array; diff --git a/contrib/awk/io.c b/contrib/awk/io.c index 0a24f8a..a83fc9d 100644 --- a/contrib/awk/io.c +++ b/contrib/awk/io.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1976, 1988, 1989, 1991-1999 the Free Software Foundation, Inc. + * Copyright (C) 1976, 1988, 1989, 1991-2000 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -479,6 +479,15 @@ int *errflg; } if (rp->fp != NULL && isatty(fd)) rp->flag |= RED_NOBUF; + /* Move rp to the head of the list. */ + if (red_head != rp) { + if ((rp->prev->next = rp->next) != NULL) + rp->next->prev = rp->prev; + red_head->prev = rp; + rp->prev = NULL; + rp->next = red_head; + red_head = rp; + } } } if (rp->fp == NULL && rp->iop == NULL) { @@ -491,6 +500,13 @@ int *errflg; else if (errno == 0) /* HACK! */ close_one(); #endif +#ifdef VMS + /* Alpha/VMS V7.1's C RTL is returning this instead + of EMFILE (haven't tried other post-V6.2 systems) */ +#define SS$_EXQUOTA 0x001C + else if (errno == EIO && vaxc$errno == SS$_EXQUOTA) + close_one(); +#endif else { /* * Some other reason for failure. @@ -628,10 +644,6 @@ int exitwarn; what = ((rp->flag & RED_PIPE) != 0) ? "pipe" : "file"; - if (exitwarn) - warning("no explicit close of %s `%s' provided", - what, rp->value); - /* SVR4 awk checks and warns about status of close */ if (status != 0) { char *s = strerror(errno); @@ -650,6 +662,11 @@ int exitwarn; ERRNO_node->var_value = make_string(s, strlen(s)); } } + + if (exitwarn) + warning("no explicit close of %s `%s' provided", + what, rp->value); + if (rp->next != NULL) rp->next->prev = rp->prev; if (rp->prev != NULL) @@ -1953,8 +1970,16 @@ set_RS() } if (RS->stlen == 0) RS_is_null = TRUE; - else if (RS->stlen > 1) + else if (RS->stlen > 1) { + static int warned = FALSE; + RS_regexp = make_regexp(RS->stptr, RS->stlen, IGNORECASE, TRUE); + if (do_lint && ! warned) { + warning("multicharacter value of `RS' is not portable"); + warned = TRUE; + } + } + set_FS_if_not_FIELDWIDTHS(); } diff --git a/contrib/awk/main.c b/contrib/awk/main.c index 27452f0..bbd7d71 100644 --- a/contrib/awk/main.c +++ b/contrib/awk/main.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-1999 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2000 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -177,10 +177,17 @@ char **argv; /* Set up the special variables */ /* * Note that this must be done BEFORE arg parsing else -F - * breaks horribly + * breaks horribly. */ init_vars(); + /* Set up the field variables */ + /* + * Do this before arg parsing so that `-v NF=blah' won't + * break anything. + */ + init_fields(); + /* worst case */ emalloc(srcfiles, struct src *, argc * sizeof(struct src), "main"); memset(srcfiles, '\0', argc * sizeof(struct src)); @@ -379,9 +386,6 @@ out: (void) alloca(0); #endif - /* Set up the field variables */ - init_fields(); - if (do_lint && begin_block == NULL && expression_value == NULL && end_block == NULL) warning("no program"); @@ -441,8 +445,9 @@ FILE *fp; fputs("\t-W traditional\t\t--traditional\n", fp); fputs("\t-W usage\t\t--usage\n", fp); fputs("\t-W version\t\t--version\n", fp); - fputs("\nReport bugs to bug-gnu-utils@gnu.org,\n", fp); - fputs("with a Cc: to arnold@gnu.org\n", fp); + fputs("\nTo report bugs, see node `Bugs' in `gawk.info', which\n", fp); + fputs("is section `Reporting Problems and Bugs' in the\n", fp); + fputs("printed version.\n", fp); exit(exitval); } @@ -452,7 +457,7 @@ static void copyleft() { static char blurb_part1[] = -"Copyright (C) 1989, 1991-1999 Free Software Foundation.\n\ +"Copyright (C) 1989, 1991-2000 Free Software Foundation.\n\ \n\ This program is free software; you can redistribute it and/or modify\n\ it under the terms of the GNU General Public License as published by\n\ @@ -654,8 +659,13 @@ char *arg; badvar = TRUE; break; } - if (badvar) - fatal("illegal name `%s' in variable assignment", arg); + + if (badvar) { + if (do_lint) + warning("illegal name `%s' in variable assignment", arg); + *--cp = '='; /* restore original text of ARGV */ + return NULL; + } /* * Recent versions of nawk expand escapes inside assignments. diff --git a/contrib/awk/node.c b/contrib/awk/node.c index a8892a3..0f77468 100644 --- a/contrib/awk/node.c +++ b/contrib/awk/node.c @@ -3,7 +3,7 @@ */ /* - * Copyright (C) 1986, 1988, 1989, 1991-1999 the Free Software Foundation, Inc. + * Copyright (C) 1986, 1988, 1989, 1991-2000 the Free Software Foundation, Inc. * * This file is part of GAWK, the GNU implementation of the * AWK Programming Language. @@ -205,8 +205,10 @@ register NODE *s; cant_happen(); if (s->type != Node_val) cant_happen(); +/* if ((s->flags & NUM) == 0) cant_happen(); +*/ if (s->stref <= 0) cant_happen(); if ((s->flags & STR) != 0 @@ -241,7 +243,7 @@ NODE *n; } getnode(r); *r = *n; - r->flags &= ~(PERM|TEMP); + r->flags &= ~(PERM|TEMP|FIELD); r->flags |= MALLOC; if (n->type == Node_val && (n->flags & STR) != 0) { r->stref = 1; @@ -513,6 +515,18 @@ char **string_ptr; } return i; default: + if (do_lint) { + static short warned[256]; + unsigned char uc = (unsigned char) c; + + /* N.B.: use unsigned char here to avoid Latin-1 problems */ + + if (! warned[uc]) { + warned[uc] = TRUE; + + warning("escape sequence `\\%c' treated as plain `%c'", uc, uc); + } + } return c; } } -- cgit v1.1