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.
This type discrimination did not seem to make much sense (why select between int
and short based on the sizes of long and int?), but more problematically was not
working as intended. This header does not include limits.h, so both LONG_MAX and
INT_MAX were undefined and this expression defaulted to 0 regardless of the
sizes of these types.
This removes yet another use of `ex->tmp` within exeval.c code. It is replaced
with a dynamically allocated buffer from vmalloc. This not only reduces reliance
on sfio, but is likely more efficient as data is written directly into a vmalloc
buffer rather than being written to an sfio buffer and then copied to a vmalloc
buffer. Related to #1998.
Upcoming changes refactor parts of this function and its current chaotic indent
style make these changes very error prone to apply. It is hoped that this
reformatting makes the upcoming change safer.
This reverts commit ab322d219b7dae03fe5f7114dfd0e1d2fc7d3b5d. A `realloc`
analogue appears to be the simplest way of removing sfputr/sfputc usage in
exeval.c. Related to #1998.