Commit graph

72 commits

Author SHA1 Message Date
2cb2c59ac6 Rewrite rev. 1.69 to suppress immutable field match check when
extending any table, empty or not:
(cur_obj_is_blank): New.
(fldval_must_match): Use it instead of initialized[].
(getobj): Set it along with cur_obj.
(setstr): Move fldval_must_match() down, so that cur_obj_is_blank is
defined.
(initialized): Remove.
2006-06-22 19:42:10 +00:00
Ron Koenderink
a21b4a0e72 (mtsymset, add2symset): Remove unused local variables. 2006-06-09 00:26:59 +00:00
a835a4b4d3 Fix the previous revision. 2006-06-04 09:01:51 +00:00
8fa0dcbe17 Don't check values for immutable fields match when initializing an
empty table:
(initialized): New.
(xundump): Set it.
(fldval_must_match): Ignore NSC_CONST when it's clear.
2006-06-04 08:37:37 +00:00
568b9d6639 Allow symbolic references not just to symbol tables:
(xunsymbol1): Use ef_elt_byname().
(setsym): Accept any table reference, not just to symbol table.
(symval): New.
(setsym, add2symset): Use it.
(mtsymset): Last remaining user of getsymtab(); inline and simplify.
(getsymtab): Remove.

(xunsymbol1, xunsymbol): Rename.
2006-06-01 19:15:30 +00:00
a1546476bf (xunsymbol1): Fix diagnostics. 2006-06-01 19:06:56 +00:00
c432e3107d Symbolic names for table entries in conditionals, closes #928376:
(ef_elt_byname): New.
(nstr_match_val): Use it to generalize to arbitrary table with
uniquely named elements.  Use ca_type to find table, remove parameter
type.  Callers changed.
(nstr_mkselval): Adapt sanity check accordingly.
(NSC_TYPEID): No longer needed, remove, users changed to use
appropriate integer type instead.  This fixes signedness of sector
selectors des and newdes.
(meta_type): Remove entry for NSC_TYPEID.
(nstr_coerce_val): Can't detect typeid - integer mismatch anymore.
Was nice to have; perhaps revive it later.
2006-06-01 18:48:42 +00:00
15635c25ae (getid): Restrict identifier syntax: outlaw conditional operators <>=#
and meta-character ".
2006-06-01 18:09:40 +00:00
2faa68c6e3 (xufld, setstr): Improve diagnostics. 2006-06-01 18:06:03 +00:00
75604d817c (nsc_type): New member NSC_HIDDEN.
(meta_type): Add its entry.
(setnum, nstr_promote, nstr_exec_val): Deal with it.  nstr_exec_val()
implements opt_HIDDEN by mapping unknown values to -1.
(natstr, nat_ca): Use it for member nat_relate.  This also halves its
size.  Fixes very minor leak: before, player could see relations to
all countries, regardless of contact.
(nation_relations): Add entry for -1.
2006-05-18 19:02:04 +00:00
fe53057977 (xuheader): Fix misleading diagnostics.
(xundump1): Fix table shrinking.
2006-02-19 17:03:33 +00:00
3a73dce58e Permit field repetition in each part of vertically split tables,
provided the values all match:
(caseen): New.
(xundump): Initialize and finalize it.
(xundump2): Update it.
(deffld): Deal with repetition.
(fldval_must_match): New, considers repetition as well as NSC_CONST.
(setnum, setstr): Use it.
2006-02-19 15:25:35 +00:00
c12cc62875 (need_uid, is_partial): Rename.
(xuheader1, chkflds): Collect all code dealing with index field of
vertically split tables in chkflds().
2006-02-19 15:15:40 +00:00
c73613ea26 (defellipsis, chkflds, xundump2, need_uid): Use new need_uid to
require index field in all parts of a split table.
2006-02-14 18:04:44 +00:00
fc676cb53a Support vertically split configuration tables (human-readable only):
(ellipsis): New.
(xuheader1): Initialize it.  Compute nflds.  Allow repetition of index
field in continued tables.
(xundump): Don't set nflds.
(xufldname, defellipsis): Accept ... and call new defellipsis().
(xufldname, chkflds): Update and elaborate check for missing fields,
move it to new chkflds().  Require repetition of index field in
continued tables.
(xundump2): New, factored out of xundump().  Parse continued tables.
2006-02-14 07:30:06 +00:00
46fcc27c6f Xdumps don't contain records not in use, cope with that:
(xundump1, setnum, setstr, getobj, cur_id): Delay table lookup until
first field is about to be assigned.
(xundump1): Record largest ID, because it's no longer given by final
value of row.

(xuheader1, xundump1, xundump): Move initialization of cur_type to
xundump().
2006-02-13 21:22:05 +00:00
eae1e590cc (xundump1): Don't suppress table growth just because it has NSC_CONST
selectors.  That's wrong for EF_SECTOR_CHR and EF_PRODUCT.  Don't
allow table shrinking just because it has no NSC_CONST selectors.
That's wrong for EF_NEWS_CHR.  Allow it for game state and unit
characteristics.
(has_const): Unused, remove.
2006-02-13 21:16:41 +00:00
1a4deb9fde (setnum): Fix computation of old for cases NSC_XCOORD, NSC_YCOORD. 2006-02-13 20:44:18 +00:00
9e362de34f (xuheader, xundump): Return -2 for empty input, so it can be
distinguished from bad input.
2006-02-13 19:07:31 +00:00
6ed05a024c (setstr): Fix for NSC_STRINGY without terminating zero. 2006-02-13 07:06:47 +00:00
86a0a43960 (xuheader1): New, factored out of xundump(). 2006-02-12 15:52:10 +00:00
10096cbf98 (xundump): Rev. 1.44 broke ef_load(). Fix. 2006-02-09 18:34:57 +00:00
66669be655 (xundump, xundump1): Fix treatment of empty lines. 2006-02-09 07:10:18 +00:00
Ron Koenderink
f76a128f5c (mtsymset, xutrailer, xundump1): Remove unused variables. 2006-02-09 00:28:28 +00:00
f5621c5a49 Accept fields out of order in human-readable syntax (indexes must
still be in order), support abbreviated field names:
(nxt_sel, nxt_idx, nxtfld, ca4fld): Remove.
(nflds, fldca, fldidx, caflds, getfld): New.
(xundump): Initialize and finalize them.
(xundump1): New, factored out of xundump().
(deffld): Match names, record field order in fldca[], fldidx[] for
getfld().  Use caflds[] to detect duplicates.
(xufldname): Catch negative index.  Used to pass it to deffld(), which
now interprets it as no index.
(setnum, setstr, setsym, mtsymset, add2symset): Use getfld().

(xufld): Improve error message.

(setstr): Fix for NULL strings.

(xuheader): Catch null ef_cadef().

(xuheader): Don't oops when an unexpected table can't be undumped.
2006-02-08 23:23:48 +00:00
28787caa95 Improve error messages. 2006-02-08 22:44:22 +00:00
b11aa718ce The separation between parsing and semantic actions is awkward and
leaks memory; rework it:
(deffld): New; semantic action for field headers.
(xufldname): Use it instead of storing a value for xucolumnheader().
(xucolumnheader): Remove, use xuflds() directly instead.
(setnum, setstr, setsym): New; semantic actions for field values.
(xufld): Use it instead of storing a value for xuloadrow().
(xuloadrow): Remove.  Was incomplete.
(xufldname, xufld, xuflds): Remove parameter values.  Callers
changed.
(cur_type, cur_obj, nxt_sel, nxt_idx, nxtfld, ca4fld, getsymtab): New
helpers.
(xundump): Initialize them.
(enum_value, value, freeflds, xunsymbol): Remove.

(mtsymset, add2symset): New.
(xufld): Use them to build a symbol set along the parse.

(xufldname, xufld, xuheader, xutrailer, xundump): Increment lineno
when and only when a linefeed is consumed, to make sure it is correct.
Move some semantic checks so that errors get reported for the correct
line.

(xundump): Use compare filenames as pointers, not strings, when
checking whether to reset lineno.

(xundump): Keep empfile[type] consistent during parse, to make
ef_ptr() usable.

(xundump): Don't call ep->init() on sentinels.
(xuinitrow): Unused, remove.
2006-02-08 22:32:53 +00:00
054d59b323 (xundump): Precise value for need_sentinel. 2006-02-08 22:02:13 +00:00
d329c4f8e6 (xutrailer): Fix parsing of /config. Change human-readable syntax not
to accept number of records.  Don't skip empty lines after trailer.
2006-02-08 21:53:04 +00:00
72127c838f (xuheader): Check for unexpected table before oopsing on !EFF_MEM. 2006-02-08 21:41:48 +00:00
8a6438b4e0 (xufldname, xufld): New, factored out of xuflds and specialized for
headers and for body lines, respectively.
(xflds): Call them through new parameter parse.  Callers changed.
2006-02-08 20:56:39 +00:00
361e33d70f (xucolumnheader): Don't gripe when xuflds() fails, because that one
already griped.
2006-02-08 20:49:47 +00:00
Ron Koenderink
426eece569 Properly parse and validate column headers:
(enum_value, value, xuflds, freeflds): Parse additional syntax:
numeric and symbolic index.
(xucolumnheader): Use it to parse column header line.  Check names
and indexes match meta-data.  Symbolic indexes not yet implemented.
(xuloadrow): Reject the additional syntax.
2006-01-30 22:23:43 +00:00
Ron Koenderink
79f672969b (xuheader): Remove values[], not used. 2006-01-29 19:12:52 +00:00
Ron Koenderink
8900dfaa3d (xuflds): Terminated the value list when a bad separator is found. 2006-01-22 17:37:05 +00:00
4515b84c59 COPYING duplicates information from README. Remove. Move GPL from
LICENSE to COPYING, because that's where it usually is.  Update all
the references to these files.
2006-01-21 19:48:41 +00:00
Ron Koenderink
036a623a40 (xunsymbol): Ensure the table is a symbol table before searching it. 2006-01-21 17:33:02 +00:00
Ron Koenderink
cf384676e8 (xuloadrow): Add support for NSC_SHORT. 2006-01-08 04:11:15 +00:00
3e400c018c Update copyright notice. 2006-01-05 13:36:57 +00:00
Ron Koenderink
4871a10a9b (xundump): Add the ability to support the parsing of the human
readable form.

(xucolumnheader): New function.
2006-01-01 03:44:41 +00:00
Ron Koenderink
15e40c55cd (xundump): Move the header parsing into a separate function xuheader().
Move the trailer parsing into a separate function xutrailer().

(xuheader, xutrailer): New functions.
2006-01-01 03:37:36 +00:00
3aebb68ee7 Include config.h. 2005-12-27 18:04:19 +00:00
3dc35a77f7 (xundump): Eat whitespace after table, so that caller can check for
trailing junk more easily.  This fixes that check in ef_load().
2005-12-17 15:09:43 +00:00
965bf6dbe4 (xundump): Fix table row counting, broken by rev. 1.23. 2005-12-17 08:25:57 +00:00
2ebc947969 (xundump): Fix rev. 1.19. 2005-12-03 16:15:16 +00:00
86a59e4de4 (xuflds, xunsymbol, xuloadrow): Symbol sets.
(VAL_SYMBOL_SET, getid, xunsymbol1): New.

(xunsymbol): New argument n for more useful diagnostics.

(xuloadrow): Remove redundant semantic check.
2005-12-03 14:14:44 +00:00
739f346584 (xunsymbol): Fix design flaw: negative symbol values were interpreted
as failure.
2005-12-03 13:38:52 +00:00
b7eb39ebef (xuflds): Allow unescaped space and tab in strings. Also fix the
previous revision, which broke '#' in strings.
2005-12-03 11:36:55 +00:00
1eb7d1795c (xuloadrow): Fix crash. 2005-12-03 11:19:20 +00:00
0a7291eb37 Less rigid field separators, support comments:
(skipfs): New.
(xuflds, xundump): Use it.  Update field scanf stop-sets accordingly.
(xuflds): Update test for good field separator.

(xundump): Fail silently if nothing can be read and no specific table
is expected.
2005-12-03 11:04:44 +00:00