[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev a note on different lynx.cfg/commandline args syntax
From: |
Leonid Pauzner |
Subject: |
Re: lynx-dev a note on different lynx.cfg/commandline args syntax |
Date: |
Mon, 5 Apr 1999 01:23:59 +0400 (MSD) |
4-Apr-99 10:55 address@hidden wrote:
>> Also the arguments tables in LYMain.c and LYReadCFG.c
>> have the different signature that may be a misguiding when adding new
>> options:
> well - by making these things table-driven, we can indeed go a step further
> and
> make the tables compatible (is that what you are asking about?)
The tables are incompatible because of different style of options
(one in lynx.cfg always have a value, but most command line switches
have no value, etc.), it will add more mess if we made them
unified (a really bad idea).
But we may change a signatue e.g. use `&variable' syntax in both tables
(now `variable' in one table and `&variable' in another)
so it would be obvious that we change the value - a minore issue.
Probably, we may add an initialization field in lynx.cfg table,
so the variables will be initialized based on userdefs.h defines
not in main() but directly in read_cfg(). But probably add more complexity,
maybe not. Just a thought.
>>
>>
>> LYMain.c:
>> ^^^^^^^^^
>> struct parse_args_type;
>> typedef int (*ParseFunc) PARAMS((struct parse_args_type *, char **, char *));
>>
>> typedef union {
>> BOOLEAN * set_value;
>> int * int_value;
>> char ** str_value;
>> ParseFunc fun_value;
>> } ParseUnion;
>>
>> #undef PARSE_DEBUG
>>
>> /*
>> * Storing the four types of data in separate fields costs about 1K of data.
>> * However, this provides usable type-checking. The initial version of the
>> * parse_args_type used 'long' for all types, and dumped core when processing
>> * "lynx -help". (The compiler was unable to detect some minor errors).
>> */
>> #ifdef PARSE_DEBUG
>> #define ParseData BOOLEAN *set_value; int *int_value; char **str_value;
>> ParseFunc fun_value
>> #define PARSE_SET(n,t,v,h) {n,t, v, 0, 0, 0, h}
>> #define PARSE_INT(n,t,v,h) {n,t, 0, &v, 0, 0, h}
>> #define PARSE_STR(n,t,v,h) {n,t, 0, 0, v, 0, h}
>> #define PARSE_FUN(n,t,v,h) {n,t, 0, 0, 0, v, h}
>> #else
>> #define ParseData long value
>> #define PARSE_SET(n,t,v,h) {n,t, (long) (v), h}
>> #define PARSE_INT(n,t,v,h) {n,t, (long)&(v), h}
>> #define PARSE_STR(n,t,v,h) {n,t, (long) (v), h}
>> #define PARSE_FUN(n,t,v,h) {n,t, (long) (v), h}
>> #endif
>>
>>
>> LYReadCFG.c:
>> ^^^^^^^^^^^^
>> typedef int (*ParseFunc) PARAMS((char *));
>>
>> typedef union {
>> lynx_html_item_type ** add_value;
>> BOOLEAN * set_value;
>> int * int_value;
>> char ** str_value;
>> ParseFunc fun_value;
>> long def_value;
>> } ConfigUnion;
>>
>> #undef PARSE_DEBUG
>> #ifdef PARSE_DEBUG
>> #define ParseData \
>> lynx_html_item_type** add_value; \
>> BOOLEAN *set_value; \
>> int *int_value; \
>> char **str_value; \
>> ParseFunc fun_value; \
>> long def_value
>> #define PARSE_ADD(n,t,v) {n,t, &v, 0, 0, 0, 0, 0}
>> #define PARSE_SET(n,t,v) {n,t, 0, &v, 0, 0, 0, 0}
>> #define PARSE_INT(n,t,v) {n,t, 0, 0, &v, 0, 0, 0}
>> #define PARSE_STR(n,t,v) {n,t, 0, 0, 0, &v, 0, 0}
>> #define PARSE_ENV(n,t,v) {n,t, 0, 0, 0, v, 0, 0}
>> #define PARSE_FUN(n,t,v) {n,t, 0, 0, 0, 0, v, 0}
>> #define PARSE_DEF(n,t,v) {n,t, 0, 0, 0, 0, 0, v}
>> #else
>> #define ParseData long value
>> #define PARSE_ADD(n,t,v) {n,t, (long)&(v)}
>> #define PARSE_SET(n,t,v) {n,t, (long)&(v)}
>> #define PARSE_INT(n,t,v) {n,t, (long)&(v)}
>> #define PARSE_STR(n,t,v) {n,t, (long)&(v)}
>> #define PARSE_ENV(n,t,v) {n,t, (long) (v)}
>> #define PARSE_FUN(n,t,v) {n,t, (long) (v)}
>> #define PARSE_DEF(n,t,v) {n,t, (long) (v)}
>> #endif
>>
>>
>>
> --
> Thomas E. Dickey
> address@hidden
> http://www.clark.net/pub/dickey