]> granicus.if.org Git - graphviz/log
graphviz
2 years agotests: svgAnalyzer: add throwing of exceptions for unimplemented attributes
Magnus Jacobsson [Sat, 30 Jul 2022 15:31:03 +0000 (17:31 +0200)]
tests: svgAnalyzer: add throwing of exceptions for unimplemented attributes

2 years agotests: SvgAnalyzer: add handling of the 'd' attribute
Magnus Jacobsson [Thu, 28 Jul 2022 10:58:49 +0000 (12:58 +0200)]
tests: SvgAnalyzer: add handling of the 'd' attribute

2 years agotests: SvgAnalyzer: add handling of the 'font-size' attribute
Magnus Jacobsson [Thu, 28 Jul 2022 10:13:08 +0000 (12:13 +0200)]
tests: SvgAnalyzer: add handling of the 'font-size' attribute

2 years agotests: SvgAnalyzer: add handling of the 'font-family' attribute
Magnus Jacobsson [Thu, 28 Jul 2022 10:00:50 +0000 (12:00 +0200)]
tests: SvgAnalyzer: add handling of the 'font-family' attribute

2 years agotests: SvgAnalyzer: add handling of the 'x' and 'y' attributes
Magnus Jacobsson [Thu, 28 Jul 2022 08:43:07 +0000 (10:43 +0200)]
tests: SvgAnalyzer: add handling of the 'x' and 'y' attributes

2 years agotests: SvgAnalyzer: add handling of the 'text-anchor' attribute
Magnus Jacobsson [Thu, 28 Jul 2022 08:27:29 +0000 (10:27 +0200)]
tests: SvgAnalyzer: add handling of the 'text-anchor' attribute

2 years agotests: SvgAnalyzer: add handling of the 'rx' and 'ry' attributes
Magnus Jacobsson [Wed, 27 Jul 2022 20:07:08 +0000 (22:07 +0200)]
tests: SvgAnalyzer: add handling of the 'rx' and 'ry' attributes

2 years agotests: SvgAnalyzer: add handling of the 'cx' and 'cy' attributes
Magnus Jacobsson [Wed, 27 Jul 2022 19:42:19 +0000 (21:42 +0200)]
tests: SvgAnalyzer: add handling of the 'cx' and 'cy' attributes

2 years agotests: SvgAnalyzer: add handling of the 'points' attribute
Magnus Jacobsson [Wed, 27 Jul 2022 14:17:28 +0000 (16:17 +0200)]
tests: SvgAnalyzer: add handling of the 'points' attribute

2 years agogvrender_core_svg: remove unnecessary space in the 'points' attribute for polyline
Magnus Jacobsson [Mon, 1 Aug 2022 11:27:38 +0000 (13:27 +0200)]
gvrender_core_svg: remove unnecessary space in the 'points' attribute for polyline

2 years agotests: SvgAnalyzer: add handling of the 'stroke' attribute
Magnus Jacobsson [Wed, 27 Jul 2022 13:40:08 +0000 (15:40 +0200)]
tests: SvgAnalyzer: add handling of the 'stroke' attribute

2 years agotests: SvgAnalyzer: add handling of the 'fill' attribute
Magnus Jacobsson [Wed, 27 Jul 2022 12:28:44 +0000 (14:28 +0200)]
tests: SvgAnalyzer: add handling of the 'fill' attribute

2 years agotests: SvgAnalyzer: add handling of the 'transform' attribute
Magnus Jacobsson [Wed, 27 Jul 2022 10:40:42 +0000 (12:40 +0200)]
tests: SvgAnalyzer: add handling of the 'transform' attribute

2 years agotests: SvgAnalyzer: add handling of the 'id' attribute
Magnus Jacobsson [Wed, 27 Jul 2022 09:05:08 +0000 (11:05 +0200)]
tests: SvgAnalyzer: add handling of the 'id' attribute

2 years agotests: SvgAnalyzer: add generation of the 'xmlns' and' xmlns:xlink' attributes
Magnus Jacobsson [Tue, 26 Jul 2022 19:40:01 +0000 (21:40 +0200)]
tests: SvgAnalyzer: add generation of the 'xmlns' and' xmlns:xlink' attributes

2 years agotests: SvgAnalyzer: add handling of the 'viewBox' attribute
Magnus Jacobsson [Tue, 26 Jul 2022 18:51:08 +0000 (20:51 +0200)]
tests: SvgAnalyzer: add handling of the 'viewBox' attribute

2 years agotests: SvgAnalyzer: add handling of the 'width' and 'height' attributes
Magnus Jacobsson [Tue, 26 Jul 2022 13:22:29 +0000 (15:22 +0200)]
tests: SvgAnalyzer: add handling of the 'width' and 'height' attributes

2 years agotests: SvgAnalyzer: add node and edge ID comments to the recreated SVG
Magnus Jacobsson [Fri, 29 Jul 2022 14:07:37 +0000 (16:07 +0200)]
tests: SvgAnalyzer: add node and edge ID comments to the recreated SVG

2 years agotests: SvgAnalyzer: add handling of the 'class' attribute
Magnus Jacobsson [Sat, 23 Jul 2022 10:50:06 +0000 (12:50 +0200)]
tests: SvgAnalyzer: add handling of the 'class' attribute

This will be used in an upcoming commit to identify Graphviz graphs,
nodes and edges.

2 years agotests: SvgAnalyzer: add comment with graph title (ID) to the recreated SVG
Magnus Jacobsson [Wed, 27 Jul 2022 12:28:44 +0000 (14:28 +0200)]
tests: SvgAnalyzer: add comment with graph title (ID) to the recreated SVG

2 years agotests: SvgAnalyzer: add storage of the Graphviz graph ID also on 'svg' element
Magnus Jacobsson [Fri, 29 Jul 2022 13:55:27 +0000 (15:55 +0200)]
tests: SvgAnalyzer: add storage of the Graphviz graph ID also on 'svg' element

2 years agotests: SvgAnalyzer: add storage of the Graphviz component ID on 'g' elements
Magnus Jacobsson [Mon, 25 Jul 2022 07:02:15 +0000 (09:02 +0200)]
tests: SvgAnalyzer: add storage of the Graphviz component ID on 'g' elements

2 years agotests: SvgAnalyzer: add Graphviz version and build date to the generated SVG string
Magnus Jacobsson [Mon, 25 Jul 2022 14:00:31 +0000 (16:00 +0200)]
tests: SvgAnalyzer: add Graphviz version and build date to the generated SVG string

2 years agogvc++: add GVContext::buildDate()
Magnus Jacobsson [Mon, 7 Mar 2022 12:37:54 +0000 (13:37 +0100)]
gvc++: add GVContext::buildDate()

2 years agogvc++: add GVContext::version()
Magnus Jacobsson [Mon, 7 Mar 2022 12:32:07 +0000 (13:32 +0100)]
gvc++: add GVContext::version()

2 years agotests: SvgAnalyzer: add handling of SVG element text node contents
Magnus Jacobsson [Mon, 25 Jul 2022 06:49:33 +0000 (08:49 +0200)]
tests: SvgAnalyzer: add handling of SVG element text node contents

2 years agotests: SvgAnalyzer: add handling of 'text' elements
Magnus Jacobsson [Sun, 24 Jul 2022 20:26:32 +0000 (22:26 +0200)]
tests: SvgAnalyzer: add handling of 'text' elements

2 years agotests: SvgAnalyzer: add an svg_string method
Magnus Jacobsson [Thu, 28 Jul 2022 11:56:26 +0000 (13:56 +0200)]
tests: SvgAnalyzer: add an svg_string method

2 years agotests: SvgAnalyzer: add internal re-creation of the SVG element hierarchy
Magnus Jacobsson [Thu, 21 Jul 2022 11:16:41 +0000 (13:16 +0200)]
tests: SvgAnalyzer: add internal re-creation of the SVG element hierarchy

This will be used in upcoming commits in this series to store
attributes on and to re-create the original SVG from. Also, an
upcoming commit series will extend the SVG analyzer to be aware of
Graphviz graphs, nodes and edges and will use this hierarchy and the
associated attributes to be able to answer questions about their
properties.

2 years agotests: add new test_svg_analyzer test skeleton
Magnus Jacobsson [Thu, 21 Jul 2022 11:16:41 +0000 (13:16 +0200)]
tests: add new test_svg_analyzer test skeleton

Upcoming commits will add functionality to the SVG analyzer and extend
this test.

2 years agotests: svgAnalyzer: remove useless const on pass-by-value parameter declarations
Magnus Jacobsson [Sun, 14 Aug 2022 15:03:58 +0000 (17:03 +0200)]
tests: svgAnalyzer: remove useless const on pass-by-value parameter declarations

2 years agotests: SvgAnalyzer: remove unused parameter names instead of void casting them to...
Magnus Jacobsson [Wed, 27 Jul 2022 09:37:20 +0000 (11:37 +0200)]
tests: SvgAnalyzer: remove unused parameter names instead of void casting them to avoid warnings

2 years agotests: svgAnalyzer: remove useless handling of 'any' SVG element
Magnus Jacobsson [Tue, 2 Aug 2022 14:26:00 +0000 (16:26 +0200)]
tests: svgAnalyzer: remove useless handling of 'any' SVG element

We haven't asked SVG++ to be called back for any element, just for
explicitly specified elements. Therefore we will never receive any
unknown elements that the SVG analyzer could count so this
functionality is also removed.

2 years agotests: SvgAnalyzer: remove useless extra 'private' access specifier
Magnus Jacobsson [Wed, 3 Aug 2022 08:28:13 +0000 (10:28 +0200)]
tests: SvgAnalyzer: remove useless extra 'private' access specifier

2 years agoMerge branch 'markhnsn-main-patch-73982' into 'main'
Matthew Fernandez [Sun, 14 Aug 2022 18:03:38 +0000 (18:03 +0000)]
Merge branch 'markhnsn-main-patch-73982' into 'main'

Replace wrong 'CELLSBORDER' in error message

See merge request graphviz/graphviz!2790

2 years agoReplace wrong 'CELLSBORDER' in error message
Mark Hansen [Sat, 13 Aug 2022 19:49:59 +0000 (19:49 +0000)]
Replace wrong 'CELLSBORDER' in error message

Should be 'CELLBORDER'.

See rationale at
https://gitlab.com/graphviz/graphviz.gitlab.io/-/issues/158

2 years agoMerge branch 'smattr/5768cfa8-e3ed-4e0f-b0e1-79f061a886cf' into 'main'
Matthew Fernandez [Sat, 13 Aug 2022 18:24:47 +0000 (18:24 +0000)]
Merge branch 'smattr/5768cfa8-e3ed-4e0f-b0e1-79f061a886cf' into 'main'

gvpr: remove long lived scratch SFIO buffer

See merge request graphviz/graphviz!2784

2 years agogvpr: remove 'Gpr_t.tmp'
Matthew Fernandez [Sun, 7 Aug 2022 17:30:23 +0000 (10:30 -0700)]
gvpr: remove 'Gpr_t.tmp'

As of the previous commit, this is no longer used.

Gitlab: #1873

2 years agogvpr colorx: use a local agxbuf instead of GVPR state’s 'tmp'
Matthew Fernandez [Sun, 7 Aug 2022 17:25:32 +0000 (10:25 -0700)]
gvpr colorx: use a local agxbuf instead of GVPR state’s 'tmp'

This makes it clearer to both humans and the compiler that the data written to
this buffer is not required beyond this function. This also gets us closer to
removing an SFIO dependency.

Gitlab: #1873

2 years agogvpr lookup: remove now unused 'state' parameter
Matthew Fernandez [Sun, 7 Aug 2022 17:15:11 +0000 (10:15 -0700)]
gvpr lookup: remove now unused 'state' parameter

2 years agoexpr: remove now unused 'disc' parameter to 'Exdisc_t.stringof'
Matthew Fernandez [Sun, 7 Aug 2022 17:10:43 +0000 (10:10 -0700)]
expr: remove now unused 'disc' parameter to 'Exdisc_t.stringof'

2 years agogvpr nameOf: use an agxbuf instead of SFIO stream
Matthew Fernandez [Sun, 7 Aug 2022 17:05:19 +0000 (10:05 -0700)]
gvpr nameOf: use an agxbuf instead of SFIO stream

This makes it clearer to both humans and the compiler that the data written to
this buffer has a much more constrained scope than was previously implied. This
also gets us closer to removing an SFIO dependency.

Gitlab: #1873

2 years agogvpr compile.c: wrap some long lines
Matthew Fernandez [Sun, 7 Aug 2022 16:47:02 +0000 (09:47 -0700)]
gvpr compile.c: wrap some long lines

This will make an upcoming change more readable.

2 years agogvpr traverse: use a local agxbuf instead of GVPR state’s 'tmp'
Matthew Fernandez [Sun, 7 Aug 2022 16:42:49 +0000 (09:42 -0700)]
gvpr traverse: use a local agxbuf instead of GVPR state’s 'tmp'

This makes it clearer to both humans and the compiler that the data written to
this buffer is not required beyond this function. This also gets us closer to
removing an SFIO dependency.

Gitlab: #1873

2 years agogvpr toUpper: rewrite to use a single buffer
Matthew Fernandez [Sun, 7 Aug 2022 16:31:24 +0000 (09:31 -0700)]
gvpr toUpper: rewrite to use a single buffer

`toUpper` worked by using the GVPR state’s temporary buffer, `tmp`, to
incrementally construct an uppercase copy of the input. This works but is
suboptimal. When printing to the temporary buffer, it has no knowledge of what
we are up to and needs to make heuristic-based decisions on how to allocate
memory. But we know the exact size of the result string already. This commit
takes advantage of this knowledge and allocates the destination memory upfront
and then simply writes directly into it. By doing this, we reduce heap pressure
and eliminate an intermediate copying operation.

This commit also renames the `s` parameter to something more descriptive.

Gitlab: #1873

2 years agogvpr toLower: rewrite to use a single buffer
Matthew Fernandez [Sun, 7 Aug 2022 16:24:43 +0000 (09:24 -0700)]
gvpr toLower: rewrite to use a single buffer

`toLower` worked by using the GVPR state’s temporary buffer, `tmp`, to
incrementally construct a lowercase copy of the input. This works but is
suboptimal. When printing to the temporary buffer, it has no knowledge of what
we are up to and needs to make heuristic-based decisions on how to allocate
memory. But we know the exact size of the result string already. This commit
takes advantage of this knowledge and allocates the destination memory upfront
and then simply writes directly into it. By doing this, we reduce heap pressure
and eliminate an intermediate copying operation.

This commit also renames the `s` parameter to something more descriptive.

Gitlab: #1873

2 years agoMerge branch 'svg-1.1-compliance' into 'main'
Matthew Fernandez [Sat, 13 Aug 2022 16:14:12 +0000 (16:14 +0000)]
Merge branch 'svg-1.1-compliance' into 'main'

Use "none" instead of "transparent" when painting in SVG

See merge request graphviz/graphviz!2472

2 years agoUse "none" instead of "transparent" when painting in SVG
Roger Nesbitt [Wed, 23 Feb 2022 16:42:25 +0000 (05:42 +1300)]
Use "none" instead of "transparent" when painting in SVG

The SVG 1.1 spec, which SVGs generated by gvrender_core_svg.c are
labeled as, does not have the color "transparent" available which is
causing issues with SVG 1.1 parsers.

When specifying paint in the fill or stroke attributes, use "none"
instead of "transparent".  When specifying a gradient color that has
zero opacity, use that color at zero opacity instead of "transparent".
When specifying a gradient with the graphviz transparent color, use
a zero-opacity black as this is how SVG interprets "transparent" in
gradients in SVG 2.0.

2 years agoMerge branch 'lib' into 'main'
Matthew Fernandez [Sat, 13 Aug 2022 03:16:34 +0000 (03:16 +0000)]
Merge branch 'lib' into 'main'

add doxygen comments to some lib directories

See merge request graphviz/graphviz!2762

2 years agoupdate cdt comment
Costa Shulyupin [Fri, 15 Jul 2022 05:29:45 +0000 (08:29 +0300)]
update cdt comment

2 years agovpsc doxygen comment
Costa Shulyupin [Fri, 15 Jul 2022 05:29:04 +0000 (08:29 +0300)]
vpsc doxygen comment

2 years agopathplan doxygen comments
Costa Shulyupin [Fri, 15 Jul 2022 05:28:13 +0000 (08:28 +0300)]
pathplan doxygen comments

2 years agolib/pack doxygen comments
Costa Shulyupin [Fri, 15 Jul 2022 05:26:42 +0000 (08:26 +0300)]
lib/pack doxygen comments

2 years agoGraphviz context library doxygen comments
Costa Shulyupin [Fri, 15 Jul 2022 04:52:12 +0000 (07:52 +0300)]
Graphviz context library doxygen comments

2 years agoMerge branch 'smattr/66e9b6f5-ee5b-43b3-ab61-435db8059def' into 'main'
Matthew Fernandez [Fri, 12 Aug 2022 05:23:50 +0000 (05:23 +0000)]
Merge branch 'smattr/66e9b6f5-ee5b-43b3-ab61-435db8059def' into 'main'

some agxbuf fixing and design polishing

See merge request graphviz/graphviz!2786

2 years agogvc gvPluginList: abbreviate an open coded 'strview_str'
Matthew Fernandez [Thu, 11 Aug 2022 02:35:17 +0000 (19:35 -0700)]
gvc gvPluginList: abbreviate an open coded 'strview_str'

2 years agoabbreviate 'agxbdisown' usage and remove 'agxbfree' calls
Matthew Fernandez [Thu, 11 Aug 2022 02:33:00 +0000 (19:33 -0700)]
abbreviate 'agxbdisown' usage and remove 'agxbfree' calls

As discussed in the previous commit, `agxbfree` following an `agxbdisown` is no
longer necessary.

2 years agocgraph agxbdisown: exit on allocation failure instead of returning NULL
Matthew Fernandez [Thu, 11 Aug 2022 02:14:08 +0000 (19:14 -0700)]
cgraph agxbdisown: exit on allocation failure instead of returning NULL

82b7d2021a7faa565065804df8b730a3213a8356 abbreviated some xdot code into a call
to `agxbdisown`. But it failed to account for the fact that `agxbdisown` could
return `NULL` on `strdup` failure, leaving still-allocated memory in the agxbuf.
Thus this commit introduced a new code path that leaked memory. I.e. the removed
call to `agxbfree` should have been retained.

So the obvious fix would be to re-add the `agxbfree` call, right? Well closer
inspection of agxbuf reveals another incongruity. agxbuf takes design decisions
based on the idea that the caller either cannot handle failure or does not want
to handle failure. It calls the alloc.h wrappers that exit on out-of-memory,
alleviating the caller from having to think about such things. Except for one
case: calling `strdup` in `agxbdisown`. Here it assumes the caller _does_ want
to handle failure. Except actually not, because it previously calls `agxbputc`
that conditionally calls `agxbmore` that exits on allocation failure. This is a
bit convoluted, but putting this all together we can see that the caller of
`agxbdisown` actually _cannot_ robustly recover from failure because, even if
they try to, `agxbmore` can still exit before they have a chance.

The way out of this quagmire is to adhere to the original principle more
strongly in `agxbdisown`. We assume, here too, that the caller does not want to
or cannot handle failure. `agxbdisown` now exits on all allocation failure
paths.

This has two coincidental beneficial side effects:

  1. In one case, we can leverage `gv_strndup` to avoid writing a trailing
     `'\0'` that is only for the purposes of immediately copying it somewhere
     else.

  2. Any caller of `agxbdisown` no longer needs to call `agxbfree` afterwards.
     In an analogy to C++, `agxbdisown` is effectively a move operator and
     destructor in one.

2 years agocgraph: clang-format agxbuf.h
Matthew Fernandez [Thu, 11 Aug 2022 02:05:53 +0000 (19:05 -0700)]
cgraph: clang-format agxbuf.h

We do not usually reformat existing code unless it is otherwise being edited.
But in this case the file was so close to compliant already, it seems worth it.

2 years agoMerge branch 'smattr/8EEAED96-8A05-4124-86F0-C7288D4113A6' into 'main'
Matthew Fernandez [Fri, 12 Aug 2022 04:26:25 +0000 (04:26 +0000)]
Merge branch 'smattr/8EEAED96-8A05-4124-86F0-C7288D4113A6' into 'main'

stop selectively disabling compiler optimization for MinGW

See merge request graphviz/graphviz!2787

2 years agostop selectively disabling compiler optimization for MinGW
Matthew Fernandez [Thu, 11 Aug 2022 02:54:43 +0000 (19:54 -0700)]
stop selectively disabling compiler optimization for MinGW

I do not know why these lines are here and the originating commit messages do
not explain either. Lets remove them and see what (if anything) breaks.

2 years agoMerge branch 'smattr/8eaea08d-5afc-48f7-a2f0-09cbc5a07181' into 'main'
Matthew Fernandez [Wed, 10 Aug 2022 16:46:07 +0000 (16:46 +0000)]
Merge branch 'smattr/8eaea08d-5afc-48f7-a2f0-09cbc5a07181' into 'main'

xdot warning squashing and some simplification

See merge request graphviz/graphviz!2785

2 years agoxdot parsePolyline: standardize on returning 'NULL' instead of '0'
Matthew Fernandez [Wed, 10 Aug 2022 15:49:06 +0000 (08:49 -0700)]
xdot parsePolyline: standardize on returning 'NULL' instead of '0'

2 years agoxdot: fuse adjacent 'print' calls
Matthew Fernandez [Wed, 10 Aug 2022 02:20:33 +0000 (19:20 -0700)]
xdot: fuse adjacent 'print' calls

This leads to shorter and more efficient code.

2 years agoxdot: inline and specialize 'printInt'
Matthew Fernandez [Wed, 10 Aug 2022 02:07:03 +0000 (19:07 -0700)]
xdot: inline and specialize 'printInt'

Squashes 8 compiler warnings and leads to simpler code.

2 years agoxdot: pass around a printf-like callback instead of fputs-like callback
Matthew Fernandez [Wed, 10 Aug 2022 01:45:44 +0000 (18:45 -0700)]
xdot: pass around a printf-like callback instead of fputs-like callback

This simplifies code, improves flexibility, and removes the need for some
intermediate buffers.

2 years agoxdot printAlign: squash -Wswitch-default warning
Matthew Fernandez [Wed, 10 Aug 2022 00:53:26 +0000 (17:53 -0700)]
xdot printAlign: squash -Wswitch-default warning

This switch is exhaustive.

2 years agoxdot parseXDotFOn: squash -Wsign-compare warning
Matthew Fernandez [Wed, 10 Aug 2022 00:44:27 +0000 (17:44 -0700)]
xdot parseXDotFOn: squash -Wsign-compare warning

2 years agoxdot parseString: squash -Wconversion warings
Matthew Fernandez [Wed, 10 Aug 2022 00:43:24 +0000 (17:43 -0700)]
xdot parseString: squash -Wconversion warings

`i` is known non-negative here.

2 years agoxdot parsePolyline: squash -Wconversion warning
Matthew Fernandez [Wed, 10 Aug 2022 00:39:45 +0000 (17:39 -0700)]
xdot parsePolyline: squash -Wconversion warning

This code parses an int, but then uses it to allocate an array, so clearly
should take the error path when the parsed int is negative.

2 years agoMerge branch 'smattr/b9770144-a277-4aac-8c6c-16d7b2b42a85' into 'main'
Matthew Fernandez [Wed, 10 Aug 2022 15:45:36 +0000 (15:45 +0000)]
Merge branch 'smattr/b9770144-a277-4aac-8c6c-16d7b2b42a85' into 'main'

gvpr warning squashing

See merge request graphviz/graphviz!2783

2 years agogvpr parseProg: squash -Wswitch-default warning
Matthew Fernandez [Sun, 7 Aug 2022 03:41:18 +0000 (20:41 -0700)]
gvpr parseProg: squash -Wswitch-default warning

This switch is exhaustive.

2 years agogvpr parseCase: squash -Wswitch-default warning
Matthew Fernandez [Sun, 7 Aug 2022 03:39:42 +0000 (20:39 -0700)]
gvpr parseCase: squash -Wswitch-default warning

This switch is exhaustive.

2 years agogvpr: cast values when calling 'endBracket'
Matthew Fernandez [Sun, 7 Aug 2022 03:34:16 +0000 (20:34 -0700)]
gvpr: cast values when calling 'endBracket'

Squashes 2 -Wconversion warnings and we know `c` is a char here.

2 years agogvpr: cast values when calling endString
Matthew Fernandez [Sun, 7 Aug 2022 03:30:01 +0000 (20:30 -0700)]
gvpr: cast values when calling endString

Squashes a -Wconversion warning and we know `c` is a char here.

2 years agoMerge branch 'smattr/3a899209-8743-447d-99f9-2c4a3a145265' into 'main'
Matthew Fernandez [Mon, 8 Aug 2022 15:54:50 +0000 (15:54 +0000)]
Merge branch 'smattr/3a899209-8743-447d-99f9-2c4a3a145265' into 'main'

cgraph: minor agxbuf ergonomics improvement

See merge request graphviz/graphviz!2782

2 years agoreplace NULL-hinted agxbuf usage with zero initialization
Matthew Fernandez [Sat, 30 Jul 2022 00:24:05 +0000 (17:24 -0700)]
replace NULL-hinted agxbuf usage with zero initialization

This leads to easy to read code and fewer things for the caller to think about.
I think this should probably become the default pattern for agxbuf usage for the
cases where the data you are printing is unpredictable or you are unsure.

2 years agocgraph: rename 'agxbuf.dyna' and flip its polarity
Matthew Fernandez [Sat, 30 Jul 2022 00:24:05 +0000 (17:24 -0700)]
cgraph: rename 'agxbuf.dyna' and flip its polarity

On the surface, this change looks a little odd – why care about what bit means
what in an internal field of a data structure? But this has an interesting side
effect. After this change, the zeroed state of an agxbuf is a valid 0-sized
dynamically allocated buffer, the same as the end state after `agxbdisown`. In
other words, C99 zero initialization (`agxbuf xb = {0}`) now defines a
reasonably “default” agxbuf state. This gives you all the benefits of the
previous “I don’t know how long my data will be so I’ll just use `BUFSIZ` as a
hint” approach with less typing and less hard coding. The next commit will roll
this out for some simplification in agxbuf usage.

2 years agocgraph agxbput_n: take an early exit when input string is zero
Matthew Fernandez [Sun, 7 Aug 2022 02:52:18 +0000 (19:52 -0700)]
cgraph agxbput_n: take an early exit when input string is zero

An upcoming change makes it possible to enter this function with `xb->ptr` as
`NULL`. It looks as if there is nothing wrong with this; a zero-sized string
fits in any agxbuf, including an unallocated one. However UBSan educates us that
calling `memcpy` with a `NULL` destination pointer is undefined behavior, even
when the passed size is 0. So this change avoids reaching `memcpy` when we know
the function will be a no-op.

Note that this is sort of fixing a latent bug, in that an agxbuf user could
already cause the scenario described above by `agxbdisown`ing an agxbuf and then
calling `agxbput_n` on it with size 0. However no existing callers do this.

2 years agocgraph: when an agxbuf to be expanded has 0 size, expand by 'BUFSIZ'
Matthew Fernandez [Sat, 30 Jul 2022 00:24:05 +0000 (17:24 -0700)]
cgraph: when an agxbuf to be expanded has 0 size, expand by 'BUFSIZ'

When calling `agxbmore` on a 0-sized buffer, the new size to expand to would be
chosen based on the length of the current string being appended. This string
often originated from user’s input graph and hence its length was often
user-defined. There is nothing strictly wrong with this, but it is a little
unpredictable and sometimes leads to pathological outcomes, e.g:

  agxbputc(&xb, 'a'); // expands 0-sized buffer to 1
  agxbputc(&xb, 'b'); // doubles 1-sized buffer to 2
  agxbputc(&xb, 'c'); // doubles 2-sized buffer to 4
  agxbputc(&xb, 'd');
  agxbputc(&xb, 'e'); // doubles 4-sized buffer to 8
  …

This is functionally correct, but that is a lot of `realloc` calls just to
accrue 5 bytes.¹ It is more convenient to enlarge our initial allocation to
something matching the default hint when an agxbuf is initialized.

The situation described above has not typically been a concern in the past
because a 0-sized agxbuf is hard to obtain to begin with. You need to either
call `agxbinit` while supplying your own backing storage that also has 0 size
(why would you do this?) or reuse an agxbuf after `agxbdisown` (technically
legal, but no good reason to do this). Neither of these scenarios occur anywhere
in the Graphviz tree to my knowledge. However an upcoming change will make
0-sized agxbufs more common.

¹ Some of these `realloc`s are likely no-ops, as the system allocator generally
  does not give you exactly 1 byte when you ask for 1. It will probably give you
  more and then when you ask to double to 2, it will tell you your existing
  pointer is just fine to keep on using. But the agxbuf code does not know any
  of these details and will still repeatedly call into `realloc`.

2 years agoMerge branch 'smattr/2BE494E7-8D54-4DBE-BAED-2190AF488504' into 'main'
Matthew Fernandez [Mon, 8 Aug 2022 14:56:43 +0000 (14:56 +0000)]
Merge branch 'smattr/2BE494E7-8D54-4DBE-BAED-2190AF488504' into 'main'

remove dotty, lefty, lneato

Closes #552 and #219

See merge request graphviz/graphviz!2779

2 years agoremove dotty, lefty, lneato
Matthew Fernandez [Wed, 3 Aug 2022 02:40:15 +0000 (19:40 -0700)]
remove dotty, lefty, lneato

Lefty, and its dependent tools Dotty and Lneato, have been suspected unused for
a long time. They were scheduled for removal, but we took a cautious and very
slow approach to this given how pervasive Graphviz is and the limited visibility
we have into its usage:

  1. 2021-09-25 make Lefty default to disabled in the build system¹
  2. 2022-01-16 disable Lefty in published graphviz.org packages²
  3. 2022-03-28 remove build system support³

This completes the final step of removing the code from the repository. It is
still retained in the history, should anyone need access to it or need to build
a past version of Graphviz with Lefty.

So far, we have only heard two notable reactions from the downstream world:

  1. Lefty disabling was not quite complete on the first attempt.⁴
  2. There has been an offer of assistance to maintain Lefty.⁵ No patches have
     yet emerged, but if and when they do we could feasibly reverse direction on
     this and reinstate Lefty and friends.

Gitlab: closes #219, closes #552, related to #1836, #1854

¹ 1a4ad00b59cc1e1e9302fcbd1a205495ee59cab5
² 04a78cc9ae01b2a7e5d5435146cd503c45af90b9
³ 6faa34010f947510ec129af2d998614de8a513ed
⁴ https://gitlab.com/graphviz/graphviz/-/issues/2153
⁵ https://forum.graphviz.org/t/lefty-not-a-graphviz-application/835/6

2 years agoremove legacy Dotty, Lefty, Lneato references from man pages
Matthew Fernandez [Wed, 3 Aug 2022 03:06:43 +0000 (20:06 -0700)]
remove legacy Dotty, Lefty, Lneato references from man pages

2 years agogvpr endString: squash -Wconversion warning
Matthew Fernandez [Sun, 7 Aug 2022 03:28:51 +0000 (20:28 -0700)]
gvpr endString: squash -Wconversion warning

`c` is known to be a character here.

2 years agogvpr parseID: squash -Wconversion warnings
Matthew Fernandez [Sun, 7 Aug 2022 03:27:43 +0000 (20:27 -0700)]
gvpr parseID: squash -Wconversion warnings

`c` is known to be a character here.

2 years agogvpr pop: remove 'delete' parameter that is always 1 and unused 'head'
Matthew Fernandez [Sun, 7 Aug 2022 03:21:45 +0000 (20:21 -0700)]
gvpr pop: remove 'delete' parameter that is always 1 and unused 'head'

2 years agogvpr freef: squash -Wunused-parameter warnings
Matthew Fernandez [Sun, 7 Aug 2022 03:16:19 +0000 (20:16 -0700)]
gvpr freef: squash -Wunused-parameter warnings

These cannot easily be removed because this function is used as a callback.

2 years agogvpr makef: squash -Wunused-parameter warnings
Matthew Fernandez [Sun, 7 Aug 2022 03:15:42 +0000 (20:15 -0700)]
gvpr makef: squash -Wunused-parameter warnings

These cannot easily be removed because this function is used as a callback.

2 years agoMerge branch 'smattr/03db530d-2fe9-47e3-b566-bda45c2928ce' into 'main'
Matthew Fernandez [Sat, 6 Aug 2022 19:13:43 +0000 (19:13 +0000)]
Merge branch 'smattr/03db530d-2fe9-47e3-b566-bda45c2928ce' into 'main'

expr: replace 'exdump' SFIO buffer with an 'agxbuf'

See merge request graphviz/graphviz!2781

2 years agoexpr: remove unused parameters from 'Exdisc_t.matchf'
Matthew Fernandez [Fri, 5 Aug 2022 04:43:03 +0000 (21:43 -0700)]
expr: remove unused parameters from 'Exdisc_t.matchf'

I guess when I committed 260f650085eb25b5b68c81a5960232d025fb6942 it was not
obvious to me that this is entirely part of private internal interfaces and the
callback signature involved is not exposed publicly.

2 years agoexpr: remove unused parameters from 'Exdisc_t.setf'
Matthew Fernandez [Fri, 5 Aug 2022 04:35:28 +0000 (21:35 -0700)]
expr: remove unused parameters from 'Exdisc_t.setf'

I guess when I committed 5b4de3922a2f169c2e773ffe85651898aedd9351 it was not
obvious to me that this is entirely part of private internal interfaces and the
callback signature involved is not exposed publicly.

2 years agoexpr: remove dereferencing and parens around calling 'Exdisc_t.keyf'
Matthew Fernandez [Fri, 5 Aug 2022 04:29:21 +0000 (21:29 -0700)]
expr: remove dereferencing and parens around calling 'Exdisc_t.keyf'

The compiler does not need to be explicitly told how to call through a function
pointer.

2 years agoexpr: remove unused parameters from 'Exdisc_t.keyf'
Matthew Fernandez [Fri, 5 Aug 2022 04:28:01 +0000 (21:28 -0700)]
expr: remove unused parameters from 'Exdisc_t.keyf'

I guess when I committed 2e9753d9c9886f5bc013212420528e9a18bc592b it was not
obvious to me that this is entirely part of private internal interfaces and the
callback signature involved is not exposed publicly.

2 years agoexpr: remove dereferencing and parens around calling 'Exdisc_t.stringof'
Matthew Fernandez [Fri, 5 Aug 2022 04:23:19 +0000 (21:23 -0700)]
expr: remove dereferencing and parens around calling 'Exdisc_t.stringof'

The compiler does not need to be explicitly told how to call through a function
pointer.

2 years agoexpr: remove dereferencing and parens around calling 'Exdisc_t.typename'
Matthew Fernandez [Fri, 5 Aug 2022 04:21:45 +0000 (21:21 -0700)]
expr: remove dereferencing and parens around calling 'Exdisc_t.typename'

The compiler does not need to be explicitly told how to call through a function
pointer.

2 years agoexpr: remove unused 'pg' parameter from 'Exdisc_t.typename'
Matthew Fernandez [Fri, 5 Aug 2022 04:20:54 +0000 (21:20 -0700)]
expr: remove unused 'pg' parameter from 'Exdisc_t.typename'

2 years agoexpr: remove dereferencing and parens around calling 'Exdisc_t.binaryf'
Matthew Fernandez [Fri, 5 Aug 2022 04:16:27 +0000 (21:16 -0700)]
expr: remove dereferencing and parens around calling 'Exdisc_t.binaryf'

The compiler does not need to be explicitly told how to call through a function
pointer.

2 years agoexpr: remove unused parameters from 'Exdisc_t.binaryf'
Matthew Fernandez [Fri, 5 Aug 2022 04:15:09 +0000 (21:15 -0700)]
expr: remove unused parameters from 'Exdisc_t.binaryf'

I guess when I committed b0ec7b2eb448a2cb68ffb3751e9e054aecc60c24 it was not
obvious to me that this is entirely part of private internal interfaces and the
callback signature involved is not exposed publicly.

2 years agoexpr: remove dereferencing and parens around calling 'Exdisc_t.convertf'
Matthew Fernandez [Fri, 5 Aug 2022 04:10:26 +0000 (21:10 -0700)]
expr: remove dereferencing and parens around calling 'Exdisc_t.convertf'

The compiler does not need to be explicitly told how to call through a function
pointer.

2 years agoexpr: remove unused parameters from 'Exdisc_t.convertf'
Matthew Fernandez [Fri, 5 Aug 2022 04:07:55 +0000 (21:07 -0700)]
expr: remove unused parameters from 'Exdisc_t.convertf'

I guess when I committed 17479ab6569d40a4778870f712226aa7916f3ca3 it was not
obvious to me that this is entirely part of private internal interfaces and the
callback signature involved is not exposed publicly.