"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "awkgram.y" between
gawk-5.0.1.tar.xz and gawk-5.1.0.tar.xz

About: GNU awk - pattern scanning and processing language.

awkgram.y  (gawk-5.0.1.tar.xz):awkgram.y  (gawk-5.1.0.tar.xz)
/* /*
* awkgram.y --- yacc/bison parser * awkgram.y --- yacc/bison parser
*/ */
/* /*
* Copyright (C) 1986, 1988, 1989, 1991-2019 the Free Software Foundation, Inc. * Copyright (C) 1986, 1988, 1989, 1991-2020 the Free Software Foundation, Inc.
* *
* This file is part of GAWK, the GNU implementation of the * This file is part of GAWK, the GNU implementation of the
* AWK Programming Language. * AWK Programming Language.
* *
* GAWK is free software; you can redistribute it and/or modify * GAWK is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or * the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* GAWK is distributed in the hope that it will be useful, * GAWK is distributed in the hope that it will be useful,
skipping to change at line 418 skipping to change at line 418
$$ = list_append(list_merge(list_prepend($1, $2), $3), tp ); $$ = list_append(list_merge(list_prepend($1, $2), $3), tp );
else else
$$ = list_append(list_merge($1, $3), tp); $$ = list_append(list_merge($1, $3), tp);
rule = Rule; rule = Rule;
} }
| LEX_BEGIN | LEX_BEGIN
{ {
static int begin_seen = 0; static int begin_seen = 0;
if (do_lint_old && ++begin_seen == 2) if (do_lint_old && ++begin_seen == 2)
warning_ln($1->source_line, lintwarn_ln($1->source_line,
_("old awk does not support multiple `BEGIN' or ` END' rules")); _("old awk does not support multiple `BEGIN' or ` END' rules"));
$1->in_rule = rule = BEGIN; $1->in_rule = rule = BEGIN;
$1->source_file = source; $1->source_file = source;
$$ = $1; $$ = $1;
} }
| LEX_END | LEX_END
{ {
static int end_seen = 0; static int end_seen = 0;
if (do_lint_old && ++end_seen == 2) if (do_lint_old && ++end_seen == 2)
warning_ln($1->source_line, lintwarn_ln($1->source_line,
_("old awk does not support multiple `BEGIN' or ` END' rules")); _("old awk does not support multiple `BEGIN' or ` END' rules"));
$1->in_rule = rule = END; $1->in_rule = rule = END;
$1->source_file = source; $1->source_file = source;
$$ = $1; $$ = $1;
} }
| LEX_BEGINFILE | LEX_BEGINFILE
{ {
$1->in_rule = rule = BEGINFILE; $1->in_rule = rule = BEGINFILE;
$1->source_file = source; $1->source_file = source;
skipping to change at line 995 skipping to change at line 995
if ($8 != NULL) { if ($8 != NULL) {
merge_comments($8, NULL); merge_comments($8, NULL);
if ($1->comment == NULL) { if ($1->comment == NULL) {
$8->memory->comment_type = FOR_COMMENT; $8->memory->comment_type = FOR_COMMENT;
$1->comment = $8; $1->comment = $8;
} else } else
$1->comment->comment = $8; $1->comment->comment = $8;
} }
if ($11 != NULL) if ($11 != NULL)
$12 = list_prepend($12, $11); $12 = list_prepend($12, $11);
add_lint($6, LINT_assign_in_cond);
$$ = mk_for_loop($1, $3, $6, $9, $12); $$ = mk_for_loop($1, $3, $6, $9, $12);
break_allowed--; break_allowed--;
continue_allowed--; continue_allowed--;
} }
| LEX_FOR '(' opt_simple_stmt semi opt_nls semi opt_nls opt_simple_stmt r _paren opt_nls statement | LEX_FOR '(' opt_simple_stmt semi opt_nls semi opt_nls opt_simple_stmt r _paren opt_nls statement
{ {
if ($5 != NULL) { if ($5 != NULL) {
merge_comments($5, NULL); merge_comments($5, NULL);
$1->comment = $5; $1->comment = $5;
skipping to change at line 1426 skipping to change at line 1427
lintwarn(_("concatenation as I/O `>' redirection target i s ambiguous")); lintwarn(_("concatenation as I/O `>' redirection target i s ambiguous"));
$$ = list_prepend($3, $1); $$ = list_prepend($3, $1);
} }
; ;
if_statement if_statement
: LEX_IF '(' exp r_paren opt_nls statement : LEX_IF '(' exp r_paren opt_nls statement
{ {
if ($5 != NULL) if ($5 != NULL)
$1->comment = $5; $1->comment = $5;
add_lint($3, LINT_assign_in_cond);
$$ = mk_condition($3, $1, $6, NULL, NULL); $$ = mk_condition($3, $1, $6, NULL, NULL);
} }
| LEX_IF '(' exp r_paren opt_nls statement | LEX_IF '(' exp r_paren opt_nls statement
LEX_ELSE opt_nls statement LEX_ELSE opt_nls statement
{ {
if ($5 != NULL) if ($5 != NULL)
$1->comment = $5; $1->comment = $5;
if ($8 != NULL) if ($8 != NULL)
$7->comment = $8; $7->comment = $8;
add_lint($3, LINT_assign_in_cond);
$$ = mk_condition($3, $1, $6, $7, $9); $$ = mk_condition($3, $1, $6, $7, $9);
} }
; ;
nls nls
: NEWLINE : NEWLINE
{ {
$$ = $1; $$ = $1;
} }
| nls NEWLINE | nls NEWLINE
skipping to change at line 1664 skipping to change at line 1667
bcfree($3); /* Op_list */ bcfree($3); /* Op_list */
$$ = list_append($1, $2); $$ = list_append($1, $2);
} else { } else {
$2->memory = make_regnode(Node_dynregex, NULL); $2->memory = make_regnode(Node_dynregex, NULL);
$$ = list_append(list_merge($1, $3), $2); $$ = list_append(list_merge($1, $3), $2);
} }
} }
| exp LEX_IN simple_variable | exp LEX_IN simple_variable
{ {
if (do_lint_old) if (do_lint_old)
warning_ln($2->source_line, lintwarn_ln($2->source_line,
_("old awk does not support the keyword `in' exce pt after `for'")); _("old awk does not support the keyword `in' exce pt after `for'"));
$3->nexti->opcode = Op_push_array; $3->nexti->opcode = Op_push_array;
$2->opcode = Op_in_array; $2->opcode = Op_in_array;
$2->expr_count = 1; $2->expr_count = 1;
$$ = list_append(list_merge($1, $3), $2); $$ = list_append(list_merge($1, $3), $2);
} }
| exp a_relop exp %prec RELOP | exp a_relop exp %prec RELOP
{ {
if (do_lint && $3->lasti->opcode == Op_match_rec) if (do_lint && $3->lasti->opcode == Op_match_rec)
lintwarn_ln($2->source_line, lintwarn_ln($2->source_line,
skipping to change at line 1813 skipping to change at line 1816
$$ = mk_assignment($1, NULL, $2); $$ = mk_assignment($1, NULL, $2);
} }
| variable DECREMENT | variable DECREMENT
{ {
$2->opcode = Op_postdecrement; $2->opcode = Op_postdecrement;
$$ = mk_assignment($1, NULL, $2); $$ = mk_assignment($1, NULL, $2);
} }
| '(' expression_list r_paren LEX_IN simple_variable | '(' expression_list r_paren LEX_IN simple_variable
{ {
if (do_lint_old) { if (do_lint_old) {
/* first one is warning so that second one comes out if warni ngs are fatal */
warning_ln($4->source_line, warning_ln($4->source_line,
_("old awk does not support the keyword `in' exce pt after `for'")); _("old awk does not support the keyword `in' exce pt after `for'"));
warning_ln($4->source_line, lintwarn_ln($4->source_line,
_("old awk does not support multidimensional arra ys")); _("old awk does not support multidimensional arra ys"));
} }
$5->nexti->opcode = Op_push_array; $5->nexti->opcode = Op_push_array;
$4->opcode = Op_in_array; $4->opcode = Op_in_array;
if ($2 == NULL) { /* error */ if ($2 == NULL) { /* error */
errcount++; errcount++;
$4->expr_count = 0; $4->expr_count = 0;
$$ = list_merge($5, $4); $$ = list_merge($5, $4);
} else { } else {
INSTRUCTION *t = $2; INSTRUCTION *t = $2;
skipping to change at line 1997 skipping to change at line 2001
{ {
/* indirect function call */ /* indirect function call */
INSTRUCTION *f, *t; INSTRUCTION *f, *t;
char *name; char *name;
NODE *indirect_var; NODE *indirect_var;
static bool warned = false; static bool warned = false;
const char *msg = _("indirect function calls are a gawk extension "); const char *msg = _("indirect function calls are a gawk extension ");
if (do_traditional || do_posix) if (do_traditional || do_posix)
yyerror("%s", msg); yyerror("%s", msg);
else if (do_lint && ! warned) { else if (do_lint_extensions && ! warned) {
warned = true; warned = true;
lintwarn("%s", msg); lintwarn("%s", msg);
} }
f = $2->lasti; f = $2->lasti;
f->opcode = Op_indirect_func_call; f->opcode = Op_indirect_func_call;
name = estrdup(f->func_name, strlen(f->func_name)); name = estrdup(f->func_name, strlen(f->func_name));
if (is_std_var(name)) if (is_std_var(name))
yyerror(_("can not use special variable `%s' for indirect function call"), name); yyerror(_("cannot use special variable `%s' for indirect function call"), name);
indirect_var = variable(f->source_line, name, Node_var_new); indirect_var = variable(f->source_line, name, Node_var_new);
t = instruction(Op_push); t = instruction(Op_push);
t->memory = indirect_var; t->memory = indirect_var;
/* prepend indirect var instead of appending to arguments (opt_ex pression_list), /* prepend indirect var instead of appending to arguments (opt_ex pression_list),
* and pop it off in setup_frame (eval.c) (left to right evaluati on order); Test case: * and pop it off in setup_frame (eval.c) (left to right evaluati on order); Test case:
* f = "fun" * f = "fun"
* @f(f="real_fun") * @f(f="real_fun")
*/ */
skipping to change at line 2851 skipping to change at line 2855
return do_add_srcfile(stype, src, NULL, thisfile); return do_add_srcfile(stype, src, NULL, thisfile);
path = find_source(src, & sbuf, & errno_val, stype == SRC_EXTLIB); path = find_source(src, & sbuf, & errno_val, stype == SRC_EXTLIB);
if (path == NULL) { if (path == NULL) {
if (errcode) { if (errcode) {
*errcode = errno_val; *errcode = errno_val;
return NULL; return NULL;
} }
/* use full messages to ease translation */ /* use full messages to ease translation */
fatal(stype != SRC_EXTLIB fatal(stype != SRC_EXTLIB
? _("can't open source file `%s' for reading (%s)") ? _("cannot open source file `%s' for reading: %s")
: _("can't open shared library `%s' for reading (%s)"), : _("cannot open shared library `%s' for reading: %s"),
src, src,
errno_val ? strerror(errno_val) : _("reason unkno wn")); errno_val ? strerror(errno_val) : _("reason unkno wn"));
} }
/* N.B. We do not eliminate duplicate SRC_FILE (-f) programs. */ /* N.B. We do not eliminate duplicate SRC_FILE (-f) programs. */
for (s = srcfiles->next; s != srcfiles; s = s->next) { for (s = srcfiles->next; s != srcfiles; s = s->next) {
if ((s->stype == SRC_FILE || s->stype == SRC_INC || s->stype == S RC_EXTLIB) && files_are_same(path, s)) { if ((s->stype == SRC_FILE || s->stype == SRC_INC || s->stype == S RC_EXTLIB) && files_are_same(path, s)) {
if (stype == SRC_INC || stype == SRC_EXTLIB) { if (stype == SRC_INC || stype == SRC_EXTLIB) {
/* eliminate duplicates */ /* eliminate duplicates */
if ((stype == SRC_INC) && (s->stype == SRC_FILE)) if ((stype == SRC_INC) && (s->stype == SRC_FILE))
fatal(_("can't include `%s' and use it as a program file"), src); fatal(_("cannot include `%s' and use it a s a program file"), src);
if (do_lint) { if (do_lint) {
int line = sourceline; int line = sourceline;
/* Kludge: the line number may be off for `@include file'. /* Kludge: the line number may be off for `@include file'.
* Since, this function is also used for '-f file' in main.c, * Since, this function is also used for '-f file' in main.c,
* sourceline > 1 check ensures that the call is at * sourceline > 1 check ensures that the call is at
* parse time. * parse time.
*/ */
if (sourceline > 1 && lasttok == NEWLINE) if (sourceline > 1 && lasttok == NEWLINE)
line--; line--;
skipping to change at line 2887 skipping to change at line 2891
: _("already loaded shared library `%s'"), : _("already loaded shared library `%s'"),
src); src);
} }
efree(path); efree(path);
if (already_included) if (already_included)
*already_included = true; *already_included = true;
return NULL; return NULL;
} else { } else {
/* duplicates are allowed for -f */ /* duplicates are allowed for -f */
if (s->stype == SRC_INC) if (s->stype == SRC_INC)
fatal(_("can't include `%s' and use it as a program file"), src); fatal(_("cannot include `%s' and use it a s a program file"), src);
/* no need to scan for further matches, since /* no need to scan for further matches, since
* they must be of homogeneous type */ * they must be of homogeneous type */
break; break;
} }
} }
} }
s = do_add_srcfile(stype, src, path, thisfile); s = do_add_srcfile(stype, src, path, thisfile);
s->sbuf = sbuf; s->sbuf = sbuf;
s->mtime = sbuf.st_mtime; s->mtime = sbuf.st_mtime;
skipping to change at line 2929 skipping to change at line 2933
if (do_lint) if (do_lint)
lintwarn_ln(file->source_line, _("empty filename after @i nclude")); lintwarn_ln(file->source_line, _("empty filename after @i nclude"));
return true; return true;
} }
s = add_srcfile(SRC_INC, src, sourcefile, &already_included, &errcode); s = add_srcfile(SRC_INC, src, sourcefile, &already_included, &errcode);
if (s == NULL) { if (s == NULL) {
if (already_included) if (already_included)
return true; return true;
error_ln(file->source_line, error_ln(file->source_line,
_("can't open source file `%s' for reading (%s)"), _("cannot open source file `%s' for reading: %s"),
src, errcode ? strerror(errcode) : _("reason unknown")); src, errcode ? strerror(errcode) : _("reason unknown"));
return false; return false;
} }
/* save scanner state for the current sourcefile */ /* save scanner state for the current sourcefile */
sourcefile->srclines = sourceline; sourcefile->srclines = sourceline;
sourcefile->lexptr = lexptr; sourcefile->lexptr = lexptr;
sourcefile->lexend = lexend; sourcefile->lexend = lexend;
sourcefile->lexptr_begin = lexptr_begin; sourcefile->lexptr_begin = lexptr_begin;
sourcefile->lexeme = lexeme; sourcefile->lexeme = lexeme;
skipping to change at line 2988 skipping to change at line 2992
if (do_pretty_print && ! do_profile) { if (do_pretty_print && ! do_profile) {
// create a fake one, don't try to open the file // create a fake one, don't try to open the file
s = do_add_srcfile(SRC_EXTLIB, src, src, sourcefile); s = do_add_srcfile(SRC_EXTLIB, src, src, sourcefile);
} else { } else {
s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, & errcode); s = add_srcfile(SRC_EXTLIB, src, sourcefile, &already_included, & errcode);
if (s == NULL) { if (s == NULL) {
if (already_included) if (already_included)
return true; return true;
error_ln(file->source_line, error_ln(file->source_line,
_("can't open shared library `%s' for reading (%s )"), _("cannot open shared library `%s' for reading: % s"),
src, errcode ? strerror(errcode) : _("reason unkn own")); src, errcode ? strerror(errcode) : _("reason unkn own"));
return false; return false;
} }
load_ext(s->fullpath); load_ext(s->fullpath);
} }
*srcfile_p = (void *) s; *srcfile_p = (void *) s;
return true; return true;
} }
skipping to change at line 3166 skipping to change at line 3170
source = sourcefile->src; source = sourcefile->src;
if (source == NULL) if (source == NULL)
return NULL; return NULL;
fd = srcopen(sourcefile); fd = srcopen(sourcefile);
if (fd <= INVALID_HANDLE) { if (fd <= INVALID_HANDLE) {
char *in; char *in;
/* suppress file name and line no. in error mesg */ /* suppress file name and line no. in error mesg */
in = source; in = source;
source = NULL; source = NULL;
error(_("can't open source file `%s' for reading (%s)"), error(_("cannot open source file `%s' for reading: %s"),
in, strerror(errno)); in, strerror(errno));
errcount++; errcount++;
lexeof = true; lexeof = true;
return sourcefile->src; return sourcefile->src;
} }
sourcefile->fd = fd; sourcefile->fd = fd;
l = optimal_bufsize(fd, &sbuf); l = optimal_bufsize(fd, &sbuf);
/* /*
* Make sure that something silly like * Make sure that something silly like
* AWKBUFSIZE=8 make check * AWKBUFSIZE=8 make check
* works ok. * works ok.
*/ */
#define A_DECENT_BUFFER_SIZE 128 #define A_DECENT_BUFFER_SIZE 128
if (l < A_DECENT_BUFFER_SIZE) if (l < A_DECENT_BUFFER_SIZE)
l = A_DECENT_BUFFER_SIZE; l = A_DECENT_BUFFER_SIZE;
#undef A_DECENT_BUFFER_SIZE #undef A_DECENT_BUFFER_SIZE
sourcefile->bufsize = l; sourcefile->bufsize = l;
newfile = true; newfile = true;
emalloc(sourcefile->buf, char *, sourcefile->bufsize, "get_src_bu f"); emalloc(sourcefile->buf, char *, sourcefile->bufsize, "get_src_bu f");
memset(sourcefile->buf, '\0', sourcefile->bufsize); // keep v algrind happy
lexptr = lexptr_begin = lexeme = sourcefile->buf; lexptr = lexptr_begin = lexeme = sourcefile->buf;
savelen = 0; savelen = 0;
sourceline = 1; sourceline = 1;
thisline = NULL; thisline = NULL;
} else { } else {
/* /*
* Here, we retain the current source line in the beginning of th e buffer. * Here, we retain the current source line in the beginning of th e buffer.
*/ */
int offset; int offset;
for (scan = lexeme; scan > lexptr_begin; scan--) for (scan = lexeme; scan > lexptr_begin; scan--)
skipping to change at line 3233 skipping to change at line 3238
lexeme = lexptr - offset; lexeme = lexptr - offset;
} else { } else {
savelen = 0; savelen = 0;
lexptr = lexeme = lexptr_begin; lexptr = lexeme = lexptr_begin;
thisline = NULL; thisline = NULL;
} }
} }
n = (*readfunc)(sourcefile->fd, lexptr, sourcefile->bufsize - savelen); n = (*readfunc)(sourcefile->fd, lexptr, sourcefile->bufsize - savelen);
if (n == -1) { if (n == -1) {
error(_("can't read sourcefile `%s' (%s)"), error(_("cannot read source file `%s': %s"),
source, strerror(errno)); source, strerror(errno));
errcount++; errcount++;
lexeof = true; lexeof = true;
} else { } else {
lexend = lexptr + n; lexend = lexptr + n;
if (n == 0) { if (n == 0) {
static bool warned = false; static bool warned = false;
if (do_lint && newfile && ! warned) { if (do_lint && newfile && ! warned) {
warned = true; warned = true;
sourceline = 0; sourceline = 0;
skipping to change at line 3303 skipping to change at line 3308
case '\f': case '\f':
case '\n': case '\n':
case '\r': case '\r':
case '\t': case '\t':
return; return;
default: default:
break; break;
} }
if (iscntrl(c) && ! isspace(c)) if (iscntrl(c) && ! isspace(c))
fatal(_("PEBKAC error: invalid character '\\%03o' in source code" // This is a PEBKAC error, but we'll be nice and not say so.
), c & 0xFF); fatal(_("error: invalid character '\\%03o' in source code"), c &
0xFF);
} }
/* nextc --- get the next input character */ /* nextc --- get the next input character */
// For namespaces, -e chunks must be syntactic units. // For namespaces, -e chunks must be syntactic units.
#define NO_CONTINUE_SOURCE_STRINGS 1 #define NO_CONTINUE_SOURCE_STRINGS 1
static int static int
nextc(bool check_for_bad) nextc(bool check_for_bad)
{ {
skipping to change at line 3858 skipping to change at line 3864
case ';': case ';':
case ',': case ',':
case '[': case '[':
return lasttok = c; return lasttok = c;
case ']': case ']':
c = nextc(true); c = nextc(true);
pushback(); pushback();
if (c == '[') { if (c == '[') {
if (do_traditional) if (do_traditional)
fatal(_("multidimensional arrays are a gawk exten sion")); fatal(_("multidimensional arrays are a gawk exten sion"));
if (do_lint) if (do_lint_extensions)
lintwarn(_("multidimensional arrays are a gawk ex tension")); lintwarn(_("multidimensional arrays are a gawk ex tension"));
yylval = GET_INSTRUCTION(Op_sub_array); yylval = GET_INSTRUCTION(Op_sub_array);
lasttok = ']'; lasttok = ']';
} else { } else {
yylval = GET_INSTRUCTION(Op_subscript); yylval = GET_INSTRUCTION(Op_subscript);
lasttok = SUBSCRIPT; /* end of subscripts */ lasttok = SUBSCRIPT; /* end of subscripts */
} }
return ']'; return ']';
case '*': case '*':
skipping to change at line 3884 skipping to change at line 3890
yylval = GET_INSTRUCTION(Op_times); yylval = GET_INSTRUCTION(Op_times);
return lasttok = '*'; return lasttok = '*';
} else if (c == '*') { } else if (c == '*') {
/* make ** and **= aliases for ^ and ^= */ /* make ** and **= aliases for ^ and ^= */
static bool did_warn_op = false, did_warn_assgn = false; static bool did_warn_op = false, did_warn_assgn = false;
if (nextc(true) == '=') { if (nextc(true) == '=') {
if (! did_warn_assgn) { if (! did_warn_assgn) {
did_warn_assgn = true; did_warn_assgn = true;
if (do_lint) if (do_lint)
lintwarn(_("POSIX does not allow operator `**='")); lintwarn(_("POSIX does not allow operator `%s'"), "**=");
if (do_lint_old) if (do_lint_old)
warning(_("old awk does not suppo rt operator `**='")); lintwarn(_("operator `%s' is not supported in old awk"), "**=");
} }
yylval = GET_INSTRUCTION(Op_assign_exp); yylval = GET_INSTRUCTION(Op_assign_exp);
return ASSIGNOP; return ASSIGNOP;
} else { } else {
pushback(); pushback();
if (! did_warn_op) { if (! did_warn_op) {
did_warn_op = true; did_warn_op = true;
if (do_lint) if (do_lint)
lintwarn(_("POSIX does not allow operator `**'")); lintwarn(_("POSIX does not allow operator `%s'"), "**");
if (do_lint_old) if (do_lint_old)
warning(_("old awk does not suppo rt operator `**'")); lintwarn(_("operator `%s' is not supported in old awk"), "**");
} }
yylval = GET_INSTRUCTION(Op_exp); yylval = GET_INSTRUCTION(Op_exp);
return lasttok = '^'; return lasttok = '^';
} }
} }
pushback(); pushback();
yylval = GET_INSTRUCTION(Op_times); yylval = GET_INSTRUCTION(Op_times);
return lasttok = '*'; return lasttok = '*';
case '/': case '/':
skipping to change at line 3932 skipping to change at line 3938
yylval = GET_INSTRUCTION(Op_mod); yylval = GET_INSTRUCTION(Op_mod);
return lasttok = '%'; return lasttok = '%';
case '^': case '^':
{ {
static bool did_warn_op = false, did_warn_assgn = false; static bool did_warn_op = false, did_warn_assgn = false;
if (nextc(true) == '=') { if (nextc(true) == '=') {
if (do_lint_old && ! did_warn_assgn) { if (do_lint_old && ! did_warn_assgn) {
did_warn_assgn = true; did_warn_assgn = true;
warning(_("operator `^=' is not supported in old awk")); lintwarn(_("operator `%s' is not supported in old awk"), "^=");
} }
yylval = GET_INSTRUCTION(Op_assign_exp); yylval = GET_INSTRUCTION(Op_assign_exp);
return lasttok = ASSIGNOP; return lasttok = ASSIGNOP;
} }
pushback(); pushback();
if (do_lint_old && ! did_warn_op) { if (do_lint_old && ! did_warn_op) {
did_warn_op = true; did_warn_op = true;
warning(_("operator `^' is not supported in old awk")); lintwarn(_("operator `%s' is not supported in old awk"), "^");
} }
yylval = GET_INSTRUCTION(Op_exp); yylval = GET_INSTRUCTION(Op_exp);
return lasttok = '^'; return lasttok = '^';
} }
case '+': case '+':
if ((c = nextc(true)) == '=') { if ((c = nextc(true)) == '=') {
yylval = GET_INSTRUCTION(Op_assign_plus); yylval = GET_INSTRUCTION(Op_assign_plus);
return lasttok = ASSIGNOP; return lasttok = ASSIGNOP;
} }
skipping to change at line 4395 skipping to change at line 4401
} }
if ((tokentab[mid].flags & NOT_POSIX) != 0 && (warntab[mi d] & NOT_POSIX) == 0) { if ((tokentab[mid].flags & NOT_POSIX) != 0 && (warntab[mi d] & NOT_POSIX) == 0) {
lintwarn(_("POSIX does not allow `%s'"), lintwarn(_("POSIX does not allow `%s'"),
tokentab[mid].operator); tokentab[mid].operator);
warntab[mid] |= NOT_POSIX; warntab[mid] |= NOT_POSIX;
} }
} }
if (do_lint_old && (tokentab[mid].flags & NOT_OLD) != 0 if (do_lint_old && (tokentab[mid].flags & NOT_OLD) != 0
&& (warntab[mid] & NOT_OLD) == 0 && (warntab[mid] & NOT_OLD) == 0
) { ) {
warning(_("`%s' is not supported in old awk"), lintwarn(_("`%s' is not supported in old awk"),
tokentab[mid].operator); tokentab[mid].operator);
warntab[mid] |= NOT_OLD; warntab[mid] |= NOT_OLD;
} }
if ((tokentab[mid].flags & BREAK) != 0) if ((tokentab[mid].flags & BREAK) != 0)
break_allowed++; break_allowed++;
if ((tokentab[mid].flags & CONTINUE) != 0) if ((tokentab[mid].flags & CONTINUE) != 0)
continue_allowed++; continue_allowed++;
switch (class) { switch (class) {
skipping to change at line 4597 skipping to change at line 4603
expr = list_create(instruction(Op_push_i)); expr = list_create(instruction(Op_push_i));
expr->nexti->memory = set_profile_text(make_numbe r(0.0), "0", 1); expr->nexti->memory = set_profile_text(make_numbe r(0.0), "0", 1);
(void) mk_expression_list(subn, (void) mk_expression_list(subn,
list_append(expr, instruction(Op_ field_spec))); list_append(expr, instruction(Op_ field_spec)));
} }
arg = arg->lasti->nexti; /* third arg list */ arg = arg->lasti->nexti; /* third arg list */
ip = arg->lasti; ip = arg->lasti;
if (ip->opcode == Op_push_i) { if (ip->opcode == Op_push_i) {
if (do_lint) if (do_lint)
lintwarn(_("%s: string literal as last ar g of substitute has no effect"), lintwarn(_("%s: string literal as last ar gument of substitute has no effect"),
operator); operator);
r->sub_flags |= LITERAL; r->sub_flags |= LITERAL;
} else { } else {
if (make_assignable(ip) == NULL) if (make_assignable(ip) == NULL)
yyerror(_("%s third parameter is not a ch angeable object"), yyerror(_("%s third parameter is not a ch angeable object"),
operator); operator);
else else
ip->do_reference = true; ip->do_reference = true;
} }
skipping to change at line 4912 skipping to change at line 4918
dump_vars(const char *fname) dump_vars(const char *fname)
{ {
FILE *fp; FILE *fp;
NODE **vars; NODE **vars;
if (fname == NULL) if (fname == NULL)
fp = stderr; fp = stderr;
else if (strcmp(fname, "-") == 0) else if (strcmp(fname, "-") == 0)
fp = stdout; fp = stdout;
else if ((fp = fopen(fname, "w")) == NULL) { else if ((fp = fopen(fname, "w")) == NULL) {
warning(_("could not open `%s' for writing (%s)"), fname, strerro r(errno)); warning(_("could not open `%s' for writing: %s"), fname, strerror (errno));
warning(_("sending variable list to standard error")); warning(_("sending variable list to standard error"));
fp = stderr; fp = stderr;
} }
vars = variable_list(); vars = variable_list();
print_vars(vars, fprintf, fp); print_vars(vars, fprintf, fp);
efree(vars); efree(vars);
if (fp != stdout && fp != stderr && fclose(fp) != 0) if (fp != stdout && fp != stderr && fclose(fp) != 0)
warning(_("%s: close failed (%s)"), fname, strerror(errno)); warning(_("%s: close failed: %s"), fname, strerror(errno));
} }
/* dump_funcs --- print all functions */ /* dump_funcs --- print all functions */
void void
dump_funcs() dump_funcs()
{ {
NODE **funcs; NODE **funcs;
funcs = function_list(true); funcs = function_list(true);
(void) foreach_func(funcs, (int (*)(INSTRUCTION *, void *)) pp_func, (voi d *) 0); (void) foreach_func(funcs, (int (*)(INSTRUCTION *, void *)) pp_func, (voi d *) 0);
skipping to change at line 5079 skipping to change at line 5085
emalloc(pnames, char **, pcount * sizeof(char *), "check_params"); emalloc(pnames, char **, pcount * sizeof(char *), "check_params");
for (i = 0, p = list->nexti; p != NULL; i++, p = np) { for (i = 0, p = list->nexti; p != NULL; i++, p = np) {
np = p->nexti; np = p->nexti;
name = p->lextok; name = p->lextok;
p->lextok = NULL; p->lextok = NULL;
if (strcmp(name, fname) == 0) { if (strcmp(name, fname) == 0) {
/* check for function foo(foo) { ... }. bleah. */ /* check for function foo(foo) { ... }. bleah. */
error_ln(p->source_line, error_ln(p->source_line,
_("function `%s': can't use function name as para meter name"), fname); _("function `%s': cannot use function name as par ameter name"), fname);
} else if (is_std_var(name)) { } else if (is_std_var(name)) {
error_ln(p->source_line, error_ln(p->source_line,
_("function `%s': can't use special variable `%s' as a function parameter"), _("function `%s': cannot use special variable `%s ' as a function parameter"),
fname, name); fname, name);
} else if (strchr(name, ':') != NULL) } else if (strchr(name, ':') != NULL)
error_ln(p->source_line, error_ln(p->source_line,
_("function `%s': parameter `%s' cannot contain a namespace"), _("function `%s': parameter `%s' cannot contain a namespace"),
fname, name); fname, name);
/* check for duplicate parameters */ /* check for duplicate parameters */
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {
if (strcmp(name, pnames[j]) == 0) { if (strcmp(name, pnames[j]) == 0) {
error_ln(p->source_line, error_ln(p->source_line,
skipping to change at line 5261 skipping to change at line 5267
memset(n, 0, sizeof(NODE)); memset(n, 0, sizeof(NODE));
n->type = type; n->type = type;
n->re_cnt = 1; n->re_cnt = 1;
if (type == Node_regex) { if (type == Node_regex) {
n->re_reg[0] = make_regexp(exp->stptr, exp->stlen, false, true, f alse); n->re_reg[0] = make_regexp(exp->stptr, exp->stlen, false, true, f alse);
if (n->re_reg[0] == NULL) { if (n->re_reg[0] == NULL) {
freenode(n); freenode(n);
return NULL; return NULL;
} }
n->re_reg[1] = make_regexp(exp->stptr, exp->stlen, true, true, fa
lse);
if (n->re_reg[1] == NULL) {
refree(n->re_reg[0]);
freenode(n);
return NULL;
}
n->re_exp = exp; n->re_exp = exp;
n->re_flags = CONSTANT; n->re_flags = CONSTANT;
} }
return n; return n;
} }
/* mk_rexp --- make a regular expression constant */ /* mk_rexp --- make a regular expression constant */
static NODE * static NODE *
mk_rexp(INSTRUCTION *list) mk_rexp(INSTRUCTION *list)
 End of changes. 34 change blocks. 
37 lines changed or deleted 36 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)