[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lynx-dev suggestions for new features
From: |
John E. Davis |
Subject: |
Re: lynx-dev suggestions for new features |
Date: |
Fri, 24 Apr 1998 18:33:43 -0400 |
I think that before any new features get added, we should make an
effort to clean up some of the code. As more features get added, the
code becomes harder and harder to follow, discouraging others from
getting involved in lynx development. Is there a list of things that
need to be cleaned up?
I think that we all agree that MainLoop needs alot of work, but there
are other, more easily understood parts of code that should be
reworked. For example, while it appears that LYReadCfg:read_cfg looks
a lot better than it did the last time I looked at it, it should be
table driven, e.g.,
typedef struct
{
char *option_name;
int (*function) (char *);
} Option_Type;
static Option_Type Option_Table [] =
{
{"SOME_OPTION", some_option_function},
.
.
{NULL, NULL}
};
void read_cfg (...)
{
.
.
while (NULL != fgets (line, sizeof (line), fp))
{
Option_Type *opt;
.
.
opt = Option_Table;
while (1)
{
if (opt->name == NULL)
{
error...;
break;
}
if ((*line == opt->option_name[0])
&& (strncmp (line, opt->option_name, strlen
(opt->option_name))))
{
if (-1 == (*opt->function) (line))
error ....
break;
}
opt++;
}
}
.
.
}
Actually, since many of the option functions do similar things, e.g.,
parse an integer field on the line, and set a variable, some of that
could be done up front before calling (*opt->function). This would
not only improve readibility, but cut down on the size of the
resulting executable.
--John
- Re: lynx-dev suggestions for new features, (continued)
- Re: lynx-dev suggestions for new features, David Combs, 1998/04/24
- Re: lynx-dev suggestions for new features, David Combs, 1998/04/24
- Re: lynx-dev suggestions for new features, John E. Davis, 1998/04/24
- Re: lynx-dev suggestions for new features, T.E.Dickey, 1998/04/24
- Re: lynx-dev suggestions for new features,
John E. Davis <=