sccmap: replace inline stack with generation implementation
Similar to previous changes to `gc` in 4e2875fd7376338259dcb3ccc8f029d58bdf22dd,
this replaces some duplicated functionality with the generic Graphviz stack
implementation. This also introduces some missing allocation failure checks.
Without this change, attempting to include geomproc.h in render.h
would cause the following warning:
In file included from /home/magjac/graphviz/lib/common/shapes.c:12:
/home/magjac/graphviz/lib/common/render.h:24: warning: "__USE_GNU" redefined
24 | #define __USE_GNU
|
In file included from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
from /usr/include/limits.h:26,
from /usr/lib/gcc/x86_64-linux-gnu/11/include/limits.h:203,
from /usr/lib/gcc/x86_64-linux-gnu/11/include/syslimits.h:7,
from /usr/lib/gcc/x86_64-linux-gnu/11/include/limits.h:34,
from /home/magjac/graphviz/lib/common/arith.h:21,
from /home/magjac/graphviz/lib/common/geom.h:16,
from /home/magjac/graphviz/lib/common/geomprocs.h:21,
from /home/magjac/graphviz/lib/common/shapes.c:11:
/usr/include/features.h:407: note: this is the location of the previous definition
407 | # define __USE_GNU 1
|
This is casued by arith.h defining _GNU_SOURCE to 1 which seems to
implicitly set __USE_GNU.
gml2gv: replace 'liststk' stack with generic implementation
Similar to previous changes to `gc` in 4e2875fd7376338259dcb3ccc8f029d58bdf22dd,
this replaces some duplicated functionality with the generic Graphviz stack
implementation. This also introduces some missing allocation failure checks.
graphml2gv: replace custom 'slist' string stack with generic stack
Similar to previous changes to `gc` in 4e2875fd7376338259dcb3ccc8f029d58bdf22dd,
this replaces some duplicated functionality with the generic Graphviz stack
implementation. Apart from reducing code duplication and complexity, this
removes an unnecessary rounding of allocations. The prior code rounded up
`slist` allocations to `sizeof(void*)`, but `malloc` effectively does this
internally anyway.
graphml2gv: replace inline stack implementation with generic API
Similar to previous changes to `gc` in 4e2875fd7376338259dcb3ccc8f029d58bdf22dd,
this replaces some duplicated functionality with the generic Graphviz stack
implementation. This removes the previously hard coded nested subgraph limit of
32. The number of supported subgraphs in now solely limited by available memory.
bcomps: replace inline stack implementation with generic API
Similar to previous changes to `gc` in 4e2875fd7376338259dcb3ccc8f029d58bdf22dd,
this replaces some duplicated functionality with the generic Graphviz stack
implementation.
David Seifert [Sat, 16 Apr 2022 16:00:18 +0000 (18:00 +0200)]
Define `$(pkgconfigdir)` using `PKG_INSTALLDIR` in configure.ac
* This allows overriding the default using `--with-pkgconfigdir`
passed to the configure script. FreeBSD for instance doesn't use
the standard `$libdir/pkgconfig` directory. This macro has been
present in pkg.m4 for over 9 years:
https://gitlab.freedesktop.org/pkg-config/pkg-config/-/commit/5fc77a96b7a1114e296f968037342f060d4bc34b
David Seifert [Sat, 16 Apr 2022 16:00:18 +0000 (18:00 +0200)]
`$(txtdir)` -> `$(docdir)`
* All documentation directories should be a function of `$(docdir)`, and
not `$(datadir)`, which is to be used for files that the program
actually needs at runtime.
* Also amend the debian install rules, since documentation is now
natively installed into `$(docdir)` == `usr/share/doc/graphviz`.
David Seifert [Sat, 16 Apr 2022 16:00:18 +0000 (18:00 +0200)]
Let Autoconf set `$(htmldir)`
* The previous variable would not respect `--docdir` passed to configure.
Autoconf sets `$(htmldir)` to `$(docdir)` by default and AC_SUBST()s
this value.
David Seifert [Sat, 16 Apr 2022 16:00:18 +0000 (18:00 +0200)]
Let Autoconf set `$(pdfdir)`
* The previous variable would not respect `--docdir` passed to configure.
Autoconf sets `$(pdfdir)` to `$(docdir)` by default and AC_SUBST()s
this value.
tred: [nfc] replace inline stack implementation with generic API
Similar to previous changes to `gc` in 4e2875fd7376338259dcb3ccc8f029d58bdf22dd,
this replaces some duplicated functionality with the generic Graphviz stack
implementation.
David Seifert [Thu, 14 Apr 2022 08:23:49 +0000 (10:23 +0200)]
Prefer `dist_` prefix over `EXTRA_DIST`
* `dist_` expresses the clear intent for files to be distributed along in the tarball:
https://www.gnu.org/software/automake/manual/html_node/Program-and-Library-Variables.html
David Seifert [Thu, 14 Apr 2022 08:23:49 +0000 (10:23 +0200)]
Use Autoconf recommended path quoting
* `-DDATADIR='"$(datadir)"'` is less error-prone than `-DDATADIR=\""$(datadir)"\"`
since the shell will handle the correct escaping of the double quotes:
https://www.gnu.org/software/autoconf/manual/autoconf-2.71/html_node/Defining-Directories.html
ccomps: replace inline stack implementation with generic API
Similar to previous changes to `gc` in 4e2875fd7376338259dcb3ccc8f029d58bdf22dd,
this replaces some duplicated functionality with the generic Graphviz stack
implementation.
To further reinforce this, it is worth observing that they were not usable in
the CMake build system. 5b620771b7e5f07529ff7a41177ae27048c91865, despite
correcting an absence of sprint.h, failed to also correct the absence of
sprint.c. Any attempt to use these functions resulted in link failures in the
CMake build.
CMake: fix: use a relative 'DATA_INSTALL_DIR' on non-Linux
Some installers like NSIS on Windows do not allow absolute paths in installation
destinations. This is already followed in e.g. `BINARY_INSTALL_DIR`, but
`DATA_INSTALL_DIR` was using an absolute path. This issue was not detected
because this is currently only used in Smyrna which is not enabled on Windows in
CI. But an upcoming commit enables general example installation, which exposes
this issue.
gc: replace inline stack implementation with generic one
This code was using two abstractions, a block `blk_t` and stack `stk_t`, to
amortize the cost of allocations. We can remove the block abstraction and
rewrite the stack implementation to use the simpler generic stack while still
retaining these amortization benefits. Note that this refactoring also makes
initialization of the stack data structure unnecessary as a zeroed `gv_stack_t`
is also a valid empty stack.
The new code also deallocates the stack prior to exit, aiding tools like
Valgrind and Address Sanitizer.
This pattern of using both a hand-rolled block and hand-rolled stack appears in
numerous places in the Graphviz code base, of which this is just one instance.
Similar to prior abstractions like `bitarray_t`, this is implemented header-only
so as to be usable throughout the Graphviz tree, even by code that is not
linking against cgraph.
Given this implementation is header-only, it is natural to wonder why the type
needs a `gv_` prefix. The answer is that one of the macOS system headers flouts
the rule of `__` prefixing symbols that are part of the implementation and
defines a typedef of `__darwin_sigaltstack` under the name `stack_t`. Hence this
name is not usable by us.
macOS provides an `INT8_C` macro that generates an `int`, not an `int8_t`, which
ends up resulting in this code generating `printf` format warnings. An upcoming
commit which enables `-Werror` on this code causes test failures without this.