]> granicus.if.org Git - graphviz/log
graphviz
2 years agosmyrna: fix memory leak in 'mTestgvpr'
Matthew Fernandez [Sat, 9 Jul 2022 15:17:44 +0000 (08:17 -0700)]
smyrna: fix memory leak in 'mTestgvpr'

Even when a text field is empty, calling `gtk_text_buffer_get_text` returns a
dynamically allocated (empty) string that must be freed.

2 years agosmyrna load_attributes: use a string view for 'ss'
Matthew Fernandez [Sun, 10 Jul 2022 18:03:02 +0000 (11:03 -0700)]
smyrna load_attributes: use a string view for 'ss'

This code contained multiple memory leaks and unchecked allocations:¹

  1. `pch` was `strdup`-ed into `ss` on line 58. But `strdup`-ed again when
     being saved to an `attr` field. This lost the memory originating from the
     first `strdup`.

  2. Cases 0, 3, and 4 of the switch do not save the full contents of `ss` at
     all. This means naively removing the `strdup` calls in cases 1, 2, and
     default would not have solved the memory leak in (1) because cases 0, 3,
     and 4 would still leak memory.

  3. None of the `strdup` calls in this function were checked for failure.

This commit attempts to solve all the above. We now take a read-only reference
to the string data on line 58 and only `strdup` it when needed.

¹ It also assumes all lines of the input file are fewer characters than
  `BUFSIZ`, a platform-dependent constant. I do not know why this would be
  guaranteed. However, this problem seems orthogonal to the above.

2 years agocgraph: add a 'strdup' equivalent for 'strview_t'
Matthew Fernandez [Sun, 10 Jul 2022 17:53:54 +0000 (10:53 -0700)]
cgraph: add a 'strdup' equivalent for 'strview_t'

This will be used in an upcoming commit.

2 years agocgraph: add a 'strstr' equivalent for 'strview_t'
Matthew Fernandez [Sun, 10 Jul 2022 17:50:42 +0000 (10:50 -0700)]
cgraph: add a 'strstr' equivalent for 'strview_t'

This will be used in an upcoming commit.

2 years agosmyrna: simplify outer 'load_attributes' loop
Matthew Fernandez [Sat, 9 Jul 2022 15:13:48 +0000 (08:13 -0700)]
smyrna: simplify outer 'load_attributes' loop

This loop contains no `continue` statements, its counter is incremented in a
regular way, and the counter is unused outside the loop. So we can write the
loop more concisely and scope `attrcount` more tightly by using a `for` loop
instead of a `while` loop.

2 years agosmyrna: simplify inner 'load_attributes' loop
Matthew Fernandez [Sat, 9 Jul 2022 15:11:44 +0000 (08:11 -0700)]
smyrna: simplify inner 'load_attributes' loop

This loop contains no `continue` statements, its counter is incremented in a
regular way, and the counter is unused outside the loop. So we can write the
loop more concisely and scope `ind` more tightly by using a `for` loop instead
of a `while` loop.

2 years agosmyrna: remove an unnecessary 'strdup'
Matthew Fernandez [Sat, 9 Jul 2022 15:05:04 +0000 (08:05 -0700)]
smyrna: remove an unnecessary 'strdup'

Pointers `getopt` returns in `optarg` point into the original `argv` which lives
in immortal storage. There is no need to duplicate such a pointer to prolong its
lifetime.

2 years agocgraph: fix a missing header guard
Matthew Fernandez [Sun, 10 Jul 2022 02:44:32 +0000 (19:44 -0700)]
cgraph: fix a missing header guard

2 years agoMerge branch 'smattr/53F5F123-E14D-494D-B685-B8F9C64A50DD' into 'main'
Matthew Fernandez [Fri, 15 Jul 2022 01:17:44 +0000 (01:17 +0000)]
Merge branch 'smattr/53F5F123-E14D-494D-B685-B8F9C64A50DD' into 'main'

mm2gv: remove unused 'mm_typecode_to_str'

See merge request graphviz/graphviz!2753

2 years agomm2gv: remove unused 'mm_typecode_to_str'
Matthew Fernandez [Sun, 10 Jul 2022 19:40:58 +0000 (12:40 -0700)]
mm2gv: remove unused 'mm_typecode_to_str'

2 years agomm2gv SparseMatrix_import_matrix_market: replace an 'assert' with 'UNREACHABLE'
Matthew Fernandez [Sun, 10 Jul 2022 19:39:36 +0000 (12:39 -0700)]
mm2gv SparseMatrix_import_matrix_market: replace an 'assert' with 'UNREACHABLE'

This is slightly clearer and yields more reliable error behavior.

2 years agoMerge branch 'types-h' into 'main'
Matthew Fernandez [Sun, 10 Jul 2022 01:30:24 +0000 (01:30 +0000)]
Merge branch 'types-h' into 'main'

types.h: doxygen comments

See merge request graphviz/graphviz!2742

2 years agotypes.h: doxygen comments
Costa Shulyupin [Tue, 5 Jul 2022 16:16:50 +0000 (19:16 +0300)]
types.h: doxygen comments

2 years agoMerge branch 'smattr/72B145EF-707C-4237-AEAC-A88969A1AF9F' into 'main'
Matthew Fernandez [Sat, 9 Jul 2022 23:43:12 +0000 (23:43 +0000)]
Merge branch 'smattr/72B145EF-707C-4237-AEAC-A88969A1AF9F' into 'main'

cgraph: some warning squashing

See merge request graphviz/graphviz!2743

2 years agocgraph: more uniform treatment of sequence IDs
Matthew Fernandez [Wed, 6 Jul 2022 00:24:05 +0000 (17:24 -0700)]
cgraph: more uniform treatment of sequence IDs

Sequence IDs are calculated using 64-bit counters in `Agclos_s`. But then the
field used to store sequence IDs, `Agtag_s.seq`, is `sizeof(unsigned) * 8 - 4`
bits wide, 28-bit on x86 and x86-64. As a result, the compiler believes IDs that
exceed 2²⁸ - 1 can occur and overflow `Agtag_s.seq`:

  edge.c:213:30: warning: conversion from 'int' to 'unsigned int:28' may change
    value [-Wconversion]
  213 |     AGSEQ(in) = AGSEQ(out) = seq;
      |                              ^~~
  ...
  graph.c: In function 'agopen1':
  graph.c:77:20: warning: conversion from 'uint64_t' {aka 'long unsigned int'}
    to 'unsigned int:28' may change value [-Wconversion]
   77 |         AGSEQ(g) = agnextseq(par, AGRAPH);
      |                    ^~~~~~~~~
  ...
  node.c: In function 'newnode':
  node.c:76:16: warning: conversion from 'uint64_t' {aka 'long unsigned int'} to
    'unsigned int:28' may change value [-Wconversion]
   76 |     AGSEQ(n) = seq;
      |                ^~~
  ...
  node.c: In function 'agnodebefore':
  node.c:359:22: warning: conversion from 'uint64_t' {aka 'long unsigned int'}
    to 'unsigned int:28' may change value [-Wconversion]
  359 |         AGSEQ(snd) = (g->clos->seq[AGNODE] + 2);
      |                      ^

In practice, ingesting a graph of this size is not achievable, so these
overflows cannot occur.

This change introduces assertions and casts in these cases to explain the
assumptions to the compiler. It squashes the above warnings. In future, perhaps
these fields should all be made to all consistently use the same type.

2 years agocgraph: rephrase ID comparison in 'agraphidcmpf'
Matthew Fernandez [Wed, 6 Jul 2022 00:24:05 +0000 (17:24 -0700)]
cgraph: rephrase ID comparison in 'agraphidcmpf'

Avoids a possible integer overflow and squashes a -Wsign-conversion warning.

2 years agocgraph: remove unnecessary casts in 'agraphidcmpf'
Matthew Fernandez [Wed, 6 Jul 2022 00:24:05 +0000 (17:24 -0700)]
cgraph: remove unnecessary casts in 'agraphidcmpf'

2 years agoMerge branch 'smattr/52D7B067-5BE8-44F3-AC13-6CA93F46B9A5' into 'main'
Matthew Fernandez [Sat, 9 Jul 2022 20:24:23 +0000 (20:24 +0000)]
Merge branch 'smattr/52D7B067-5BE8-44F3-AC13-6CA93F46B9A5' into 'main'

CI: some minor fixes to the deployment script

See merge request graphviz/graphviz!2748

2 years agoCI: call Windows ZIP artifact 'archive' not 'installer'
Matthew Fernandez [Fri, 8 Jul 2022 02:29:15 +0000 (19:29 -0700)]
CI: call Windows ZIP artifact 'archive' not 'installer'

This is what the website’s JSON has always called this artifact, but a mistake
in 32b91edef64d1c726c88c7a7d6e68239399cc358 labelled this 'installer' instead.

2 years agoCI: remove legacy TODO in deploy script
Matthew Fernandez [Fri, 8 Jul 2022 02:28:11 +0000 (19:28 -0700)]
CI: remove legacy TODO in deploy script

This was addressed in 6117abe680037824d134149b0de42f589fb24466, with subsequent
fixes in 92804597802903f126c3d701179fc06bda58ed4c and
156b57941de82d1d229c0ccf331cf2dc3a9f7e32.

2 years agoMerge branch 'smattr/6a4630c7-4928-4c5c-a28f-4b9a0f7ad13d' into 'main'
Matthew Fernandez [Sat, 9 Jul 2022 19:21:30 +0000 (19:21 +0000)]
Merge branch 'smattr/6a4630c7-4928-4c5c-a28f-4b9a0f7ad13d' into 'main'

gv_trim_zeros: identify string extent instead of writing a '\0'

See merge request graphviz/graphviz!2749

2 years agogv_trim_zeros: identify string extent instead of writing a '\0'
Matthew Fernandez [Fri, 8 Jul 2022 03:19:38 +0000 (20:19 -0700)]
gv_trim_zeros: identify string extent instead of writing a '\0'

The buffer that this function was truncating is destined for `gvwrite`. So we
can make the whole thing read-only by identifying a string extent instead of
modifying the buffer in place. The compiler may have been able to identify the
intent of this code anyway¹ but if not these changes make it clearer how this
code can be optimized.

¹ Though probably not if the experience discussed in
  bf800b51ccf5808c9b4faecdec01488b5513c307 is anything to go by.

2 years agoMerge branch 'smattr/AC13F6AC-696F-43DA-AA5E-4B62E0EE03FB' into 'main'
Matthew Fernandez [Sat, 9 Jul 2022 18:17:24 +0000 (18:17 +0000)]
Merge branch 'smattr/AC13F6AC-696F-43DA-AA5E-4B62E0EE03FB' into 'main'

glcomp: remove no-op casts

See merge request graphviz/graphviz!2751

2 years agoglcomp: remove no-op casts
Matthew Fernandez [Sat, 9 Apr 2022 19:05:35 +0000 (12:05 -0700)]
glcomp: remove no-op casts

2 years agoMerge branch 'smattr/255050CF-C355-4788-9063-95138C4395EB' into 'main'
Matthew Fernandez [Sat, 9 Jul 2022 17:09:47 +0000 (17:09 +0000)]
Merge branch 'smattr/255050CF-C355-4788-9063-95138C4395EB' into 'main'

move dot_builtins.c into C++

See merge request graphviz/graphviz!2752

2 years agomove dot_builtins.c into C++
Matthew Fernandez [Sat, 28 May 2022 17:40:34 +0000 (10:40 -0700)]
move dot_builtins.c into C++

This looks like a bit of a strange change, when we now wrap the entire file in
`extern "C"`. However this has two key benefits:

  1. `dot_builtins` and `dot_static` that include this source needed an
     Autotools hack¹ to force compilation to use the C++ front end (`c++`)
     instead of the C front end (`cc`) in order to link against the C++ standard
     library. By moving this source into C++ we can remove this hack.

  2. When trying to integrate `dot_builtins` into the CMake build system, MSVC
     complains (correctly) that the initializers to the array in this file are
     not compile-time constants. GCC and Clang apparently allow this by a
     non-standard extension. By moving this into C++, we get more relaxed
     initialization semantics that allow this on all compilers.

Gitlab: #1836

¹ https://www.gnu.org/software/automake/manual/automake.html#Libtool-Convenience-Libraries

2 years agoMerge branch 'smattr/B5CBD467-EBB2-4F04-B9EA-75F2E2AC4093' into 'main'
Matthew Fernandez [Sat, 9 Jul 2022 15:59:50 +0000 (15:59 +0000)]
Merge branch 'smattr/B5CBD467-EBB2-4F04-B9EA-75F2E2AC4093' into 'main'

common: some macro clean up

See merge request graphviz/graphviz!2744

2 years agocommon: remove 'GD_inleaf'
Matthew Fernandez [Wed, 6 Jul 2022 04:11:43 +0000 (21:11 -0700)]
common: remove 'GD_inleaf'

As discussed in the prior commit, this refers to a field that does not and has
never existed.

2 years agodotgen: remove 'OBSOLETE'-guarded code
Matthew Fernandez [Wed, 6 Jul 2022 04:00:34 +0000 (21:00 -0700)]
dotgen: remove 'OBSOLETE'-guarded code

This code is not currently compiled and, in fact, will not compile if you try to
re-enable it. As an example issue, it uses `GD_inleaf`, a macro intended for
accessing `Agraphinfo_t` fields, on a `node_t`. This is sort of a double mistake
as `Agraphinfo_t` also has no `inleaf` field. This problem seems to have been
present in the very first Graphviz revision,
256ef66663ca0c072554ee3f5e7971911031b3c7. Fortunately the mistakes sort of
cancelled each other out because the `GD_*` marcos did no casting and
`Agnodeinfo_t` _does_ have an `inleaf` field. The outcome seems to be what the
author intended, even if the route by which they got there was not intended.

The above is only one of several issues with this code. Resurrecting it has
unknown cost and unknown benefit, so we remove it here to avoid the implication
that it can be easily switched back on.

2 years agocommon: remove 'GD_cl_cnt'
Matthew Fernandez [Wed, 6 Jul 2022 03:48:39 +0000 (20:48 -0700)]
common: remove 'GD_cl_cnt'

This macro is clearly typoed (it refers to the field `cl_nt` while its name says
`cl_cnt`), but this macro has also never been used.

2 years agoMerge branch 'smattr/gitlab-2256' into 'main'
Matthew Fernandez [Sat, 9 Jul 2022 06:14:00 +0000 (06:14 +0000)]
Merge branch 'smattr/gitlab-2256' into 'main'

xlib plugin: relax button value assertions

Closes #2256

See merge request graphviz/graphviz!2740

2 years agoxlib plugin: relax button value assertions
Matthew Fernandez [Mon, 4 Jul 2022 21:44:42 +0000 (14:44 -0700)]
xlib plugin: relax button value assertions

Contrary to the X11 documentation,¹ it seems button values other than 1-5 can be
returned as button press events. The assertions altered in this commit were
introduced to guarantee the value does not exceed the limits of the type of the
parameter in the user’s callback (`int`). So we can safely relax this to just
the limit itself.

Gitlab: fixes #2256

¹ https://www.x.org/releases/X11R7.7/doc/libX11/libX11/libX11.html#Keyboard_and_Pointer_Events_b

2 years agoMerge branch 'clone-name-clash' into 'main'
Matthew Fernandez [Sat, 9 Jul 2022 04:26:34 +0000 (04:26 +0000)]
Merge branch 'clone-name-clash' into 'main'

rename clone to cloneO to avoid clone(2) nameclash

See merge request graphviz/graphviz!2750

2 years agorename clone to cloneO to avoid clone(2) nameclash
Natanael Copa [Tue, 26 Jul 2011 12:41:21 +0000 (12:41 +0000)]
rename clone to cloneO to avoid clone(2) nameclash

Rename clone to cloneO to avoid a name clash with the Linux `clone`
syscall. https://man7.org/linux/man-pages/man2/clone.2.html

2 years agoMerge branch 'chgraph-h' into 'main'
Matthew Fernandez [Sat, 9 Jul 2022 03:21:23 +0000 (03:21 +0000)]
Merge branch 'chgraph-h' into 'main'

doxygen doc for cgraph.h

See merge request graphviz/graphviz!2741

2 years agocgraph.h: exclude irrelevant from doxygen
Costa Shulyupin [Tue, 5 Jul 2022 13:16:53 +0000 (16:16 +0300)]
cgraph.h: exclude irrelevant from doxygen

2 years agocgraph.h: reformat comments for doxygen
Costa Shulyupin [Tue, 5 Jul 2022 13:15:57 +0000 (16:15 +0300)]
cgraph.h: reformat comments for doxygen

2 years agoDoxyfile: ignore attribute PRINTF_LIKE
Costa Shulyupin [Tue, 5 Jul 2022 12:34:24 +0000 (15:34 +0300)]
Doxyfile: ignore attribute PRINTF_LIKE

because it is not relevant for documentation

2 years agoMerge branch 'logic' into 'main'
Matthew Fernandez [Fri, 8 Jul 2022 03:15:21 +0000 (03:15 +0000)]
Merge branch 'logic' into 'main'

replace obsolete logic.h

See merge request graphviz/graphviz!2745

2 years agoremove obsolete unused logic.h
Costa Shulyupin [Wed, 6 Jul 2022 09:38:31 +0000 (12:38 +0300)]
remove obsolete unused logic.h

to reduce number of files in overpopulated directory lib/common
and make project a little bit more tidy

2 years agoreplace include of logic.h with stdbool.h
Costa Shulyupin [Wed, 6 Jul 2022 09:35:18 +0000 (12:35 +0300)]
replace include of logic.h with stdbool.h

and replace FALSE/TRUE with false/true

to reuse standard definitions

2 years agoremove unused includes of logic.h
Costa Shulyupin [Wed, 6 Jul 2022 09:32:46 +0000 (12:32 +0300)]
remove unused includes of logic.h

to keep the code a bit cleaner

2 years agoMerge branch 'smattr/A2FCED53-DEC0-47DE-BC19-01625CA7B4E9' into 'main'
Matthew Fernandez [Fri, 8 Jul 2022 01:00:59 +0000 (01:00 +0000)]
Merge branch 'smattr/A2FCED53-DEC0-47DE-BC19-01625CA7B4E9' into 'main'

Start 5.0.1 development

See merge request graphviz/graphviz!2747

2 years agoStart 5.0.1 development
Matthew Fernandez [Fri, 8 Jul 2022 00:24:05 +0000 (17:24 -0700)]
Start 5.0.1 development

2 years agoMerge branch 'smattr/02831009-9CCD-442E-B5A1-42688269FF91' into 'main' 5.0.0
Matthew Fernandez [Thu, 7 Jul 2022 15:40:57 +0000 (15:40 +0000)]
Merge branch 'smattr/02831009-9CCD-442E-B5A1-42688269FF91' into 'main'

Stable Release 5.0.0

See merge request graphviz/graphviz!2738

2 years agoStable Release 5.0.0
Matthew Fernandez [Sun, 3 Jul 2022 04:49:22 +0000 (21:49 -0700)]
Stable Release 5.0.0

2 years agofix CHANGELOG link
Matthew Fernandez [Sun, 3 Jul 2022 04:48:43 +0000 (21:48 -0700)]
fix CHANGELOG link

2 years agofix markdown indentation
Matthew Fernandez [Sun, 3 Jul 2022 04:45:38 +0000 (21:45 -0700)]
fix markdown indentation

2 years agoMerge branch 'smattr/C9FBABF6-463E-4B3D-9EA4-2EE6F963B313' into 'main'
Matthew Fernandez [Tue, 5 Jul 2022 16:11:15 +0000 (16:11 +0000)]
Merge branch 'smattr/C9FBABF6-463E-4B3D-9EA4-2EE6F963B313' into 'main'

gvpr: rewrite 'indexOf' to a simpler equivalent

See merge request graphviz/graphviz!2732

2 years agogvpr: rewrite 'indexOf' to a simpler equivalent
Matthew Fernandez [Fri, 1 Jul 2022 15:13:56 +0000 (08:13 -0700)]
gvpr: rewrite 'indexOf' to a simpler equivalent

This was initially attempted in 84efe93d5c5a4da0e778dbf01ed8550d2d774fdf and
then reverted in 51d787ece01fb4443db5eabd6932046b7b715dbc when it was discovered
this introduced a bug. The present commit fixes the, now obvious in retrospect,
bug with the original change of flipping the operands in the final subtraction.

This was validated by doing an exhaustive comparison of all strlen ≤2 inputs to
both the before and after function. Not bulletproof, but it is a strong signal
that the new version is functionally identical.

2 years agoMerge branch 'smattr/FDF1EA53-08F9-4F8C-8A22-2430083D6152' into 'main'
Matthew Fernandez [Tue, 5 Jul 2022 04:44:54 +0000 (04:44 +0000)]
Merge branch 'smattr/FDF1EA53-08F9-4F8C-8A22-2430083D6152' into 'main'

some allocation call clean up

See merge request graphviz/graphviz!2734

2 years agogxl2gv: fix an unchecked allocation failure
Matthew Fernandez [Sat, 2 Jul 2022 02:46:21 +0000 (19:46 -0700)]
gxl2gv: fix an unchecked allocation failure

2 years agographml2gv: fix an unchecked allocation failure
Matthew Fernandez [Sat, 2 Jul 2022 02:45:20 +0000 (19:45 -0700)]
graphml2gv: fix an unchecked allocation failure

2 years agodiffimg: replace 'xmalloc' with central allow wrapper
Matthew Fernandez [Sat, 2 Jul 2022 02:43:29 +0000 (19:43 -0700)]
diffimg: replace 'xmalloc' with central allow wrapper

2 years agopango plugin: replace 'xstrdup' with central alloc wrapper
Matthew Fernandez [Sat, 2 Jul 2022 02:41:53 +0000 (19:41 -0700)]
pango plugin: replace 'xstrdup' with central alloc wrapper

2 years agoMerge branch 'smattr/AA938AAA-1935-4594-A534-5EC62FFFBF57' into 'main'
Matthew Fernandez [Tue, 5 Jul 2022 02:56:17 +0000 (02:56 +0000)]
Merge branch 'smattr/AA938AAA-1935-4594-A534-5EC62FFFBF57' into 'main'

reference counted strings: de-duplicate some code, introduce malloc failure checks

See merge request graphviz/graphviz!2735

2 years agoagstrdup_internal: handle allocation failures
Matthew Fernandez [Sat, 2 Jul 2022 02:06:58 +0000 (19:06 -0700)]
agstrdup_internal: handle allocation failures

2 years agooutline the common core of 'agstrdup' and 'agstrdup_html'
Matthew Fernandez [Sat, 2 Jul 2022 02:04:01 +0000 (19:04 -0700)]
outline the common core of 'agstrdup' and 'agstrdup_html'

2 years agoMerge branch 'smattr/25FB51E1-C422-452D-9D1F-130886D5BAC3' into 'main'
Matthew Fernandez [Tue, 5 Jul 2022 01:53:26 +0000 (01:53 +0000)]
Merge branch 'smattr/25FB51E1-C422-452D-9D1F-130886D5BAC3' into 'main'

core plugin: fix unchecked allocation failure in dot rendering

See merge request graphviz/graphviz!2736

2 years agocore plugin: fix unchecked allocation failure in dot rendering
Matthew Fernandez [Sat, 2 Jul 2022 15:45:18 +0000 (08:45 -0700)]
core plugin: fix unchecked allocation failure in dot rendering

2 years agoMerge branch 'smattr/c7e76059-49ef-436d-940e-f756525e7a55' into 'main'
Matthew Fernandez [Mon, 4 Jul 2022 23:19:30 +0000 (23:19 +0000)]
Merge branch 'smattr/c7e76059-49ef-436d-940e-f756525e7a55' into 'main'

gvpr simplification

See merge request graphviz/graphviz!2737

2 years agogvpr: squash -Wunused-parameter warnings in 'gvexitf'
Matthew Fernandez [Sat, 2 Jul 2022 20:50:47 +0000 (13:50 -0700)]
gvpr: squash -Wunused-parameter warnings in 'gvexitf'

This function needs to conform to the `exitf` type signature, so these
parameters cannot be removed.

2 years agogvpr: make use of 'okay' clearer in 'evalNode'
Matthew Fernandez [Sat, 2 Jul 2022 20:48:26 +0000 (13:48 -0700)]
gvpr: make use of 'okay' clearer in 'evalNode'

Squashes a -Wconversion warning.

2 years agogvpr: make use of 'okay' clearer in 'evalEdge'
Matthew Fernandez [Sat, 2 Jul 2022 20:47:40 +0000 (13:47 -0700)]
gvpr: make use of 'okay' clearer in 'evalEdge'

Squashes a -Wconversion warning.

2 years agogvpr: exit on allocation failure in 'concat'
Matthew Fernandez [Sat, 2 Jul 2022 15:37:37 +0000 (08:37 -0700)]
gvpr: exit on allocation failure in 'concat'

This function gracefully handled allocation failures by returning 0. Except its
caller does not check for this and assumes the returned pointer is non-null.

2 years agogvpr: fix unchecked allocation failures in 'resolve'
Matthew Fernandez [Sat, 2 Jul 2022 15:36:00 +0000 (08:36 -0700)]
gvpr: fix unchecked allocation failures in 'resolve'

2 years agogvpr: fix unchecked allocation failure in 'parseArgs'
Matthew Fernandez [Sat, 2 Jul 2022 15:35:46 +0000 (08:35 -0700)]
gvpr: fix unchecked allocation failure in 'parseArgs'

2 years agogvpr: simplify 'freeOpts' by passing by value
Matthew Fernandez [Sat, 2 Jul 2022 15:30:52 +0000 (08:30 -0700)]
gvpr: simplify 'freeOpts' by passing by value

This also removes the conditional on `argc` in this function. The contained loop
is a no-op when `argc` is 0 and in this case `argv` is NULL, which it is well
defined to `free`.

2 years agogvpr: stack-allocate options struct
Matthew Fernandez [Sat, 2 Jul 2022 15:28:09 +0000 (08:28 -0700)]
gvpr: stack-allocate options struct

There is no need to heap-allocate this struct that is small and whose usage is
well scoped.

2 years agoMerge branch 'cgraph' into 'main'
Matthew Fernandez [Mon, 4 Jul 2022 22:18:19 +0000 (22:18 +0000)]
Merge branch 'cgraph' into 'main'

cgraph doxygen title comments

See merge request graphviz/graphviz!2739

2 years agocgraph doxygen title comments
Costa Shulyupin [Mon, 4 Jul 2022 22:18:19 +0000 (22:18 +0000)]
cgraph doxygen title comments

2 years agoMerge branch 'smattr/gitlab-358' into 'main'
Matthew Fernandez [Mon, 4 Jul 2022 21:23:10 +0000 (21:23 +0000)]
Merge branch 'smattr/gitlab-358' into 'main'

fix: Revert "rewrite versionStr2Version to use strtoul"

Closes #358

See merge request graphviz/graphviz!2733

2 years agofix: Revert "rewrite versionStr2Version to use strtoul"
Matthew Fernandez [Sat, 2 Jul 2022 03:23:27 +0000 (20:23 -0700)]
fix: Revert "rewrite versionStr2Version to use strtoul"

This reverts commit 5aa56175c4715700cc8bf9fecad7b27665c04379. This commit
inadvertently changed the parsing of the `xdotversion` attribute to make
something like “1.7” parse as version 1.

Gitlab: fixes #358

2 years agoadd a test case for #358
Matthew Fernandez [Sat, 2 Jul 2022 03:17:18 +0000 (20:17 -0700)]
add a test case for #358

2 years agoMerge branch 'smattr/gitlab-1801' into 'main'
Matthew Fernandez [Sun, 3 Jul 2022 05:49:31 +0000 (05:49 +0000)]
Merge branch 'smattr/gitlab-1801' into 'main'

Proutespline: remove exception-style control flow

See merge request graphviz/graphviz!2731

2 years agogrowops: squash a -Wsign-conversion warning
Matthew Fernandez [Tue, 28 Jun 2022 01:44:18 +0000 (18:44 -0700)]
growops: squash a -Wsign-conversion warning

By construction, `newopn` can only ever be non-negative here. Though in the long
term a more sweeping change should be done to count items in `size_t` variables
pervasively.

2 years agoreallyroutespline: squash a -Wsign-conversion warning
Matthew Fernandez [Tue, 28 Jun 2022 01:42:29 +0000 (18:42 -0700)]
reallyroutespline: squash a -Wsign-conversion warning

By construction, `inpn` can only ever be non-negative here. Though in the long
term a more sweeping change should be done to count items in `size_t` variables
pervasively.

2 years agoProutespline: remove exception-style control flow
Matthew Fernandez [Tue, 28 Jun 2022 01:40:07 +0000 (18:40 -0700)]
Proutespline: remove exception-style control flow

Memory allocation failures now result in a conventional return, propagated up
through the call stack.

Github: #1801

2 years agoreallyroutespline: fix unchecked failures on recursion
Matthew Fernandez [Tue, 28 Jun 2022 01:20:24 +0000 (18:20 -0700)]
reallyroutespline: fix unchecked failures on recursion

2 years agoMerge branch 'smattr/5c305fc5-c55f-4cb9-a061-007ed0d2be2a' into 'main'
Matthew Fernandez [Sat, 2 Jul 2022 02:18:56 +0000 (02:18 +0000)]
Merge branch 'smattr/5c305fc5-c55f-4cb9-a061-007ed0d2be2a' into 'main'

use a string view abstraction to simplify plugin parsing code

See merge request graphviz/graphviz!2729

2 years agogvplugin_graph: fix unchecked allocation failures
Matthew Fernandez [Sun, 26 Jun 2022 20:28:20 +0000 (13:28 -0700)]
gvplugin_graph: fix unchecked allocation failures

The substring construction in `gvplugin_graph` unfortunately cannot be easily
converted to `strview_t` because it passes pointers to `agxset` which expects a
`'\0'` terminated string. We can at least fix previously unnoticed allocation
failures though.

2 years agogvPluginList: fix: manage 'q' as a 'strview_t'
Matthew Fernandez [Sun, 26 Jun 2022 20:22:57 +0000 (13:22 -0700)]
gvPluginList: fix: manage 'q' as a 'strview_t'

This fixes a memory leak that would occur when duplicate items were encountered.
The conditional block in this loop would not be entered and the memory that `q`
pointed to would be lost in the next iteration of the loop when `q` was set to a
new string.

2 years agogvPluginList: fix unchecked allocation failure
Matthew Fernandez [Sun, 26 Jun 2022 20:18:46 +0000 (13:18 -0700)]
gvPluginList: fix unchecked allocation failure

When `strdup` failed to allocate memory, this would go unnoticed, leading to a
crash.

2 years agogvPluginList: use a 'strview_t' for 'typestr_last'
Matthew Fernandez [Sun, 26 Jun 2022 20:16:34 +0000 (13:16 -0700)]
gvPluginList: use a 'strview_t' for 'typestr_last'

This has no immediate effect, but will simply the next commit.

2 years agogvPluginList: squash -Wunused-parameter warning
Matthew Fernandez [Sun, 26 Jun 2022 20:09:17 +0000 (13:09 -0700)]
gvPluginList: squash -Wunused-parameter warning

As described in the leading comment, this is intentionally unused for now.

2 years agogvplugin_list: use a 'strview_t' for 'type' in second loop
Matthew Fernandez [Sun, 26 Jun 2022 20:08:05 +0000 (13:08 -0700)]
gvplugin_list: use a 'strview_t' for 'type' in second loop

Slightly more readable and less error prone than doing this inline.

2 years agogvplugin_list: use a 'strview_t' for 'type_last'
Matthew Fernandez [Sun, 26 Jun 2022 20:03:21 +0000 (13:03 -0700)]
gvplugin_list: use a 'strview_t' for 'type_last'

Slightly more readable and less error prone than doing this inline.

2 years agogvplugin_list: use a 'strview_t' for handling prefix of 'str'
Matthew Fernandez [Sun, 26 Jun 2022 19:58:01 +0000 (12:58 -0700)]
gvplugin_list: use a 'strview_t' for handling prefix of 'str'

Slightly more readable and less error prone than doing this inline.

2 years agogvplugin_list: use a 'strview_t' for 'type' in first loop
Matthew Fernandez [Sun, 26 Jun 2022 19:47:04 +0000 (12:47 -0700)]
gvplugin_list: use a 'strview_t' for 'type' in first loop

Slightly more readable and less error prone than doing this inline.

2 years agogvplugin_load: use a 'strview_t' for 'reqtyp'
Matthew Fernandez [Sun, 26 Jun 2022 19:41:02 +0000 (12:41 -0700)]
gvplugin_load: use a 'strview_t' for 'reqtyp'

Slightly more readable and less error prone than doing this inline.

2 years agogvplugin_load: use a 'strview_t' for 'typ'
Matthew Fernandez [Sun, 26 Jun 2022 19:02:15 +0000 (12:02 -0700)]
gvplugin_load: use a 'strview_t' for 'typ'

Slightly more readable and less error prone than doing this inline.

2 years agogvplugin_load: use a 'strview_t' for 'reqdep'
Matthew Fernandez [Sun, 26 Jun 2022 18:58:06 +0000 (11:58 -0700)]
gvplugin_load: use a 'strview_t' for 'reqdep'

Slightly more readable and less error prone than doing this inline.

2 years agogvplugin_load: use a 'strview_t' for 'dep'
Matthew Fernandez [Sun, 26 Jun 2022 19:19:25 +0000 (12:19 -0700)]
gvplugin_load: use a 'strview_t' for 'dep'

Similar to the previous commit, this string is either `NULL` or terminated by a
`'\0'`, so there is little advantage in using a `strview_t` over a
`const char*`. But this will make it more consistent with surrounding code after
upcoming changes.

2 years agogvplugin_load: use a 'strview_t' for 'reqpkg'
Matthew Fernandez [Sun, 26 Jun 2022 19:10:34 +0000 (12:10 -0700)]
gvplugin_load: use a 'strview_t' for 'reqpkg'

This string is always terminated by `'\0'`, not `':'`, so there is little
advantage in using a `strview_t` over a `const char*`. But upcoming changes will
refactor the surrounding code to use `strview_t`, so it will be more readable to
use `strview_t` consistently here.

2 years agogvplugin_install: use 'strview_t' to simplify second type string comparison loop
Matthew Fernandez [Sun, 26 Jun 2022 18:46:16 +0000 (11:46 -0700)]
gvplugin_install: use 'strview_t' to simplify second type string comparison loop

2 years agogvplugin_install: use 'strview_t' to simplify type string comparison loop
Matthew Fernandez [Sun, 26 Jun 2022 18:40:13 +0000 (11:40 -0700)]
gvplugin_install: use 'strview_t' to simplify type string comparison loop

2 years agogvplugin_install: refactor 'typestr' end locating logic to use a 'strview_t'
Matthew Fernandez [Sun, 26 Jun 2022 18:24:17 +0000 (11:24 -0700)]
gvplugin_install: refactor 'typestr' end locating logic to use a 'strview_t'

Slightly more readable and less error prone than doing this inline.

2 years agoadd an abstraction for string references
Matthew Fernandez [Sun, 26 Jun 2022 18:01:38 +0000 (11:01 -0700)]
add an abstraction for string references

2 years agoMerge branch 'smattr/4C27B32D-9DA4-4AE8-846A-42EC6F6422C4' into 'main'
Matthew Fernandez [Sat, 2 Jul 2022 00:12:24 +0000 (00:12 +0000)]
Merge branch 'smattr/4C27B32D-9DA4-4AE8-846A-42EC6F6422C4' into 'main'

compiler warning squashing

See merge request graphviz/graphviz!2730

2 years agorecordlintrsx: remove unused 'xlp' parameter
Matthew Fernandez [Sun, 26 Jun 2022 22:54:39 +0000 (15:54 -0700)]
recordlintrsx: remove unused 'xlp' parameter