The header "wraster.h" needs different behaviour depending on whether the
support for X Shared Memory extension was enabled or not; but the related
macro USE_XSHM is defined by WindowMaker's configure. After this header
have been installed, the macro is no more useable.
This patch makes the "wraster.h" a generated file, so it will be different
depending on USE_XSHM, but will not make use of the macro itself.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The translation check would complain because it does not find any '.po'
files, so I am providing one translation.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The original error messages tended to be a bit sparse, now they try to be
a little bit more helpful, and translatable in user's language.
In xutil.c:122, took opportunity fix a problem because calling 'perror'
after other function which are likely to have changed the errno is likely
to provide a wrong error string.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Because the library does not have an initialisation function, we need to
rely on an automatic called-on-load mechanism, which is provided through
a compiler attribute 'constructor'.
However, as the project aims to still compile on old hard/software, we
include a check in 'configure' to ensure it works, and if not use the
legacy solution.
Note: Because we introduce a new DEFINE, the 'config.h.in' needs to be
regenerated, otherwise you may get a compilation error in wrlib. This is
done by re-running './autogen.sh'
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This patch is just adding a single header, but because it also modifies
all the C files to add the #include, it was made as a patch on its own to
ease review.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The library did not propose the mechanisms to be translated, this patch is
creating the structure in autoconf/automake and the translation directory
so its messages can be also translated.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
With proper attributes, the compiler is able to do some extra checks on
user side to make code safer and/or better optimised.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The library maintains a cache to not reload a file that was previously
loaded. In order to still reload an image in case its file would have
changed in the meantime, the cache saves the file's modification time.
As reported by Coverity (CID #331576) the 'stat' function was not on the
execution path the first time an image is loaded, which means the cache
information is populated with junk data. This could lead to an image not
being reloaded for example.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
When the function 'pm_getuint' is reading a number, it prints an error
message if it encounters a non-digit number, yet it still enters the
processing loop which will cause an invalid number to be calculated.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Duplicating things makes maintenance error-prone, which is not a good idea.
In case the abort procedure would need an update, it would be easy then
to forget some place, leading to leaks, if not worse.
Beside, goto is not as bad as academics would like people to believe, when
it is used correctly (and this case is one of them).
The name for the label was given an explicit meaning to make code easy to
understand.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
It's USE_MAGICK, not USE_MAGIC. Also, we wrap the if/else statement
in an ifdef. This doesn't really affect anything since load_magick.c
won't be compiled if USE_MAGICK is undefined because of an if statement
in the Makefile. But in the off chance that it is somehow, then we will
try to load a nonexistent version 6 header file since USE_MAGICK will
be interprested as 0 and 0 < 7 is true.
We dropped ImageMagick 6 support in 0.95.9. However, ImageMagick 6 is
still widespread (e.g., ImageMagick 7 has not been packaged in Debian
yet), and upstream plans on maintaining it until at least 2028 [1].
In this patch, we detect the version of the MagickWand library installed
on the user's system and include the appropriate header file when
building wrlib.
Note: I've only tested this with ImageMagick 6, so I'd appreciate
confirmation that it works with ImageMagick 7.
[1] https://github.com/ImageMagick/ImageMagick6/blob/master/NEWS.txt
This patch removes the code not used. Because the if block
check that buffer[0] is NULL, then, we don't need check it
again inside.
Image is not used yet, so is NULL. We can return NULL.
Signed-off-by: Rodolfo GarcÃa Peñas (kix) <kix@kix.es>
This patch returns NULL, because the variable image is not used yet.
The patch also removes three lines:
- buffer[0] = NULL; /* Initialize pointer to avoid spurious free in cleanup code */
RErrorCode = RERR_BADIMAGEFILE;
jpeg_destroy_decompress(&cinfo);
fclose(file);
- if (buffer[0])
- free(buffer[0]);
buffer is a local variable. The malloc is not used yet. So:
- We set the value to NULL, then check if is null to call free(). So the free()
call is never used. We can remove the last too lines.
- We don't need set now to NULL, because the variable is empty (the
initializated (or not) value is not used, and is destroyed as local variable
when we returns, just one line later.
Signed-off-by: Rodolfo GarcÃa Peñas (kix) <kix@kix.es>
This patch removes the goto call. I copied the code after the bye: label and
I paste it in the goto-calls.
Signed-off-by: Rodolfo GarcÃa Peñas (kix) <kix@kix.es>
This patch adds the comments to remove the warnings.
gradient.c: In function ‘renderGradientWidth’:
gradient.c:162:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
*ptr++ = b;
~~~~~~~^~~
gradient.c:163:2: note: here
case 2:
^~~~
gradient.c:166:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
*ptr++ = b;
~~~~~~~^~~
gradient.c:167:2: note: here
case 1:
^~~~
Signed-off-by: Rodolfo GarcÃa Peñas (kix) <kix@kix.es>
We use only 1 function from this library, and it is in a case that should
be rare nowadays: displays with indexed color.
This commit makes it acceptable to compile if the library is missing.
The support for a custom message in the attribute 'deprecated' have been
added only from gcc 4.5.0 and not 4.0, so the check was updated accordingly
to avoid compilation error with version 4.0 to 4.4.
Reported-by: Josip Deanovic <djosip+news@linuxpages.net>
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The original code was using double precision floating point to perform the
color corrections for the creation of the standard colormap. This precision
is not necessary because color coding is 16 bits anyway, and on some
architecture the double precision comes with a cost.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
To preserve the accuracy of the operation, the C standard request that the
mathematical operation is performed using double precision, but in many
case this is not necessary so this patch fixes a few constants to avoid
that conversion.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As pointed by Coverity, in the "Configuration" panel of WPrefs there are
some images loaded, but if the images cannot be loaded correctly then the
returned NULL pointer can crash the application as it is dereferenced in
further function calls.
To solve this case, this patch is adding a NULL pointer check in the
functions RScaleImage (wrlib) and WMCreatePixmapFromRImage (WINGs), so both
can accept that NULL pointer to also return NULL, which means the existing
check for "icon == NULL" in the WPrefs code will be useful.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
This script should have been removed a long time ago, in favour of
pkg-config which has to be present anyway to compile Window Maker.
This patch makes the script print a warning about it, and now calls itself
pkg-config, instead of being generated; the man page was also updated
accordingly (and spell-checked).
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Instead of having to maintain manually the map file for LD with the list of
symbols that we want to keep in the WRaster library (the purpose is to hide
internal symbols), this patch implements a script that parses the public
API header and extracts automatically the list of names that are supposed
to be visible to the user.
The goal is to reduce possible human errors, like for example the function
RCombineAlpha that was forgotten from the list, yet still keep the map file
feature which is considered a good practice (it reduces the risk for name
clash and the risk of mis-use of internal stuff from the library).
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
For code maintainability, it is better to have a single definition of the
constant than many ones dispatched in many places. In addition, we try to
count on the constant M_PI that can be defined by the header <math.h> if
possible because it may have the best accuracy for the platform.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
We have a few directories with source codes that we tell configure to
prepare, but we do not actually want them built during normal operations
(tests and examples only).
However, there are some special targets brought by automake which still
need to see them, so this patch adds these directories to the list, but
only for these rules, we keep them unvisited by the normal build process.
The wanted side effect of this is that now "make distcheck" works untill
the end as expectable.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As reported by Andrew, the compilation of the WRaster broke because
there was an API change in libgif v5.1 versus the v5.0 (something had been
forgotten for DGifCloseFile to be easily used in wrappers for dynamic
languages).
Now, if we have detected that we're in 5.x release, we use the GIFLIB_MINOR
macro to see what the function prototype is (this macro was introduced only
in 4.1.6 so we cannot fully rely on it to detect the version of the
library).
The possible error code is not used because at the place we use the
function we would not be able do do anything more meaningful with it.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
It seems that the argument to the attribute 'deprecated' is a novelty of
gcc 4.x, the attribute introduced in gcc 3.x did not take any parameter.
As Solaris 10 is providing gcc 3.4.3, this patch updates the detection in
the public API header to make it compile properly.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
cppcheck is reporting:
[wrlib/tests/testgrad.c:148]: (error) Memory leak: color_name
but seems some other variables were never freed.
This patch is cleaning them property.
WRaster:
- new function 'RShutdown'
- removed flag 'optimize_for_speed' from RContext
- new functions '...(operate_xxx)', '...(flip_image)'
WUtil:
- new function 'wutil_shutdown'
- new macro 'wlengthof'
WINGs:
- new function 'WMReleaseApplication'
- new function 'WMCreateScaledBlendedPixmapFromFile'
(And maybe a few more I missed)
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The commit #d1f9b801 removed it because the code behind it is actually
useless, unfortunately removing the flag itself from the structure is
breaking the compatibility of the API.
To avoid problems, this patch re-introduces the flag in the structure, but
not the code behind it so it is useless, and adds an attribute so that gcc
will report its use as deprecated, to help application migration.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
It is generally not a good idea to have an API with a high number of
functions because it adds complexity for user and for maintainability,
so both function have been "merged" into a single RFlipImage with
a parameter to specify what flip is expected.
As a bonus, the function can perform both flips at once if wanted.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
As it does not cost anything in the current code to not add this channel,
it is then probably a good idea to keep the output image with the same
format as the input image, this avoid wasting +33% of memory for something
that may be at best unused and at worst will induce extra cost when
manipulating the image.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
Instead of calling all variables with variants of 'image', changed
the name to reflect what image it is about for clarity.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
The function RRotateImage contains code to handle efficiently the 4 simple
angles 0, 90, 180 and 270 degrees, which makes it a long function.
This patch separate the code for the different cases into dedicated
functions so the main function's code ends up being simple (aka: easier to
understand/review/maintain).
As a side effect, the function for the 180 degree function is not static
because it can be reused to flip an image both horizontally and vertically.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
When defining enums as types instead of simple enums allows to use these
types at the places where the corresponding enum values are expected, then
allowing the compiler to check that, potentially reporting incorrect use
of values to the user.
This patch adds the type for the gradient style for RRender*Gradient.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
When defining enums as types instead of simple enums allows to use these
types at the places where the corresponding enum values are expected, then
allowing the compiler to check that, potentially reporting incorrect use
of values to the user.
This patch adds the types for the drawing operations used by the functions
who drawing shapes into an RImage.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>
When defining enums as types instead of simple enums allows to use these
types at the places where the corresponding enum values are expected, then
allowing the compiler to check that, potentially reporting incorrect use
of values to the user.
This patch adds types for the configuration fields in the RContextAttributes
structure.
Signed-off-by: Christophe CURIS <christophe.curis@free.fr>