Denys Vlasenko wrote:
> Vladimir, please CC: [email protected]

>> An example of usage is included in parse_config.c.
>>
>> N.B. A simple format string can someday be added to perform tokens 
>> typecasting.
>> That way we would be able to reduce calls to strto*()s outside config 
>> parsing procedure.
> 
> I have a performance objection. You read entire file in one go.
> Config files often have big comments. Not to mention that
> in many cases, keeping entire file (even sans comments)
> is not needed, the file can be processed line-by-line.
> 
> Can you read file line-by-line, and throw away empty lines,
> comments, excessive delimiters etc?
> 
> Naming your structure PARSER is strange. Is it mimicking FILE naming scheme?
> How about
> 
> typedef struct parser_t {
>       char *data;
>       char *line;
>         ...
> } parser_t;
> 
> Regarding config_read: can you keep state and parser config in parser struct
> so that config_read() does not need so many parameters? Then config_read()
> can work similarly to xmalloc_fgets: take only one parameter (parser struct 
> ptr)
> and return result (malloced, NULL terminated char* vector?
> pointer to pre-allocated, NULL padded char* vector[MAX] inside parser struct?
> you decide).
> 
> char* FAST_FUNC config_read(PARSER *parser, char comment, const char *delims, 
> int ntokens, char **tokens)
> --

hi all,
first of all thanks to vladimir for your thoughts about the parser stuff.

when i started thinking about config-files i notice there are two types, line 
and block configs.
i guess a code that reads a file in a array, perhaps with an option of removing 
blank lines and comments
(and not more) valdimir showed nicely how to treat \<NL> and
other fancy stuff like kill leading/trainling spaces *maybe* that can be added 
also.

The parsing itself could easily be done within the programm it self. It also 
decides about block or line
parsing code, no need for elaborated code because the common stuff is moved to 
libbb.

btw: i do not like typedef's

re,
 wh





_______________________________________________
busybox mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/busybox

Reply via email to