fix dangerous-default-value issues in gvtest.py test suite support
Pylint warns that using `[]` as a default is dangerous due to modifications to
the parameter unintentionally persisting across calls. I do not believe that
happens in this case, but it is better to rephrase this code to pacify Pylint
and make it clearer to readers that this is not happening.
Magnus Jacobsson [Mon, 26 Jul 2021 14:51:16 +0000 (16:51 +0200)]
common: add declaration of drand48 to utils.h when the system doesn't have it
This function is implemented in utils.c when not available otherwise.
Removes this warning with MinGW:
C:/Users/magja/graphviz/lib/fdpgen/tlayout.c:597:33: warning: implicit declaration of function 'drand48'; did you mean 'srand48'? [-Wimplicit-function-declaration]
597 | double angle = PItimes2 * drand48();
| ^~~~~~~
| srand48
Magnus Jacobsson [Sat, 24 Jul 2021 10:57:04 +0000 (12:57 +0200)]
common: remove weak declaration of drand48 that causes it to be undefined with MinGW
Fixes this error with MinGW:
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot export drand48: symbol not defined
C:/tools/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.3.0/../../../../x86_64-w64-mingw32/bin/ld.exe: ../ortho/CMakeFiles/ortho_obj.dir/partition.c.obj:partition.c:(.text+0x4de): undefined reference to `drand48'
Towards https://gitlab.com/graphviz/graphviz/-/issues/2102.
There is no need to generate this file. It contains statically known content.
Generating it was proving a maintenance headache across the three build systems.
Related to #2102.
Graph [Mon, 16 Aug 2021 16:19:41 +0000 (00:19 +0800)]
quartz plugin: Fix the graph rotation
When graph is set to be landscape (rotate = 90), quartz renderer seems to rotate
the image incorrectly. In order to make a top-to-bottom image left-to-right
(i.e. landscape), we will need to:
1. Set the anchor point to the left-bottom corner.
2. Rotate counterclockwise by 90 degrees around the anchor point.
3. Translate from left to right by original height of the image.
In step 2, the second parameter of the CGContextRotateCTM should be positive
according to the documentation.¹
Visio plugin: manage Texts by value instead of pointer
The Text class does not participate in any inheritance hierarchy and Text
objects that are constructed have a well-defined lifetime. So we can manage them
as objects instead of pointers to heap-allocated data. This simplifies some code
and allows avoiding some manual memory management.
Magnus Jacobsson [Tue, 17 Aug 2021 04:43:44 +0000 (06:43 +0200)]
dotgen: fix: defined but unused 'setEdgeLabelPos' function in builds without ortho
Fixes this warning when building without ortho.
lib/dotgen/dotsplines.c:278:1: warning: ‘setEdgeLabelPos’ defined but not used [-Wunused-function]
278 | setEdgeLabelPos (graph_t * g)
| ^~~~~~~~~~~~~~~
Magnus Jacobsson [Tue, 17 Aug 2021 04:36:16 +0000 (06:36 +0200)]
dotgen: fix: defined but unused label 'finish' in builds without ortho
Fixes this warning when building without ortho.
lib/dotgen/dotsplines.c: In function ‘_dot_splines’:
lib/dotgen/dotsplines.c:530:1: warning: label ‘finish’ defined but not used [-Wunused-label]
530 | finish :
| ^~~~~~
Magnus Jacobsson [Sat, 14 Aug 2021 09:23:28 +0000 (11:23 +0200)]
CMake: add with_zlib option
The zlib library is already optional. This option allows the user to
explictly not use it even if they have it.
This will be used in an upcoming commit to add a minimal CMake build
job to CI which will test that it is possible to build Graphviz
without any of the optional libraries.
Magnus Jacobsson [Fri, 13 Aug 2021 12:39:12 +0000 (14:39 +0200)]
gvc: CMake: fix: link to zlib only if we have it
Fixes the following error when we don't have zlib:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
ZLIB_LIBRARY
linked by target "gvc" in directory C:/Users/magja/graphviz/lib/gvc
Magnus Jacobsson [Sat, 14 Aug 2021 09:23:09 +0000 (11:23 +0200)]
CMake: add with_expat option
The expat library is already optional. This option allows the user to
explictly not use it even if they have it.
This will be used in an upcoming commit to add a minimal CMake build
job to CI which will test that it is possible to build Graphviz
without any of the optional libraries.
There's however no need to specify anything more then the ltdl name
itself since CMake does this kind of magic automatically. From
https://cmake.org/cmake/help/latest/command/find_library.html:
"Each library name given to the NAMES option is first considered as a
library file name and then considered with platform-specific prefixes
(e.g. lib) and suffixes (e.g. .so)."
Magnus Jacobsson [Fri, 13 Aug 2021 13:32:22 +0000 (15:32 +0200)]
CMake: fix: find the LTDL package only if the enable_ltdl option is ON
Fixes this error when we don't have ltdl:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
C:/Users/magja/graphviz/lib/gvc/LTDL_INCLUDE_DIR
used as include directory in directory C:/Users/magja/graphviz/lib/gvc
There is another problem when the LTDL library is not available that
will be fixed in an upcoming commit, hence no changelog entry yet.
Magnus Jacobsson [Mon, 16 Aug 2021 17:42:48 +0000 (19:42 +0200)]
gvc: CMake: fix: use the ltdl include dir only if we have it
Fixes this error when we don't have ltdl:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
C:/Users/magja/graphviz/lib/gvc/LTDL_INCLUDE_DIR
used as include directory in directory C:/Users/magja/graphviz/lib/gvc
On Windows, we currently only use the ltdl compatibility header
introduced in d70cdba7937724c19393d97bd280320cdf8c3c8f, not the link
library itself. Hence the WIN32 OR MINGW guard for the link library,
but not for the include directory.
There are other problems when the LTDL library is not available that
will be fixed in upcoming commits, hence no changelog entry yet.
gvc: CMake: fix: link to the ltdl lib only if we have it
Before this we tried to use the ltdl link library when not on Windows,
regardless of whether we found it or not. On Windows, we currently
only use the ltdl compatibility header introduced in d70cdba7937724c19393d97bd280320cdf8c3c8f, not the link library itself.
Fixes the LTDL_LIBRARY part of the following error on non-Windows
systems when we don't have ltdl:
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
/home/magjac/graphviz/lib/gvc/LTDL_INCLUDE_DIR
used as include directory in directory /home/magjac/graphviz/lib/gvc
LTDL_LIBRARY (ADVANCED)
linked by target "gvc" in directory /home/magjac/graphviz/lib/gvc
There are other problems when the LTDL library is not available that
will be fixed in upcoming commits, hence no changelog entry yet.
After the prior type signature changes, this string no longer needs to be
dynamically allocated. This also fixes a memory leak that would occur when
passing the -c command line argument multiple times.
Render_Contour2: allocate vertices as a single block
Rather than an array of pointers and then individual allocations for each
vertex, we can simply allocate a single block ahead of time. This decreases
memory requirements and increases cache locality. Note that this does nothing
about the fairly egregious memory leak in this code.
It is clear from surrounding code that this was attempting to allocate an array
of GLdouble *pointers*, not an array of GLdoubles. It is unlikely this would
have caused any noticeable issues as sizeof(GLdouble) is typically greater than
sizeof(GLdouble*), but nevertheless the calculation was incorrect. This change
not only corrects this, but uses the more appropriate calloc instead of malloc
for array allocation.
The CMake build system was setup to unconditionally install man pages to man3.
This is only correct for libraries, whose man pages have the extension .3.
Binaries have man pages with the extension .1 and were intended to be installed
in man1. Now both go to the correct man subdirectory. Fixes #1936.
agsafeset: take const pointers for 'value' and 'def' arguments
Neither of these are modified by this function. Closes #634. I believe this is
the last Cgraph function currently able to receive a modification like this.
This function is only ever called with `agattr` as this parameter. Removing this
takes care of the sole use of `agattr` with a function pointer, clearing the way
to modify the type signature of `agattr`. Related to #634.
cmake: remove ability to override GRAPHVIZ_VERSION_BUILD
Commit 705ced5fa22ba13f239adfe1ba45713553c1fe05 added the ability to override
the Graphviz version from the command line when configuring the CMake build
system. This is not currently in use and does not seem desirable to maintain
going forwards.