diff options
57 files changed, 165 insertions, 133 deletions
diff --git a/Makefile.am b/Makefile.am index 8c9bec7..d6a49b6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ # This file is part of GNU cflow -# Copyright (C) 2005-2021 Free Software Foundation, Inc. +# Copyright (C) 2005-2022 Free Software Foundation, Inc. # # Written by Sergey Poznyakoff # @@ -1,9 +1,9 @@ -GNU cflow NEWS -- history of user-visible changes. 2021-04-05 +GNU cflow NEWS -- history of user-visible changes. 2021-12-30 See the end of file for copying conditions. Please send cflow bug reports to <bug-cflow@gnu.org>. -Version 1.6.92 (git) +Version 1.7, 2021-12-30 * Multiple start functions are allowed @@ -35,6 +35,7 @@ programs. ** CVE-2019-16166 ** Fix parsing of K&R style function declarations ** Improve parsing of typecasts +** Fix recursive call detection Version 1.6, 2019-02-23 @@ -152,7 +153,7 @@ Initial version restored from 1997 snapshots. ---------------------------------------------------------------------- * Copyright information: -Copyright (C) 2005-2021 Sergey Poznyakoff +Copyright (C) 2005-2022 Sergey Poznyakoff Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the @@ -1,5 +1,5 @@ GNU cflow README -Copyright (C) 2005-2021 Sergey Poznyakoff +Copyright (C) 2005-2022 Sergey Poznyakoff See the end of file for copying conditions. * Introduction diff --git a/README-alpha b/README-alpha index 9e20c30..b7b4828 100644 --- a/README-alpha +++ b/README-alpha @@ -71,7 +71,7 @@ Now set your breakpoints and proceed as usual. * Copyright information: -Copyright (C) 2005-2021 Sergey Poznyakoff +Copyright (C) 2005-2022 Sergey Poznyakoff Permission is granted to anyone to make or distribute verbatim copies of this document as received, in any medium, provided that the diff --git a/README-hacking b/README-hacking index de36eb5..240eec4 100644 --- a/README-hacking +++ b/README-hacking @@ -39,7 +39,7 @@ Enjoy! ----- -Copyright (C) 2002-2021 Sergey Poznyakoff +Copyright (C) 2002-2022 Sergey Poznyakoff This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/acinclude.m4 b/acinclude.m4 index cc1c799..87fa982 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1,34 +1,49 @@ dnl This file is part of GNU mailutils. -dnl Copyright (C) 2001, 2016, 2021 Free Software Foundation, Inc. +dnl Copyright (C) 2001-2023 Free Software Foundation, Inc. dnl dnl This file is free software; as a special exception the author gives dnl unlimited permission to copy and/or distribute it, with or without dnl modifications, as long as this notice is preserved. dnl -dnl This program is distributed in the hope that it will be useful, but +dnl GNU Mailutils is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. dnl dnl Check for --enable-debug switch. When the switch is specified, add dnl -ggdb to CFLAGS and remove any optimization options from there. -dnl +dnl AC_DEFUN([MU_DEBUG_MODE], - [AC_ARG_ENABLE(debug, - [ --enable-debug enable debugging mode], - [if test x"$enableval" = xyes; then - if test x"$GCC" = xyes; then - AC_MSG_CHECKING(whether gcc accepts -ggdb) - save_CFLAGS=$CFLAGS - CFLAGS="-ggdb -Wall" - AC_TRY_COMPILE([],void f(){}, - AC_MSG_RESULT(yes), - [if test x"$ac_cv_prog_cc_g" = xyes; then - CFLAGS="-g -Wall" - else - CFLAGS= - fi - AC_MSG_RESULT(no)]) - CFLAGS="`echo $save_CFLAGS | sed 's/-O[[0-9]]//g'` $CFLAGS" - fi - fi])]) + [AC_ARG_ENABLE(debug, + AS_HELP_STRING([--enable-debug], [enable debugging mode]), + [mu_debug_mode=$enableval], + [mu_debug_mode=maybe]) + + save_CC=$CC + CC="$CC -Wall" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], + [[void main(){}]])], + [], + [CFLAGS="$CFLAGS -Wall"]) + + CC="$CC -Wdeclaration-after-statement" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], + [[void main(){}]])], + [], + [CFLAGS="$CFLAGS -Wdeclaration-after-statement"]) + + if test "$mu_debug_mode" != no; then + CFLAGS=`echo $CFLAGS | sed 's/-O[[0-9]]//g'` + AC_MSG_CHECKING([whether cc accepts -ggdb]) + CC="$CC -ggdb" + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([], + [[void main(){}]])], + [AC_MSG_RESULT(yes) + CFLAGS="$CFLAGS -ggdb"], + [AC_MSG_RESULT(no) + CFLAGS="$CFLAGS -g"]) + fi + CC=$save_CC]) @@ -2,7 +2,8 @@ # Bootstrap this package from checked-out sources. -# Copyright (C) 2003-2009, 2016, 2021 Free Software Foundation, Inc. +# Copyright (C) 2003-2009, 2016, 2021-2022 Free Software Foundation, +# Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/bootstrap.conf b/bootstrap.conf index e70974a..cfba292 100644 --- a/bootstrap.conf +++ b/bootstrap.conf @@ -1,5 +1,5 @@ # Bootstrap configuration. -# Copyright (C) 2006-2021 Free Software Foundation, Inc. +# Copyright (C) 2006-2022 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/configure.ac b/configure.ac index b73772b..e8df452 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # This file is part of GNU cflow -# Copyright (C) 2005-2021 Free Software Foundation, Inc. +# Copyright (C) 2005-2022 Free Software Foundation, Inc. # # Written by Sergey Poznyakoff # @@ -16,14 +16,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -AC_PREREQ(2.64) -AC_INIT([GNU cflow], [1.6.92], [bug-cflow@gnu.org], - [cflow], +AC_PREREQ([2.71]) +AC_INIT([GNU cflow],[1.7],[bug-cflow@gnu.org],[cflow], [http://www.gnu.org/software/cflow]) AC_CONFIG_SRCDIR([src/cflow.h]) AC_CONFIG_AUX_DIR([build-aux]) -AM_INIT_AUTOMAKE([1.15 gnits tar-ustar dist-bzip2 dist-xz std-options silent-rules subdir-objects]) -AC_CONFIG_HEADER([config.h]) +AM_INIT_AUTOMAKE([1.16.5 gnits tar-ustar dist-bzip2 dist-xz std-options silent-rules subdir-objects]) +AC_CONFIG_HEADERS([config.h]) # Enable silent rules by default: AM_SILENT_RULES([yes]) @@ -32,16 +31,11 @@ gl_EARLY # Checks for programs. AC_PROG_CC -AC_PROG_LEX +AC_PROG_LEX([noyywrap]) AC_PROG_RANLIB -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([stdlib.h string.h unistd.h locale.h]) - # Checks for library functions. AC_FUNC_ERROR_AT_LINE -AC_CHECK_FUNCS([memmove memset strdup strerror strtol setlocale]) gl_INIT MU_DEBUG_MODE @@ -57,7 +51,7 @@ AC_SUBST(lisp_LISP) # Gettext. AM_ICONV AM_GNU_GETTEXT([external], [need-formatstring-macros]) -AM_GNU_GETTEXT_VERSION(0.17) +AM_GNU_GETTEXT_VERSION(0.19) IMPRIMATUR_INIT(doc/imprimatur) @@ -71,6 +65,6 @@ AC_CONFIG_FILES([ gnu/Makefile src/Makefile elisp/Makefile - po/Makefile.in + po/Makefile.in doc/Makefile]) AC_OUTPUT diff --git a/doc/Makefile.am b/doc/Makefile.am index 7202d2d..507e4bd 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,5 +1,5 @@ # This file is part of GNU cflow -# Copyright (C) 2005-2021 Free Software Foundation, Inc. +# Copyright (C) 2005-2022 Free Software Foundation, Inc. # # Written by Sergey Poznyakoff # diff --git a/doc/cflow.1 b/doc/cflow.1 index 6cccea8..ae98970 100644 --- a/doc/cflow.1 +++ b/doc/cflow.1 @@ -1,5 +1,5 @@ .\" This file is part of Cflow -*- nroff -*- -.\" Copyright (C) 2014-2021 Sergey Poznyakoff +.\" Copyright (C) 2014-2022 Sergey Poznyakoff .\" .\" Cflow is free software; you can redistribute it and/or modify .\" it under the terms of the GNU General Public License as published by diff --git a/doc/cflow.texi b/doc/cflow.texi index 12f2dab..ba08169 100644 --- a/doc/cflow.texi +++ b/doc/cflow.texi @@ -21,7 +21,7 @@ @end direntry @dircategory Emacs @direntry -* cflow mode: (cflow)cflow mode. Major mode for visiting cflow charts. +* cflow mode: (cflow)Emacs. Major mode for visiting cflow charts. @end direntry @end ifinfo @@ -30,14 +30,14 @@ Published by the Free Software Foundation, 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA -Copyright @copyright{} 2005--2021 Sergey Poznyakoff +Copyright @copyright{} 2005--2022 Sergey Poznyakoff Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no -Invariant Sections, no Front-Cover and Back-Cover texts. A copy of -the license is included in the section entitled ``GNU Free Documentation -License''. +Invariant Sections, no Front-Cover Texts, and no Back-Cover texts. A +copy of the license is included in the section entitled ``GNU Free +Documentation License''. @end copying @titlepage @@ -234,6 +234,14 @@ who_am_i() <int who_am_i (void) at whoami.c:8>: Multiple @option{--main} options can be used to introduce several start functions. +@cindex end symbol +@cindex @option{--target} command line option introduced +You can also cut off the graph at arbitrary symbol or symbols: the +@option{--target} option sets the name of the @dfn{end symbol}, i.e. a +symbol below which @command{cflow} will not descend. Of course, both +@option{--main} and @option{--target} can be used together, and +multiple @option{--target} options are allowed. + Many programs (such as libraries or interpreters) define functions that are not directly reachable from the main function. To produce flow graph for all functions in the program, use the @option{--all} @@ -1307,9 +1315,11 @@ For more information, @xref{Symbols}. Use @var{string} when indenting to each new level. @xref{ASCII Tree}. @cindex @option{-m} -@cindex @option{--main} +@cindex @option{--main} +@cindex @option{--start} @item -m @var{name} @itemx --main=@var{name} +@itemx --start=@var{name} Assume main function to be called @var{name}. Multiple main function can be specified. @xref{start symbol}. @@ -1421,8 +1431,13 @@ printed after output line number (if @option{--number} or @item -T @itemx --tree @bullet{} Use ASCII art to print graph. @xref{ASCII Tree}. - -@cindex @option{--usage} + +@cindex @option{--target} +@item --target=@var{sym} + Show only graphs leading from start symbols to this function. +Multiple options are allowed. @xref{start symbol}. + +@cindex @option{--usage} @item --usage Give a short usage message. diff --git a/doc/fdl.texi b/doc/fdl.texi index 1b837b4..19e405d 100644 --- a/doc/fdl.texi +++ b/doc/fdl.texi @@ -2,7 +2,8 @@ @center Version 1.2, November 2002 @display -Copyright @copyright{} 2000-2002, 2016 Free Software Foundation, Inc. +Copyright @copyright{} 2000--2002, 2016, 2022 Free Software Foundation, +Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies diff --git a/doc/gendocs.sh b/doc/gendocs.sh index 0828905..e3bc736 100755 --- a/doc/gendocs.sh +++ b/doc/gendocs.sh @@ -4,7 +4,7 @@ scriptversion=2021-03-01.13 -# Copyright 2003-2021 Free Software Foundation, Inc. +# Copyright 2003-2022 Free Software Foundation, Inc. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/doc/gendocs_template b/doc/gendocs_template index cd9ac38..c8c8fc6 100644 --- a/doc/gendocs_template +++ b/doc/gendocs_template @@ -2,7 +2,7 @@ <!-- Parent-Version: 1.78 --> <!-- -Copyright (C) 2006-2021 Free Software Foundation, Inc. +Copyright (C) 2006-2022 Free Software Foundation, Inc. Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright diff --git a/elisp/Makefile.am b/elisp/Makefile.am index 42491ee..95c7d6c 100644 --- a/elisp/Makefile.am +++ b/elisp/Makefile.am @@ -1,5 +1,5 @@ # This file is part of GNU cflow -# Copyright (C) 2005-2021 Free Software Foundation, Inc. +# Copyright (C) 2005-2022 Free Software Foundation, Inc. # # Written by Sergey Poznyakoff # diff --git a/elisp/cflow-mode.el b/elisp/cflow-mode.el index 1acac60..74a21aa 100644 --- a/elisp/cflow-mode.el +++ b/elisp/cflow-mode.el @@ -5,7 +5,7 @@ ;; Keywords: cflow ;; This file is part of GNU cflow -;; Copyright (C) 1994-2021 Sergey Poznyakoff +;; Copyright (C) 1994-2022 Sergey Poznyakoff ;; GNU cflow is free software; you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by diff --git a/src/Makefile.am b/src/Makefile.am index b8920a3..cbd8a4e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,5 @@ # This file is part of GNU cflow -# Copyright (C) 2005-2021 Free Software Foundation, Inc. +# Copyright (C) 2005-2022 Free Software Foundation, Inc. # # Written by Sergey Poznyakoff # @@ -1,5 +1,5 @@ /* This file is part of GNU cflow - Copyright (C) 1997-2021 Sergey Poznyakoff + Copyright (C) 1997-2022 Sergey Poznyakoff GNU cflow is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/cflow.h b/src/cflow.h index ec11be6..48cca5b 100644 --- a/src/cflow.h +++ b/src/cflow.h @@ -1,11 +1,11 @@ /* This file is part of GNU cflow - Copyright (C) 1997-2021 Sergey Poznyakoff - + Copyright (C) 1997-2022 Sergey Poznyakoff + GNU cflow is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. - + GNU cflow is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -34,12 +34,7 @@ #define _(c) gettext(c) #define N_(c) c -#if HAVE_LOCALE_H -# include <locale.h> -#endif -#if !HAVE_SETLOCALE -# define setlocale(category, locale) /* empty */ -#endif +#include <locale.h> /* Exit codes */ #define EX_OK 0 /* Success */ @@ -99,7 +94,7 @@ struct symbol { struct table_entry *owner; Symbol *next; /* Next symbol with the same hash */ struct linked_list_entry *entry; - + enum symtype type; /* Type of the symbol */ char *name; /* Identifier */ enum symbol_flag flag; /* Specific flag */ @@ -107,7 +102,7 @@ struct symbol { type==SymToken and flag==symbol_alias. In this case, the rest of the structure is ignored */ - + int active; /* Set to 1 when the symbol's subtree is being processed, prevent recursion */ int expand_line; /* Number of the output line where this @@ -116,21 +111,21 @@ struct symbol { int visible; /* Visibility marker. Symbol will be shown on output only if its value equals that of the output_visible global. */ - + int token_type; /* Type of the token */ char *source; /* Source file */ int def_line; /* Source line */ struct linked_list *ref_line; /* Referenced in */ - + int level; /* Block nesting level (for local vars), Parameter nesting level (for params) */ - - char *decl; /* Declaration */ + + char *decl; /* Declaration */ enum storage storage; /* Storage type */ - + int arity; /* Number of parameters or -1 for - variables */ - + variables */ + int recursive; /* Is the function recursive */ size_t ord; /* ordinal number */ struct linked_list *caller; /* List of callers */ @@ -213,7 +208,7 @@ struct linked_list *linked_list_create(linked_list_free_data_fp fun); void linked_list_destroy(struct linked_list **plist); void linked_list_append(struct linked_list **plist, void *data); void linked_list_prepend(struct linked_list **plist, void *data); -void linked_list_iterate(struct linked_list **plist, +void linked_list_iterate(struct linked_list **plist, int (*itr) (void *, void *), void *data); void linked_list_unlink(struct linked_list *list, struct linked_list_entry *ent); @@ -225,7 +220,7 @@ int get_token(void); int source(char *name); void init_lex(int debug_level); void set_preprocessor(const char *arg); -void pp_option(const char *arg); +void pp_option(const char *arg); void init_parse(void); int yyparse(void); diff --git a/src/depmap.c b/src/depmap.c index ebd1153..6a48c5f 100644 --- a/src/depmap.c +++ b/src/depmap.c @@ -1,5 +1,5 @@ /* This file is part of GNU cflow. - Copyright (C) 2008-2021 Sergey Poznyakoff + Copyright (C) 2008-2022 Sergey Poznyakoff GNU cflow is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1,5 +1,5 @@ /* This file is part of GNU cflow - Copyright (C) 2021 Sergey Poznyakoff + Copyright (C) 2021-2022 Sergey Poznyakoff GNU cflow is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1,5 +1,5 @@ /* This file is part of GNU cflow - Copyright (C) 1997-2021 Sergey Poznyakoff + Copyright (C) 1997-2022 Sergey Poznyakoff GNU cflow is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/src/linked-list.c b/src/linked-list.c index 4b202ca..d3a97a7 100644 --- a/src/linked-list.c +++ b/src/linked-list.c @@ -1,5 +1,5 @@ /* This file is part of GNU cflow - Copyright (C) 1997-2021 Sergey Poznyakoff + Copyright (C) 1997-2022 Sergey Poznyakoff GNU cflow is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -1,5 +1,5 @@ /* This file is part of GNU cflow - Copyright (C) 1997-2021 Sergey Poznyakoff + Copyright (C) 1997-2022 Sergey Poznyakoff GNU cflow is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -148,12 +148,15 @@ static struct argp_option options[] = { { "no-omit-symbol-names", OPT_NO_OMIT_SYMBOL_NAMES, NULL, 0, N_("print symbol names in declaration strings (default)"), GROUP_ID+1 }, { "main", 'm', N_("NAME"), 0, - N_("assume main function to be called NAME; multiple options are allowed"), + N_("start graph at this function; multiple options are allowed"), + GROUP_ID+1 }, + { "start", 0, NULL, OPTION_ALIAS, + NULL, GROUP_ID+1 }, { "no-main", OPT_NO_MAIN, NULL, 0, N_("there's no main function; print graphs for all functions in the program") }, { "target", OPT_TARGET, N_("NAME"), 0, - N_("show only graphs leading from starting symbols to this function; multiple options are allowed"), + N_("show only graphs leading from start symbols to this function; multiple options are allowed"), GROUP_ID+1 }, #undef GROUP_ID #define GROUP_ID 30 @@ -237,6 +240,7 @@ find_option_type(struct option_type *optype, const char *str, int len) len = strlen(str); for ( ; optype->str; optype++) { if (len >= optype->min_match && + len <= strlen(optype->str) && memcmp(str, optype->str, len) == 0) { return optype->type; } diff --git a/src/output.c b/src/output.c index 1248fb4..1ba2da2 100644 --- a/src/output.c +++ b/src/output.c @@ -1,5 +1,5 @@ /* This file is part of GNU cflow - Copyright (C) 1997-2021 Sergey Poznyakoff + Copyright (C) 1997-2022 Sergey Poznyakoff GNU cflow is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -364,12 +364,12 @@ tree_output() for (p = linked_list_head(symbols[i]->callee); p; p = p->next) { Symbol *s = (Symbol*) p->data; - if (symbol_is_function(s)) - depmap_set(depmap, i, ((Symbol*)p->data)->ord); + if (s->ord != -1 && symbol_is_function(s)) + depmap_set(depmap, i, s->ord); } } } - + depmap_tc(depmap); /* Mark recursive calls */ diff --git a/src/parser.c b/src/parser.c index b71d14d..8c53942 100644 --- a/src/parser.c +++ b/src/parser.c @@ -1,5 +1,5 @@ /* This file is part of GNU cflow - Copyright (C) 1997-2021 Sergey Poznyakoff |