1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-04 08:17:17 -05:00
elinks/src/main
Kalle Olavi Niemitalo 8b00e1ef70 bug 764: Initialize the right member of union option_value
INIT_OPTION used to initialize union option_value at compile time by
casting the default value to LIST_OF(struct option) *, which is the
type of the first member.  On sparc64 and other big-endian systems
where sizeof(int) < sizeof(struct list_head *), this tended to leave
option->value.number as zero, thus messing up OPT_INT and OPT_BOOL
at least.  OPT_LONG however tended to work right.

This would be easy to fix with C99 designated initializers,
but doc/hacking.txt says ELinks must be kept C89 compatible.
Another solution would be to make register_options() read the
value from option->value.tree (the first member), cast it back
to the right type, and write it to the appropriate member;
but that would still require somewhat dubious conversions
between integers, data pointers, and function pointers.

So here's a rather more invasive solution.  Add struct option_init,
which is somewhat similar to struct option but has non-overlapping
members for different types of values, to ensure nothing is lost
in compile-time conversions.  Move unsigned char *path from struct
option_info to struct option_init, and replace struct option_info
with a union that contains struct option_init and struct option.
Now, this union can be initialized with no portability problems,
and register_options() then moves the values from struct option_init
to their final places in struct option.

In my x86 ELinks build with plenty of options configured in, this
change bloated the text section by 340 bytes but compressed the data
section by 2784 bytes, presumably because union option_info is a
pointer smaller than struct option_info was.
(cherry picked from elinks-0.12 commit e5f6592ee2)

Conflicts:
	src/protocol/fsp/fsp.c: All options had been removed in 0.13.GIT.
	src/protocol/smb/smb2.c: Ditto.
2012-11-03 22:16:32 +02:00
..
event.c More missing va_ends. 2007-09-04 10:26:57 +03:00
event.h Bug 810: Add a few comments pointing to the bug. 2006-09-24 00:21:03 +03:00
interlink.c Add a comment about CONFIG_TCP_INTERLINK. 2006-01-13 00:10:06 +01:00
interlink.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
main.c Merge branch 'elinks-0.12' into elinks-0.13 2008-07-11 22:28:45 +03:00
main.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
Makefile path_to_top -> top_builddir 2005-10-20 04:00:35 +02:00
module.c Create a module for src/viewer, which subsumes some existing modules 2006-05-20 15:01:24 +00:00
module.h bug 764: Initialize the right member of union option_value 2012-11-03 22:16:32 +02:00
object.h Revert OBJECT_HEAD() part of tcc cleanups 2006-01-22 06:18:40 +01:00
select.c Do not set FD_SETSIZE too high on Windows. 2012-08-08 22:22:37 +02:00
select.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
timer.c Declare element types of lists. 2007-07-26 22:47:23 +03:00
timer.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00
version.c Bug 824: Disable combining characters unless --enable-combining. 2008-01-19 20:58:22 +02:00
version.h Remove empty lines in start of header files 2005-11-15 11:33:27 +01:00