1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 21:19:24 +00:00
Commit Graph

330 Commits

Author SHA1 Message Date
Bruno Haible
9e29799ac3 Refactor: Use an array-list instead of a linked-list of equiv.-classes.
* src/search.h (Search::compute_partition): Return a 'Partition *', not
a 'EquivalenceClass *'.
(Search::count_possible_collisions, Search::unchanged_partition): Change
parameter from 'EquivalenceClass *' to 'Partition *'.
* src/search.cc (struct EquivalenceClass): Remove field _next.
(struct Partition): New type.
(struct Step): Change type of _partition from 'EquivalenceClass *' to
'Partition *'.
(Search::compute_partition): Return a 'Partition *', not a
'EquivalenceClass *'.
(delete_partition): Update.
(Search::count_possible_collisions, Search::unchanged_partition): Change
parameter from 'EquivalenceClass *' to 'Partition *'.
(Search::find_asso_values): Update.
2025-04-20 02:31:42 +02:00
Bruno Haible
b1ff3c70b1 Optimize: Use an array-list instead of a linked-list of keywords.
Storing list elements in contiguous memory means: less cache misses.
This reduces the execution time of gperf on large inputs by ca. 30%.

* src/arraylist.h: New file.
* src/arraylist.cc: New file.
* src/Makefile.in (OBJECTS): Add arraylist.$(OBJEXT).
(ARRAYLIST_H): New variable.
(arraylist.$(OBJEXT)): New rule.
(search.$(OBJEXT)): Update dependencies.
(SOURCE_FILES): Add arraylist.cc and arraylist.h.
* src/search.cc: Include arraylist.h.
(struct EquivalenceClass): An an ArrayList field. Remove the linked-list
fields. Add a constructor.
(Search::compute_partition, delete_partition): Update.
(Search::count_possible_collisions, Search::unchanged_partition,
Search::find_asso_values): Update.
2025-04-20 02:31:35 +02:00
Bruno Haible
a69b7c1c81 Optimize: Minimize object references in find_asso_values.
This reduces the execution time of gperf on large inputs by ca. 4%.

* src/search.cc (Search::find_asso_values): Cache some values in local
variables.
2025-04-19 15:05:31 +02:00
Bruno Haible
772a63e46d Optimize: Use a hash table in compute_partition.
This reduces the execution time of gperf on large inputs by ca. 30%.

* autogen.sh (GNULIB_MODULES): Add map-c++, hash-map.
* src/keyword.h: Include <stddef.h>.
(struct KeywordExt): Add fields _undetermined_chars,
_undetermined_chars_length, _undetermined_chars_hashcode.
* src/search.cc: Include gl_map.hh, gl_hash_map.h.
(Search::prepare_asso_values): Initialize the _undetermined_chars field.
(struct EquivalenceClass): Remove the fields _undetermined_chars,
_undetermined_chars_length.
(undetermined_equals, undetermined_hashcode): New functions.
(Search::compute_partition): Initialize the _undetermined_chars* fields
of all keywords. Use a hash map instead of a loop over the equivalence
classes.
(Search::find_good_asso_values): Deallocate the _undetermined_chars field.
2025-04-19 15:03:10 +02:00
Bruno Haible
43fa5ebcb7 Optimize: Make Bool_Array take less memory.
Less memory means: less cache misses.
This reduces the execution time of gperf on large inputs by ca. 2.5%.

* src/bool-array.h (Bool_Array): For the _storage_array and
_iteration_number fields, use 'unsigned char' instead of 'unsigned int'.
* src/bool-array.icc (Bool_Array::Bool_Array, Bool_Array::clear: Update.
* src/bool-array.cc (Bool_Array::~Bool_Array): Update.
2025-04-19 15:01:26 +02:00
Bruno Haible
b52ad8ef32 tests: Add unit test with many keywords.
* tests/generate-5000.sh: New file.
* tests/5000.gperf: New generated file.
* tests/5000.exp: New generated file.
* tests/Makefile.in (SOURCE_FILES): Add them.
(check-large): New rule.
2025-04-19 14:59:15 +02:00
Bruno Haible
3cb2d2f1d2 build: Update dependencies after 2025-04-16 change.
* src/Makefile.in (*.$(OBJEXT)): Depend on $(CONFIG_H).
2025-04-19 14:33:33 +02:00
Bruno Haible
8872451544 Improve comments.
* src/search.cc: Fix comments.
2025-04-17 17:30:21 +02:00
Bruno Haible
cb6f05f337 build: Update after gnulib changed.
* gnulib-local/lib/getopt-pfx-ext.h.diff: Remove file.
* Makefile.in (SOURCE_FILES): Remove it.
2025-04-17 00:11:21 +02:00
Bruno Haible
46db237ecc build: Use more gnulib modules.
* autogen.sh (GNULIB_MODULES): Add getopt-gnu.
Use directory gnulib-local.
* gnulib-local/lib/getopt-pfx-ext.h.diff: New file.
* Makefile.in (SOURCE_FILES): Add it.
(distdir): Use 'mkdir -p' instead of 'mkdir'.
* lib/getopt.h: Remove file.
* lib/getopt.c: Remove file.
* lib/getopt1.c: Remove file.
* lib/Makefile.am (libgp_a_SOURCES): Remove them.
2025-04-16 23:21:12 +02:00
Bruno Haible
6ca5ea1384 build: Use more gnulib modules.
* autogen.sh (GNULIB_MODULES): Add read-file.
Copy also config.guess and config.sub.
* lib/Makefile.am (BUILT_SOURCES, MOSTLYCLEANDIRS): New variables.
(libgp_a_SOURCES): Remove getline.h, getline.cc.
* lib/getline.h: Remove file.
* lib/getline.cc: Remove file.
* src/configure.ac: Change config.h to also include ../lib/config.h.
* src/output.cc: Include <config.h> first.
* src/search.cc: Likewise.
* src/bool-array.cc: Include <config.h>.
* src/keyword.cc: Likewise.
* src/keyword-list.cc: Likewise.
* src/hash-table.cc: Likewise.
* src/main.cc: Likewise.
* src/options.cc: Likewise.
* src/positions.cc: Likewise.
* src/version.cc: Likewise.
* src/input.cc: Likewise. Include read-file.h instead of getline.h.
(Input<KT>::read_input): Use fread_file instead of get_delim.
2025-04-16 22:28:11 +02:00
Bruno Haible
5533d54f9a build: Prepare for using generated .h files in lib/.
* src/Makefile.in (CPPFLAGS): Add more -I options.
2025-04-16 22:28:11 +02:00
Bruno Haible
ad7a21f223 build: Use gnulib-tool with a module list.
* .gitmodules: New file.
* gitsub.sh: New file, from gnulib/top/gitsub.sh.
* autopull.sh: Use gitsub.sh to check out gnulib.
* autogen.sh: Accept --skip-gnulib option. Invoke gnulib-tool, assuming
a gnulib checkout is already present.
* Makefile.devel (lib/aclocal.m4): Update reference to macros directory.
* lib/configure.ac: Likewise. Invoke gl_EARLY, gl_INIT.
* lib/Makefile.am (EXTRA_DIST, MOSTLYCLEANFILES): New variables.
Include Makefile.gnulib.
2025-04-16 22:05:58 +02:00
Bruno Haible
e60835d424 build: Use Automake in lib/.
* autopull.sh: Copy also m4/init-package-version.m4.
* autogen.sh: Mention the requirement for Automake.
* Makefile.devel (lib/aclocal.m4, lib/config.h.in, lib/Makefile.in): New
rules.
(lib/configure): Use lib/aclocal.m4 instead of the top-level aclocal.m4.
(src/config.h.in): Fix rule.
(totally-clean): Remove the new generated files.
* lib/configure.ac: Require Autoconf >= 2.70. Change AC_INIT invocation.
Invoke AC_CONFIG_MACRO_DIRS, gl_INIT_PACKAGE_VERSION, AM_INIT_AUTOMAKE,
AC_CONFIG_HEADERS. Don't invoke AC_MAKE_SET, AC_PROG_CPP,
AC_PROG_CXXCPP, AC_PROG_INSTALL.
* lib/Makefile.am: New file.
* lib/Makefile.in: Remove file.
* Makefile.in (IMPORTED_FILES): Remove lib/filename.h.
2025-04-16 22:02:43 +02:00
Bruno Haible
1a67526a17 Release gperf-3.2.1.
* src/version.cc (version_string): Bump.
* tests/*.exp: Update.
* NEWS: Mention the changes.
2025-04-13 18:12:04 +02:00
Bruno Haible
1a8e476f99 Fix "make check" failure with an ISO C 23 conforming C compiler.
Prompted by
<https://lists.gnu.org/archive/html/bug-gperf/2025-04/msg00002.html>.

* tests/smtp.gperf (my_case_strcmp, main): Convert from K&R C syntax
to ISO C 90 syntax.
2025-04-09 13:10:17 +02:00
Bruno Haible
3bab6ab7bf Avoid "-Wundef" warnings in C++ mode on the generated code.
Reported by Heiko Becker <mail@heiko-becker.de> in
<https://lists.gnu.org/archive/html/bug-gperf/2025-04/msg00001.html>
and by Thomas Klausner <wiz@netbsd.org>.

* src/output.cc (Output::output_hash_function): Emit a
'defined __STDC_VERSION__' before the test of __STDC_VERSION__.
* tests/c-parse.exp, tests/charsets.exp, tests/chill.exp,
tests/cplusplus.exp, tests/java.exp, tests/languages.exp,
tests/modula2.exp, tests/objc.exp: Update.
2025-04-09 12:29:19 +02:00
Bruno Haible
fe7539a0f9 Release gperf-3.2.
* src/options.cc (Options::parse_options): Bump copyright year.
* NEWS: Mention a few more changes.
2025-04-05 16:31:52 +02:00
Bruno Haible
a041291c80 Remove all occurrences of reinterpret_cast<>.
* src/keyword-list.h (Keyword_List): Add template parameter list <KT>.
(KeywordExt_List): Define as a typedef, not as a subclass.
(copy_list, delete_list, mergesort_list): Templatize accordingly.
* src/keyword-list.icc (Keyword_List): Add template parameter list <KT>.
(KeywordExt_List): Remove method definitions.
* src/keyword-list.cc (Keyword_List): Add template parameter list <KT>.
(copy_list, mergesort_list): Remove definitions on subclass.
Add explicit template instantiation.
* src/keyword.h (Keyword_Factory): Add template parameter list <KT>.
* src/keyword.cc (Keyword_Factory): Likewise.
Add explicit template instantiation.
* src/input.h (Input): Add template parameter list <KT>.
* src/input.cc (Input): Likewise. Add explicit template instantiation.
* src/main.cc (KeywordExt_Factory): Define as a typedef, not as a
subclass.
(main): Update.
2025-04-05 14:18:27 +02:00
Bruno Haible
67c697622f Make output on Windows identical to output on Unix.
* src/options.cc (Options::print_options): Drop a ".exe" suffix from the
program name before printing it.
2025-04-05 10:23:32 +02:00
Bruno Haible
2dd5061f4d Avoid "-Wzero-as-null-pointer-constant" warnings on the generated code.
Reported in
<https://lists.gnu.org/archive/html/bug-gnulib/2024-11/msg00123.html>.

* src/output.cc (Output::output_lookup_function_body): To denote a null
pointer, emit a cast expression instead of plain "0".
* tests/c-parse.exp, tests/charsets.exp, tests/chill.exp,
tests/cplusplus.exp, tests/gpc.exp, tests/incomplete.exp,
tests/java.exp, tests/languages.exp, tests/modula2.exp, tests/objc.exp,
tests/permut2.exp, tests/permut3.exp, tests/permutc2.exp,
tests/test-4.exp: Update.
2024-11-16 08:23:49 +01:00
Bruno Haible
78a4fe8e9d doc: Improve text rendering in PDF output.
Suggested by Collin Funk <collin.funk1@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gperf/2024-10/msg00000.html>.

* doc/texinfo.tex: Update from the texinfo-7.1 release.
* doc/gperf.texi: Override the colour for interactive links. Bump date.
2024-10-28 12:17:06 +01:00
Bruno Haible
97c1fbcc8c Replace FSF snail-mail addresses with URLs.
* tests/java.gperf: Update GPL license notice.
* tests/java.exp: Likewise.
2024-09-01 15:28:44 +02:00
Bruno Haible
b76568199f build: Simplify last change.
* Makefile.in (doc/gperf.1): Simplify rule.
2024-07-22 14:21:52 +02:00
Bruno Haible
5d1c6f3e24 build: Fix failure of "./configure; make dist".
* Makefile.in (srcdir, VPATH): New variables.
(VERSION): Refer to src/version.cc in $(srcdir).
(dist): Depend on doc/gperf.1.
(doc/gperf.1): New rule.
* doc/Makefile.in (DISTRIBUTED_BUILT_FILES): Remove wildcard patterns.
(DISTRIBUTED_BUILT_FILES_EXTRA_PATTERNS): New variable.
(distdir): Handle the files from DISTRIBUTED_BUILT_FILES_EXTRA_PATTERNS.
2024-07-22 02:32:12 +02:00
Bruno Haible
043d5ea719 build: Don't leave an empty gperf.1 on disk if help2man fails.
* doc/Makefile.in (gperf.1): Use a temporary file.
(clean): Remove this temporary file.
2024-07-22 02:32:12 +02:00
Bruno Haible
5e4394dfcb build: Fix VPATH builds.
* doc/Makefile.in (TEXINFO): Look up texi2html in the current directory.
(gperf.1): Look up help2man in the source directory. Generate gperf.1 in
the source directory.
2024-07-22 02:32:12 +02:00
Bruno Haible
efeba7b8bd build: Fix use of perl on Guix, FreeBSD, NetBSD.
* doc/help2man: Search for perl in $PATH.
2024-07-22 02:32:12 +02:00
Bruno Haible
634824575d build: Fix "make maintainer-clean".
* doc/Makefile.in (maintainer-clean): Remove also gperf.1.
2024-07-22 02:32:03 +02:00
Collin Funk
fcb7fc41c4 doc: Make the detailed menu title appear as intended.
* doc/gperf.texi (Top): Add a line break after @detailmenu.

Copyright-paperwork-exempt: Yes
2024-06-13 00:33:43 +02:00
Bruno Haible
0246553284 Fix build (regression 2024-04-04).
Reported by Pádraig Brady <P@draigBrady.com> in
<https://lists.gnu.org/archive/html/bug-gperf/2024-06/msg00000.html>.

* doc/configure.ac: Invoke AC_CONFIG_AUX_DIR, needed for locating
install-sh.
* lib/configure.ac: Likewise.
* src/configure.ac: Likewise.
* tests/configure.ac: Likewise.
2024-06-05 11:31:18 +02:00
Bruno Haible
84183912e0 Remove outdated Autoconf macro.
* aclocal.m4 (CL_PROG_INSTALL): Remove macro.
* doc/configure.ac: Invoke AC_PROG_INSTALL instead of CL_PROG_INSTALL.
* lib/configure.ac: Likewise.
* src/configure.ac: Likewise.
2024-04-04 15:10:51 +02:00
Bruno Haible
ca5217fc79 Mark autoconf 2.72 as supported.
* autogen.sh: Update comment.
2023-12-30 10:08:54 +01:00
Bruno Haible
a02b4653ee Fix "make extracheck" failure (regression 2016-11-27).
* tests/validate (KR-C): Remove the test against ' const ', since the
input files jstest*.gperf now contain 'const' keywords.
2023-09-07 13:20:52 +02:00
Bruno Haible
ce5106eb19 Avoid "clang -Wimplicit-fallthrough" warnings also in C mode.
* src/output.cc (Output::output_hash_function): Enhance the fallthrough
marker, to include clang >= 10 in C mode.
* tests/*.exp: Update.
2023-09-07 12:55:29 +02:00
Bruno Haible
8d68fff1c7 Avoid "gcc -Wmissing-field-initializers" warnings on the generated code.
* src/options.h (Options::has_initializer_suffix): New declaration.
* src/options.cc (Options::has_initializer_suffix): New function.
* src/output.cc (Output::output_keyword_table): If option -t is
specified and option -F is not specified, emit '#pragma GCC diagnostic'
lines, to silence -Wmissing-field-initializers warnings from gcc or
clang.
* tests/charsets.exp: Update.
* tests/gpc.exp: Likewise.
* tests/incomplete.exp: Likewise.
* tests/languages.exp: Likewise.
* tests/objc.exp: Likewise.
* tests/test-4.exp: Likewise.
2023-09-05 21:20:51 +02:00
Bruno Haible
91ed1621cc Avoid "gcc -Wunused-parameter" warnings on the generated hash function.
Reported by Vinícius dos Santos Oliveira <vini.ipsmaker@gmail.com> in
<https://savannah.gnu.org/bugs/index.php?64393>.

* src/output.cc (Output::output_hash_function): If str is not used, emit
a cast from str to void. If len is not used, emit a cast from len to
void.
* tests/permut2.exp: Update.
* tests/permut3.exp: Likewise.
* tests/permutc2.exp: Likewise.
2023-07-08 12:30:47 +02:00
Bruno Haible
2173338a30 doc: Tweaks.
Reported by Laurent Lyaudet <laurent.lyaudet@gmail.com> in
<https://lists.gnu.org/archive/html/bug-gperf/2023-06/msg00000.html>.

* doc/gperf.texi: Update copyright year. Fix some typos.
(Bugs): Don't use the term "recent enhancements", since that's over
20 years ago. Don't mention RAM requirements, since the execution time
is the bigger inconvenience nowadays.
2023-07-01 13:05:26 +02:00
Bruno Haible
3b38ffa21e Update the installation instructions for Windows.
* INSTALL.windows: Add a note about MSYS2.
2023-06-29 15:12:05 +02:00
Bruno Haible
8f9d2b67b7 Ensure that makeinfo ≥ 6.8 checks the @menu structure.
See <https://lists.gnu.org/archive/html/bug-texinfo/2023-06/msg00015.html>.

* doc/Makefile.in (MAKEINFO): Add option
"-c CHECK_NORMAL_MENU_STRUCTURE=1".
2023-06-22 23:04:24 +02:00
Bruno Haible
09844ce4ca Fix a warning regarding strncmp.
Reported by Sam James in <https://savannah.gnu.org/bugs/?63031>.

* lib/getopt.c (strncmp): Declare with a prototype.
2022-09-08 04:45:03 +02:00
Bruno Haible
64940479e3 Split autogen.sh into autopull.sh and autogen.sh.
* autopull.sh: New file, based on autogen.sh.
* autogen.sh: Remove code that was moved to autopull.sh.
* Makefile.in (SOURCE_FILES): Add autogen.sh.
2022-07-17 16:15:08 +02:00
Bruno Haible
1862c6e57a Add support for reproducible builds.
Suggested by Richard Purdie <richard.purdie@linuxfoundation.org> in
<https://lists.gnu.org/archive/html/bug-gperf/2022-07/msg00000.html>.

* autogen.sh: Import also lib/filename.h.
* Makefile.in (IMPORTED_FILES): Add lib/filename.h.
* src/options.cc: Include filename.h.
(Options::print_options): Print only the base name of the program name.
* tests/*.exp: Update.
2022-07-05 07:51:46 +02:00
Bruno Haible
4a6274f6ca Add GNU Project notice.
* JOIN-GNU: New file. Inspired by a suggestion from José E. Marchesi
on the gnu-prog-discuss mailing list.
* README: Refer to it.
* Makefile.in (SOURCE_FILES): Add it.
2022-05-23 00:56:50 +02:00
Bruno Haible
d89cab8712 tests: Fix undefined behaviour.
* tests/test2.c (main): Cast bytes to unsigned before shifting left.
2022-02-08 01:16:48 +01:00
Bruno Haible
6d53a2dbe0 Release gperf-3.2.
* src/version.cc (version_string): Bump to 3.2.
* src/options.cc (Options::parse_options): Bump copyright year.
* tests/*.exp: Update.
* doc/gperf.texi: Bump date.
2022-01-05 12:59:54 +01:00
Michael Drake
96ebd0b95d Honor --readonly-tables when outputting table for --ignore-case.
* src/output.cc (output_upperlower_table): Add 'const' when suitable.
2021-06-06 11:23:17 +02:00
Bruno Haible
b0f961a9b3 Mark Autoconf 2.71 as supported.
* autogen.sh: Update comment.
2021-01-30 14:46:54 +01:00
Bruno Haible
556e87b5c5 Mark Autoconf 2.70 as supported.
* autogen.sh: Update comment.
2020-12-09 01:18:42 +01:00
Bruno Haible
8cb07d4235 Fix warnings from Autoconf 2.69c.
* configure.ac: Invoke AC_INIT, AC_OUTPUT without arguments.
* doc/configure.ac: Likewise.
* lib/configure.ac: Likewise.
* src/configure.ac: Invoke AC_INIT, AC_OUTPUT without arguments. Use
AC_CACHE_CHECK, AC_LANG_PUSH/AC_LANG_POP, AC_COMPILE_IFELSE
* tests/configure.ac: Invoke AC_INIT, AC_OUTPUT without arguments. Use
ac_cv_c_compiler_gnu instead of ac_cv_prog_gcc, and
ac_cv_cxx_compiler_gnu instead of ac_cv_prog_gxx. Don't use 'test' with
option '-a'.
2020-10-05 00:45:25 +02:00