Erwin Janssen [Sat, 7 Jan 2017 11:51:01 +0000 (12:51 +0100)]
Fixed use of unitialized variable in lefty
In the file cmd/lefty/ws/x11/gquery.c, function Gqwpopaction:
THe char c is declared without initializer, giving it a unpredictable
value. If the next if statement takes the false branch, the function where
c is set is not executed. The next if statement then checks `c != 13`, but
because C could have any value, the behavior is unpredictable.
Initializing c with a known value, such as 0, fixes the problem.
Erwin Janssen [Fri, 6 Jan 2017 14:06:42 +0000 (15:06 +0100)]
Replace Windows' pragma linking with VS linking
In various places, mostly the projects in `cmd` and `plugin`, had a
`#pragma comment( lib, "libname.lib" )` in the source code for linking
under Windows. Were possible, these have been removed and replaced link
specifications in the Visual Studio project files.
This seperates the linking from the source code and makes transitioning to
other build systems easier.
Erwin Janssen [Thu, 5 Jan 2017 23:59:09 +0000 (00:59 +0100)]
Made vmalloc a static library on Windows
vmalloc is a static library with the Autotools build, but was for some
reason a dynamic library on Windows. Since Autotools is considered the
default, this commit makes vmalloc a static library on Windows as well.
To disable the function export that is required for a dynamic library,
but not for a static one, various define checks were removed.
Erwin Janssen [Thu, 5 Jan 2017 14:00:38 +0000 (15:00 +0100)]
Remove usage of features/vmalloc
The only check left in features/vmalloc, checks if the return type of
malloc is the old `char *`. Because we are using standard C, we can
always assume the returntype of malloc is `void *`, this define is
there never set. We can remove this check and with it the usage of
features/vmalloc and FEATURE/vmalloc.
Erwin Janssen [Thu, 5 Jan 2017 13:34:50 +0000 (14:34 +0100)]
Move checks from features/vmalloc to configure.ac
Instead of checking certain headers and functions in a seperate config
script, place these checks in configure.ac and use HAVE_* style defines.
Some checks were already present in configure.ac, the others have been
added. No addtional defines in windows/config.h were needed.
There is only one check remaining in features/vmalloc.
Erwin Janssen [Wed, 4 Jan 2017 23:20:03 +0000 (00:20 +0100)]
Remove declaration enqueue_neighbors from render.h
The function `enqueue_neighbors` is declared in both render.h and in
dotprocs.h, while it is only used in lib/dotgen. The double declaration
causes "inconstant dll linkage" warnings on Windows.
Erwin Janssen [Tue, 3 Jan 2017 18:20:58 +0000 (19:20 +0100)]
Made xdot a dynamic library on Windows
xdot is a dynamic library with the Autotools build, but was for some
reason a static library on Windows. Since Autotools is considered the
default, this commit makes xdot a dynamic library on Windows as well.
The added define "XDOT_API", is used for linking, so a seperate xdot.def
file is not needed. On non-Windows platforms, this define is set to
"extern", so nothing changes there.
Erwin Janssen [Thu, 29 Dec 2016 15:58:37 +0000 (16:58 +0100)]
Disable warning 4706 in Windows build of lib/cdt
Warning C4706: assignment within conditional expression
The CDT library is mostly an external library included with the Graphviz
source and modified. It throws a lot of C4706 warnings, which isn't the
warning with the highest priority. We disable it for now.
Erwin Janssen [Wed, 28 Dec 2016 20:22:27 +0000 (21:22 +0100)]
Remove checks for 'libgen', library not used
configure.ac contains checks for the `libgen` library and header, but the
header is never included, which means the library is never used. Checking
and linking is therefore not needed.
Erwin Janssen [Wed, 28 Dec 2016 18:19:02 +0000 (19:19 +0100)]
Remove definition and usage of HAVE_STRERROR
This function is part of the standard C library, checking is therefore not
needed. With this change, check that sets HAVE_ERRNO_DECLS and the file
lib/ast/strerror.c can both be removed.
Erwin Janssen [Wed, 21 Dec 2016 13:18:25 +0000 (14:18 +0100)]
Replace remaining "ast_common.h" includes
Added a typedef for `ssize_t` to the Windows config.h, which is the
location were Autotools would define it if it isn't found.
Removed the remaining includes of "ast_common.h", instead include
"config.h" and add a check to include "sys/typesh" (were ssize_t is
located on Linux)
Erwin Janssen [Mon, 19 Dec 2016 11:10:46 +0000 (12:10 +0100)]
Remove `_dll_import` define block in ast_common.h
The define `_dll_import` is never set by any file that includes
ast_common.h, the define block is therefore never triggered. DLL linkage
is Windows is currently done with `def` files.
Erwin Janssen [Sun, 18 Dec 2016 14:49:15 +0000 (15:49 +0100)]
Replace last usage of _BEGIN/END_EXTERNS_
The last occurence of the defines _BEGIN_EXTERNS_ and _END_EXTERNS_ in the
code was in lib/sfio/sfsetbuf.h, this is now replaced with the standard
`extern "C"` define and check. Because of this, the definition of
_BEGIN_EXTERNS_ and _END_EXTERNS_ can be removed from ast_common.h
Erwin Janssen [Sun, 18 Dec 2016 12:01:35 +0000 (13:01 +0100)]
Remove unused function checks and defines
congigure.ac checks for the presence of certain functions and creates
define indicating if it was found. Some of these defines are never
used, so the check (and the static define for Windows) can be safely
removed. This is the case for the following functions:
- __freadable
- _sysconf
- getrusage
- lsqrt
- memset
- nl_langinfo
- pow
- sqrt
- strchr
- strdup
- strstr
- strtoll
- strtoul
- strtoull
- uname
Also removed duplicate `strerror` in `AC_CHECK_FUNCS`.
Erwin Janssen [Sun, 18 Dec 2016 11:30:14 +0000 (12:30 +0100)]
Remove check for `const` keyword in configure.ac
The macro `AC_C_CONST` checks whether the used C compiler supports
the keyword `const` and defines it accordingly. But as stated in
the autoconf documentation, this macro is becomming obsolete as
current C compilers `cost`. Checking is therefore no longer required.
Erwin Janssen [Mon, 12 Dec 2016 15:12:49 +0000 (16:12 +0100)]
Remove unused header checks and defines
congigure.ac checkes for the presence of header files and creates
define indicating if it was found. Some of these defines are never
used, so the check (and the static define for Windows) can be safely
removed. This is the case for the following headers:
- langinfo.h
- libintl.h
- pthread.h
- setjmp.h
- sys/times.h
Erwin Janssen [Sun, 11 Dec 2016 00:55:02 +0000 (01:55 +0100)]
Remove definition of HAVE_FLOAT_H
The header <float.h> is part of the standard C library and is always
available, checking is therefore not needed. In addition to this,
this define is never used.
Erwin Janssen [Fri, 9 Dec 2016 15:07:50 +0000 (16:07 +0100)]
Removed all _ast_int and _ast_flt defines
The defines _ast_int and _ast_flt used to be generated, but were now defined
in ast_common.h. Most of these defines were not used either, only _ast_intmax_t
and _ast_fltmax_t were used to define another define in sfio.h. Instead, we now
directly use the values `long long` and `long double` to set the defines in
sfio.h and we can safely remove the _ast_int and _ast_flt defines.
Erwin Janssen [Fri, 9 Dec 2016 00:24:14 +0000 (01:24 +0100)]
Remove defintion of HAVE_STDARG_H and _hdr_stdarg
The define _hdr_stdarg was only used in ast_common.h to include <stdarg.h>
but this include was not needed, compilation succeeds without it.
The define HAVE_STDARG_H was only used to set _hdr_starg in ast_common.h.
Both defines and the include can therefore safely be removed.
Erwin Janssen [Mon, 19 Dec 2016 14:39:32 +0000 (15:39 +0100)]
Fix fonts errors on Windows with binary outputs
Outputs like 'png' didn't render the text properly on Windows (rectangles
instead of letters). The cause was that Pango was missings its modules. This
change adds post build commands to the `smyrna` en `gvplugin_pango` Visual
Studio projects, so the required modules are copied and then recognized by
pango.
Fixes issue #1186
Emden Gansner [Fri, 16 Dec 2016 22:15:01 +0000 (17:15 -0500)]
Fix a couple of lose ends where incorrect information is given in
error messages. Make sure each call to agmemread resets the line number
to 1 and the file name to NULL. If the input contains cpp line directive,
another run of agmemread with errors would report them incorrectly.
In addition, the gvNextInputGraph in common/input.s was not resetting the
the file name in the case that the new FILE* happened to use the same memory
as the previous FILE*.
Emden Gansner [Fri, 16 Dec 2016 20:02:23 +0000 (15:02 -0500)]
At present, if the graph has no nodes, no layout is done. But then if gvFreeLayout is called
and there are subgraphs, dot_cleanup_graph assumes the subgraphs are bound to a Agraphinfo_t,
which doesn't exist. The calls to free the associated memory cause a crash.
The simplest solution is to check that Agraphinfo_t exists in dot_cleanup_graph before using it.
Erwin Janssen [Mon, 12 Dec 2016 14:50:50 +0000 (15:50 +0100)]
Remove unused FPE initialization from dot.c
In cmd/dot/dot.c, non standard floating point exceptions are enabled
in a platform specific way in a sequence of `ifdef`s. However, this
is never used because:
- The rest of the code never checks for set floating point exception
flags (with `fetestexcept` for example).
- The check that toggles the whole block, `ifndef NO_FPERR` is almost
false. `NO_FPERR` is always defined on Windows and only disabled on
specific platforms that do not support `-ffast-math`.
In conclusion, the code adds unnecessary complexity and can be removed.
Emden Gansner [Fri, 9 Dec 2016 20:28:41 +0000 (15:28 -0500)]
Fix verbose printing. First, we are not printing the graph depth, but the
maximum number of steps to the center. Second, we can't use SLEAF if the root
is specified, since SLEAF is not calculated in that case.
Erwin Janssen [Wed, 7 Dec 2016 13:56:39 +0000 (14:56 +0100)]
Fixed 3 potential memory leaks in QuadTree.c
In the function `QuadTree_new_from_point_list` in lib/sparse/QuadTree.c,
memory is allocated for tree variables. The check that follows returns
NULL if one of the pointers is NULL (indicating memory allocation
failure). However, it is possible that memory allocation succeeds for one
or two variables, but fails for the third. If this happens, the functions
returns NULL, but the allocated memory isn't freed.
The fix is to free all three pointers in case of a failure. If memory is
allocated it is freed. If the pointer is NULL, free can still safely be
called.
Erwin Janssen [Sat, 19 Nov 2016 01:20:46 +0000 (02:20 +0100)]
Fixed: 'dereference before null check' in DotIO.c
When the local variables in the function `convert_edge_labels_to_nodes` in
lib/spare/DotIO.c are initialized, the pointer `g` is dereferenced. But a
the check that tests if `g` is NULL happens after this initialization. The
fix is placing the `if (!g) return NULL` as the first line of the
function, so dereferencing only occurs if the pointer is not NULL.
Erwin Janssen [Sat, 19 Nov 2016 01:06:57 +0000 (02:06 +0100)]
Fixed: 2 'dereference before null check' in SparseMatrix
In the file lib/sparse/SparseMatric.x, there were two functions were a
pointer is dereferenced before checking if the pointer is NULL. The check
`if(!A)` caused an early return in both functions.
The fix is placing the check and the early return as the first line in
both functions. Dereferencing then only occures if the pointer A is not
NULL.
Erwin Janssen [Sat, 19 Nov 2016 00:53:25 +0000 (01:53 +0100)]
Fixed: 'dereference before null check' in stack.c
The pointer `theStack` is dereferenced before the if statement that
checks whether `theStack` is null. This is fixed by placing the variable
declarations in the if statement.
Erwin Janssen [Thu, 17 Nov 2016 16:11:13 +0000 (17:11 +0100)]
Fixed: three memory leaks in neatoinit.c
In the function `makeGraphData()` memory is allocated in various places,
but not all allocated memory is freed at the end of this function. This
commit fixes this by calling `free()` on the pointers `edges`, `edists`
and `ewgts`.
Erwin Janssen [Sun, 13 Nov 2016 20:21:38 +0000 (21:21 +0100)]
Replace WIN32 with _WIN32 in ast, common, dotgen2
WIN32 is defined by the user, _WIN32 is set by the compiler to indicate
the platform. It is better to use the latter.
This commit replaces WIN32 with _WIN32 in source and header files of
lib/ast, lib/common and lib/dotgen2.