Skip to content

Commit

Permalink
More SYMTAB and FUNCTAB improvements.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnoldrobbins committed Oct 3, 2012
1 parent 9e2703f commit 3d9b832
Show file tree
Hide file tree
Showing 10 changed files with 357 additions and 299 deletions.
12 changes: 11 additions & 1 deletion ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
2012-10-02 Arnold D. Robbins <arnold@skeeve.com>

* symbol.c (lookup): If do_posix, skip the global table.
* awk.h (func_table): Declare.
* awkgram.y: If do_posix or do_traditional, then check for
delete on SYMTAB. Add check for delete on FUNCTAB, also.
* interpret.h (Op_Subscript): For FUNCTAB, return the element name
as its value too. Avoids lots of weirdness and allows indirect calls
after assignment from FUNCTAB["foo"] to work.
(Op_store_sub): Disallow assignment to elements of FUNCTAB.
(Op_indirect_func_all): Turn assert into check and fatal error.
* symbol.c (func_table): No longer static.
(lookup): If do_posix or do_traditional, skip the global table.
(release_all_vars): Clear func_table too.

2012-09-25 Arnold D. Robbins <arnold@skeeve.com>

Expand Down
1 change: 1 addition & 0 deletions awk.h
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,7 @@ extern int get_numbase(const char *str, bool use_locale);
extern void load_symbols();
extern void init_symbol_table();
extern NODE *symbol_table;
extern NODE *func_table;
extern NODE *install_symbol(char *name, NODETYPE type);
extern NODE *remove_symbol(NODE *r);
extern void destroy_symbol(NODE *r);
Expand Down
16 changes: 12 additions & 4 deletions awkgram.c
Original file line number Diff line number Diff line change
Expand Up @@ -2990,8 +2990,12 @@ yyparse ()
(yyvsp[(2) - (4)])->opcode = Op_push_array;
(yyvsp[(2) - (4)])->memory = variable((yyvsp[(2) - (4)])->source_line, arr, Node_var_new);

if ((yyvsp[(2) - (4)])->memory == symbol_table)
fatal(_("`delete' is not allowed with SYMTAB"));
if (! do_posix && ! do_traditional) {
if ((yyvsp[(2) - (4)])->memory == symbol_table)
fatal(_("`delete' is not allowed with SYMTAB"));
else if ((yyvsp[(2) - (4)])->memory == func_table)
fatal(_("`delete' is not allowed with FUNCTAB"));
}

if ((yyvsp[(4) - (4)]) == NULL) {
/*
Expand Down Expand Up @@ -3035,8 +3039,12 @@ yyparse ()
(yyvsp[(1) - (4)])->expr_count = 0;
(yyval) = list_append(list_create((yyvsp[(3) - (4)])), (yyvsp[(1) - (4)]));

if ((yyvsp[(3) - (4)])->memory == symbol_table)
fatal(_("`delete' is not allowed with SYMTAB"));
if (! do_posix && ! do_traditional) {
if ((yyvsp[(3) - (4)])->memory == symbol_table)
fatal(_("`delete' is not allowed with SYMTAB"));
else if ((yyvsp[(3) - (4)])->memory == func_table)
fatal(_("`delete' is not allowed with FUNCTAB"));
}
}
break;

Expand Down
16 changes: 12 additions & 4 deletions awkgram.y
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,12 @@ regular_print:
$2->opcode = Op_push_array;
$2->memory = variable($2->source_line, arr, Node_var_new);

if ($2->memory == symbol_table)
fatal(_("`delete' is not allowed with SYMTAB"));
if (! do_posix && ! do_traditional) {
if ($2->memory == symbol_table)
fatal(_("`delete' is not allowed with SYMTAB"));
else if ($2->memory == func_table)
fatal(_("`delete' is not allowed with FUNCTAB"));
}

if ($4 == NULL) {
/*
Expand Down Expand Up @@ -1018,8 +1022,12 @@ regular_print:
$1->expr_count = 0;
$$ = list_append(list_create($3), $1);

if ($3->memory == symbol_table)
fatal(_("`delete' is not allowed with SYMTAB"));
if (! do_posix && ! do_traditional) {
if ($3->memory == symbol_table)
fatal(_("`delete' is not allowed with SYMTAB"));
else if ($3->memory == func_table)
fatal(_("`delete' is not allowed with FUNCTAB"));
}
}
| exp
{ $$ = optimize_assignment($1); }
Expand Down
3 changes: 2 additions & 1 deletion doc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
2012-10-02 Arnold D. Robbins <arnold@skeeve.com>

* gawk.texi, gawk.1, awkcard.in: Document FUNCTAB, SYMTAB, and
PROCINFO["identifiers"].
PROCINFO["identifiers"]. Including that delete does not work
on FUNCTAB and SYMTAB.

2012-09-23 Arnold D. Robbins <arnold@skeeve.com>

Expand Down
10 changes: 10 additions & 0 deletions doc/gawk.1
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,11 @@ An array whose indices are the names of all the user-defined
or extension functions in the program.
.BR NOTE :
The array values cannot currently be used.
Also, you may not use the
.B delete
statment with the
.B FUNCTAB
array.
.TP
.B IGNORECASE
Controls the case-sensitivity of all regular expression
Expand Down Expand Up @@ -1289,6 +1294,11 @@ The
function may be used to test if an element in
.B SYMTAB
is an array.
You may not use the
.B delete
statment with the
.B SYMTAB
array.
.TP
.B TEXTDOMAIN
The text domain of the \*(AK program; used to find the localized
Expand Down
Loading

0 comments on commit 3d9b832

Please sign in to comment.