[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gawk-diffs] [SCM] gawk branch, constants, updated. gawk-4.1.0-1122-g45e
From: |
Arnold Robbins |
Subject: |
[gawk-diffs] [SCM] gawk branch, constants, updated. gawk-4.1.0-1122-g45e6261 |
Date: |
Tue, 17 Feb 2015 20:46:31 +0000 |
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gawk".
The branch, constants has been updated
via 45e6261d0a1eee4efd433c19ca2f79801db00a6d (commit)
from fabbef63448b32723072cadc706dd909828c432a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://git.sv.gnu.org/cgit/gawk.git/commit/?id=45e6261d0a1eee4efd433c19ca2f79801db00a6d
commit 45e6261d0a1eee4efd433c19ca2f79801db00a6d
Author: Arnold D. Robbins <address@hidden>
Date: Tue Feb 17 22:46:10 2015 +0200
Disallow := to special variables.
diff --git a/ChangeLog b/ChangeLog
index ec79fdd..de8b3db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2015-02-17 Arnold D. Robbins <address@hidden>
+
+ Disallow := to special variables.
+
+ * awk.h (VAR_SPEC): New flag for the value of special variables.
+ * array.c (set_SUBSEP): Set it.
+ * eval.c (flags2str): Add an entry for it.
+ (update_NR, update_NF): Set it.
+ * field.c (set_NF, set_FS, set_FIELDWIDTHS, set_FPAT): Set it.
+ * interpret.h (r_interpret): At Op_assign_const, check it.
+ * io.c (set_FNR, set_NR, set_RS): Set it.
+ * main.c (init_args): Set it for ARGC.
+ (init_vars): Set it for the others.
+ * mpfr.c (set_PREC, set_ROUNDMODE): Set it.
+
2015-02-13 Arnold D. Robbins <address@hidden>
* interpet.h (Op_store_var): Handle assignment from a constant.
diff --git a/array.c b/array.c
index f799362..d7c55a4 100644
--- a/array.c
+++ b/array.c
@@ -375,6 +375,7 @@ void
set_SUBSEP()
{
SUBSEP_node->var_value = force_string(SUBSEP_node->var_value);
+ SUBSEP_node->var_value->flags |= VAR_SPEC;
SUBSEP = SUBSEP_node->var_value->stptr;
SUBSEPlen = SUBSEP_node->var_value->stlen;
}
diff --git a/awk.h b/awk.h
index 7921ba5..fb4744a 100644
--- a/awk.h
+++ b/awk.h
@@ -428,6 +428,7 @@ typedef struct exp_node {
* See cint_array.c */
# define XARRAY 0x20000
# define VAR_CONST 0x40000 /* value is for a const */
+# define VAR_SPEC 0x80000 /* value belongs to a
special var */
} NODE;
#define vname sub.nodep.name
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 9724ce1..2b7fd46 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,7 @@
+2015-02-17 Arnold D. Robbins <address@hidden>
+
+ * gawktexi.in (Symbol table by name): Document sym_constant().
+
2015-02-13 Arnold D. Robbins <address@hidden>
* gawktexi.in: O'Reilly fixes. Through QC1 review.
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 1e3a7c8..4ddccea 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -31815,6 +31815,16 @@ Changing types (scalar to array or vice versa) of an
existing variable
is @emph{not} allowed, nor may this routine be used to update an array.
This routine cannot be used to update any of the predefined
variables (such as @code{ARGC} or @code{NF}).
+
address@hidden awk_bool_t sym_constant(const char *name, awk_value_t *value);
+Create a variable named by the string @code{name}, which is
+a regular C string, that has the constant value as given by
address@hidden @command{awk}-level code cannot change the value of this
+variable. The extension may change the value of @code{name}'s
+variable with subsequent calls to this routine, and may also convert
+a variable created by @code{sym_update()} into a constant. However,
+once a variable becomes a constant, it cannot later be reverted into a
+mutable variable.
@end table
An extension can look up the value of @command{gawk}'s special variables.
diff --git a/eval.c b/eval.c
index 63f1d0d..6154ce1 100644
--- a/eval.c
+++ b/eval.c
@@ -449,6 +449,7 @@ flags2str(int flagval)
{ HALFHAT, "HALFHAT" },
{ XARRAY, "XARRAY" },
{ VAR_CONST, "VAR_CONST" },
+ { VAR_SPEC, "VAR_SPEC" },
{ 0, NULL },
};
@@ -1068,6 +1069,7 @@ update_NR()
if (NR_node->var_value->numbr != NR) {
unref(NR_node->var_value);
NR_node->var_value = make_number(NR);
+ NR_node->var_value->flags |= VAR_SPEC;
}
}
@@ -1084,6 +1086,7 @@ update_NF()
(void) get_field(UNLIMITED - 1, NULL); /* parse record
*/
unref(NF_node->var_value);
NF_node->var_value = make_number(NF);
+ NF_node->var_value->flags |= VAR_SPEC;
}
}
diff --git a/field.c b/field.c
index 6a7c6b1..7ae3543 100644
--- a/field.c
+++ b/field.c
@@ -340,6 +340,7 @@ set_NF()
assert(NF != -1);
+ NF_node->var_value->flags |= VAR_SPEC;
(void) force_number(NF_node->var_value);
nf = get_number_si(NF_node->var_value);
if (nf < 0)
@@ -1179,6 +1180,8 @@ set_FIELDWIDTHS()
}
FIELDWIDTHS[i+1] = -1;
+ FIELDWIDTHS_node->var_value->flags |= VAR_SPEC;
+
update_PROCINFO_str("FS", "FIELDWIDTHS");
if (fatal_error)
fatal(_("invalid FIELDWIDTHS value, near `%s'"),
@@ -1315,6 +1318,7 @@ choose_fs_function:
if (fs->stlen == 1 && parse_field == re_parse_field)
FS_regexp = FS_re_yes_case;
+ FS_node->var_value->flags |= VAR_SPEC;
update_PROCINFO_str("FS", "FS");
}
@@ -1429,6 +1433,7 @@ set_fpat_function:
FPAT_regexp = (IGNORECASE ? FPAT_re_no_case : FPAT_re_yes_case);
}
+ FPAT_node->var_value->flags |= VAR_SPEC;
update_PROCINFO_str("FS", "FPAT");
}
diff --git a/interpret.h b/interpret.h
index d776801..4d55d93 100644
--- a/interpret.h
+++ b/interpret.h
@@ -766,8 +766,12 @@ mod:
case Op_assign_const:
lhs = POP_ADDRESS();
- if (*lhs != NULL && ((*lhs)->flags & VAR_CONST) != 0)
- fatal(_("cannot assign to defined constant"));
+ if (*lhs != NULL) {
+ if (((*lhs)->flags & VAR_CONST) != 0)
+ fatal(_("cannot assign to defined
constant"));
+ else if (((*lhs)->flags & VAR_SPEC) != 0)
+ fatal(_("cannot convert built-in
variable to constant"));
+ }
r = TOP_SCALAR();
unref(*lhs);
r->flags |= VAR_CONST;
diff --git a/io.c b/io.c
index c1b031f..e087404 100644
--- a/io.c
+++ b/io.c
@@ -563,6 +563,7 @@ set_FNR()
else
#endif
FNR = get_number_si(n);
+ FNR_node->var_value->flags |= VAR_SPEC;
}
/* set_NR --- update internal NR from awk variable */
@@ -578,6 +579,7 @@ set_NR()
else
#endif
NR = get_number_si(n);
+ NR_node->var_value->flags |= VAR_SPEC;
}
/* inrec --- This reads in a record from the input file */
@@ -3646,6 +3648,7 @@ set_RS()
set_FS:
if (current_field_sep() == Using_FS)
set_FS();
+ RS_node->var_value->flags |= VAR_SPEC;
}
diff --git a/main.c b/main.c
index f8d8b1c..a113318 100644
--- a/main.c
+++ b/main.c
@@ -715,6 +715,7 @@ init_args(int argc0, int argc, const char *argv0, char
**argv)
ARGC_node = install_symbol(estrdup("ARGC", 4), Node_var);
ARGC_node->var_value = make_number((AWKNUM) j);
+ ARGC_node->var_value->flags |= VAR_SPEC;
}
@@ -792,6 +793,7 @@ init_vars()
n->var_update = (Func_ptr) vp->update;
if (vp->do_assign)
(*(vp->assign))();
+ n->flags |= VAR_SPEC;
}
/* Load PROCINFO and ENVIRON */
diff --git a/mpfr.c b/mpfr.c
index 571b334..95ed569 100644
--- a/mpfr.c
+++ b/mpfr.c
@@ -521,6 +521,7 @@ set_PREC()
if (! do_mpfr)
return;
+ PREC_node->var_value->flags |= VAR_SPEC;
val = PREC_node->var_value;
if ((val->flags & MAYBE_NUM) != 0)
force_number(val);
@@ -613,6 +614,7 @@ set_ROUNDMODE()
ROUND_MODE = rndm;
} else
warning(_("RNDMODE value `%.*s' is invalid"), (int)
n->stlen, n->stptr);
+ ROUNDMODE_node->var_value->flags |= VAR_SPEC;
}
}
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 15 +++++++++++++++
array.c | 1 +
awk.h | 1 +
doc/ChangeLog | 4 ++++
doc/gawktexi.in | 10 ++++++++++
eval.c | 3 +++
field.c | 5 +++++
interpret.h | 8 ++++++--
io.c | 3 +++
main.c | 2 ++
mpfr.c | 2 ++
11 files changed, 52 insertions(+), 2 deletions(-)
hooks/post-receive
--
gawk
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gawk-diffs] [SCM] gawk branch, constants, updated. gawk-4.1.0-1122-g45e6261,
Arnold Robbins <=