Robert Spalek [Tue, 25 Apr 2006 20:25:27 +0000 (22:25 +0200)]
conf2: add basic type CT_LOOKUP that maps strings to integers
Since I need to store both type==CT_LOOKUP and a pointer to the lookup
table, I moved the type out the union. However, I have not blown up the
size of struct cf_item, because I have compressed class and type to 16
bits.
Martin Mares [Mon, 24 Apr 2006 21:49:55 +0000 (23:49 +0200)]
bopen_safe() in conf2 was leaking file descriptors. I've replaced it
by a new bopen_try() in the fastbuf library and also cleaned up error
messages on unsuccessful file opens.
Robert Spalek [Sun, 23 Apr 2006 19:41:18 +0000 (21:41 +0200)]
lib: revert unwanted commit
damn, I tried to just delete one unwanted file from the list when
editing the commit-log, but cogito ignored the deletion and committed the
file anyway. rollback then.
Robert Spalek [Sun, 23 Apr 2006 19:13:08 +0000 (21:13 +0200)]
conf2: tested a few more test-cases and fixed/polished the code
- journal blocks are "transactions", don't overload the word "sections" too much
- added 2 long-term TODO's and 1 short-term FIXME
- the include command must be the last one on a line
Robert Spalek [Sun, 23 Apr 2006 00:13:05 +0000 (02:13 +0200)]
conf2: removed handling of dirty pages
2 XXX's and 1 FIXME deleted by just omitting the whole functionality and
commiting _all_ pages after each reload. it should not cost much more than
a bit of memory.
Robert Spalek [Sun, 23 Apr 2006 00:09:32 +0000 (02:09 +0200)]
conf2: debugged a lot
- closing_brace() confused current operation with the one on the stack a lot
- get_word() fix when recognizing = in the parameter name
- split_line() totally rewritten to 2 nice procedures: get_token() and
split_command()
- #include back to include, otherwise it would be a comment
- local fastbufs in parse_fastbuf()
Robert Spalek [Fri, 21 Apr 2006 17:44:13 +0000 (19:44 +0200)]
conf2: bugfix in editing and adding before/after a node of a link list
interpret_add_list() allocates memory himself, hence it is not suitable for
these operations. since the real code is only 2 lines long, I moved the
functionality to closing_brace(). I changed its interface too, hence it
can be used much simpler and interpret_line() can be returned to its
original form.
Robert Spalek [Fri, 21 Apr 2006 16:20:38 +0000 (18:20 +0200)]
conf2: implemented all list operations in the interpreter
- added operations OP_EDIT, OP_AFTER, OP_BEFORE, and flags OP_1ST, OP_2ND
denoting the phase (forming a search query vs. filling in the data)
- add_to_list() extended to support all list operations
- definition of stack moved closer to the interpreter, because many
functions don't need it
- implemented find_list_node(), opening_brace (former increase_stack), and
closing_brace() that fully support all operations
- the top of interpret_line() rewritten too
Robert Spalek [Fri, 21 Apr 2006 12:45:26 +0000 (14:45 +0200)]
conf2: record used selectors when searching in lists
- store number of entries to section flags
- find_item() fixed so that it correctly handles accesses to unknown
top-level sections. also setting an absolute attribute (i.e. not
relative to the current section) starts with a caret now.
- added an u32 mask to the stack and record_selector() that fills it
Robert Spalek [Fri, 21 Apr 2006 10:40:57 +0000 (12:40 +0200)]
conf2: resolve an issue concerning variable numbers of parameters
When a node of a link list is parsed on one line, then the inner section
is checked for dynamic attributes at the end. If they are present, the
outer node is just parsed once and the flag allowing dynamic parsing is
passed inside. If we did not allow this, then an error would have occured
anyway, and this behaviour is actually useful.
Along the way, I unified the headers and semantics of most interpreters and
cleaned up the code.
Robert Spalek [Fri, 21 Apr 2006 09:26:24 +0000 (11:26 +0200)]
conf2: enhanced the interpreter so that it can parse almost anything on 1 line
I cleaned up the subroutines so that they form a nice recursive structure
that allows to parse almost anything (static and dynamic arrays, lists,
parsed value, and sections in all combinations) on 1 line, while detecting
ambiguities.
Robert Spalek [Thu, 20 Apr 2006 22:56:54 +0000 (00:56 +0200)]
implemented parser of a single line and top-level sections unified
- we store registered sections in the same format as subsections so that we
can search/process them in a uniform way
- implemented find_item() that can parse both absolute and relative paths
- all parsers of basic types simplified to take care of only 1 value;
arrays are handled by the caller
- implemented a part of the interpretter: it gets parsed line (attribute
name, desired operations, and parameters) and loads the values into
memory. since declarations can be nested and they can span over multiple
lines, the interpretter operates on a stack
Robert Spalek [Thu, 20 Apr 2006 10:50:44 +0000 (12:50 +0200)]
substantially changed the interface again
I realised that in the last interface I couldn't distinguish between static
and dynamic arrays of length exactly 1. thinking about how to resolve the
problem led me to a different solution that is as easy to use as before,
but easier to implement, easier to extend by new basic types, and as a
bonus I get a natural interface for static arrays.
I then immediately scratched a duplicate code for parsing dynamic arrays,
because it can be easily unified now. also, CF_ITEMS does not expect a
parameter now, because they the compiler messes up line numbers when an
error occurs.
Pavel Charvat [Thu, 20 Apr 2006 06:58:00 +0000 (08:58 +0200)]
Removed previously added parameter {KMP,HASH}_PARAM_POOL from
hashtable and KMP... it is not really necessary.
Added full support for non-integer character types and custom
allocation routines to KMP.
Robert Spalek [Wed, 19 Apr 2006 10:02:37 +0000 (12:02 +0200)]
implemented a few functions of the new configuration mechanism:
- memory allocation
- skeleton of future journal functions
- parsers of all basic types and arrays of these types