Tue 10 Jul 2007 11:42:25 PM UTC, original submission:
There are too many places to look to see how an option is set on the command-line or wgetrc, what it's default value is, etc. To find out what opt field is set by a given command-line option, for example, you need to search for the command-line option in main.c's OPTION_DATA array, note the value of the DATA field, and use that to search in init.c's COMMANDS array. Then, to find its default value, you need to check init.c's DEFAULTS function.
Too involved. If necessary, the necessary data structures could be generated from a special source file designed to map a wgetrc command to its short and long options (if any), its internal "opt" structure member, its default value, tables of conflicting options, and perhaps its usage string and usage category. This could make maintenance and addition of new options much easier, as well as code comprehensibility.
Additional benefits would be that there's no particular need to keep options in alphabetical order, since the generator could re-sort them for binary searches. If we wish, we could generate tries instead of lists for lookup of options, resulting in O(N) complexity, rather than the current O(N log M), where N is the number of chars in the option or command name, and M is the number of entries. In addition, time would no longer be wasted on each invocation of wget to construct the table for getopt_long, which could already have been generated at build time.
|