We probably don't want our users to have to endure them, so they
are enabled only when Debug is activated, because they tend to
help keeping the code safe.
The equality comparison (a == b) is known to be a dangerous trap
when floating-point arithmetics are involved. In the current case
the offending operation can be done with integers directly.
The equality comparison (a == b) is known to be a dangerous trap
when floating-point arithmetics are involved. This patch changes
all the cases which try to do this to a safer check.
The original code allowed to have 0.0, but this can generate
division by zero in WScrollView. As a value of 0.0 is not realistic
anyway, use a minimum constant instead.
The equality comparison (a == b) is known to be a dangerous trap
when floating-point arithmetics are involved. This patch changes
all the cases which try to do this to a safer check.
Some header were creating variable, this is a bad practice which
is likely to not behave as expected. This creates one distinct
variable in each object file that used the header, and:
- on well behaved compiler, this ends up in a link error (see
commit 39fdb451ba for an example)
- on bad behaving compiler, this can be linked as multiple local
variable, thus having strange effects when running program
- on insouciant compiler (who said gcc?) the variables are
silently merged, hiding portability issues
Autoconf provides the necessary stuff to detect if inline keyword
is supported, and to detect special syntaxes, so let's use this
and remove the multiple local definitions, this makes code simpler.
When using the formula [sizeof(array) / sizeof( x )] to get the number
of element in a static array, it is better to use array[0] for 'x'
instead of the base type of array:
- in case the base type would change someday;
- if the compiler were deciding to insert padding somewhere
Some compilation options are actually targetting the preprocessor
instead of the compiler; using the wrong variable can have some
subtile side effects, so let's get things right.
Considering the number of headers we have, it is a good idea to
avoid possible problems. For details, you may read:
http://en.wikipedia.org/wiki/Include_guard
All headers should be ok now.
The automake documentation states that using substitution inside the
list of SOURCES will not work and calls for not doing it. The use
of 'EXTRA_xxx' made things look like they worked but is probably not
enough for corner cases.
This patches switches to the conditional method which will be safe.
This patch includes info about XRandR extension in the info panel
dialog. If wmaker was compiled with xrandr support, then the dialog
show the XRandR info. The info includes if the X-Server supports or not
XRandR (wmaker could be compiled with XRandR support, but the X Server
may not include XRandR extension).
The string was separated in two by Christophe Curis to allow translation,
as suggested by Alexey I. Froloff.
To be able to do this in a clean way, it was necessary to add the
attribute also in PLData's ptr field, which is actually right
because none of the function changes its content.
The function that fills it from a file/pipe however needed small
changes to respect the const-ness of the field.
The history is actually loaded from a file into a property list that
is then converted to an array. The intermediate property list was
not freed, which led to memory leak.
It looks like it was a tentative of optimisation to avoid duplicating
an already allocated string and re-use the pointer instead, but this
means it is not possible to free the original container as it would
free the string too.
There is a better way to do this, but it requires an API change on the
WUtil library so it is left for a future improvment.
The previous code limited the number of entries that were read into
the history array, but the user is expecting a maximum on the
number of entries displayed. This can make a little difference in
two cases:
- if there are duplicate entries (dups are checked for and removed)
- if some entries are not strings (unlikely, but not impossible)
The new code just stops adding history entries when the user
specified count is reached.
When menus are read in the PropList format, they are loaded into a
temporary PropList object, which is parsed into the internal menu
structure, and the PropList object is no more used. There were two
cases where this temp object was not freed.
A common argument to all these functions is the name of the key to
operate on, and this name is never modified by the functions. Marking
it as const reflects this, and can allow compiler to generate better
results thanks to this info.
The addition of the const attributes is actually an API change, so
we have to reflect this for the next official release.
Because the change on 'wusergnusteppath' may impact users of the API,
we won't only change REVISION like it was done for WRaster lib.
The first optimisation is to compute only once the path, and then
always re-use the value which did not change anyway.
The second optimisation is to avoid a lot of excessive function
calls, including alloc+free that are not necessary and participate
in memory fragmentation.
According to the way its value is being used everywhere, that is
what would be expected, so let's make it official.
Please note that this may introduce warnings on user code using
this function ("...discard const...") but that's an opportunity
for them to check that their code is not doing anything wrong.
The internal function 'unescapestr' is used to transform strings which
may contain escape sequences (\x) into their plain representation.
There are a few cases where the function can misbehave (typically parse
after the end of string, thus writing past the end of the reserved
result area) which can be a source of problem later. The new code
should be safer.
The previous syntax used an explicit cast to remove the CONST
attribute, but the right way is to keep the attribute and store
the result in a variable which is defined properly.