12 コミット 017728110b ... f467f429b2

作者 SHA1 メッセージ 日付
  Christoph Biedl f467f429b2 tcpreplay 4.5.1-1 4 ヶ月 前
  Christoph Biedl 6d79272a72 Add a crude autopkgtest 4 ヶ月 前
  Christoph Biedl 4cebf8dae2 Refresh patch queue 4 ヶ月 前
  Christoph Biedl f4508d8dc3 Merge upstream version 4.5.1 4 ヶ月 前
  Fred Klassen 8d183dfd1d Import upstream version 4.5.1 5 ヶ月 前
  Christoph Biedl 164bbf30dd tcpreplay 4.4.4-1 1 年間 前
  Christoph Biedl c1b83f98dd Merge upstream version 4.4.4 1 年間 前
  Fred Klassen 27a7598261 Import upstream version 4.4.4 1 年間 前
  Christoph Biedl a4f88bf4b5 tcpreplay 4.4.3-1 1 年間 前
  Christoph Biedl 3f6629e956 Compile with libdumbnet in order to enable the fragroute feature. Closes: #1006783 1 年間 前
  Christoph Biedl ad173214ea Merge upstream version 4.4.3 1 年間 前
  Fred Klassen 63f8138876 Import upstream version 4.4.3 2 年 前
100 ファイル変更3862 行追加2848 行削除
  1. 0 303
      INSTALL
  2. 16 8
      Makefile.in
  3. 29 32
      aclocal.m4
  4. 9 8
      config/ar-lib
  5. 3 3
      config/compile
  6. 1 1
      config/depcomp
  7. 92 69
      config/install-sh
  8. 6 4
      config/ltmain.sh
  9. 1 1
      config/missing
  10. 612 220
      configure
  11. 217 147
      configure.ac
  12. 20 0
      debian/changelog
  13. 1 0
      debian/control
  14. 2 2
      debian/patches/debian.disable-tcpreplay-test.patch
  15. 4 0
      debian/tests/control
  16. 84 0
      debian/tests/run-testsuite
  17. 57 5
      docs/CHANGELOG
  18. 34 1
      docs/CREDIT
  19. 29 0
      docs/INSTALL
  20. 3 2
      docs/Makefile.in
  21. 3 2
      lib/Makefile.in
  22. 67 44
      lib/sll.h
  23. 20 21
      lib/strlcat.c
  24. 17 18
      lib/strlcpy.c
  25. 1 1
      lib/strlcpy.h
  26. 1 1
      libopts/COPYING.gplv3
  27. 3 3
      libopts/COPYING.lgplv3
  28. 1 1
      libopts/COPYING.mbsd
  29. 14 13
      libopts/Makefile.am
  30. 28 23
      libopts/Makefile.in
  31. 1 1
      libopts/README
  32. 0 0
      libopts/_Noreturn.h
  33. 2 2
      libopts/ag-char-map.h
  34. 2 2
      libopts/alias.c
  35. 143 139
      libopts/ao-strs.c
  36. 151 145
      libopts/ao-strs.h
  37. 8 14
      libopts/autoopts.c
  38. 9 2
      libopts/autoopts.h
  39. 44 11
      libopts/autoopts/options.h
  40. 5 1
      libopts/autoopts/project.h
  41. 247 253
      libopts/autoopts/usage-txt.h
  42. 2 2
      libopts/boolean.c
  43. 2 2
      libopts/check.c
  44. 4 4
      libopts/compat/compat.h
  45. 1 1
      libopts/compat/windows-config.h
  46. 25 78
      libopts/configfile.c
  47. 1 9
      libopts/cook.c
  48. 3 27
      libopts/enum.c
  49. 3 9
      libopts/env.c
  50. 1 1
      libopts/file.c
  51. 23 38
      libopts/find.c
  52. 111 110
      libopts/genshell.c
  53. 18 3
      libopts/genshell.h
  54. 7 5
      libopts/gettext.h
  55. 4 9
      libopts/init.c
  56. 95 52
      libopts/intprops.h
  57. 4 2
      libopts/libopts.c
  58. 5 25
      libopts/load.c
  59. 17 19
      libopts/m4/libopts.m4
  60. 1 1
      libopts/m4/liboptschk.m4
  61. 38 28
      libopts/m4/stdnoreturn.m4
  62. 15 54
      libopts/makeshell.c
  63. 6 48
      libopts/nested.c
  64. 7 13
      libopts/numeric.c
  65. 5 5
      libopts/option-value-type.c
  66. 5 5
      libopts/option-xat-attribute.c
  67. 2 2
      libopts/parse-duration.c
  68. 3 3
      libopts/parse-duration.h
  69. 1 1
      libopts/pgusage.c
  70. 491 17
      libopts/proto.h
  71. 1 24
      libopts/putshell.c
  72. 1 1
      libopts/reset.c
  73. 2 2
      libopts/restore.c
  74. 248 0
      libopts/save-flags.c
  75. 68 0
      libopts/save-flags.h
  76. 313 206
      libopts/save.c
  77. 2 16
      libopts/sort.c
  78. 2 2
      libopts/stack.c
  79. 21 11
      libopts/stdnoreturn.in.h
  80. 2 2
      libopts/streqvcmp.c
  81. 2 2
      libopts/text_mmap.c
  82. 1 1
      libopts/time.c
  83. 1 18
      libopts/tokenize.c
  84. 8 62
      libopts/usage.c
  85. 7 4
      libopts/version.c
  86. 11 5
      m4/libtool.m4
  87. 3 2
      scripts/Makefile.in
  88. 3 3
      src/Makefile.am
  89. 11 9
      src/Makefile.in
  90. 56 95
      src/bridge.c
  91. 11 15
      src/bridge.h
  92. 24 28
      src/common.h
  93. 6 4
      src/common/Makefile.in
  94. 63 77
      src/common/cache.c
  95. 4 5
      src/common/cache.h
  96. 70 165
      src/common/cidr.c
  97. 8 13
      src/common/cidr.h
  98. 22 0
      src/common/dlt_names.c
  99. 4 0
      src/common/dlt_names.h
  100. 0 0
      src/common/err.c

+ 0 - 303
INSTALL

@@ -1,303 +0,0 @@
-Installation Instructions
-*************************
-
-Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
-2006, 2014 Free Software Foundation, Inc.
-
-This file is free documentation; the Free Software Foundation gives
-unlimited permission to copy, distribute and modify it.
-
-
-Advanced Installation
-=====================
-Visit http://tcpreplay.appneta.com/wiki/installation.html
-
-
-Basic Installation
-==================
-
-    ./configure 
-    make
-    sudo make install
-
-Briefly, the shell commands `./configure; make; make install' should
-configure, build, and install this package.  The following
-more-detailed instructions are generic; see the `README' file for
-instructions specific to this package.
-
-   The `configure' shell script attempts to guess correct values for
-various system-dependent variables used during compilation.  It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions.  Finally, it creates a shell script `config.status' that
-you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
-
-   It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.
-
-   If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
-be considered for the next release.  If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
-may remove or edit it.
-
-   The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
-
-The simplest way to compile this package is:
-
-  1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.
-
-     Running `configure' might take a while.  While running, it prints
-     some messages telling which features it is checking for.
-
-  2. Type `make' to compile the package.
-
-  3. Optionally, type `make check' to run any self-tests that come with
-     the package.
-
-  4. Type `make install' to install the programs and any data files and
-     documentation.
-
-  5. You can remove the program binaries and object files from the
-     source code directory by typing `make clean'.  To also remove the
-     files that `configure' created (so you can compile the package for
-     a different kind of computer), type `make distclean'.  There is
-     also a `make maintainer-clean' target, but that is intended mainly
-     for the package's developers.  If you use it, you may have to get
-     all sorts of other programs in order to regenerate files that came
-     with the distribution.
-
-
-How to make Tcpreplay go fast
-=============================
-
-1) netmap
-   ------
-This feature will detect netmap capable network drivers on Linux and
-BSD systems. If detected, the network driver is bypassed for the
-execution duration of tcpreplay and tcpreplay-edit, and network buffers
-will be written to directly. This will allow you to achieve full 10GigE
-line rates on commodity 10GigE network adapters, similar to rates 
-achieved by commercial network traffic generators.
-
-Note that bypassing the network driver will disrupt other applications
-connected through the test interface. Use caution when testing on the
-same interface you ssh'ed into.
-
-Ensure that you have supported NICs installed. Most Intel and nForce 
-(nVidia) adapters will work. Some virtual adapters are supported.
-
-FreeBSD 10 and higher already contains netmap capabilities and should
-be detected automatically by "configure". But first you must enable
-netmap on the system by adding 'device netmap' to your kernel config
-and rebuilding the kernel. When complete, /dev/netmap will be
-available.
-
-For Linux, download latest netmap sources from http://info.iet.unipi.it/~luigi/netmap/
-or run 'git clone https://code.google.com/p/netmap/'. You will also need to have 
-kernel sources installed so the build system can patch the sources and build 
-netmap-enabled drivers. If kernel sources are in /a/b/c/linux-A.B.C/ , then you
-should do:
-
-    cd netmap/LINUX
-    make KSRC=/a/b/c/linux-A.B.C/       # builds the kernel modules
-    make KSRC=/a/b/c/linux-A.B.C/ apps  # builds sample applications
-
-You can omit KSRC if your kernel sources are in a standard place.
-
-Once you load the netmap.lin.ko module on your Linux machine, /dev/netmap 
-will be available. You will also need to replace your existing network drivers
-(beyond the scope of this document).
-
-Building netmap-aware Tcpreplay suite is relatively straight forward. For
-FreeBSD, build normally. For Linux, if you extracted netmap into /usr/src/ you 
-can also build normally. Otherwise you will have to specify the netmap source
-directory, for example:
-
-    ./configure --with-netmap=/home/fklassen/git/netmap
-    make
-    sudo make install
-
-
-Compilers and Options
-=====================
-
-Some systems require unusual options for compilation or linking that the
-`configure' script does not know about.  Run `./configure --help' for
-details on some of the pertinent environment variables.
-
-   You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment.  Here
-is an example:
-
-     ./configure CC=c99 CFLAGS=-g LIBS=-lposix
-
-   *Note Defining Variables::, for more details.
-
-
-Compiling For Multiple Architectures
-====================================
-
-You can compile the package for more than one kind of computer at the
-same time, by placing the object files for each architecture in their
-own directory.  To do this, you can use GNU `make'.  `cd' to the
-directory where you want the object files and executables to go and run
-the `configure' script.  `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.
-
-   With a non-GNU `make', it is safer to compile the package for one
-architecture at a time in the source code directory.  After you have
-installed the package for one architecture, use `make distclean' before
-reconfiguring for another architecture.
-
-
-Installation Names
-==================
-
-By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc.  You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX'.
-
-   You can specify separate installation prefixes for
-architecture-specific files and architecture-independent files.  If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
-PREFIX as the prefix for installing programs and libraries.
-Documentation and other data files still use the regular prefix.
-
-   In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files.  Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.
-
-   If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-
-Optional Features
-=================
-
-Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System).  The
-`README' should mention any `--enable-' and `--with-' options that the
-package recognizes.
-
-   For packages that use the X Window System, `configure' can usually
-find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
-
-
-Specifying the System Type
-==========================
-
-There may be some features `configure' cannot figure out automatically,
-but needs to determine by the type of machine the package will run on.
-Usually, assuming the package is built to be run on the _same_
-architectures, `configure' can figure that out, but if it prints a
-message saying it cannot guess the machine type, give it the
-`--build=TYPE' option.  TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
-
-     CPU-COMPANY-SYSTEM
-
-where SYSTEM can have one of these forms:
-
-     OS KERNEL-OS
-
-   See the file `config.sub' for the possible values of each field.  If
-`config.sub' isn't included in this package, then this package doesn't
-need to know the machine type.
-
-   If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
-produce code for.
-
-   If you want to _use_ a cross compiler, that generates code for a
-platform different from the build platform, you should specify the
-"host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
-
-
-Sharing Defaults
-================
-
-If you want to set default values for `configure' scripts to share, you
-can create a site shell script called `config.site' that gives default
-values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists.  Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
-
-
-Defining Variables
-==================
-
-Variables not defined in a site shell script can be set in the
-environment passed to `configure'.  However, some packages may run
-configure again during the build, and the customized values of these
-variables may be lost.  In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'.  For example:
-
-     ./configure CC=/usr/local2/bin/gcc
-
-causes the specified `gcc' to be used as the C compiler (unless it is
-overridden in the site shell script).
-
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf bug.  Until the bug is fixed you can use this workaround:
-
-     CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
-
-
-`configure' Invocation
-======================
-
-`configure' recognizes the following options to control how it operates.
-
-`--help'
-`-h'
-     Print a summary of the options to `configure', and exit.
-
-`--version'
-`-V'
-     Print the version of Autoconf used to generate the `configure'
-     script, and exit.
-
-`--cache-file=FILE'
-     Enable the cache: use and save the results of the tests in FILE,
-     traditionally `config.cache'.  FILE defaults to `/dev/null' to
-     disable caching.
-
-`--config-cache'
-`-C'
-     Alias for `--cache-file=config.cache'.
-
-`--quiet'
-`--silent'
-`-q'
-     Do not print messages saying which checks are being made.  To
-     suppress all normal output, redirect it to `/dev/null' (any error
-     messages will still be shown).
-
-`--srcdir=DIR'
-     Look for the package's source code in directory DIR.  Usually
-     `configure' can determine that directory automatically.
-
-`configure' also accepts some other, not widely useful, options.  Run
-`configure --help' for more details.
-

+ 16 - 8
Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -166,10 +166,9 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/doxygen.cfg.in \
 	$(top_srcdir)/config/config.guess \
 	$(top_srcdir)/config/config.sub \
 	$(top_srcdir)/config/install-sh $(top_srcdir)/config/ltmain.sh \
-	$(top_srcdir)/config/missing INSTALL config/ar-lib \
-	config/compile config/config.guess config/config.sub \
-	config/depcomp config/install-sh config/ltmain.sh \
-	config/missing
+	$(top_srcdir)/config/missing config/ar-lib config/compile \
+	config/config.guess config/config.sub config/depcomp \
+	config/install-sh config/ltmain.sh config/missing
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 distdir = $(PACKAGE)-$(VERSION)
 top_distdir = $(distdir)
@@ -208,6 +207,8 @@ am__relativize = \
 DIST_ARCHIVES = $(distdir).tar.gz
 GZIP_ENV = --best
 DIST_TARGETS = dist-gzip
+# Exists only to be overridden by the user if desired.
+AM_DISTCHECK_DVI_TARGET = dvi
 distuninstallcheck_listfiles = find . -type f -print
 am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
   | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
@@ -327,6 +328,7 @@ build_alias = @build_alias@
 build_asan = @build_asan@
 build_cpu = @build_cpu@
 build_os = @build_os@
+build_tsan = @build_tsan@
 build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@
@@ -633,6 +635,10 @@ dist-xz: distdir
 	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
 	$(am__post_remove_distdir)
 
+dist-zstd: distdir
+	tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst
+	$(am__post_remove_distdir)
+
 dist-tarZ: distdir
 	@echo WARNING: "Support for distribution archives compressed with" \
 		       "legacy program 'compress' is deprecated." >&2
@@ -675,6 +681,8 @@ distcheck: dist
 	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
 	*.zip*) \
 	  unzip $(distdir).zip ;;\
+	*.tar.zst*) \
+	  zstd -dc $(distdir).tar.zst | $(am__untar) ;;\
 	esac
 	chmod -R a-w $(distdir)
 	chmod u+w $(distdir)
@@ -690,7 +698,7 @@ distcheck: dist
 	    $(DISTCHECK_CONFIGURE_FLAGS) \
 	    --srcdir=../.. --prefix="$$dc_install_base" \
 	  && $(MAKE) $(AM_MAKEFLAGS) \
-	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
+	  && $(MAKE) $(AM_MAKEFLAGS) $(AM_DISTCHECK_DVI_TARGET) \
 	  && $(MAKE) $(AM_MAKEFLAGS) check \
 	  && $(MAKE) $(AM_MAKEFLAGS) install \
 	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
@@ -855,7 +863,7 @@ uninstall-am:
 	am--refresh check check-am clean clean-cscope clean-generic \
 	clean-libtool cscope cscopelist-am ctags ctags-am dist \
 	dist-all dist-bzip2 dist-gzip dist-hook dist-lzip dist-shar \
-	dist-tarZ dist-xz dist-zip distcheck distclean \
+	dist-tarZ dist-xz dist-zip dist-zstd distcheck distclean \
 	distclean-generic distclean-libtool distclean-local \
 	distclean-tags distcleancheck distdir distuninstallcheck dvi \
 	dvi-am html html-am info info-am install install-am \

+ 29 - 32
aclocal.m4

@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.16.1 -*- Autoconf -*-
+# generated automatically by aclocal 1.16.3 -*- Autoconf -*-
 
-# Copyright (C) 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-2020 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002-2018 Free Software Foundation, Inc.
+# Copyright (C) 2002-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION],
 [am__api_version='1.16'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.16.1], [],
+m4_if([$1], [1.16.3], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -51,12 +51,12 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.16.1])dnl
+[AM_AUTOMAKE_VERSION([1.16.3])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
-# Copyright (C) 2011-2018 Free Software Foundation, Inc.
+# Copyright (C) 2011-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -118,7 +118,7 @@ AC_SUBST([AR])dnl
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -170,7 +170,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2018 Free Software Foundation, Inc.
+# Copyright (C) 1997-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -201,7 +201,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -392,7 +392,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -431,7 +431,9 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
   done
   if test $am_rc -ne 0; then
     AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments
-    for automatic dependency tracking.  Try re-running configure with the
+    for automatic dependency tracking.  If GNU make was not used, consider
+    re-running the configure script with MAKE="gmake" (or whatever is
+    necessary).  You can also try re-running configure with the
     '--disable-dependency-tracking' option to at least be able to build
     the package (albeit without support for automatic dependency tracking).])
   fi
@@ -457,7 +459,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
      [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])])
 
 
-# Copyright (C) 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -481,7 +483,7 @@ fi], [AC_MSG_RESULT([no])])
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -678,7 +680,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -699,7 +701,7 @@ if test x"${install_sh+set}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2018 Free Software Foundation, Inc.
+# Copyright (C) 2003-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -721,7 +723,7 @@ AC_SUBST([am__leading_dot])])
 # Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
 # From Jim Meyering
 
-# Copyright (C) 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -756,7 +758,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -799,7 +801,7 @@ AC_SUBST([am__quote])])
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2018 Free Software Foundation, Inc.
+# Copyright (C) 1997-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -820,12 +822,7 @@ AC_DEFUN([AM_MISSING_HAS_RUN],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 AC_REQUIRE_AUX_FILE([missing])dnl
 if test x"${MISSING+set}" != xset; then
-  case $am_aux_dir in
-  *\ * | *\	*)
-    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
-  *)
-    MISSING="\${SHELL} $am_aux_dir/missing" ;;
-  esac
+  MISSING="\${SHELL} '$am_aux_dir/missing'"
 fi
 # Use eval to expand $SHELL
 if eval "$MISSING --is-lightweight"; then
@@ -838,7 +835,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -867,7 +864,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -914,7 +911,7 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -933,7 +930,7 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1014,7 +1011,7 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2018 Free Software Foundation, Inc.
+# Copyright (C) 2009-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1074,7 +1071,7 @@ AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
 ])
 
-# Copyright (C) 2001-2018 Free Software Foundation, Inc.
+# Copyright (C) 2001-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1102,7 +1099,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2018 Free Software Foundation, Inc.
+# Copyright (C) 2006-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1121,7 +1118,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2018 Free Software Foundation, Inc.
+# Copyright (C) 2004-2020 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,

+ 9 - 8
config/ar-lib

@@ -2,9 +2,9 @@
 # Wrapper for Microsoft lib.exe
 
 me=ar-lib
-scriptversion=2012-03-01.08; # UTC
+scriptversion=2019-07-04.01; # UTC
 
-# Copyright (C) 2010-2018 Free Software Foundation, Inc.
+# Copyright (C) 2010-2020 Free Software Foundation, Inc.
 # Written by Peter Rosin <peda@lysator.liu.se>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -53,7 +53,7 @@ func_file_conv ()
 	  MINGW*)
 	    file_conv=mingw
 	    ;;
-	  CYGWIN*)
+	  CYGWIN* | MSYS*)
 	    file_conv=cygwin
 	    ;;
 	  *)
@@ -65,7 +65,7 @@ func_file_conv ()
 	mingw)
 	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
 	  ;;
-	cygwin)
+	cygwin | msys)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
 	wine)
@@ -224,10 +224,11 @@ elif test -n "$extract"; then
       esac
     done
   else
-    $AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member
-    do
-      $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
-    done
+    $AR -NOLOGO -LIST "$archive" | tr -d '\r' | sed -e 's/\\/\\\\/g' \
+      | while read member
+        do
+          $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $?
+        done
   fi
 
 elif test -n "$quick$replace"; then

+ 3 - 3
config/compile

@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2020 Free Software Foundation, Inc.
 # Written by Tom Tromey <tromey@cygnus.com>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -53,7 +53,7 @@ func_file_conv ()
 	  MINGW*)
 	    file_conv=mingw
 	    ;;
-	  CYGWIN*)
+	  CYGWIN* | MSYS*)
 	    file_conv=cygwin
 	    ;;
 	  *)
@@ -67,7 +67,7 @@ func_file_conv ()
 	mingw/*)
 	  file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
 	  ;;
-	cygwin/*)
+	cygwin/* | msys/*)
 	  file=`cygpath -m "$file" || echo "$file"`
 	  ;;
 	wine/*)

+ 1 - 1
config/depcomp

@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1999-2018 Free Software Foundation, Inc.
+# Copyright (C) 1999-2020 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

+ 92 - 69
config/install-sh

@@ -1,7 +1,7 @@
 #!/bin/sh
 # install - install a program, script, or datafile
 
-scriptversion=2018-03-11.20; # UTC
+scriptversion=2020-11-14.01; # UTC
 
 # This originates from X11R5 (mit/util/scripts/install.sh), which was
 # later released in X11R6 (xc/config/util/install.sh) with the
@@ -69,6 +69,11 @@ posix_mkdir=
 # Desired mode of installed file.
 mode=0755
 
+# Create dirs (including intermediate dirs) using mode 755.
+# This is like GNU 'install' as of coreutils 8.32 (2020).
+mkdir_umask=22
+
+backupsuffix=
 chgrpcmd=
 chmodcmd=$chmodprog
 chowncmd=
@@ -99,18 +104,28 @@ Options:
      --version  display version info and exit.
 
   -c            (ignored)
-  -C            install only if different (preserve the last data modification time)
+  -C            install only if different (preserve data modification time)
   -d            create directories instead of installing files.
   -g GROUP      $chgrpprog installed files to GROUP.
   -m MODE       $chmodprog installed files to MODE.
   -o USER       $chownprog installed files to USER.
+  -p            pass -p to $cpprog.
   -s            $stripprog installed files.
+  -S SUFFIX     attempt to back up existing files, with suffix SUFFIX.
   -t DIRECTORY  install into DIRECTORY.
   -T            report an error if DSTFILE is a directory.
 
 Environment variables override the default commands:
   CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
   RMPROG STRIPPROG
+
+By default, rm is invoked with -f; when overridden with RMPROG,
+it's up to you to specify -f if you want it.
+
+If -S is not specified, no backups are attempted.
+
+Email bug reports to bug-automake@gnu.org.
+Automake home page: https://www.gnu.org/software/automake/
 "
 
 while test $# -ne 0; do
@@ -137,8 +152,13 @@ while test $# -ne 0; do
     -o) chowncmd="$chownprog $2"
         shift;;
 
+    -p) cpprog="$cpprog -p";;
+
     -s) stripcmd=$stripprog;;
 
+    -S) backupsuffix="$2"
+        shift;;
+
     -t)
         is_target_a_directory=always
         dst_arg=$2
@@ -255,6 +275,10 @@ do
     dstdir=$dst
     test -d "$dstdir"
     dstdir_status=$?
+    # Don't chown directories that already exist.
+    if test $dstdir_status = 0; then
+      chowncmd=""
+    fi
   else
 
     # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
@@ -301,22 +325,6 @@ do
   if test $dstdir_status != 0; then
     case $posix_mkdir in
       '')
-        # Create intermediate dirs using mode 755 as modified by the umask.
-        # This is like FreeBSD 'install' as of 1997-10-28.
-        umask=`umask`
-        case $stripcmd.$umask in
-          # Optimize common cases.
-          *[2367][2367]) mkdir_umask=$umask;;
-          .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
-
-          *[0-7])
-            mkdir_umask=`expr $umask + 22 \
-              - $umask % 100 % 40 + $umask % 20 \
-              - $umask % 10 % 4 + $umask % 2
-            `;;
-          *) mkdir_umask=$umask,go-w;;
-        esac
-
         # With -d, create the new directory with the user-specified mode.
         # Otherwise, rely on $mkdir_umask.
         if test -n "$dir_arg"; then
@@ -326,52 +334,49 @@ do
         fi
 
         posix_mkdir=false
-        case $umask in
-          *[123567][0-7][0-7])
-            # POSIX mkdir -p sets u+wx bits regardless of umask, which
-            # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
-            ;;
-          *)
-            # Note that $RANDOM variable is not portable (e.g. dash);  Use it
-            # here however when possible just to lower collision chance.
-            tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
-
-            trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
-
-            # Because "mkdir -p" follows existing symlinks and we likely work
-            # directly in world-writeable /tmp, make sure that the '$tmpdir'
-            # directory is successfully created first before we actually test
-            # 'mkdir -p' feature.
-            if (umask $mkdir_umask &&
-                $mkdirprog $mkdir_mode "$tmpdir" &&
-                exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
-            then
-              if test -z "$dir_arg" || {
-                   # Check for POSIX incompatibilities with -m.
-                   # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
-                   # other-writable bit of parent directory when it shouldn't.
-                   # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
-                   test_tmpdir="$tmpdir/a"
-                   ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
-                   case $ls_ld_tmpdir in
-                     d????-?r-*) different_mode=700;;
-                     d????-?--*) different_mode=755;;
-                     *) false;;
-                   esac &&
-                   $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
-                     ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
-                     test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
-                   }
-                 }
-              then posix_mkdir=:
-              fi
-              rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
-            else
-              # Remove any dirs left behind by ancient mkdir implementations.
-              rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
-            fi
-            trap '' 0;;
-        esac;;
+	# The $RANDOM variable is not portable (e.g., dash).  Use it
+	# here however when possible just to lower collision chance.
+	tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+
+	trap '
+	  ret=$?
+	  rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null
+	  exit $ret
+	' 0
+
+	# Because "mkdir -p" follows existing symlinks and we likely work
+	# directly in world-writeable /tmp, make sure that the '$tmpdir'
+	# directory is successfully created first before we actually test
+	# 'mkdir -p'.
+	if (umask $mkdir_umask &&
+	    $mkdirprog $mkdir_mode "$tmpdir" &&
+	    exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
+	then
+	  if test -z "$dir_arg" || {
+	       # Check for POSIX incompatibilities with -m.
+	       # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+	       # other-writable bit of parent directory when it shouldn't.
+	       # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+	       test_tmpdir="$tmpdir/a"
+	       ls_ld_tmpdir=`ls -ld "$test_tmpdir"`
+	       case $ls_ld_tmpdir in
+		 d????-?r-*) different_mode=700;;
+		 d????-?--*) different_mode=755;;
+		 *) false;;
+	       esac &&
+	       $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {
+		 ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`
+		 test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+	       }
+	     }
+	  then posix_mkdir=:
+	  fi
+	  rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"
+	else
+	  # Remove any dirs left behind by ancient mkdir implementations.
+	  rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null
+	fi
+	trap '' 0;;
     esac
 
     if
@@ -382,7 +387,7 @@ do
     then :
     else
 
-      # The umask is ridiculous, or mkdir does not conform to POSIX,
+      # mkdir does not conform to POSIX,
       # or it failed possibly due to a race condition.  Create the
       # directory the slow way, step by step, checking for races as we go.
 
@@ -411,7 +416,7 @@ do
           prefixes=
         else
           if $posix_mkdir; then
-            (umask=$mkdir_umask &&
+            (umask $mkdir_umask &&
              $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
             # Don't fail if two instances are running concurrently.
             test -d "$prefix" || exit 1
@@ -451,7 +456,18 @@ do
     trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
 
     # Copy the file name to the temp name.
-    (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+    (umask $cp_umask &&
+     { test -z "$stripcmd" || {
+	 # Create $dsttmp read-write so that cp doesn't create it read-only,
+	 # which would cause strip to fail.
+	 if test -z "$doit"; then
+	   : >"$dsttmp" # No need to fork-exec 'touch'.
+	 else
+	   $doit touch "$dsttmp"
+	 fi
+       }
+     } &&
+     $doit_exec $cpprog "$src" "$dsttmp") &&
 
     # and set any options; do chmod last to preserve setuid bits.
     #
@@ -477,6 +493,13 @@ do
     then
       rm -f "$dsttmp"
     else
+      # If $backupsuffix is set, and the file being installed
+      # already exists, attempt a backup.  Don't worry if it fails,
+      # e.g., if mv doesn't support -f.
+      if test -n "$backupsuffix" && test -f "$dst"; then
+        $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null
+      fi
+
       # Rename the file to the real destination.
       $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
 
@@ -491,9 +514,9 @@ do
         # file should still install successfully.
         {
           test ! -f "$dst" ||
-          $doit $rmcmd -f "$dst" 2>/dev/null ||
+          $doit $rmcmd "$dst" 2>/dev/null ||
           { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
-            { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+            { $doit $rmcmd "$rmtmp" 2>/dev/null; :; }
           } ||
           { echo "$0: cannot unlink or rename $dst" >&2
             (exit 1); exit 1

+ 6 - 4
config/ltmain.sh

@@ -31,7 +31,7 @@
 
 PROGRAM=libtool
 PACKAGE=libtool
-VERSION="2.4.6 Debian-2.4.6-9"
+VERSION="2.4.6 Debian-2.4.6-15"
 package_revision=2.4.6
 
 
@@ -387,7 +387,7 @@ EXIT_SKIP=77	  # $? = 77 is used to indicate a skipped test to automake.
 # putting '$debug_cmd' at the start of all your functions, you can get
 # bash to show function call trace with:
 #
-#    debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
+#    debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
 debug_cmd=${debug_cmd-":"}
 exit_cmd=:
 
@@ -2141,7 +2141,7 @@ include the following information:
        compiler:       $LTCC
        compiler flags: $LTCFLAGS
        linker:         $LD (gnu? $with_gnu_ld)
-       version:        $progname $scriptversion Debian-2.4.6-9
+       version:        $progname $scriptversion Debian-2.4.6-15
        automake:       `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
        autoconf:       `($AUTOCONF --version) 2>/dev/null |$SED 1q`
 
@@ -7368,10 +7368,12 @@ func_mode_link ()
       # -stdlib=*            select c++ std lib with clang
       # -fsanitize=*         Clang/GCC memory and address sanitizer
       # -fuse-ld=*           Linker select flags for GCC
+      # -static-*            direct GCC to link specific libraries statically
+      # -fcilkplus           Cilk Plus language extension features for C/C++
       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
       -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
-      -specs=*|-fsanitize=*|-fuse-ld=*)
+      -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus)
         func_quote_for_eval "$arg"
 	arg=$func_quote_for_eval_result
         func_append compile_command " $arg"

+ 1 - 1
config/missing

@@ -3,7 +3,7 @@
 
 scriptversion=2018-03-07.03; # UTC
 
-# Copyright (C) 1996-2018 Free Software Foundation, Inc.
+# Copyright (C) 1996-2020 Free Software Foundation, Inc.
 # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
 
 # This program is free software; you can redistribute it and/or modify

ファイルの差分が大きいため隠しています
+ 612 - 220
configure


+ 217 - 147
configure.ac

@@ -4,7 +4,7 @@ dnl $Id$
 AC_PREREQ([2.69])
 
 dnl Set version info here!
-AC_INIT([tcpreplay],[4.4.2],[https://github.com/appneta/tcpreplay/issues],[tcpreplay],[http://tcpreplay.sourceforge.net/])
+AC_INIT([tcpreplay],[4.5.1],[https://github.com/appneta/tcpreplay/issues],[tcpreplay],[http://tcpreplay.sourceforge.net/])
 AC_CONFIG_SRCDIR([src/tcpreplay.c])
 AC_CONFIG_HEADERS([src/config.h])
 AC_CONFIG_AUX_DIR(config)
@@ -14,7 +14,7 @@ AM_WITH_DMALLOC
 dnl People building from GitHub need the same version of Autogen as I'm using
 dnl or specify --disable-local-libopts to force using the locally-installed
 dnl copy of libopts rather than the source in the `./libopts/` directory.
-MAINTAINER_AUTOGEN_VERSION=5.18.12
+MAINTAINER_AUTOGEN_VERSION=5.18.16
 
 AC_CONFIG_MACRO_DIR([m4])
 
@@ -405,12 +405,28 @@ if test "x$enable_asan" = "xyes"; then
                 [AC_MSG_ERROR([libasan.so not found, this is required for --enable-asan])])
         CFLAGS="${CFLAGS} -O1 -g -fsanitize=address -fno-omit-frame-pointer"
         dnl -lasan always need to be the first library
-        LDFLAGS="-lasan ${LDFLAGS}"
+        LDFLAGS="-fsanitize=address ${LDFLAGS}"
 else
         build_asan=no
 fi
 AC_SUBST(build_asan)
 
+AC_ARG_ENABLE([tsan],
+    AS_HELP_STRING([--enable-tsan],[Enable Thread Sanitizer support]))
+if test "x$enable_tsan" = "xyes"; then
+        build_tsan=yes
+        CFLAGS="${CFLAGS} -O1 -g -fsanitize=thread -fno-omit-frame-pointer"
+        dnl -ltsan always need to be the first library
+        LDFLAGS="-fsanitize=thread ${LDFLAGS}"
+else
+        build_tsan=no
+fi
+AC_SUBST(build_tsan)
+
+if test "$build_asan" = "yes" -a "$build_tsan" = "yes" ; then
+    AC_MSG_ERROR([--enable-asan and --eanble-tsan are mutually exclusive])
+fi
+
 dnl Enable debugging in code/compiler options
 debug=no
 debug_flag=NDEBUG
@@ -550,6 +566,10 @@ AC_ARG_ENABLE(force-libdnet,
     AS_HELP_STRING([--enable-force-libdnet],[Force using libdnet for sending packets]),
     [ AC_DEFINE([FORCE_INJECT_LIBDNET], [1], [Force using libdnet for sending packets])])
 
+AC_ARG_ENABLE(force-libxdp,
+    AS_HELP_STRING([--enable-force-libxdp],[Force using libxdp for sending packets]),
+    [ AC_DEFINE([FORCE_INJECT_LIBXDP], [1], [Force using libxdp for sending packets])])
+
 AC_ARG_ENABLE(force-inject,
     AS_HELP_STRING([--enable-force-inject],[Force using libpcap's pcap_inject() for sending packets]),
     [ AC_DEFINE([FORCE_INJECT_PCAP_INJECT],[1], [Force using libpcap's pcap_inject() for sending packets])])
@@ -589,32 +609,61 @@ else
 fi
 
 dnl Check for inet_aton and inet_pton
+dnl On Haiku these functions are in libnetwork.
 AC_CHECK_FUNC(inet_aton,
     AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?])
     inet_aton=yes,
-    inet_aton=no)
+    [
+        AC_CHECK_LIB(network, inet_aton,
+            AC_DEFINE([HAVE_INET_ATON], [1], [Do we have inet_aton?])
+            use_libnetwork=yes,
+            [inet_aton=no]
+        )
+    ]
+)
 AC_CHECK_FUNC(inet_pton,
     AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?])
     inet_pton=yes,
-    inet_pton=no)
+    [
+        AC_CHECK_LIB(network, inet_pton,
+            AC_DEFINE([HAVE_INET_PTON], [1], [Do we have inet_pton?])
+            use_libnetwork=yes,
+            [inet_pton=no]
+        )
+    ]
+)
 AC_CHECK_FUNC(inet_ntop,
     AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?])
     inet_ntop=yes,
-    inet_ntop=no)
+    [
+        AC_CHECK_LIB(network, inet_ntop,
+            AC_DEFINE([HAVE_INET_NTOP], [1], [Do we have inet_ntop?])
+            use_libnetwork=yes,
+            [inet_ntop=no]
+        )
+    ]
+)
 
 if test "$inet_ntop" = "no" -a "$inet_pton" = "no" ; then
     AC_MSG_ERROR([We need either inet_ntop or inet_pton])
 fi
 
+if test "$use_libnetwork" = "yes" ; then
+	LIBS="-lnetwork $LIBS"
+fi
+
 AC_CHECK_FUNC(inet_addr,
     AC_DEFINE([HAVE_INET_ADDR], [1], [Do we have inet_addr?])
     inet_addr=yes,
     inet_addr=no)
 
-if test x$inet_addr = no ; then
+if test x$inet_addr = xno ; then
     AC_MSG_ERROR([We need inet_addr.  See bug 26])
 fi
 
+dnl On Haiku fts_*() functions are in libbsd.
+AC_CHECK_FUNC(fts_read,,[AC_CHECK_LIB(bsd, fts_read)])
+
 dnl #####################################################
 dnl Checks for tuntap device support
 dnl #####################################################
@@ -655,10 +704,11 @@ AC_ARG_WITH(libpcap,
         LPCAPINCDIR=${testdir}
         if test $dynamic_link = yes; then
             for ext in .dylib .so .tbd ; do
-                for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
+                for dir in . lib lib64 lib32 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
                     sharefile=$(ls ${testdir}/$dir/libpcap${ext}* 2> /dev/null | sort | head -n1)
                     if test -n "${sharefile}"; then
-                        LPCAPLIB="-L$(dirname ${sharefile}) -lpcap"
+                        LPCAP_LD_LIBRARY_PATH="$(dirname ${sharefile})"
+                        LPCAPLIB="-L$LPCAP_LD_LIBRARY_PATH -lpcap"
                         foundpcap=$testdir
                         break
                     fi
@@ -673,7 +723,7 @@ AC_ARG_WITH(libpcap,
             dnl If dynamic library not found, try static
             dnl
             for ext in ${libext} .a .A.tbd ; do
-                for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
+                for dir in . lib lib64 lib32 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
                     staticfile=$(ls ${testdir}/$dir/libpcap${ext} 2> /dev/null | sort | head -n1)
                     if test -n "${staticfile}"; then
                         LPCAPLIB="${staticfile}"
@@ -682,36 +732,6 @@ AC_ARG_WITH(libpcap,
                     fi
                 done
 
-                if ! test $foundpcap = no; then
-                    ## could be PF_RING
-                    #
-                    #  library is static and in PF_RING build tree
-                    #
-                    #  Need access to libpfring library
-                    #  and must find an associated libpfring.a
-                    if test -n "${with_pfring_lib}"; then
-                        if test -f ${with_pfring_lib}; then
-                            pf_ring_lib=${with_pfring_lib}
-                            pf_ring_found=yes
-                        else
-                            AC_MSG_ERROR(["Unable to find PF_RING library ${with_pfring_lib}"])
-                        fi
-                    else
-                        ## search locally for most likely PF_RING library
-                        for lib in ${foundpcap}/../lib/libs/libpfring_zc_${host_cpu}.a \
-                                ${foundpcap}/../lib/libs/libpfring_dna_${host_cpu}.a \
-                                ${foundpcap}/../lib/libs/libpfring_zero_${host_cpu}.a \
-                                ${foundpcap}/../lib/libs/libpfring_nt_${host_cpu}.a \
-                                ${foundpcap}/../lib/libpfring.a; do
-                            if test -f "${lib}"; then
-                                pf_ring_lib=${lib}
-                                pf_ring_found=yes
-                                break
-                            fi
-                        done
-                    fi
-                    break
-                fi
             done
         fi
 
@@ -732,13 +752,13 @@ AC_ARG_WITH(libpcap,
     # and was created to address portability issues. Unfortunately, the script is not updated properly
     # outside of the base distribution. Examples: PF_RING requires 'pthreads', 'numa' and 'rt', but
     # this is not reflect that in the script. OS X Xcode 10.11 SDK creates its own very broken
-    # 'pcap-config' script that only occasionally works for dynamic definitions, and defintely
+    # 'pcap-config' script that only occasionally works for dynamic definitions, and definitely
     # does not work for static.
     #
     # The ability to enable this script exists for corner cases where libpcap distributions starts
     # using even more libraries than I am currently not aware of. Originally, you only had to worry
     # about 'nl', but now we have to be prepared to add 'nl-3', 'nl-genl-3' and 'dbus-1' to make
-    # libpcap fucntional. In the future, there may be more.
+    # libpcap functional. In the future, there may be more.
     #
     # (sigh)
     #
@@ -784,7 +804,7 @@ AC_ARG_WITH(libpcap,
                 LPCAPINCDIR="${testdir}/include"
                 if test $dynamic_link = yes; then
                     for ext in .dylib .so .tbd; do
-                        for dir in . lib lib64 ${host_cpu} lib/${host_cpu} ${host_cpu}-${host_os} lib/${host_cpu}-${host_os} ${MULTIARCH} lib/${MULTIARCH}; do
+                        for dir in . lib lib64 lib32 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
                             sharefile=$(ls "${testdir}/$dir/libpcap${ext}" 2> /dev/null | sort | head -n1)
                             if test -n "${sharefile}"; then
                                 LPCAPLIB="-L$(dirname ${sharefile}) -lpcap"
@@ -803,7 +823,7 @@ AC_ARG_WITH(libpcap,
                     dnl If dynamic library not found, try static
                     dnl
                     for ext in ${libext} .a .A.tbd ; do
-                        for dir in . lib lib64 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
+                        for dir in . lib lib64 lib32 lib/${host_cpu}-${host_os} ${host_cpu}-${host_os} lib/${MULTIARCH} ${MULTIARCH}; do
                             staticfile=$(ls "${testdir}/$dir/libpcap${ext}" 2> /dev/null | sort | head -n1)
                             if test -n "${staticfile}"; then
                                 LPCAPLIB="${staticfile}"
@@ -838,10 +858,31 @@ else
     AC_MSG_RESULT($foundpcap)
 fi
 
+## could be PF_RING
+#
+#  library is static and in PF_RING build tree
+#
+#  Need access to libpfring library
+#  and must find an associated libpfring.a
+if test -n "${with_pfring_lib}"; then
+    if test -f ${with_pfring_lib}; then
+        pf_ring_lib=${with_pfring_lib}
+        pf_ring_found=yes
+    else
+        AC_MSG_ERROR(["Unable to find PF_RING library ${with_pfring_lib}"])
+    fi
+fi
+
 # libpcap can require libnl
 AC_SEARCH_LIBS([nl_handle_alloc], [nl],
         [AC_MSG_NOTICE([Unable to find nl library - may be needed by libpcap])])
 
+AC_CHECK_LIB(bpf, bpf_object__open_file,,
+        [AC_MSG_NOTICE([Unable to find libbpf library ])])
+
+AC_CHECK_LIB(xdp, xsk_umem__delete,,
+        [AC_MSG_NOTICE([Unable to find libxdp library ])])
+
 ##
 ## If not automatically configured,
 ## check for newer and full-featured libpcap's
@@ -886,11 +927,19 @@ if test -n "$LPCAPINCDIR"; then
 else
     OLDCFLAGS="$CFLAGS"
     LPCAPINCDIR=$(echo $CFLAGS | sed -e 's/^\-I//')
-    LPCAPINC="$LPCAPINCDIR/pcap.h"
+    if test -d "$LPCAPINCDIR/pcap"; then
+        LPCAPINC="$LPCAPINCDIR/pcap/pcap.h"
+    else
+        LPCAPINC="$LPCAPINCDIR/pcap.h"
+    fi
 fi
 
 LIBS="$LPCAPLIB"
-AC_SEARCH_LIBS([pcap_get_pfring_id], [pcap], AC_DEFINE([HAVE_PF_RING_PCAP], [1], [Do we have PF_RING libpcap support?]))
+AC_SEARCH_LIBS([pcap_get_pfring_id],
+               [pcap],
+               AC_DEFINE([HAVE_PF_RING_PCAP],
+               ,
+               [${with_pfring_lib} numa pthread rt]))
 
 ## Does libpcap work with selected libraries?
 AC_SEARCH_LIBS([pcap_close], [pcap],
@@ -901,107 +950,55 @@ AC_SUBST(LPCAPLIB)
 
 
 dnl Check to see what version of libpcap
-dnl this code has been reduced a lot, but probably still could be
-dnl reduced quite a bit more if we chose too
-AC_MSG_CHECKING(for libpcap version)
-
-dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important
-dnl fix for OSX.  See: http://tcpreplay.synfin.net/trac/ticket/167
-AC_RUN_IFELSE([AC_LANG_PROGRAM([[
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "$LPCAPINC"
-#define PCAP_TEST "0.9.6"
-]], [[
-/*
- * simple proggy to test the version of libpcap
- * returns zero if version >= 0.9.6
- * or one otherwise
- */
-    if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
-        exit(0);
-
-    if (strncmp(pcap_lib_version(), PCAP_TEST, 5) >= 0) {
-        printf("%s ", pcap_lib_version());
-        exit(0);
-    }
-
-    exit(1);
-]])],
- [libpcap_version_096=yes],
- [libpcap_version_096=no],
- [libpcap_version_096=yes]
-)
-
-AC_RUN_IFELSE([AC_LANG_PROGRAM([[
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include "$LPCAPINC"
-#define PCAP_TEST "0.8"
-]], [[
-/*
- * simple proggy to test the version of libpcap
- * returns zero if version >= 0.8.0
- * or one otherwise
- */
-    if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
-        exit(0);
-
-    /* winpcap? */
-    if (strncmp(pcap_lib_version(), "WinPcap", 7) == 0)
-        exit(0);
-
-    exit(1);
-]])],
- [libpcap_ver8=yes],
- [libpcap_ver8=no],
- [libpcap_ver8=yes]
-)
-
-AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+AC_MSG_CHECKING(libpcap version)
+libpcap_version=unknown
+libpcap_version_096=no
+cat >conftest.c <<EOF
 #include <string.h>
-#include <stdlib.h>
 #include <stdio.h>
 #include "$LPCAPINC"
-#define PCAP_TEST "0.7.2"
-extern const char pcap_version[[]]; /* double up since autoconf escapes things */
-]], [[
 /*
- * simple proggy to test the version of libpcap
- * returns zero if version >= 0.7.2
- * or one otherwise
+ * simple proggy to get the version of libpcap
  */
-    if (strncmp(pcap_lib_version(), PCAP_TEST, 3) >= 0)
-        exit(0);
-
-    if (strncmp(pcap_version, PCAP_TEST, 5) >= 0)
-            exit(0);
+ int main() {
+    printf("%s\n", pcap_lib_version());
+    return 0;
+}
+EOF
+${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LPCAPLIB \
+    conftest.c $LIBS >/dev/null 2>&1
+if test -x conftest -a "$cross_compiling" != "yes"; then
+    full_libpcap_version=$(LD_LIBRARY_PATH="$LPCAP_LD_LIBRARY_PATH" ./conftest)
+    libpcap_version=$(echo "$full_libpcap_version" | ${CUT} -d' ' -f3)
+    pcap_version_ok=yes
+fi
+AC_MSG_RESULT([$libpcap_version])
+rm -rf conftest.* core core.conftest 2>&1 > /dev/null
+
+AC_MSG_CHECKING(for valid libpcap version)
+if test x$libpcap_version != xunknown; then
+    libpcap_major=$(echo ${libpcap_version} | ${CUT} -d '.' -f1)
+    libpcap_minor=$(echo ${libpcap_version} | ${CUT} -d '.' -f2)
+    libpcap_build=$(echo ${libpcap_version} | ${CUT} -d '.' -f3)
+    if test $libpcap_major -eq 0 && \
+        (test $libpcap_minor -lt 7 || \
+         (test $libpcap_minor -eq 7 && test $libpcap_build -lt 2))
+    then
+        AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
+        Please upgrade to version 0.7.2 or better. Your version is $libpcap_version])
+    fi
 
-    exit(1);
-]])],
- [libpcap_ver7=yes],
- [libpcap_ver7=no],
- [libpcap_ver7=yes]
-)
+    dnl 0.9.6 (which is still thinks it is 0.9.5 due to a bug) introduces an important
+    dnl fix for OSX.  See: http://tcpreplay.synfin.net/trac/ticket/167
+    if test $libpcap_major -gt 0 || \
+       (test $libpcap_minor -eq 9 && test $libpcap_build -ge 6)
+    then
+        libpcap_version_096=yes
+    fi
 
-if test x$libpcap_ver8 = xyes ; then
-    AC_MSG_RESULT(>= 0.8.0)
-elif test x$libpcap_ver7 = xyes ; then
-    AC_MSG_RESULT(>= 0.7.2)
+    AC_MSG_RESULT([yes])
 else
-    AC_MSG_ERROR([Libpcap versions < 0.7.2 are not supported
-    Please upgrade to version 0.7.2 or better])
-fi
-
-libpcap_version=unknown
-if test x$libpcap_version_096 = xyes ; then
-    libpcap_version=">= 0.9.6"
-elif test x$libpcap_ver8 = xyes ; then
-    libpcap_version=">= 0.8.0"
-elif test x$libcap_ver7 = xyes ; then
-    libpcap_version=">= 0.7.0"
+    AC_MSG_RESULT([unknown])
 fi
 
 dnl Check for pcap_setnonblock()
@@ -1226,6 +1223,35 @@ if test $have_pcap_snapshot = yes ; then
               [Does libpcap have pcap_snapshot?])
 fi
 
+have_pcap_open_offline_with_tstamp_precision=no
+dnl Check to see if we've got pcap_open_offline_with_tstamp_precision()
+AC_MSG_CHECKING(for pcap_open_offline_with_tstamp_precision support)
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "$LPCAPINC"
+]],[[
+    pcap_t *pcap;
+    char ebuf[PCAP_ERRBUF_SIZE];
+    pcap = pcap_open_offline_with_tstamp_precision("fake.pcap", PCAP_TSTAMP_PRECISION_NANO, &ebuf[0]);
+]])],[
+    have_pcap_open_offline_with_tstamp_precision=yes
+    AC_MSG_RESULT(yes)
+], [
+    have_pcap_open_offline_with_tstamp_precision=no
+    AC_MSG_RESULT(no)
+])
+
+if test $have_pcap_open_offline_with_tstamp_precision = yes ; then
+    AC_DEFINE([HAVE_PCAP_OPEN_OFFLINE_WITH_TSTAMP_PRECISION], [1], [Does libpcap have pcap_open_offline_with_tstamp_precision?])
+    AC_DEFINE([PCAP_TSTAMP_US_TO_NS_MULTIPLIER], [1], [Multiplier for conversion from PCAP usec to nsec])
+    AC_DEFINE([PCAP_TSTAMP_US_TO_US_DIVISOR], [1000], [Divisor for conversion from PCAP usec to usec])
+else
+   AC_DEFINE([PCAP_TSTAMP_US_TO_NS_MULTIPLIER], [1000], [Multiplier for conversion from PCAP usec to nsec])
+   AC_DEFINE([PCAP_TSTAMP_US_TO_US_DIVISOR], [1], [Divisor for conversion from PCAP usec to usec])
+fi
+
 
 # Tcpbridge requires libpcap and pcap_sendpacket()
 enable_tcpbridge=no
@@ -1441,6 +1467,36 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
     AC_MSG_RESULT(no)
 ])
 
+have_libxdp=no
+dnl Check for LIBXDP AF_XDP socket support
+AC_MSG_CHECKING(for LIBXDP XDP packet sending support)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <stdlib.h>
+#include <xdp/xsk.h>
+#include <sys/socket.h>
+]], [[
+    struct xsk_socket {
+        struct xsk_ring_cons *rx;
+        struct xsk_ring_prod *tx;
+        struct xsk_ctx *ctx;
+        struct xsk_socket_config config;
+        int fd;
+    };
+    struct xsk_socket xsk;
+	struct xsk_ring_cons *rxr = NULL;
+	struct xsk_ring_prod *txr = NULL;
+    int queue_id = 0;
+    xsk_socket__create(&xsk, "lo", queue_id, NULL, rxr, txr, NULL);
+    socket(AF_XDP, SOCK_RAW, 0);
+]])],[
+    AC_DEFINE([HAVE_LIBXDP], [1],
+            [Do we have LIBXDP AF_XDP socket support?])
+    AC_MSG_RESULT(yes)
+    have_libxdp=yes
+],[
+    AC_MSG_RESULT(no)
+])
+
 have_tx_ring=no
 dnl Check for older Linux TX_RING support
 AC_MSG_CHECKING(for TX_RING socket sending support)
@@ -1462,6 +1518,9 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
     AC_MSG_RESULT(no)
 ])
 
+AC_CHECK_HEADERS([bpf/libbpf.h])
+AC_CHECK_HEADERS([bpf/bpf.h])
+AC_CHECK_HEADERS([xdp/libxdp.h])
 
 AC_CHECK_HEADERS([net/bpf.h], [have_bpf=yes], [have_bpf=no])
 if test $have_bpf = yes ; then
@@ -1567,6 +1626,15 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "$LPCAPINC"]], [[ int foo;
                ],[AC_MSG_RESULT(no)
                ])
 
+AC_MSG_CHECKING(for DLT_LINUX_SLL2 in libpcap)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "$LPCAPINC"]], [[ int foo;
+                 foo = DLT_LINUX_SLL2
+               ]])],[ AC_DEFINE([HAVE_DLT_LINUX_SLL2], [1],
+                           [Does pcap.h include a header with DLT_LINUX_SLL2?])
+                 AC_MSG_RESULT(yes)
+               ],[AC_MSG_RESULT(no)
+               ])
+
 AC_MSG_CHECKING(for DLT_C_HDLC in libpcap)
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include "$LPCAPINC"]], [[ int foo;
                  foo = DLT_C_HDLC ]])],[ AC_DEFINE([HAVE_DLT_C_HDLC], [1],
@@ -1681,8 +1749,8 @@ int
 main (int argc, char *argv[])
 {
     if (strncmp(PCAPNAV_VERSION, PCAPNAV_TEST, 3) >= 0)
-        exit(0);
-    exit(1);
+        return 0;
+    return 1;
 }           ]])],[libpcapnav_ver=yes
             AC_MSG_RESULT(>= 0.4)],[libpcapnav_ver=no
             AC_MSG_RESULT(< 0.4)],[libpcapnav_ver=no
@@ -1726,31 +1794,32 @@ case "$host_os" in
         #include <sys/types.h>
         #include <sys/wait.h>
         #include <stdio.h>
+        #include <unistd.h>
         unsigned char a[[5]] = { 1, 2, 3, 4, 5 };
-        main() {
+        int main() {
             unsigned int i;
             pid_t pid;
             int status;
             /* avoid "core dumped" message */
             pid = fork();
             if (pid <  0)
-                exit(2);
+                return 2;
             if (pid > 0) {
                 /* parent */
                 pid = waitpid(pid, &status, 0);
                 if (pid < 0)
-                        exit(3);
-                exit(!WIFEXITED(status));
+                        return 3;
+                return !WIFEXITED(status);
             }
             /* child */
             i = *(unsigned int *)&a[[1]];
             printf("%d\n", i);
-            exit(0);
+            return 0;
         }
 EOF
         ${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS \
             conftest.c $LIBS >/dev/null 2>&1
-        if test ! -x conftest ; then
+        if test ! -x conftest -o "$cross_compiling" = "yes" ; then
             dnl failed to compile for some reason
             unaligned_cv_fail=yes
         else
@@ -1980,6 +2049,7 @@ pcap_sendpacket:            ${have_pcap_sendpacket} **
 pcap_netmap                 ${have_pcap_netmap}
 Linux/BSD netmap:           ${have_netmap}
 Tuntap device support:      ${have_tuntap}
+LIBXDP for AF_XDP socket:   ${have_libxdp}
 
 * In order of preference; see configure --help to override
 ** Required for tcpbridge

+ 20 - 0
debian/changelog

@@ -1,3 +1,23 @@
+tcpreplay (4.5.1-1) unstable; urgency=medium
+
+  * New upstream version 4.5.1
+
+ -- Christoph Biedl <debian.axhn@manchmal.in-ulm.de>  Sat, 10 Aug 2024 22:00:30 +0200
+
+tcpreplay (4.4.4-1) unstable; urgency=medium
+
+  * New upstream version 4.4.4
+
+ -- Christoph Biedl <debian.axhn@manchmal.in-ulm.de>  Sat, 02 Sep 2023 17:46:31 +0200
+
+tcpreplay (4.4.3-1) unstable; urgency=medium
+
+  * New upstream version 4.4.3
+  * Compile with libdumbnet in order to enable the fragroute feature.
+    Closes: #1006783
+
+ -- Christoph Biedl <debian.axhn@manchmal.in-ulm.de>  Mon, 02 Jan 2023 18:36:37 +0100
+
 tcpreplay (4.4.2-1) unstable; urgency=medium
 
   * New upstream version 4.4.2. Closes: #1018057

+ 1 - 0
debian/control

@@ -6,6 +6,7 @@ Vcs-Browser: https://git.in-ulm.de/cbiedl/tcpreplay
 Vcs-Git: https://git.in-ulm.de/cbiedl/tcpreplay.git
 Build-Depends: debhelper-compat (= 13),
     autogen,
+    libdumbnet-dev,
     libpcap0.8-dev,
     tcpdump,
 Priority: optional

+ 2 - 2
debian/patches/debian.disable-tcpreplay-test.patch

@@ -5,8 +5,8 @@ Last-Update: 2017-04-26
 
 --- a/test/Makefile.am
 +++ b/test/Makefile.am
-@@ -43,7 +43,7 @@
- 		test2.rewrite_fixlen_pad test2.rewrite_fixlen_trunc test2.rewrite_fixlen_del
+@@ -49,7 +49,7 @@
+ 		test2.replay_unique_ip test2.replay_include test2.replay_exclude
  
  test: all
 -all: clearlog check tcpprep tcpreplay tcprewrite

+ 4 - 0
debian/tests/control

@@ -0,0 +1,4 @@
+Tests: run-testsuite
+Depends: @, perl
+Restrictions:
+    allow-stderr,

+ 84 - 0
debian/tests/run-testsuite

@@ -0,0 +1,84 @@
+#!/usr/bin/perl
+
+# Transform Makefile.am and config.in so they can be executed
+# standalone. Then run the test suite.
+
+# There should be a way to use m4 for this.
+
+use 5.010;
+use strict;
+use warnings;
+
+use Config;
+use Cwd;
+
+my $big_endian = sub {
+    my $bo = $Config{'byteorder'};
+    ($bo == 87654321) and return 1;
+    ($bo == 12345678) and return;
+    die ("Cannot understand byte order: $bo");
+}->();
+
+chdir ('test') or die ("Cannot change to test/: $!");
+
+my $PWD = getcwd;
+
+sub transform {
+    my ($src_file, $dst_file) = @_;
+
+    my $fh_in;
+    my $fh_out;
+    open ($fh_in, '<', $src_file) or
+        die ("Cannot open '$src_file': $!");
+    open ($fh_out, '>', $dst_file) or
+        die ("Cannot write '$dst_file': $!");
+
+    my $in_clause;
+    my $mute;
+    while (defined (my $line = <$fh_in>)) {
+        if ($line =~ /if WORDS_BIGENDIAN/) {
+            $in_clause and die ('State machine error');
+            $in_clause = 1;
+            $mute = !$big_endian;
+            next;
+        } elsif ($line =~ /^else/) {
+            $in_clause or die ('State machine error');
+            $mute = $big_endian;
+            next;
+        } elsif ($line =~ /^endif/) {
+            $in_clause or die ('State machine error');
+            $mute = undef;
+            $in_clause = undef;
+            next;
+        }
+
+        $mute and next;
+
+        $line =~ s/\@PRINTF\@/printf/;
+        $line =~ s/\@host\@/localhost/;
+        $line =~ s/\@(target|build|nic1|nic2)\@/'-$1-'/;
+        $line =~ s:=../src/:=/usr/bin/:;
+        $line =~ s/\@debug_run_time_flag\@/--dbug=1/;
+        $line =~ s/^(all: .+) tcpreplay (.+)$/$1 $2/;
+        $line =~ s/\@srcdir\@/$PWD/g;
+        print $fh_out $line;
+    }
+    close ($fh_in);
+    close ($fh_out) or die;
+
+    system ('diff', '-u', $src_file, $dst_file);
+}
+
+transform ('Makefile.am', 'Makefile.test');
+transform ('config.in', 'config');
+
+$ENV{'srcdir'} = $PWD;
+system ('make', '-f', 'Makefile.test');
+my $exit = $? ? 1 : 0;
+
+print "test.log content:\n";
+system ('cat', 'test.log');
+
+exit $exit;
+
+__END__

+ 57 - 5
docs/CHANGELOG

@@ -1,4 +1,55 @@
+07/12/2024 Version 4.5.1
+    - NULL Pointer Dereference in parse_endpoints (#888)
+    - tcpreplay --include / --exclude to control which packets are replayed (#884)
+    - add -W (--suppress-warnings) option to suppress warning messages (#878)
+    - AF_XDP compile issue due to merge issue (#876)
+    - memory leak in tcpprep when using include/exclude (#869)
+    - memory leak in tcpprep when using RegEx (#867)
+    - fix nanosecond timestamp regression bug (#863)
+    - autotools - AC_HELP_STRING is obsolete in 2.70 (#856)
+    - add -w output.pcap command line option to direct the output to a pcap (#853)
+    - configure.ac: do not run conftest in case of cross compilation (#849)
+    - Haiku support (#847)
+    - --fixhdrlen option added to control action on packet length changes (#846)
+    - incorrect checksum for certain IPv4 packets - fixed by #846 (#844)
+    - add check for IPv6 extension header length (#827 #842)
+    - GitHub template for pull requests (#839)
+    - improved 802.3 (Ethernet I) handling and warning messages (#835)
+    - handle IPv6 fragment extension header (#832 #837)
+    - Linux tap interfaces fail intermittently (#828)
+    - Infinite loop in tcprewrite at get.c (#827 #842)
+    - SLL incorrect size and protocol when converted to Ethernet (#826)
+    - CVE-2023-43279 add check for empty CIDR (#824 #843)
+    - AF_XDP socket extension (#822 #823)
+    - configure.ac: unify search dirs for pcap and add lib32 (#819)
+    - tcpreplay-edit recomputes IPv4 checksums unnecessarily (#815 #846)
+    - CVE-2023-4256 double free in tcprewrite DLT_JUNIPER_ETHER (#813 #851)
+    - dlt_jnpr_ether_cleanup: check config before cleanup (#812 #851)
+    - SEGV on invalid Juniper Ethernet header length (#811)
+    - nanosecond timestamps support (#796)
+    - Linux cooked packet fatal error (#792)
+    - low PPS values run at full speed after several days (#779)
+    - create DLT_LINUX_SLL2 plugin (#727)
+
+06/04/2023 Version 4.4.4
+    - overflow check fix for parse_mpls (#795)
+    - tcpreplay-edit: prevent L2 flooding of ipv6 unicast packets (#793)
+    - CVE-2023-27784 CVE-2023-27785 CVE-2023-27786 CVE-2023-27787 CVE-2023-27788 CVE-2023-27789
+      bugs caused by strtok_r (#782 #784 #785 #786 #787 #788)
+    - CVE-2023-27783 reachable assert in tcpedit_dlt_cleanup (#780)
+    - add CI and C/C++ Linter and CodeQL (#773)
+    - reachable assert in fast_edit_packet (#772)
+
+01/01/2023 Version 4.4.3
+    - upgrade autogen/libopts to version 5.18.16 (#759)
+    - avoid implicit int in configure.ac (#757)
+    - remove invalid assert in tree (#756)
+    - program exit after send error (#751)
+    - make libpcap version test more robust (#750)
+    - looping inflates some packet counters (#749)
+
 08/28/2022 Version 4.4.2
+    - fix tests when building in a directory outside source tree (#767)
     - remove autogen.sh from distribution tarballs (#745)
     - CVE-2022-37048 heap-overflow in get_l2len_protocol (#735)
     - replaying on a loopback interface is broken (#732)
@@ -16,15 +67,16 @@
     - build failures Debian/kfreebsd (#706)
     - bus error when building on armhf (#705)
     - typo fixes (#704)
-    - heap buffer overflow in tcpreplay (#703)
-    - double free in Juniper DLT (#702)
+    - CVE-2022-27418 heap buffer overflow in tcpreplay (#703)
+    - CVE-2022-27416 double free in Juniper DLT (#702)
 
 01/31/2022 Version 4.4.0
     - remove obsolete FORCE_ALIGN support to fix macOS 11 compile (#695)
     - add a security policy document (#689)
+    - CVE-2021-45386 CVE-2021-45387 two reachable assertions in add_tree_ipv4() and add_tree_ipv6() (#687 #678)
     - ability to specify directory of pcap files (#682)
     - incorrect PPS rate for long-running sessions (#679)
-    - option --skipbroadcast not working (#677)
+    - option --skipbroadcast not working (#677 #678)
     - revert #630 to fix --multiplier issues (#674)
     - gcc 9.3 compiler warnings (#670)
     - installed netmap not automatically detected (#669)
@@ -63,7 +115,7 @@
     - CVE-2018-20553 Correct L2 header length calculations so that IP header offset is correct (#584)
     - Correct L2 header length to correct IP header offset (#583)
     - Fix warnings from gcc version 10 (#580)
-    - Heap Buffer Overflow in randomize_iparp (#579)
+    -  CVE-2020-23273 Heap Buffer Overflow in randomize_iparp (#579)
     - Use after free in get_ipv6_next (#578)
     - CVE-2020-12740 Heap Buffer Overflow in git_ipv6_next (#576)
     - Call pcap_freecode() on pcap_compile() (#572)
@@ -71,7 +123,7 @@
     - Fix divide by zero in fuzzing (#570)
     - Unique IP repeats at very high iteration counts (#566)
     - Fails to compile on FreeBSD amd64 13.0 (#558)
-    - Heap Buffer Overflow in do_checksum (#556) (#577)
+    - CVE-2020-18976 Heap Buffer Overflow in do_checksum (#556) (#577)
     - Attempt to correct corrupt pcap files, if possible (#557)
     - Fix GCC v10 warnings (#555)
     - Remove some duplicated SOURCES entries (#551)

+ 34 - 1
docs/CREDIT

@@ -105,5 +105,38 @@ Dave Craig <GitHub @davecraig>
 Vincent Bernat <GitHub @vincentbernat>
     - tcprewrite: fix DLT name for DLT_C_JNPR_ETHER in documentation
 
-Halver <GigHub @Halver>
+Halver <GitHub @Halver>
     - specify directories as files
+
+Florian Weimer <GitHub @fweimer-rh>
+    - Avoid implicit int in configure.ac
+
+David Guti <GitHub @david-guti>
+    - prevent L2 flooding of ipv6 unicast packets for tcpreplay-edit
+
+Bastian Triller <GitHub @btriller>
+    - Linux SLL2
+
+GithHub @plangarbalint
+    - eBPF (AF_XDF)
+    - nanosecond timers
+
+Chuck Cottrill <GitHub @ChuckCottrill>
+    - handle IPv6 fragment extensions
+    - --fixhdrlen option
+    - bug fixes
+
+Martin 'JaMa' Jansa <GitHub @shr-project>
+    - configure.ac: unify search dirs for pcap and add lib32
+
+Marsman <GitHub Marsman1996>
+    - dlt_jnpr_ether_cleanup: check config before cleanup
+
+Chen Qi <GitHub ChenQi1989>
+    - configure.ac: do not run conftest in case of cross compilation
+
+Denis Ovsienko <GitHub infrastation>
+    - Haiku support
+
+Jason Lue <GitHub jasonlue>
+    - tcpreplay -w option

+ 29 - 0
docs/INSTALL

@@ -128,6 +128,35 @@ directory, for example:
     make
     sudo make install
 
+2) AF_XDF
+   ------
+
+This feature will detect AF_XDP capable network drivers on Linux. If detected,
+the `--xdp` option becomes available, allowing eBPF enabled adapters to be
+written to directly.
+
+This feature requires `libxdp-dev` and `libbpf-dev` packages to be installed.
+For example:
+
+    $ sudo apt install -y libxdp-dev libbpf-dev
+    $ ./configure | tail
+    Linux/BSD netmap:           no
+    Tuntap device support:      yes
+    LIBXDP for AF_XDP socket:   yes
+    $ make
+    $ sudo make install
+    $ tcpreplay -i eth0 --xdp test/test.pcap
+
+If you want to compile a version that only uses AF_XDP, use the `--enable-force-libxdp`
+configure option, e.g.
+
+    $ ./configure --enable-force-libxdp | tail
+    Linux/BSD netmap:           no
+    Tuntap device support:      yes
+    LIBXDP for AF_XDP socket:   yes
+    $ make
+    $ sudo make install
+    $ tcpreplay -i eth0 test/test.pcap
 
 Compilers and Options
 =====================

+ 3 - 2
docs/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -240,6 +240,7 @@ build_alias = @build_alias@
 build_asan = @build_asan@
 build_cpu = @build_cpu@
 build_os = @build_os@
+build_tsan = @build_tsan@
 build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@

+ 3 - 2
lib/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -301,6 +301,7 @@ build_alias = @build_alias@
 build_asan = @build_asan@
 build_cpu = @build_cpu@
 build_os = @build_os@
+build_tsan = @build_tsan@
 build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@

+ 67 - 44
lib/sll.h

@@ -1,10 +1,10 @@
 /*-
  * Copyright (c) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
- *	The Regents of the University of California.  All rights reserved.
+ *    The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from the Stanford/CMU enet packet filter,
  * (net/enet.c) distributed as part of 4.3BSD, and code contributed
- * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence 
+ * to Berkeley by Steven McCanne and Van Jacobson both of Lawrence
  * Berkeley Laboratory.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -42,30 +42,30 @@
  * For captures on Linux cooked sockets, we construct a fake header
  * that includes:
  *
- *	a 2-byte "packet type" which is one of:
+ *    a 2-byte "packet type" which is one of:
  *
- *		LINUX_SLL_HOST		packet was sent to us
- *		LINUX_SLL_BROADCAST	packet was broadcast
- *		LINUX_SLL_MULTICAST	packet was multicast
- *		LINUX_SLL_OTHERHOST	packet was sent to somebody else
- *		LINUX_SLL_OUTGOING	packet was sent *by* us;
+ *        LINUX_SLL_HOST         packet was sent to us
+ *        LINUX_SLL_BROADCAST    packet was broadcast
+ *        LINUX_SLL_MULTICAST    packet was multicast
+ *        LINUX_SLL_OTHERHOST    packet was sent to somebody else
+ *        LINUX_SLL_OUTGOING     packet was sent *by* us;
  *
- *	a 2-byte Ethernet protocol field;
+ *    a 2-byte Ethernet protocol field;
  *
- *	a 2-byte link-layer type;
+ *    a 2-byte link-layer type;
  *
- *	a 2-byte link-layer address length;
+ *    a 2-byte link-layer address length;
  *
- *	an 8-byte source link-layer address, whose actual length is
- *	specified by the previous value.
+ *    an 8-byte source link-layer address, whose actual length is
+ *    specified by the previous value.
  *
  * All fields except for the link-layer address are in network byte order.
  *
  * DO NOT change the layout of this structure, or change any of the
  * LINUX_SLL_ values below.  If you must change the link-layer header
  * for a "cooked" Linux capture, introduce a new DLT_ type (ask
- * "tcpdump-workers@tcpdump.org" for one, so that you don't give it a
- * value that collides with a value already being used), and use the
+ * "tcpdump-workers@lists.tcpdump.org" for one, so that you don't give it
+ * a value that collides with a value already being used), and use the
  * new header in captures of that type, so that programs that can
  * handle DLT_LINUX_SLL captures will continue to handle them correctly
  * without any change, and so that capture files with different headers
@@ -77,54 +77,77 @@
 #ifndef _SLL_H_
 #define _SLL_H_
 
+//#include <pcap/pcap-inttypes.h>
+#include <inttypes.h>
+
 /*
  * A DLT_LINUX_SLL fake link-layer header.
  */
-#define SLL_HDR_LEN	16          /* total header length */
-#define SLL_ADDRLEN	8           /* length of address field */
+#define SLL_HDR_LEN    16           /* total header length */
+#define SLL_ADDRLEN    8            /* length of address field */
 
 struct sll_header {
-    u_int16_t sll_pkttype;      /* packet type */
-    u_int16_t sll_hatype;       /* link-layer address type */
-    u_int16_t sll_halen;        /* link-layer address length */
+    u_int16_t sll_pkttype;          /* packet type */
+    u_int16_t sll_hatype;           /* link-layer address type */
+    u_int16_t sll_halen;            /* link-layer address length */
     u_int8_t sll_addr[SLL_ADDRLEN]; /* link-layer address */
-    u_int16_t sll_protocol;     /* protocol */
+    u_int16_t sll_protocol;         /* protocol */
+};
+
+/*
+ * A DLT_LINUX_SLL2 fake link-layer header.
+ */
+#define SLL2_HDR_LEN    20              /* total header length */
+
+struct sll2_header {
+    u_int16_t sll2_protocol;            /* protocol */
+    u_int16_t sll2_reserved_mbz;        /* reserved - must be zero */
+    u_int32_t sll2_if_index;            /* 1-based interface index */
+    u_int16_t sll2_hatype;              /* link-layer address type */
+    u_int8_t  sll2_pkttype;             /* packet type */
+    u_int8_t  sll2_halen;               /* link-layer address length */
+    u_int8_t  sll2_addr[SLL_ADDRLEN];   /* link-layer address */
 };
 
 /*
- * The LINUX_SLL_ values for "sll_pkttype"; these correspond to the
- * PACKET_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux, and so that they
- * don't change even if the PACKET_ values change.
+ * The LINUX_SLL_ values for "sll_pkttype" and LINUX_SLL2_ values for
+ * "sll2_pkttype"; these correspond to the PACKET_ values on Linux,
+ * which are defined by a header under include/uapi in the current
+ * kernel source, and are thus not going to change on Linux.  We
+ * define them here so that they're available even on systems other
+ * than Linux.
  */
-#define LINUX_SLL_HOST		0
-#define LINUX_SLL_BROADCAST	1
-#define LINUX_SLL_MULTICAST	2
-#define LINUX_SLL_OTHERHOST	3
-#define LINUX_SLL_OUTGOING	4
+#define LINUX_SLL_HOST         0
+#define LINUX_SLL_BROADCAST    1
+#define LINUX_SLL_MULTICAST    2
+#define LINUX_SLL_OTHERHOST    3
+#define LINUX_SLL_OUTGOING     4
 
 /*
- * The LINUX_SLL_ values for "sll_protocol"; these correspond to the
- * ETH_P_ values on Linux, but are defined here so that they're
- * available even on systems other than Linux.  We assume, for now,
- * that the ETH_P_ values won't change in Linux; if they do, then:
+ * The LINUX_SLL_ values for "sll_protocol" and LINUX_SLL2_ values for
+ * "sll2_protocol"; these correspond to the ETH_P_ values on Linux, but
+ * are defined here so that they're available even on systems other than
+ * Linux.  We assume, for now, that the ETH_P_ values won't change in
+ * Linux; if they do, then:
  *
- *	if we don't translate them in "pcap-linux.c", capture files
- *	won't necessarily be readable if captured on a system that
- *	defines ETH_P_ values that don't match these values;
+ *    if we don't translate them in "pcap-linux.c", capture files
+ *    won't necessarily be readable if captured on a system that
+ *    defines ETH_P_ values that don't match these values;
  *
- *	if we do translate them in "pcap-linux.c", that makes life
- *	unpleasant for the BPF code generator, as the values you test
- *	for in the kernel aren't the values that you test for when
- *	reading a capture file, so the fixup code run on BPF programs
- *	handed to the kernel ends up having to do more work.
+ *    if we do translate them in "pcap-linux.c", that makes life
+ *    unpleasant for the BPF code generator, as the values you test
+ *    for in the kernel aren't the values that you test for when
+ *    reading a capture file, so the fixup code run on BPF programs
+ *    handed to the kernel ends up having to do more work.
  *
  * Add other values here as necessary, for handling packet types that
  * might show up on non-Ethernet, non-802.x networks.  (Not all the ones
  * in the Linux "if_ether.h" will, I suspect, actually show up in
  * captures.)
  */
-#define LINUX_SLL_P_802_3	0x0001  /* Novell 802.3 frames without 802.2 LLC header */
-#define LINUX_SLL_P_802_2	0x0004  /* 802.2 frames (not D/I/X Ethernet) */
+#define LINUX_SLL_P_802_3    0x0001      /* Novell 802.3 frames without 802.2 LLC header */
+#define LINUX_SLL_P_802_2    0x0004     /* 802.2 frames (not D/I/X Ethernet) */
+#define LINUX_SLL_P_CAN      0x000C     /* CAN frames, with SocketCAN pseudo-headers */
+#define LINUX_SLL_P_CANFD    0x000D     /* CAN FD frames, with SocketCAN pseudo-headers */
 
 #endif

+ 20 - 21
lib/strlcat.c

@@ -16,7 +16,6 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/types.h>
 #include <string.h>
 
 /*
@@ -29,27 +28,27 @@
 size_t
 strlcat(char *dst, const char *src, size_t dsize)
 {
-	const char *odst = dst;
-	const char *osrc = src;
-	size_t n = dsize;
-	size_t dlen;
+    const char *odst = dst;
+    const char *osrc = src;
+    size_t n = dsize;
+    size_t dlen;
 
-	/* Find the end of dst and adjust bytes left but don't go past end. */
-	while (n-- != 0 && *dst != '\0')
-		dst++;
-	dlen = dst - odst;
-	n = dsize - dlen;
+    /* Find the end of dst and adjust bytes left but don't go past end. */
+    while (n-- != 0 && *dst != '\0')
+        dst++;
+    dlen = dst - odst;
+    n = dsize - dlen;
 
-	if (n-- == 0)
-		return(dlen + strlen(src));
-	while (*src != '\0') {
-		if (n != 0) {
-			*dst++ = *src;
-			n--;
-		}
-		src++;
-	}
-	*dst = '\0';
+    if (n-- == 0)
+        return (dlen + strlen(src));
+    while (*src != '\0') {
+        if (n != 0) {
+            *dst++ = *src;
+            n--;
+        }
+        src++;
+    }
+    *dst = '\0';
 
-	return(dlen + (src - osrc));	/* count does not include NUL */
+    return (dlen + (src - osrc)); /* count does not include NUL */
 }

+ 17 - 18
lib/strlcpy.c

@@ -16,7 +16,6 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <sys/types.h>
 #include <string.h>
 
 /*
@@ -27,24 +26,24 @@
 size_t
 strlcpy(char *dst, const char *src, size_t dsize)
 {
-	const char *osrc = src;
-	size_t nleft = dsize;
+    const char *osrc = src;
+    size_t nleft = dsize;
 
-	/* Copy as many bytes as will fit. */
-	if (nleft != 0) {
-		while (--nleft != 0) {
-			if ((*dst++ = *src++) == '\0')
-				break;
-		}
-	}
+    /* Copy as many bytes as will fit. */
+    if (nleft != 0) {
+        while (--nleft != 0) {
+            if ((*dst++ = *src++) == '\0')
+                break;
+        }
+    }
 
-	/* Not enough room in dst, add NUL and traverse rest of src. */
-	if (nleft == 0) {
-		if (dsize != 0)
-			*dst = '\0';		/* NUL-terminate dst */
-		while (*src++)
-			;
-	}
+    /* Not enough room in dst, add NUL and traverse rest of src. */
+    if (nleft == 0) {
+        if (dsize != 0)
+            *dst = '\0'; /* NUL-terminate dst */
+        while (*src++)
+            ;
+    }
 
-	return(src - osrc - 1);	/* count does not include NUL */
+    return (src - osrc - 1); /* count does not include NUL */
 }

+ 1 - 1
lib/strlcpy.h

@@ -1,6 +1,6 @@
 /*
  *   Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
- *   Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
+ *   Copyright (c) 2013-2024 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  *
  *   The Tcpreplay Suite of tools is free software: you can redistribute it 
  *   and/or modify it under the terms of the GNU General Public License as 

+ 1 - 1
libopts/COPYING.gplv3

@@ -1,7 +1,7 @@
                     GNU GENERAL PUBLIC LICENSE
                        Version 3, 29 June 2007
 
- Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 

+ 3 - 3
libopts/COPYING.lgplv3

@@ -1,7 +1,7 @@
 		   GNU LESSER GENERAL PUBLIC LICENSE
                        Version 3, 29 June 2007
 
- Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
@@ -10,7 +10,7 @@
 the terms and conditions of version 3 of the GNU General Public
 License, supplemented by the additional permissions listed below.
 
-  0. Additional Definitions. 
+  0. Additional Definitions.
 
   As used herein, "this License" refers to version 3 of the GNU Lesser
 General Public License, and the "GNU GPL" refers to version 3 of the GNU
@@ -111,7 +111,7 @@ the following:
        a copy of the Library already present on the user's computer
        system, and (b) will operate properly with a modified version
        of the Library that is interface-compatible with the Linked
-       Version. 
+       Version.
 
    e) Provide Installation Information, but only if you would otherwise
    be required to provide such information under section 6 of the

+ 1 - 1
libopts/COPYING.mbsd

@@ -1,4 +1,4 @@
-Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
 Redistribution and use in source and binary forms, with or without
 modification, are permitted provided that the following conditions are met:
 

+ 14 - 13
libopts/Makefile.am

@@ -7,19 +7,19 @@ noinst_LTLIBRARIES      = libopts.la
 endif
 libopts_la_SOURCES      = libopts.c
 libopts_la_CPPFLAGS     = -I$(srcdir)
-#libopts_la_LDFLAGS      = -version-info  41:1:16
+libopts_la_LDFLAGS      = -version-info  42:1:17
 EXTRA_DIST		=
 BUILT_SOURCES		=
 MOSTLYCLEANFILES	=
 
 libopts.c:		$(BUILT_SOURCES)
-	@: do-nothing rule to avoid default SCCS get
+@: do-nothing rule to avoid default SCCS get
 
 
 # Makefile fragment from gnulib-s stdnoreturn module:
 #
-_NORETURN_H=$(srcdir)/compat/_Noreturn.h
-EXTRA_DIST += $(srcdir)/compat/_Noreturn.h
+_NORETURN_H=$(srcdir)/_Noreturn.h
+EXTRA_DIST += _Noreturn.h
 BUILT_SOURCES += $(STDNORETURN_H)
 if GL_GENERATE_STDNORETURN_H
 stdnoreturn.h: stdnoreturn.in.h $(top_builddir)/config.status $(_NORETURN_H)
@@ -38,11 +38,11 @@ EXTRA_DIST += stdnoreturn.in.h
 
 EXTRA_DIST += \
     COPYING.gplv3           COPYING.lgplv3          COPYING.mbsd  \
-    MakeDefs.inc            README                  ag-char-map.h  \
-    alias.c                 ao-strs.c               ao-strs.h  \
-    autoopts.c              autoopts.h              autoopts/options.h  \
-    autoopts/project.h      autoopts/usage-txt.h    boolean.c  \
-    check.c                 compat/_Noreturn.h      compat/compat.h  \
+    MakeDefs.inc            README                  _Noreturn.h  \
+    ag-char-map.h           alias.c                 ao-strs.c  \
+    ao-strs.h               autoopts.c              autoopts.h  \
+    autoopts/options.h      autoopts/project.h      autoopts/usage-txt.h  \
+    boolean.c               check.c                 compat/compat.h  \
     compat/pathfind.c       compat/snprintf.c       compat/strchr.c  \
     compat/strdup.c         compat/windows-config.h configfile.c  \
     cook.c                  enum.c                  env.c  \
@@ -54,7 +54,8 @@ EXTRA_DIST += \
     option-value-type.h     option-xat-attribute.c  option-xat-attribute.h  \
     parse-duration.c        parse-duration.h        pgusage.c  \
     proto.h                 putshell.c              reset.c  \
-    restore.c               save.c                  sort.c  \
-    stack.c                 stdnoreturn.in.h        streqvcmp.c  \
-    text_mmap.c             time.c                  tokenize.c  \
-    usage.c                 version.c
+    restore.c               save-flags.c            save-flags.h  \
+    save.c                  sort.c                  stack.c  \
+    stdnoreturn.in.h        streqvcmp.c             text_mmap.c  \
+    time.c                  tokenize.c              usage.c  \
+    version.c

+ 28 - 23
libopts/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -140,6 +140,9 @@ AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
+libopts_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(libopts_la_LDFLAGS) $(LDFLAGS) -o $@
 @INSTALL_LIBOPTS_FALSE@am_libopts_la_rpath =
 @INSTALL_LIBOPTS_TRUE@am_libopts_la_rpath = -rpath $(libdir)
 AM_V_P = $(am__v_P_@AM_V@)
@@ -321,6 +324,7 @@ build_alias = @build_alias@
 build_asan = @build_asan@
 build_cpu = @build_cpu@
 build_os = @build_os@
+build_tsan = @build_tsan@
 build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@
@@ -377,28 +381,28 @@ MAINTAINERCLEANFILES = Makefile.in
 @INSTALL_LIBOPTS_FALSE@noinst_LTLIBRARIES = libopts.la
 libopts_la_SOURCES = libopts.c
 libopts_la_CPPFLAGS = -I$(srcdir)
-#libopts_la_LDFLAGS      = -version-info  41:1:16
-EXTRA_DIST = $(srcdir)/compat/_Noreturn.h stdnoreturn.in.h \
-	COPYING.gplv3 COPYING.lgplv3 COPYING.mbsd MakeDefs.inc README \
-	ag-char-map.h alias.c ao-strs.c ao-strs.h autoopts.c \
-	autoopts.h autoopts/options.h autoopts/project.h \
-	autoopts/usage-txt.h boolean.c check.c compat/_Noreturn.h \
-	compat/compat.h compat/pathfind.c compat/snprintf.c \
-	compat/strchr.c compat/strdup.c compat/windows-config.h \
-	configfile.c cook.c enum.c env.c file.c find.c genshell.c \
-	genshell.h gettext.h init.c intprops.h load.c m4/libopts.m4 \
-	m4/liboptschk.m4 m4/stdnoreturn.m4 makeshell.c nested.c \
-	numeric.c option-value-type.c option-value-type.h \
-	option-xat-attribute.c option-xat-attribute.h parse-duration.c \
-	parse-duration.h pgusage.c proto.h putshell.c reset.c \
-	restore.c save.c sort.c stack.c stdnoreturn.in.h streqvcmp.c \
-	text_mmap.c time.c tokenize.c usage.c version.c
+libopts_la_LDFLAGS = -version-info  42:1:17
+EXTRA_DIST = _Noreturn.h stdnoreturn.in.h COPYING.gplv3 COPYING.lgplv3 \
+	COPYING.mbsd MakeDefs.inc README _Noreturn.h ag-char-map.h \
+	alias.c ao-strs.c ao-strs.h autoopts.c autoopts.h \
+	autoopts/options.h autoopts/project.h autoopts/usage-txt.h \
+	boolean.c check.c compat/compat.h compat/pathfind.c \
+	compat/snprintf.c compat/strchr.c compat/strdup.c \
+	compat/windows-config.h configfile.c cook.c enum.c env.c \
+	file.c find.c genshell.c genshell.h gettext.h init.c \
+	intprops.h load.c m4/libopts.m4 m4/liboptschk.m4 \
+	m4/stdnoreturn.m4 makeshell.c nested.c numeric.c \
+	option-value-type.c option-value-type.h option-xat-attribute.c \
+	option-xat-attribute.h parse-duration.c parse-duration.h \
+	pgusage.c proto.h putshell.c reset.c restore.c save-flags.c \
+	save-flags.h save.c sort.c stack.c stdnoreturn.in.h \
+	streqvcmp.c text_mmap.c time.c tokenize.c usage.c version.c
 BUILT_SOURCES = $(STDNORETURN_H)
 MOSTLYCLEANFILES = stdnoreturn.h stdnoreturn.h-t
 
 # Makefile fragment from gnulib-s stdnoreturn module:
 #
-_NORETURN_H = $(srcdir)/compat/_Noreturn.h
+_NORETURN_H = $(srcdir)/_Noreturn.h
 all: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
@@ -481,7 +485,7 @@ clean-noinstLTLIBRARIES:
 	}
 
 libopts.la: $(libopts_la_OBJECTS) $(libopts_la_DEPENDENCIES) $(EXTRA_libopts_la_DEPENDENCIES) 
-	$(AM_V_CCLD)$(LINK) $(am_libopts_la_rpath) $(libopts_la_OBJECTS) $(libopts_la_LIBADD) $(LIBS)
+	$(AM_V_CCLD)$(libopts_la_LINK) $(am_libopts_la_rpath) $(libopts_la_OBJECTS) $(libopts_la_LIBADD) $(LIBS)
 
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
@@ -629,7 +633,8 @@ installdirs:
 	done
 install: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) install-am
-install-exec: install-exec-am
+install-exec: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) install-exec-am
 install-data: install-data-am
 uninstall: uninstall-am
 
@@ -732,7 +737,7 @@ ps-am:
 
 uninstall-am: uninstall-libLTLIBRARIES
 
-.MAKE: all check install install-am install-strip
+.MAKE: all check install install-am install-exec install-strip
 
 .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
 	clean-generic clean-libLTLIBRARIES clean-libtool \
@@ -753,7 +758,7 @@ uninstall-am: uninstall-libLTLIBRARIES
 
 
 libopts.c:		$(BUILT_SOURCES)
-	@: do-nothing rule to avoid default SCCS get
+@: do-nothing rule to avoid default SCCS get
 @GL_GENERATE_STDNORETURN_H_TRUE@stdnoreturn.h: stdnoreturn.in.h $(top_builddir)/config.status $(_NORETURN_H)
 @GL_GENERATE_STDNORETURN_H_TRUE@	$(AM_V_GEN)rm -f $@-t $@ && \
 @GL_GENERATE_STDNORETURN_H_TRUE@	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \

+ 1 - 1
libopts/README

@@ -115,7 +115,7 @@ These macros work as follows:
 
 LICENSING:
 
-This material is Copyright (C) 1992-2015 by Bruce Korb.  You are
+This material is Copyright (C) 1992-2018 by Bruce Korb.  You are
 licensed to use this under the terms of either the GNU Lesser General
 Public License (see: COPYING.lgpl), or, at your option, the modified
 Berkeley Software Distribution License (see: COPYING.mbsd).  Both of

libopts/compat/_Noreturn.h → libopts/_Noreturn.h


+ 2 - 2
libopts/ag-char-map.h

@@ -1,6 +1,6 @@
 /*
  *  29 bits for 46 character classifications
- *  generated by char-mapper on 08/29/16 at 14:35:22
+ *  generated by char-mapper on 08/26/18 at 10:44:22
  *
  *  This file contains the character classifications
  *  used by AutoGen and AutoOpts for identifying tokens.
@@ -8,7 +8,7 @@
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control

+ 2 - 2
libopts/alias.c

@@ -12,7 +12,7 @@
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -31,7 +31,7 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-LOCAL tSuccess
+static tSuccess
 too_many_occurrences(tOptions * opts, tOptDesc * od)
 {
     if ((opts->fOptSet & OPTPROC_ERRSTOP) != 0) {

+ 143 - 139
libopts/ao-strs.c

@@ -6,7 +6,7 @@
  * From the definitions    ao-strs.def
  * and the template file   strings
  *
- *  Copyright (C) 2011-2015 Bruce Korb, all rights reserved.
+ *  Copyright (C) 2011-2018 Bruce Korb, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the
  *  Modified (3 clause) Berkeley Software Distribution License
@@ -38,160 +38,164 @@
  */
 #include "ao-strs.h"
 
-char const ao_strs_strtable[6670] =
+char const ao_strs_strtable[6714] =
 /*     0 */ "-_^\0"
 /*     4 */ "  %s%s\n\0"
-/*    12 */ "auto-options\0"
-/*    25 */ "program\0"
-/*    33 */ "%%-%ds %%s\n\0"
-/*    45 */ "\n"
+/*    12 */ "<?auto-options\0"
+/*    27 */ "<?program\0"
+/*    37 */ "%%-%ds %%s\n\0"
+/*    49 */ "<?program %s>\n\0"
+/*    64 */ "\n"
             "%s\n\n\0"
-/*    51 */ "=file\0"
-/*    57 */ "=Mbr\0"
-/*    62 */ "=Cplx\0"
-/*    68 */ "[=arg]\0"
-/*    75 */ "--%2$s%1$s\0"
-/*    86 */ "=Tim\0"
-/*    91 */ "none\0"
-/*    96 */ "#  preset/initialization file\n"
+/*    70 */ "=file\0"
+/*    76 */ "=Mbr\0"
+/*    81 */ "=Cplx\0"
+/*    87 */ "[=arg]\0"
+/*    94 */ "--%2$s%1$s\0"
+/*   105 */ "=Tim\0"
+/*   110 */ "none\0"
+/*   115 */ "#  preset/initialization file\n"
             "#  %s#\n\0"
-/*   134 */ " %3s %-14s %s\0"
-/*   148 */ "%s\0"
-/*   151 */ "T/F\0"
-/*   155 */ "\n"
+/*   153 */ " %3s %-14s %s\0"
+/*   167 */ "%s\0"
+/*   170 */ "T/F\0"
+/*   174 */ "\n"
             "%s\n\n"
             "%s\0"
-/*   163 */ "Fil\0"
-/*   167 */ "KWd\0"
-/*   171 */ "Mbr\0"
-/*   175 */ "Cpx\0"
-/*   179 */ "no \0"
-/*   183 */ "Num\0"
-/*   187 */ "opt\0"
-/*   191 */ "YES\0"
-/*   195 */ "Str\0"
-/*   199 */ "Tim\0"
-/*   203 */ "\t\t\t\t- \0"
-/*   210 */ "\t\t\t\t  \0"
-/*   217 */ "\t\t\t\t-- and \0"
-/*   229 */ "\t\t\t\t%s\n\0"
-/*   237 */ "      \0"
-/*   244 */ "     \0"
-/*   250 */ "   \0"
-/*   254 */ "  \0"
-/*   257 */ "all\0"
-/*   261 */ " \t\n"
+/*   182 */ "Fil\0"
+/*   186 */ "KWd\0"
+/*   190 */ "Mbr\0"
+/*   194 */ "Cpx\0"
+/*   198 */ "no \0"
+/*   202 */ "Num\0"
+/*   206 */ "opt\0"
+/*   210 */ "YES\0"
+/*   214 */ "Str\0"
+/*   218 */ "Tim\0"
+/*   222 */ "\t\t\t\t- \0"
+/*   229 */ "\t\t\t\t  \0"
+/*   236 */ "\t\t\t\t-- and \0"
+/*   248 */ "\t\t\t\t%s\n\0"
+/*   256 */ "      \0"
+/*   263 */ "     \0"
+/*   269 */ "   \0"
+/*   273 */ "  \0"
+/*   276 */ "all\0"
+/*   280 */ " \t\n"
             ":=\0"
-/*   267 */ "%s_%s_%d=\0"
-/*   277 */ "''\0"
-/*   280 */ "        ;;\n\n\0"
-/*   293 */ "'\n\n\0"
-/*   297 */ "</%s>\n\0"
-/*   304 */ "  %s\n\0"
-/*   310 */ "%%-%ds\0"
-/*   317 */ "\n"
+/*   286 */ "%s_%s_%d=\0"
+/*   296 */ "''\0"
+/*   299 */ "        ;;\n\n\0"
+/*   312 */ "'\n\n\0"
+/*   316 */ "</%s>\n\0"
+/*   323 */ "  %s\n\0"
+/*   329 */ "%%-%ds\0"
+/*   336 */ "\n"
             "export %s_%s_%d\n\0"
-/*   335 */ "false\0"
-/*   341 */ "    -* )\n\0"
-/*   351 */ "flag\0"
-/*   356 */ "INVALID-%d\0"
-/*   367 */ "*INVALID*\0"
-/*   377 */ "\\n\\\n\0"
-/*   382 */ "    --* )\n\0"
-/*   393 */ "--\0"
-/*   396 */ "LONGUSAGE\0"
-/*   406 */ "            %s\n\0"
-/*   422 */ "\\%03o\0"
-/*   428 */ "more\0"
-/*   433 */ "<%s type=nested>\n\0"
-/*   451 */ "%s\n\0"
-/*   455 */ "%s\n"
+/*   354 */ "false\0"
+/*   360 */ "    -* )\n\0"
+/*   370 */ "flag\0"
+/*   375 */ "INVALID-%d\0"
+/*   386 */ "*INVALID*\0"
+/*   396 */ "\\n\\\n\0"
+/*   401 */ "    --* )\n\0"
+/*   412 */ "--\0"
+/*   415 */ "LONGUSAGE\0"
+/*   425 */ "            %s\n\0"
+/*   441 */ "\\%03o\0"
+/*   447 */ "more\0"
+/*   452 */ "<%s type=nested>\n\0"
+/*   470 */ "%s\n\0"
+/*   474 */ "%s\n"
             "  \0"
-/*   461 */ "OPT_ARG_NEEDED=NO\0"
-/*   479 */ "<%s/>\n\0"
-/*   486 */ "OPT_ARG_NEEDED=OK\0"
-/*   504 */ "\t\0"
-/*   506 */ "<%s>\0"
-/*   511 */ "option\0"
-/*   518 */ "\n"
+/*   480 */ "OPT_ARG_NEEDED=NO\0"
+/*   498 */ "<%s/>\n\0"
+/*   505 */ "OPT_ARG_NEEDED=OK\0"
+/*   523 */ "\t\0"
+/*   525 */ "<%s>\0"
+/*   530 */ "option\0"
+/*   537 */ "\n"
             "export %s_%s\n\0"
-/*   533 */ "%s_%s=\0"
-/*   540 */ " | \0"
-/*   544 */ "PAGER\0"
-/*   550 */ "%1$s %2$s ; rm -f %2$s\0"
-/*   573 */ " + \0"
-/*   577 */ "  puts(_(%s));\n\0"
-/*   593 */ "\\'\0"
-/*   596 */ "'%s'\0"
-/*   601 */ " -- %s\0"
-/*   608 */ "%s_%s_TEXT='\0"
-/*   621 */ "#! %s\n\0"
-/*   628 */ "\n"
+/*   552 */ "%s_%s=\0"
+/*   559 */ " | \0"
+/*   563 */ "PAGER\0"
+/*   569 */ "%1$s %2$s ; rm -f %2$s\0"
+/*   592 */ " + \0"
+/*   596 */ "  puts(_(%s));\n\0"
+/*   612 */ "\\'\0"
+/*   615 */ "'%s'\0"
+/*   620 */ " -- %s\0"
+/*   627 */ "%s_%s_TEXT='\0"
+/*   640 */ "#! %s\n\0"
+/*   647 */ "\n"
             "env | grep '^%s_'\n\0"
-/*   648 */ "=%1$lu # 0x%1$lX\n\0"
-/*   666 */ "stdout\0"
-/*   673 */ "%A %B %e, %Y at %r %Z\0"
-/*   695 */ "TMPDIR\0"
-/*   702 */ "%s/use-%u.XXXXXX\0"
-/*   719 */ "true\0"
-/*   724 */ "<%s type=%s>\0"
-/*   737 */ "VERSION\0"
-/*   745 */ "#x%02X;\0"
-/*   753 */ "OPT_ARG_NEEDED=YES\0"
-/*   772 */ "'\\''\0"
-/*   777 */ " '%s'\0"
-/*   783 */ "libopts misguessed length of string\n\0"
-/*   820 */ "\n"
+/*   667 */ "=%1$lu # 0x%1$lX\n\0"
+/*   685 */ "stdout\0"
+/*   692 */ "%A %B %e, %Y at %r %Z\0"
+/*   714 */ "TMPDIR\0"
+/*   721 */ "%s/use-%u.XXXXXX\0"
+/*   738 */ "true\0"
+/*   743 */ "<%s type=%s>\0"
+/*   756 */ "VERSION\0"
+/*   764 */ "#x%02X;\0"
+/*   772 */ "OPT_ARG_NEEDED=YES\0"
+/*   791 */ "\n"
+            "# %s -- %s\n\0"
+/*   804 */ "# DEFAULT: \0"
+/*   816 */ "'\\''\0"
+/*   821 */ " '%s'\0"
+/*   827 */ "libopts misguessed length of string\n\0"
+/*   864 */ "\n"
             "OPTION_CT=0\n\0"
-/*   834 */ "set --\0"
-/*   841 */ "/tmp\0"
-/*   846 */ "            ;;\n\n\0"
-/*   863 */ "        '%c' )\n\0"
-/*   879 */ "        '%s' )\n\0"
-/*   895 */ "        '%s' | \\\n\0"
-/*   913 */ "<%1$s type=boolean>%2$s</%1$s>\n\0"
-/*   945 */ "#  From the %s option definitions\n"
+/*   878 */ "set --\0"
+/*   885 */ "/tmp\0"
+/*   890 */ "            ;;\n\n\0"
+/*   907 */ "        '%c' )\n\0"
+/*   923 */ "        '%s' )\n\0"
+/*   939 */ "        '%s' | \\\n\0"
+/*   957 */ "<%1$s type=boolean>%2$s</%1$s>\n\0"
+/*   989 */ "#  From the %s option definitions\n"
             "#\n\0"
-/*   982 */ "echo 'Warning:  Cannot load options files' >&2\0"
-/*  1029 */ "echo 'Warning:  Cannot save options files' >&2\0"
-/*  1076 */ "echo 'Warning:  Cannot suppress the loading of options files' >&2\0"
-/*  1142 */ "<%1$s type=integer>0x%2$lX</%1$s>\n\0"
-/*  1177 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0"
-/*  1208 */ "%1$s_%2$s_MODE='%3$s'\n"
+/*  1026 */ "echo 'Warning:  Cannot load options files' >&2\0"
+/*  1073 */ "echo 'Warning:  Cannot save options files' >&2\0"
+/*  1120 */ "echo 'Warning:  Cannot suppress the loading of options files' >&2\0"
+/*  1186 */ "<%1$s type=integer>0x%2$lX</%1$s>\n\0"
+/*  1221 */ "%1$s_%2$s_TEXT='no %2$s text'\n\0"
+/*  1252 */ "%1$s_%2$s_MODE='%3$s'\n"
             "export %1$s_%2$s_MODE\n\0"
-/*  1253 */ "%1$s_%2$s='%3$s'\n"
+/*  1297 */ "%1$s_%2$s='%3$s'\n"
             "export %1$s_%2$s\n\0"
-/*  1288 */ "%1$s_%2$s_CT=%3$d\n"
+/*  1332 */ "%1$s_%2$s_CT=%3$d\n"
             "export %1$s_%2$s_CT\n\0"
-/*  1327 */ "OPTION_CT=%d\n"
+/*  1371 */ "OPTION_CT=%d\n"
             "export OPTION_CT\n\0"
-/*  1358 */ "%1$s_%2$s=%3$s\n"
+/*  1402 */ "%1$s_%2$s=%3$s\n"
             "export %1$s_%2$s\n\0"
-/*  1391 */ "%1$s_%2$s=%3$d # 0x%3$X\n"
+/*  1435 */ "%1$s_%2$s=%3$d # 0x%3$X\n"
             "export %1$s_%2$s\n\0"
-/*  1433 */ "        case \"${OPT_CODE}\" in\n\0"
-/*  1464 */ "            if [ $%1$s_%2$s_CT -gt %3$u ] ; then\n"
+/*  1477 */ "        case \"${OPT_CODE}\" in\n\0"
+/*  1508 */ "            if [ $%1$s_%2$s_CT -gt %3$u ] ; then\n"
             "                echo 'Error:  more than %3$d %2$s options'\n"
             "                echo \"$%1$s_USAGE_TEXT\"\n"
             "                exit 1\n"
             "            fi >&2\n\0"
-/*  1655 */ "test ${%1$s_%2$s_CT-0} -ge %3$u || {\n"
+/*  1699 */ "test ${%1$s_%2$s_CT-0} -ge %3$u || {\n"
             "    echo %1$s_%2$s has not been set\n"
             "    exit 1\n"
             "} 1>&2\n\0"
-/*  1747 */ "test -n \"$%1$s_%2$s\" || {\n"
+/*  1791 */ "test -n \"$%1$s_%2$s\" || {\n"
             "    echo %1$s_%2$s has not been set\n"
             "    exit 1\n"
             "} 1>&2\n\0"
-/*  1828 */ "            echo \"$%s_%s_TEXT\"\n"
+/*  1872 */ "            echo \"$%s_%s_TEXT\"\n"
             "            exit 0\n\0"
-/*  1879 */ "\n"
+/*  1923 */ "\n"
             "# # # # # # # # # #\n"
             "#\n"
             "#  END OF AUTOMATED OPTION PROCESSING\n"
             "#\n"
             "# # # # # # # # # # -- do not modify this marker --\n\0"
-/*  1995 */ "    if [ -n \"${OPT_ARG_VAL}\" ]\n"
+/*  2039 */ "    if [ -n \"${OPT_ARG_VAL}\" ]\n"
             "    then\n"
             "        eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n"
             "        export %1$s_${OPT_NAME}${OPT_ELEMENT}\n"
@@ -206,15 +210,15 @@ char const ao_strs_strtable[6670] =
             "unset OPT_NAME    || :\n"
             "unset OPT_CODE    || :\n"
             "unset OPT_ARG_VAL || :\n\0"
-/*  2374 */ "        OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
+/*  2418 */ "        OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
             "        shift\n"
             "        OPT_ARG=$1\n"
             "        case \"${OPT_CODE}\" in *=* )\n"
             "            OPT_ARG_VAL=`echo \"${OPT_CODE}\"|sed 's/^[^=]*=//'`\n"
             "            OPT_CODE=`echo \"${OPT_CODE}\"|sed 's/=.*$//'` ;; esac\n\0"
-/*  2625 */ "        OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
+/*  2669 */ "        OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
             "        OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\0"
-/*  2742 */ "\n"
+/*  2786 */ "\n"
             "ARG_COUNT=$#\n"
             "OPT_PROCESS=true\n"
             "OPT_ARG=$1\n"
@@ -227,7 +231,7 @@ char const ao_strs_strtable[6670] =
             "        OPT_PROCESS=false\n"
             "        shift\n"
             "        ;;\n\0"
-/*  2949 */ "        case \"${OPT_ARG_NEEDED}\" in\n"
+/*  2993 */ "        case \"${OPT_ARG_NEEDED}\" in\n"
             "        NO )\n"
             "            OPT_ARG_VAL=''\n"
             "            ;;\n"
@@ -255,10 +259,10 @@ char const ao_strs_strtable[6670] =
             "            fi\n"
             "            ;;\n"
             "        esac\n\0"
-/*  3728 */ "            %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n"
+/*  3772 */ "            %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n"
             "            OPT_ELEMENT=\"_${%1$s_%2$s_CT}\"\n"
             "            OPT_NAME='%2$s'\n\0"
-/*  3852 */ "\n"
+/*  3896 */ "\n"
             "if test -z \"${%1$s_%2$s}\"\n"
             "then\n"
             "  %1$s_%2$s_CT=0\n"
@@ -268,16 +272,16 @@ char const ao_strs_strtable[6670] =
             "  %1$s_%2$s_1=${%1$s_%2$s}\n"
             "  export %1$s_%2$s_CT %1$s_%2$s_1\n"
             "fi\n\0"
-/*  4010 */ "    * )\n"
+/*  4054 */ "    * )\n"
             "         OPT_PROCESS=false\n"
             "         ;;\n"
             "    esac\n\0"
-/*  4067 */ "            %1$s_%2$s_CT=0\n"
+/*  4111 */ "            %1$s_%2$s_CT=0\n"
             "            OPT_ELEMENT=''\n"
             "            %1$s_%2$s='%3$s'\n"
             "            export %1$s_%2$s\n"
             "            OPT_NAME='%2$s'\n\0"
-/*  4208 */ "            if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
+/*  4252 */ "            if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
             "                echo 'Error:  duplicate %2$s option'\n"
             "                echo \"$%1$s_USAGE_TEXT\"\n"
             "                exit 1\n"
@@ -286,7 +290,7 @@ char const ao_strs_strtable[6670] =
             "            %1$s_%2$s='%3$s'\n"
             "            export %1$s_%2$s\n"
             "            OPT_NAME='%2$s'\n\0"
-/*  4525 */ "\n"
+/*  4569 */ "\n"
             "ARG_COUNT=$#\n"
             "OPT_ARG=$1\n"
             "while [ $# -gt 0 ]\n"
@@ -294,7 +298,7 @@ char const ao_strs_strtable[6670] =
             "    OPT_ELEMENT=''\n"
             "    OPT_ARG_VAL=''\n"
             "    OPT_ARG=${1}\n\0"
-/*  4628 */ "        case \"${OPT_ARG_NEEDED}\" in\n"
+/*  4672 */ "        case \"${OPT_ARG_NEEDED}\" in\n"
             "        NO )\n"
             "            if [ -n \"${OPT_ARG}\" ]\n"
             "            then\n"
@@ -339,33 +343,33 @@ char const ao_strs_strtable[6670] =
             "            fi\n"
             "            ;;\n"
             "        esac\n\0"
-/*  5782 */ "            echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
+/*  5826 */ "            echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
             "            exit 0\n\0"
-/*  5856 */ "%s OF %s\n"
+/*  5900 */ "%s OF %s\n"
             "#\n"
             "#  From here to the next `-- do not modify this marker --',\n"
             "#  the text has been generated %s\n\0"
-/*  5962 */ "            eval %1$s_%2$s${OPT_ELEMENT}=true\n"
+/*  6006 */ "            eval %1$s_%2$s${OPT_ELEMENT}=true\n"
             "            export %1$s_%2$s${OPT_ELEMENT}\n\0"
-/*  6052 */ "            if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
+/*  6096 */ "            if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
             "                echo 'Error:  duplicate %2$s option'\n"
             "                echo \"$%1$s_USAGE_TEXT\"\n"
             "                exit 1\n"
             "            fi >&2\n"
             "            %1$s_%2$s_set=true\n"
             "            OPT_NAME='%2$s'\n\0"
-/*  6311 */ "\n"
+/*  6355 */ "\n"
             "%1$s_%2$s=${%1$s_%2$s-'%3$s'}\n"
             "%1$s_%2$s_set=false\n"
             "export %1$s_%2$s\n\0"
-/*  6380 */ "\n"
+/*  6424 */ "\n"
             "%1$s_%2$s=${%1$s_%2$s}\n"
             "%1$s_%2$s_set=false\n"
             "export %1$s_%2$s\n\0"
-/*  6442 */ "# # # # # # # # # # -- do not modify this marker --\n"
+/*  6486 */ "# # # # # # # # # # -- do not modify this marker --\n"
             "#\n"
             "#  DO NOT EDIT THIS SECTION\n\0"
-/*  6525 */ "        * )\n"
+/*  6569 */ "        * )\n"
             "            echo Unknown %s: \"${OPT_CODE}\" >&2\n"
             "            echo \"$%s_USAGE_TEXT\" >&2\n"
             "            exit 1\n"

+ 151 - 145
libopts/ao-strs.h

@@ -6,7 +6,7 @@
  * From the definitions    ao-strs.def
  * and the template file   strings
  *
- *  Copyright (C) 2011-2015 Bruce Korb, all rights reserved.
+ *  Copyright (C) 2011-2018 Bruce Korb, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the
  *  Modified (3 clause) Berkeley Software Distribution License
@@ -39,294 +39,300 @@
 #ifndef STRINGS_AO_STRS_H_GUARD
 #define STRINGS_AO_STRS_H_GUARD 1
 /*
- * 143 strings in ao_strs_strtable string table
+ * 146 strings in ao_strs_strtable string table
  */
-#define ARG_BREAK_STR         (ao_strs_strtable+261)
+#define ARG_BREAK_STR         (ao_strs_strtable+280)
 #define ARG_BREAK_STR_LEN     5
-#define ARG_BY_NUM_FMT        (ao_strs_strtable+267)
+#define ARG_BY_NUM_FMT        (ao_strs_strtable+286)
 #define ARG_BY_NUM_FMT_LEN    9
-#define BOOL_ATR_FMT          (ao_strs_strtable+913)
+#define BOOL_ATR_FMT          (ao_strs_strtable+957)
 #define BOOL_ATR_FMT_LEN      31
-#define CHK_MAX_COUNT         (ao_strs_strtable+1464)
+#define CHK_MAX_COUNT         (ao_strs_strtable+1508)
 #define CHK_MAX_COUNT_LEN     190
-#define CHK_MIN_COUNT         (ao_strs_strtable+1655)
+#define CHK_MIN_COUNT         (ao_strs_strtable+1699)
 #define CHK_MIN_COUNT_LEN     91
-#define CHK_ONE_REQUIRED      (ao_strs_strtable+1747)
+#define CHK_ONE_REQUIRED      (ao_strs_strtable+1791)
 #define CHK_ONE_REQUIRED_LEN  80
-#define ECHO_N_EXIT           (ao_strs_strtable+1828)
+#define ECHO_N_EXIT           (ao_strs_strtable+1872)
 #define ECHO_N_EXIT_LEN       50
-#define EMPTY_ARG             (ao_strs_strtable+277)
+#define EMPTY_ARG             (ao_strs_strtable+296)
 #define EMPTY_ARG_LEN         2
-#define END_MARK              (ao_strs_strtable+1879)
+#define END_MARK              (ao_strs_strtable+1923)
 #define END_MARK_LEN          115
-#define END_OPT_SEL_STR       (ao_strs_strtable+280)
+#define END_OPT_SEL_STR       (ao_strs_strtable+299)
 #define END_OPT_SEL_STR_LEN   12
-#define END_PRE_FMT           (ao_strs_strtable+945)
+#define END_PRE_FMT           (ao_strs_strtable+989)
 #define END_PRE_FMT_LEN       36
-#define END_SET_TEXT          (ao_strs_strtable+293)
+#define END_SET_TEXT          (ao_strs_strtable+312)
 #define END_SET_TEXT_LEN      3
-#define END_XML_FMT           (ao_strs_strtable+297)
+#define END_XML_FMT           (ao_strs_strtable+316)
 #define END_XML_FMT_LEN       6
-#define ENUM_ERR_LINE         (ao_strs_strtable+304)
+#define ENUM_ERR_LINE         (ao_strs_strtable+323)
 #define ENUM_ERR_LINE_LEN     5
-#define ENUM_ERR_WIDTH        (ao_strs_strtable+310)
+#define ENUM_ERR_WIDTH        (ao_strs_strtable+329)
 #define ENUM_ERR_WIDTH_LEN    6
-#define EXPORT_ARG_FMT        (ao_strs_strtable+317)
+#define EXPORT_ARG_FMT        (ao_strs_strtable+336)
 #define EXPORT_ARG_FMT_LEN    17
-#define FALSE_STR             (ao_strs_strtable+335)
+#define FALSE_STR             (ao_strs_strtable+354)
 #define FALSE_STR_LEN         5
-#define FINISH_LOOP           (ao_strs_strtable+1995)
+#define FINISH_LOOP           (ao_strs_strtable+2039)
 #define FINISH_LOOP_LEN       378
-#define FLAG_OPT_MARK         (ao_strs_strtable+341)
+#define FLAG_OPT_MARK         (ao_strs_strtable+360)
 #define FLAG_OPT_MARK_LEN     9
-#define FLAG_STR              (ao_strs_strtable+351)
+#define FLAG_STR              (ao_strs_strtable+370)
 #define FLAG_STR_LEN          4
-#define INIT_LOPT_STR         (ao_strs_strtable+2374)
+#define INIT_LOPT_STR         (ao_strs_strtable+2418)
 #define INIT_LOPT_STR_LEN     250
-#define INIT_OPT_STR          (ao_strs_strtable+2625)
+#define INIT_OPT_STR          (ao_strs_strtable+2669)
 #define INIT_OPT_STR_LEN      116
-#define INVALID_FMT           (ao_strs_strtable+356)
+#define INVALID_FMT           (ao_strs_strtable+375)
 #define INVALID_FMT_LEN       10
-#define INVALID_STR           (ao_strs_strtable+367)
+#define INVALID_STR           (ao_strs_strtable+386)
 #define INVALID_STR_LEN       9
-#define LINE_SPLICE           (ao_strs_strtable+377)
+#define LINE_SPLICE           (ao_strs_strtable+396)
 #define LINE_SPLICE_LEN       4
-#define LONG_OPT_MARK         (ao_strs_strtable+382)
-#define LONG_OPT_MARKER       (ao_strs_strtable+393)
+#define LONG_OPT_MARK         (ao_strs_strtable+401)
+#define LONG_OPT_MARKER       (ao_strs_strtable+412)
 #define LONG_OPT_MARKER_LEN   2
 #define LONG_OPT_MARK_LEN     10
-#define LONG_USE_STR          (ao_strs_strtable+396)
+#define LONG_USE_STR          (ao_strs_strtable+415)
 #define LONG_USE_STR_LEN      9
-#define LOOP_STR              (ao_strs_strtable+2742)
+#define LOOP_STR              (ao_strs_strtable+2786)
 #define LOOP_STR_LEN          206
-#define LOPT_ARG_FMT          (ao_strs_strtable+2949)
+#define LOPT_ARG_FMT          (ao_strs_strtable+2993)
 #define LOPT_ARG_FMT_LEN      778
-#define LVL3_CMD              (ao_strs_strtable+406)
+#define LVL3_CMD              (ao_strs_strtable+425)
 #define LVL3_CMD_LEN          15
-#define MK_STR_OCT_FMT        (ao_strs_strtable+422)
+#define MK_STR_OCT_FMT        (ao_strs_strtable+441)
 #define MK_STR_OCT_FMT_LEN    5
-#define MORE_STR              (ao_strs_strtable+428)
+#define MORE_STR              (ao_strs_strtable+447)
 #define MORE_STR_LEN          4
-#define MULTI_ARG_FMT         (ao_strs_strtable+3728)
+#define MULTI_ARG_FMT         (ao_strs_strtable+3772)
 #define MULTI_ARG_FMT_LEN     123
-#define MULTI_DEF_FMT         (ao_strs_strtable+3852)
+#define MULTI_DEF_FMT         (ao_strs_strtable+3896)
 #define MULTI_DEF_FMT_LEN     157
-#define NESTED_OPT_FMT        (ao_strs_strtable+433)
+#define NESTED_OPT_FMT        (ao_strs_strtable+452)
 #define NESTED_OPT_FMT_LEN    17
-#define NLSTR_FMT             (ao_strs_strtable+451)
+#define NLSTR_FMT             (ao_strs_strtable+470)
 #define NLSTR_FMT_LEN         3
-#define NLSTR_SPACE_FMT       (ao_strs_strtable+455)
+#define NLSTR_SPACE_FMT       (ao_strs_strtable+474)
 #define NLSTR_SPACE_FMT_LEN   5
-#define NONE_STR              (ao_strs_strtable+91)
+#define NONE_STR              (ao_strs_strtable+110)
 #define NONE_STR_LEN          4
-#define NOT_FOUND_STR         (ao_strs_strtable+4010)
+#define NOT_FOUND_STR         (ao_strs_strtable+4054)
 #define NOT_FOUND_STR_LEN     56
-#define NO_ARG_NEEDED         (ao_strs_strtable+461)
+#define NO_ARG_NEEDED         (ao_strs_strtable+480)
 #define NO_ARG_NEEDED_LEN     17
-#define NO_LOAD_WARN          (ao_strs_strtable+982)
+#define NO_LOAD_WARN          (ao_strs_strtable+1026)
 #define NO_LOAD_WARN_LEN      46
-#define NO_MULTI_ARG_FMT      (ao_strs_strtable+4067)
+#define NO_MULTI_ARG_FMT      (ao_strs_strtable+4111)
 #define NO_MULTI_ARG_FMT_LEN  140
-#define NO_SAVE_OPTS          (ao_strs_strtable+1029)
+#define NO_SAVE_OPTS          (ao_strs_strtable+1073)
 #define NO_SAVE_OPTS_LEN      46
-#define NO_SGL_ARG_FMT        (ao_strs_strtable+4208)
+#define NO_SGL_ARG_FMT        (ao_strs_strtable+4252)
 #define NO_SGL_ARG_FMT_LEN    316
-#define NO_SUPPRESS_LOAD      (ao_strs_strtable+1076)
+#define NO_SUPPRESS_LOAD      (ao_strs_strtable+1120)
 #define NO_SUPPRESS_LOAD_LEN  65
-#define NULL_ATR_FMT          (ao_strs_strtable+479)
+#define NULL_ATR_FMT          (ao_strs_strtable+498)
 #define NULL_ATR_FMT_LEN      6
-#define NUMB_ATR_FMT          (ao_strs_strtable+1142)
+#define NUMB_ATR_FMT          (ao_strs_strtable+1186)
 #define NUMB_ATR_FMT_LEN      34
-#define OK_NEED_OPT_ARG       (ao_strs_strtable+486)
+#define OK_NEED_OPT_ARG       (ao_strs_strtable+505)
 #define OK_NEED_OPT_ARG_LEN   17
-#define ONE_TAB_STR           (ao_strs_strtable+504)
+#define ONE_TAB_STR           (ao_strs_strtable+523)
 #define ONE_TAB_STR_LEN       1
-#define ONLY_OPTS_LOOP        (ao_strs_strtable+4525)
+#define ONLY_OPTS_LOOP        (ao_strs_strtable+4569)
 #define ONLY_OPTS_LOOP_LEN    102
-#define OPEN_CLOSE_FMT        (ao_strs_strtable+479)
+#define OPEN_CLOSE_FMT        (ao_strs_strtable+498)
 #define OPEN_CLOSE_FMT_LEN    6
-#define OPEN_XML_FMT          (ao_strs_strtable+506)
+#define OPEN_XML_FMT          (ao_strs_strtable+525)
 #define OPEN_XML_FMT_LEN      4
-#define OPTION_STR            (ao_strs_strtable+511)
+#define OPTION_STR            (ao_strs_strtable+530)
 #define OPTION_STR_LEN        6
-#define OPT_ARG_FMT           (ao_strs_strtable+4628)
+#define OPT_ARG_FMT           (ao_strs_strtable+4672)
 #define OPT_ARG_FMT_LEN       1153
-#define OPT_END_FMT           (ao_strs_strtable+518)
+#define OPT_END_FMT           (ao_strs_strtable+537)
 #define OPT_END_FMT_LEN       14
-#define OPT_VAL_FMT           (ao_strs_strtable+533)
+#define OPT_VAL_FMT           (ao_strs_strtable+552)
 #define OPT_VAL_FMT_LEN       6
-#define OR_STR                (ao_strs_strtable+540)
+#define OR_STR                (ao_strs_strtable+559)
 #define OR_STR_LEN            3
-#define PAGER_NAME            (ao_strs_strtable+544)
+#define PAGER_NAME            (ao_strs_strtable+563)
 #define PAGER_NAME_LEN        5
-#define PAGE_USAGE_FMT        (ao_strs_strtable+550)
+#define PAGE_USAGE_FMT        (ao_strs_strtable+569)
 #define PAGE_USAGE_FMT_LEN    22
-#define PAGE_USAGE_TEXT       (ao_strs_strtable+5782)
+#define PAGE_USAGE_TEXT       (ao_strs_strtable+5826)
 #define PAGE_USAGE_TEXT_LEN   73
-#define PLUS_STR              (ao_strs_strtable+573)
+#define PLUS_STR              (ao_strs_strtable+592)
 #define PLUS_STR_LEN          3
-#define PREAMBLE_FMT          (ao_strs_strtable+5856)
+#define PREAMBLE_FMT          (ao_strs_strtable+5900)
 #define PREAMBLE_FMT_LEN      105
-#define PUTS_FMT              (ao_strs_strtable+577)
+#define PUTS_FMT              (ao_strs_strtable+596)
 #define PUTS_FMT_LEN          15
-#define QUOT_APOS             (ao_strs_strtable+593)
+#define QUOT_APOS             (ao_strs_strtable+612)
 #define QUOT_APOS_LEN         2
-#define QUOT_ARG_FMT          (ao_strs_strtable+596)
+#define QUOT_ARG_FMT          (ao_strs_strtable+615)
 #define QUOT_ARG_FMT_LEN      4
-#define SET_MULTI_ARG         (ao_strs_strtable+5962)
+#define SET_MULTI_ARG         (ao_strs_strtable+6006)
 #define SET_MULTI_ARG_LEN     89
-#define SET_NO_TEXT_FMT       (ao_strs_strtable+1177)
+#define SET_NO_TEXT_FMT       (ao_strs_strtable+1221)
 #define SET_NO_TEXT_FMT_LEN   30
-#define SET_OFF_FMT           (ao_strs_strtable+601)
+#define SET_OFF_FMT           (ao_strs_strtable+620)
 #define SET_OFF_FMT_LEN       6
-#define SET_TEXT_FMT          (ao_strs_strtable+608)
+#define SET_TEXT_FMT          (ao_strs_strtable+627)
 #define SET_TEXT_FMT_LEN      12
-#define SGL_ARG_FMT           (ao_strs_strtable+6052)
+#define SGL_ARG_FMT           (ao_strs_strtable+6096)
 #define SGL_ARG_FMT_LEN       258
-#define SGL_DEF_FMT           (ao_strs_strtable+6311)
+#define SGL_DEF_FMT           (ao_strs_strtable+6355)
 #define SGL_DEF_FMT_LEN       68
-#define SGL_NO_DEF_FMT        (ao_strs_strtable+6380)
+#define SGL_NO_DEF_FMT        (ao_strs_strtable+6424)
 #define SGL_NO_DEF_FMT_LEN    61
-#define SHELL_MAGIC           (ao_strs_strtable+621)
+#define SHELL_MAGIC           (ao_strs_strtable+640)
 #define SHELL_MAGIC_LEN       6
-#define SHOW_PROG_ENV         (ao_strs_strtable+628)
+#define SHOW_PROG_ENV         (ao_strs_strtable+647)
 #define SHOW_PROG_ENV_LEN     19
-#define SHOW_VAL_FMT          (ao_strs_strtable+648)
+#define SHOW_VAL_FMT          (ao_strs_strtable+667)
 #define SHOW_VAL_FMT_LEN      17
-#define START_MARK            (ao_strs_strtable+6442)
+#define START_MARK            (ao_strs_strtable+6486)
 #define START_MARK_LEN        82
-#define STDOUT                (ao_strs_strtable+666)
+#define STDOUT                (ao_strs_strtable+685)
 #define STDOUT_LEN            6
-#define TIME_FMT              (ao_strs_strtable+673)
+#define TIME_FMT              (ao_strs_strtable+692)
 #define TIME_FMT_LEN          21
-#define TMPDIR                (ao_strs_strtable+695)
+#define TMPDIR                (ao_strs_strtable+714)
 #define TMPDIR_LEN            6
-#define TMP_FILE_FMT          (ao_strs_strtable+702)
+#define TMP_FILE_FMT          (ao_strs_strtable+721)
 #define TMP_FILE_FMT_LEN      16
-#define TMP_USAGE_FMT         (ao_strs_strtable+702)
+#define TMP_USAGE_FMT         (ao_strs_strtable+721)
 #define TMP_USAGE_FMT_LEN     16
-#define TRUE_STR              (ao_strs_strtable+719)
+#define TRUE_STR              (ao_strs_strtable+738)
 #define TRUE_STR_LEN          4
-#define TWO_SPACES_STR        (ao_strs_strtable+254)
+#define TWO_SPACES_STR        (ao_strs_strtable+273)
 #define TWO_SPACES_STR_LEN    2
-#define TYPE_ATR_FMT          (ao_strs_strtable+724)
+#define TYPE_ATR_FMT          (ao_strs_strtable+743)
 #define TYPE_ATR_FMT_LEN      12
-#define UNK_OPT_FMT           (ao_strs_strtable+6525)
+#define UNK_OPT_FMT           (ao_strs_strtable+6569)
 #define UNK_OPT_FMT_LEN       144
-#define VER_STR               (ao_strs_strtable+737)
+#define VER_STR               (ao_strs_strtable+756)
 #define VER_STR_LEN           7
-#define XML_HEX_BYTE_FMT      (ao_strs_strtable+745)
+#define XML_HEX_BYTE_FMT      (ao_strs_strtable+764)
 #define XML_HEX_BYTE_FMT_LEN  7
-#define YES_NEED_OPT_ARG      (ao_strs_strtable+753)
+#define YES_NEED_OPT_ARG      (ao_strs_strtable+772)
 #define YES_NEED_OPT_ARG_LEN  18
-#define apostrophe            (ao_strs_strtable+772)
+#define ao_default_use        (ao_strs_strtable+804)
+#define ao_default_use_LEN    11
+#define ao_name_use_fmt       (ao_strs_strtable+791)
+#define ao_name_use_fmt_LEN   12
+#define apostrophe            (ao_strs_strtable+816)
 #define apostrophe_LEN        4
-#define arg_fmt               (ao_strs_strtable+777)
+#define arg_fmt               (ao_strs_strtable+821)
 #define arg_fmt_LEN           5
-#define init_optct            (ao_strs_strtable+820)
+#define init_optct            (ao_strs_strtable+864)
 #define init_optct_LEN        13
-#define misguess_len          (ao_strs_strtable+783)
+#define misguess_len          (ao_strs_strtable+827)
 #define misguess_len_LEN      36
-#define set_dash              (ao_strs_strtable+834)
+#define set_dash              (ao_strs_strtable+878)
 #define set_dash_LEN          6
-#define tmp_dir               (ao_strs_strtable+841)
+#define tmp_dir               (ao_strs_strtable+885)
 #define tmp_dir_LEN           4
-#define zAll                  (ao_strs_strtable+257)
+#define zAll                  (ao_strs_strtable+276)
 #define zAll_LEN              3
 #define zCfgAO_Flags          (ao_strs_strtable+12)
-#define zCfgAO_Flags_LEN      12
-#define zCfgProg              (ao_strs_strtable+25)
-#define zCfgProg_LEN          7
-#define zEquivMode            (ao_strs_strtable+1208)
+#define zCfgAO_Flags_LEN      14
+#define zCfgProg              (ao_strs_strtable+27)
+#define zCfgProg_LEN          9
+#define zEquivMode            (ao_strs_strtable+1252)
 #define zEquivMode_LEN        44
-#define zFiveSpaces           (ao_strs_strtable+244)
+#define zFiveSpaces           (ao_strs_strtable+263)
 #define zFiveSpaces_LEN       5
-#define zFmtFmt               (ao_strs_strtable+33)
+#define zFmtFmt               (ao_strs_strtable+37)
 #define zFmtFmt_LEN           11
-#define zFullOptFmt           (ao_strs_strtable+1253)
+#define zFmtProg              (ao_strs_strtable+49)
+#define zFmtProg_LEN          14
+#define zFullOptFmt           (ao_strs_strtable+1297)
 #define zFullOptFmt_LEN       34
-#define zGnuBreak             (ao_strs_strtable+45)
+#define zGnuBreak             (ao_strs_strtable+64)
 #define zGnuBreak_LEN         5
-#define zGnuFileArg           (ao_strs_strtable+51)
+#define zGnuFileArg           (ao_strs_strtable+70)
 #define zGnuFileArg_LEN       5
-#define zGnuKeyLArg           (ao_strs_strtable+57)
+#define zGnuKeyLArg           (ao_strs_strtable+76)
 #define zGnuKeyLArg_LEN       4
-#define zGnuNestArg           (ao_strs_strtable+62)
+#define zGnuNestArg           (ao_strs_strtable+81)
 #define zGnuNestArg_LEN       5
-#define zGnuOptArg            (ao_strs_strtable+68)
+#define zGnuOptArg            (ao_strs_strtable+87)
 #define zGnuOptArg_LEN        6
-#define zGnuOptFmt            (ao_strs_strtable+75)
+#define zGnuOptFmt            (ao_strs_strtable+94)
 #define zGnuOptFmt_LEN        10
-#define zGnuTimeArg           (ao_strs_strtable+86)
+#define zGnuTimeArg           (ao_strs_strtable+105)
 #define zGnuTimeArg_LEN       4
-#define zNone                 (ao_strs_strtable+91)
+#define zNone                 (ao_strs_strtable+110)
 #define zNone_LEN             4
-#define zOptCookieCt          (ao_strs_strtable+1288)
+#define zOptCookieCt          (ao_strs_strtable+1332)
 #define zOptCookieCt_LEN      38
-#define zOptCtFmt             (ao_strs_strtable+1327)
+#define zOptCtFmt             (ao_strs_strtable+1371)
 #define zOptCtFmt_LEN         30
-#define zOptDisabl            (ao_strs_strtable+1358)
+#define zOptDisabl            (ao_strs_strtable+1402)
 #define zOptDisabl_LEN        32
-#define zOptNumFmt            (ao_strs_strtable+1391)
+#define zOptNumFmt            (ao_strs_strtable+1435)
 #define zOptNumFmt_LEN        41
-#define zOptionCase           (ao_strs_strtable+1433)
+#define zOptionCase           (ao_strs_strtable+1477)
 #define zOptionCase_LEN       30
-#define zOptionEndSelect      (ao_strs_strtable+846)
+#define zOptionEndSelect      (ao_strs_strtable+890)
 #define zOptionEndSelect_LEN  16
-#define zOptionFlag           (ao_strs_strtable+863)
+#define zOptionFlag           (ao_strs_strtable+907)
 #define zOptionFlag_LEN       15
-#define zOptionFullName       (ao_strs_strtable+879)
+#define zOptionFullName       (ao_strs_strtable+923)
 #define zOptionFullName_LEN   15
-#define zOptionPartName       (ao_strs_strtable+895)
+#define zOptionPartName       (ao_strs_strtable+939)
 #define zOptionPartName_LEN   17
-#define zPresetFile           (ao_strs_strtable+96)
+#define zPresetFile           (ao_strs_strtable+115)
 #define zPresetFile_LEN       37
-#define zReqOptFmt            (ao_strs_strtable+134)
+#define zReqOptFmt            (ao_strs_strtable+153)
 #define zReqOptFmt_LEN        13
 #define zSepChars             (ao_strs_strtable+0)
 #define zSepChars_LEN         3
-#define zShrtGnuOptFmt        (ao_strs_strtable+148)
+#define zShrtGnuOptFmt        (ao_strs_strtable+167)
 #define zShrtGnuOptFmt_LEN    2
-#define zSixSpaces            (ao_strs_strtable+237)
+#define zSixSpaces            (ao_strs_strtable+256)
 #define zSixSpaces_LEN        6
-#define zStdBoolArg           (ao_strs_strtable+151)
+#define zStdBoolArg           (ao_strs_strtable+170)
 #define zStdBoolArg_LEN       3
-#define zStdBreak             (ao_strs_strtable+155)
+#define zStdBreak             (ao_strs_strtable+174)
 #define zStdBreak_LEN         7
-#define zStdFileArg           (ao_strs_strtable+163)
+#define zStdFileArg           (ao_strs_strtable+182)
 #define zStdFileArg_LEN       3
-#define zStdKeyArg            (ao_strs_strtable+167)
+#define zStdKeyArg            (ao_strs_strtable+186)
 #define zStdKeyArg_LEN        3
-#define zStdKeyLArg           (ao_strs_strtable+171)
+#define zStdKeyLArg           (ao_strs_strtable+190)
 #define zStdKeyLArg_LEN       3
-#define zStdNestArg           (ao_strs_strtable+175)
+#define zStdNestArg           (ao_strs_strtable+194)
 #define zStdNestArg_LEN       3
-#define zStdNoArg             (ao_strs_strtable+179)
+#define zStdNoArg             (ao_strs_strtable+198)
 #define zStdNoArg_LEN         3
-#define zStdNumArg            (ao_strs_strtable+183)
+#define zStdNumArg            (ao_strs_strtable+202)
 #define zStdNumArg_LEN        3
-#define zStdOptArg            (ao_strs_strtable+187)
+#define zStdOptArg            (ao_strs_strtable+206)
 #define zStdOptArg_LEN        3
-#define zStdReqArg            (ao_strs_strtable+191)
+#define zStdReqArg            (ao_strs_strtable+210)
 #define zStdReqArg_LEN        3
-#define zStdStrArg            (ao_strs_strtable+195)
+#define zStdStrArg            (ao_strs_strtable+214)
 #define zStdStrArg_LEN        3
-#define zStdTimeArg           (ao_strs_strtable+199)
+#define zStdTimeArg           (ao_strs_strtable+218)
 #define zStdTimeArg_LEN       3
-#define zTabHyp               (ao_strs_strtable+203)
-#define zTabHypAnd            (ao_strs_strtable+217)
+#define zTabHyp               (ao_strs_strtable+222)
+#define zTabHypAnd            (ao_strs_strtable+236)
 #define zTabHypAnd_LEN        11
 #define zTabHyp_LEN           6
-#define zTabSpace             (ao_strs_strtable+210)
+#define zTabSpace             (ao_strs_strtable+229)
 #define zTabSpace_LEN         6
-#define zTabout               (ao_strs_strtable+229)
+#define zTabout               (ao_strs_strtable+248)
 #define zTabout_LEN           7
-#define zThreeSpaces          (ao_strs_strtable+250)
+#define zThreeSpaces          (ao_strs_strtable+269)
 #define zThreeSpaces_LEN      3
-#define zTwoSpaces            (ao_strs_strtable+254)
+#define zTwoSpaces            (ao_strs_strtable+273)
 #define zTwoSpaces_LEN        2
 #define zambig_file           (ao_strs_strtable+4)
 #define zambig_file_LEN       7
-extern char const ao_strs_strtable[6670];
+extern char const ao_strs_strtable[6714];
 
 #endif /* STRINGS_AO_STRS_H_GUARD */

+ 8 - 14
libopts/autoopts.c

@@ -13,7 +13,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -35,7 +35,7 @@
 /**
  * The number of tab characters to skip when printing continuation lines.
  */
-static unsigned int tab_skip_ct          = 0;
+  static unsigned int tab_skip_ct          = 0;
 
 #ifndef HAVE_PATHFIND
 #  define  pathfind(_p, _n, _m) option_pathfind(_p, _n, _m)
@@ -59,7 +59,7 @@ static unsigned int tab_skip_ct          = 0;
 #  include "compat/strchr.c"
 #endif
 
-LOCAL void *
+static void *
 ao_malloc(size_t sz)
 {
     void * res = malloc(sz);
@@ -69,10 +69,8 @@ ao_malloc(size_t sz)
     }
     return res;
 }
-#undef  malloc
-#define malloc(_s)        ao_malloc(_s)
 
-LOCAL void *
+static void *
 ao_realloc(void *p, size_t sz)
 {
     void * res = (p == NULL) ? malloc(sz) : realloc(p, sz);
@@ -82,10 +80,8 @@ ao_realloc(void *p, size_t sz)
     }
     return res;
 }
-#undef  realloc
-#define realloc(_p,_s)    ao_realloc(_p,_s)
 
-LOCAL char *
+static char *
 ao_strdup(char const *str)
 {
     char * res = strdup(str);
@@ -95,8 +91,6 @@ ao_strdup(char const *str)
     }
     return res;
 }
-#undef  strdup
-#define strdup(_p)        ao_strdup(_p)
 
 /**
  *  handle an option.
@@ -104,7 +98,7 @@ ao_strdup(char const *str)
  *  This routine handles equivalencing, sets the option state flags and
  *  invokes the handler procedure, if any.
  */
-LOCAL tSuccess
+static tSuccess
 handle_opt(tOptions * opts, tOptState * o_st)
 {
     /*
@@ -217,7 +211,7 @@ handle_opt(tOptions * opts, tOptState * o_st)
  * @param opts the program option descriptor
  * @param o_st  the state of the next found option
  */
-LOCAL tSuccess
+static tSuccess
 next_opt(tOptions * opts, tOptState * o_st)
 {
     {
@@ -244,7 +238,7 @@ next_opt(tOptions * opts, tOptState * o_st)
  *  @param[in,out] opts   program options descriptor
  *  @returns SUCCESS or FAILURE
  */
-LOCAL tSuccess
+static tSuccess
 regular_opts(tOptions * opts)
 {
     /* assert:  opts->fOptSet & OPTPROC_IMMEDIATE == 0 */

+ 9 - 2
libopts/autoopts.h

@@ -11,7 +11,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -455,7 +455,7 @@ typedef enum { AOFLAG_TABLE } ao_flags_t;
 #undef  _aof_
 
 static char const   zNil[] = "";
-static arg_types_t  argTypes             = { NULL };
+static arg_types_t  argTypes;
 static char         line_fmt_buf[32];
 static bool         displayEnum          = false;
 static char const   pkgdatadir_default[] = PKGDATADIR;
@@ -463,6 +463,13 @@ static char const * program_pkgdatadir   = pkgdatadir_default;
 static tOptionLoadMode option_load_mode  = OPTION_LOAD_UNCOOKED;
 static tePagerState pagerState           = PAGER_STATE_INITIAL;
 
+static noreturn void option_exits(int exit_code);
+static noreturn void fserr_exit(char const * prog, char const * op,
+                                char const * fname);
+static          void fserr_warn(char const * prog, char const * op,
+                                char const * fname);
+static noreturn void ao_bug(char const * msg);
+
        FILE *       option_usage_fp      = NULL;
 
 static char const * pz_enum_err_fmt;

+ 44 - 11
libopts/autoopts/options.h

@@ -9,11 +9,11 @@
  *  This file defines all the global structures and special values
  *  used in the automated option processing library.
  *
- *  Automated Options Copyright (C) 1992-2016 by Bruce Korb
+ *  Automated Options Copyright (C) 1992-2018 by Bruce Korb
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -40,9 +40,40 @@
  */
 #include <sys/types.h>
 #include <stdio.h>
-#include <stdint.h>
-#include <limits.h>
-#include <stdbool.h>
+
+#ifndef COMPAT_H_GUARD
+/*
+ * This is needed for test compilations where the "compat.h"
+ * header is not usually available.
+ */
+#  if defined(HAVE_STDINT_H)
+#    include <stdint.h>
+#  elif defined(HAVE_INTTYPES_H)
+#    include <inttypes.h>
+#  endif /* HAVE_STDINT/INTTYPES_H */
+
+#  if defined(HAVE_LIMITS_H)
+#    include <limits.h>
+#  elif defined(HAVE_SYS_LIMITS_H)
+#    include <sys/limits.h>
+#  endif /* HAVE_LIMITS/SYS_LIMITS_H */
+
+#  if defined(HAVE_SYSEXITS_H)
+#    include <sysexits.h>
+#  endif /* HAVE_SYSEXITS_H */
+
+#  if defined(HAVE_STDBOOL_H)
+#    include <stdbool.h>
+#  elif ! defined(bool)
+     typedef enum { false = 0, true = 1 } _Bool;
+#    define bool _Bool
+
+     /* The other macros must be usable in preprocessor directives.  */
+#    define false 0
+#    define true 1
+#  endif /* HAVE_SYSEXITS_H */
+#endif /* COMPAT_H_GUARD */
+// END-CONFIGURED-HEADERS
 
 /**
  * Defined to abnormal value of EX_USAGE.  Used to indicate that paged usage
@@ -78,15 +109,15 @@
  * @{
  */
 /// autoopts structure version
-#define OPTIONS_STRUCT_VERSION      167937
+#define OPTIONS_STRUCT_VERSION      172033
 /// autoopts structure version string
-#define OPTIONS_VERSION_STRING      "41:1:16"
+#define OPTIONS_VERSION_STRING      "42:1:17"
 /// minimum version the autoopts library supports
 #define OPTIONS_MINIMUM_VERSION     102400
 /// minimum version the autoopts library supports as a string
 #define OPTIONS_MIN_VER_STRING      "25:0:0"
 /// the display version of the autoopts library, as a string
-#define OPTIONS_DOTTED_VERSION      "41.1"
+#define OPTIONS_DOTTED_VERSION      "42.1"
 /// convert a version/release number pair to an integer value
 #define OPTIONS_VER_TO_NUM(_v, _r)  (((_v) * 4096) + (_r))
 /// @}
@@ -109,7 +140,8 @@ typedef enum {
     OPARG_TYPE_FLOAT        =  9, ///< opt arg is a floating point num
     OPARG_TYPE_DOUBLE       = 10, ///< opt arg is a double prec. float
     OPARG_TYPE_LONG_DOUBLE  = 11, ///< opt arg is a long double prec.
-    OPARG_TYPE_LONG_LONG    = 12  ///< opt arg is a long long int
+    OPARG_TYPE_LONG_LONG    = 12, ///< opt arg is a long long int
+    OPARG_TYPE_STATIC       = 13  ///< 
 } teOptArgType;
 
 /**
@@ -610,6 +642,7 @@ struct options {
     void *                      pSavedState;
 
     /// The procedure to call to print usage text
+    /* __attribute__((__noreturn__)) */
     // coverity[+kill]
     tpUsageProc                 pUsageProc;
     /// The procedure to call to translate translatable option messages
@@ -808,7 +841,7 @@ extern int optionFileLoad(tOptions *, char const *);
 
 
 /**
- * optionFindNextValue - find a hierarchically valued option instance
+ * optionFindNextValue - find a hierarcicaly valued option instance
  *
  *  This routine will find the next entry in a nested value option or
  *  configurable.  It will search through the list and return the next entry
@@ -825,7 +858,7 @@ extern const tOptionValue * optionFindNextValue(const tOptDesc *, const tOptionV
 
 
 /**
- * optionFindValue - find a hierarchically valued option instance
+ * optionFindValue - find a hierarcicaly valued option instance
  *
  *  This routine will find an entry in a nested value option or configurable.
  *  It will search through the list and return a matching entry.

+ 5 - 1
libopts/autoopts/project.h

@@ -4,7 +4,7 @@
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -71,6 +71,10 @@ typedef int tSuccess;
 #  define MODE extern
 #endif
 
+#undef NUL
+#define NUL '\0'
+
+#define MOD_LOCAL static
 #define parse_duration option_parse_duration
 
 #endif /* AUTOGEN_PROJECT_H */

+ 247 - 253
libopts/autoopts/usage-txt.h

@@ -8,7 +8,7 @@
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2017 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -29,7 +29,7 @@
 /** @file usage-txt.h
  *
  *  This file handles all the bookkeeping required for tracking all the little
- *  tiny strings used by the AutoOpts library.  There are 108
+ *  tiny strings used by the AutoOpts library.  There are 107
  *  of them.  This is not versioned because it is entirely internal to the
  *  library and accessed by client code only in a very well-controlled way:
  *  they may substitute translated strings using a procedure that steps through
@@ -47,7 +47,7 @@ typedef struct {
   char *        utpz_GnuKeyArg;
   char *        utpz_GnuNumArg;
   char *        utpz_GnuStrArg;
-  char const *  apz_str[104];
+  char const *  apz_str[103];
 } usage_text_t;
 
 /*
@@ -55,7 +55,7 @@ typedef struct {
  *  strings and the text array containing untranslatable strings.
  */
 extern usage_text_t option_xlateable_txt;
-extern char const option_lib_text[4285];
+extern char const option_lib_text[4267];
 
 #if defined(AUTOOPTS_INTERNAL)
 /*
@@ -110,67 +110,66 @@ extern char const option_lib_text[4285];
 #define zNoState              (option_xlateable_txt.apz_str[ 40])
 #define zNotCmdOpt            (option_xlateable_txt.apz_str[ 41])
 #define zNotDate              (option_xlateable_txt.apz_str[ 42])
-#define zNotDef               (option_xlateable_txt.apz_str[ 43])
-#define zNotDuration          (option_xlateable_txt.apz_str[ 44])
-#define zneed_more            (option_xlateable_txt.apz_str[ 45])
-#define zNotNumber            (option_xlateable_txt.apz_str[ 46])
-#define znum_too_large        (option_xlateable_txt.apz_str[ 47])
-#define zoffer_usage_fmt      (option_xlateable_txt.apz_str[ 48])
-#define zonly_one             (option_xlateable_txt.apz_str[ 49])
-#define zstdout_name          (option_xlateable_txt.apz_str[ 50])
-#define zstderr_name          (option_xlateable_txt.apz_str[ 51])
-#define zwriting              (option_xlateable_txt.apz_str[ 52])
-#define zRangeErr             (option_xlateable_txt.apz_str[ 53])
-#define zneed_fmt             (option_xlateable_txt.apz_str[ 54])
-#define zsave_warn            (option_xlateable_txt.apz_str[ 55])
-#define zalt_opt              (option_xlateable_txt.apz_str[ 56])
-#define zAuto                 (option_xlateable_txt.apz_str[ 57])
-#define zDefaultOpt           (option_xlateable_txt.apz_str[ 58])
-#define zDis                  (option_xlateable_txt.apz_str[ 59])
-#define zDisabledOpt          (option_xlateable_txt.apz_str[ 60])
-#define zDisabledWhy          (option_xlateable_txt.apz_str[ 61])
-#define zEnab                 (option_xlateable_txt.apz_str[ 62])
-#define ztoo_often_fmt        (option_xlateable_txt.apz_str[ 63])
-#define zExamineFmt           (option_xlateable_txt.apz_str[ 64])
-#define zFileCannotExist      (option_xlateable_txt.apz_str[ 65])
-#define zFileMustExist        (option_xlateable_txt.apz_str[ 66])
-#define zFlagOkay             (option_xlateable_txt.apz_str[ 67])
-#define zGenshell             (option_xlateable_txt.apz_str[ 68])
-#define zLowerBits            (option_xlateable_txt.apz_str[ 69])
-#define zMembers              (option_xlateable_txt.apz_str[ 70])
-#define zMust                 (option_xlateable_txt.apz_str[ 71])
-#define zNoFlags              (option_xlateable_txt.apz_str[ 72])
-#define zNoLim                (option_xlateable_txt.apz_str[ 73])
-#define zNoPreset             (option_xlateable_txt.apz_str[ 74])
-#define zNoRq_NoShrtTtl       (option_xlateable_txt.apz_str[ 75])
-#define zNoRq_ShrtTtl         (option_xlateable_txt.apz_str[ 76])
-#define zNrmOptFmt            (option_xlateable_txt.apz_str[ 77])
-#define zNumberOpt            (option_xlateable_txt.apz_str[ 78])
-#define zOptsOnly             (option_xlateable_txt.apz_str[ 79])
-#define zPathFmt              (option_xlateable_txt.apz_str[ 80])
-#define zPlsSendBugs          (option_xlateable_txt.apz_str[ 81])
-#define zPreset               (option_xlateable_txt.apz_str[ 82])
-#define zPresetIntro          (option_xlateable_txt.apz_str[ 83])
-#define zProhib               (option_xlateable_txt.apz_str[ 84])
-#define zProhibOne            (option_xlateable_txt.apz_str[ 85])
-#define zRange                (option_xlateable_txt.apz_str[ 86])
-#define zRangeAbove           (option_xlateable_txt.apz_str[ 87])
-#define zRangeExact           (option_xlateable_txt.apz_str[ 88])
-#define zRangeLie             (option_xlateable_txt.apz_str[ 89])
-#define zRangeOnly            (option_xlateable_txt.apz_str[ 90])
-#define zRangeOr              (option_xlateable_txt.apz_str[ 91])
-#define zRangeScaled          (option_xlateable_txt.apz_str[ 92])
-#define zRangeUpto            (option_xlateable_txt.apz_str[ 93])
-#define zReorder              (option_xlateable_txt.apz_str[ 94])
-#define zReqOne               (option_xlateable_txt.apz_str[ 95])
-#define zReqThese             (option_xlateable_txt.apz_str[ 96])
-#define zReq_NoShrtTtl        (option_xlateable_txt.apz_str[ 97])
-#define zReq_ShrtTtl          (option_xlateable_txt.apz_str[ 98])
-#define zSetMemberSettings    (option_xlateable_txt.apz_str[ 99])
-#define zUpTo                 (option_xlateable_txt.apz_str[100])
-#define zValidKeys            (option_xlateable_txt.apz_str[101])
-#define zVendIntro            (option_xlateable_txt.apz_str[102])
-#define zVendOptsAre          (option_xlateable_txt.apz_str[103])
+#define zNotDuration          (option_xlateable_txt.apz_str[ 43])
+#define zneed_more            (option_xlateable_txt.apz_str[ 44])
+#define zNotNumber            (option_xlateable_txt.apz_str[ 45])
+#define znum_too_large        (option_xlateable_txt.apz_str[ 46])
+#define zoffer_usage_fmt      (option_xlateable_txt.apz_str[ 47])
+#define zonly_one             (option_xlateable_txt.apz_str[ 48])
+#define zstdout_name          (option_xlateable_txt.apz_str[ 49])
+#define zstderr_name          (option_xlateable_txt.apz_str[ 50])
+#define zwriting              (option_xlateable_txt.apz_str[ 51])
+#define zRangeErr             (option_xlateable_txt.apz_str[ 52])
+#define zneed_fmt             (option_xlateable_txt.apz_str[ 53])
+#define zsave_warn            (option_xlateable_txt.apz_str[ 54])
+#define zalt_opt              (option_xlateable_txt.apz_str[ 55])
+#define zAuto                 (option_xlateable_txt.apz_str[ 56])
+#define zDefaultOpt           (option_xlateable_txt.apz_str[ 57])
+#define zDis                  (option_xlateable_txt.apz_str[ 58])
+#define zDisabledOpt          (option_xlateable_txt.apz_str[ 59])
+#define zDisabledWhy          (option_xlateable_txt.apz_str[ 60])
+#define zEnab                 (option_xlateable_txt.apz_str[ 61])
+#define ztoo_often_fmt        (option_xlateable_txt.apz_str[ 62])
+#define zExamineFmt           (option_xlateable_txt.apz_str[ 63])
+#define zFileCannotExist      (option_xlateable_txt.apz_str[ 64])
+#define zFileMustExist        (option_xlateable_txt.apz_str[ 65])
+#define zFlagOkay             (option_xlateable_txt.apz_str[ 66])
+#define zGenshell             (option_xlateable_txt.apz_str[ 67])
+#define zLowerBits            (option_xlateable_txt.apz_str[ 68])
+#define zMembers              (option_xlateable_txt.apz_str[ 69])
+#define zMust                 (option_xlateable_txt.apz_str[ 70])
+#define zNoFlags              (option_xlateable_txt.apz_str[ 71])
+#define zNoLim                (option_xlateable_txt.apz_str[ 72])
+#define zNoPreset             (option_xlateable_txt.apz_str[ 73])
+#define zNoRq_NoShrtTtl       (option_xlateable_txt.apz_str[ 74])
+#define zNoRq_ShrtTtl         (option_xlateable_txt.apz_str[ 75])
+#define zNrmOptFmt            (option_xlateable_txt.apz_str[ 76])
+#define zNumberOpt            (option_xlateable_txt.apz_str[ 77])
+#define zOptsOnly             (option_xlateable_txt.apz_str[ 78])
+#define zPathFmt              (option_xlateable_txt.apz_str[ 79])
+#define zPlsSendBugs          (option_xlateable_txt.apz_str[ 80])
+#define zPreset               (option_xlateable_txt.apz_str[ 81])
+#define zPresetIntro          (option_xlateable_txt.apz_str[ 82])
+#define zProhib               (option_xlateable_txt.apz_str[ 83])
+#define zProhibOne            (option_xlateable_txt.apz_str[ 84])
+#define zRange                (option_xlateable_txt.apz_str[ 85])
+#define zRangeAbove           (option_xlateable_txt.apz_str[ 86])
+#define zRangeExact           (option_xlateable_txt.apz_str[ 87])
+#define zRangeLie             (option_xlateable_txt.apz_str[ 88])
+#define zRangeOnly            (option_xlateable_txt.apz_str[ 89])
+#define zRangeOr              (option_xlateable_txt.apz_str[ 90])
+#define zRangeScaled          (option_xlateable_txt.apz_str[ 91])
+#define zRangeUpto            (option_xlateable_txt.apz_str[ 92])
+#define zReorder              (option_xlateable_txt.apz_str[ 93])
+#define zReqOne               (option_xlateable_txt.apz_str[ 94])
+#define zReqThese             (option_xlateable_txt.apz_str[ 95])
+#define zReq_NoShrtTtl        (option_xlateable_txt.apz_str[ 96])
+#define zReq_ShrtTtl          (option_xlateable_txt.apz_str[ 97])
+#define zSetMemberSettings    (option_xlateable_txt.apz_str[ 98])
+#define zUpTo                 (option_xlateable_txt.apz_str[ 99])
+#define zValidKeys            (option_xlateable_txt.apz_str[100])
+#define zVendIntro            (option_xlateable_txt.apz_str[101])
+#define zVendOptsAre          (option_xlateable_txt.apz_str[102])
 
   /*
    *  First, set up the strings.  Some of these are writable.  These are all in
@@ -181,7 +180,7 @@ static char eng_zGnuBoolArg[]  = "=T/F";
 static char eng_zGnuKeyArg[]   = "=KWd";
 static char eng_zGnuNumArg[]   = "=num";
 static char eng_zGnuStrArg[]   = "=str";
-char const option_lib_text[4285] =
+char const option_lib_text[4267] =
 /*     0 */ "allocation of %d bytes failed\n\0"
 /*    31 */ "AutoOpts function called without option descriptor\n\0"
 /*    83 */ "\tThis exceeds the compiled library version:  \0"
@@ -190,7 +189,7 @@ char const option_lib_text[4285] =
 /*   228 */ "realloc of %d bytes at 0x%p failed\n\0"
 /*   264 */ "\tThis is less than the minimum library version:  \0"
 /*   314 */ "Automated Options version %s\n"
-            "\tCopyright (C) 1999-2014 by Bruce Korb - all rights reserved\n\0"
+            "\tCopyright (C) 1999-2017 by Bruce Korb - all rights reserved\n\0"
 /*   405 */ "(AutoOpts bug):  %s.\n\0"
 /*   427 */ "optionResetOpt() called, but reset-option not configured\0"
 /*   484 */ "could not locate the 'help' option\0"
@@ -231,76 +230,75 @@ char const option_lib_text[4285] =
 /*  1771 */ "%s error: no saved option state\n\0"
 /*  1804 */ "'%s' is not a command line option.\n\0"
 /*  1840 */ "%s error:  '%s' is not a recognizable date/time.\n\0"
-/*  1890 */ "'%s' not defined\n\0"
-/*  1908 */ "%s error:  '%s' is not a recognizable time duration.\n\0"
-/*  1962 */ "%s error:  The %s option must appear %d times.\n\0"
-/*  2010 */ "%s error:  '%s' is not a recognizable number.\n\0"
-/*  2057 */ "%s error:  %s exceeds %s keyword count\n\0"
-/*  2097 */ "Try '%s %s' for more information.\n\0"
-/*  2132 */ "one %s%s option allowed\n\0"
-/*  2157 */ "standard output\0"
-/*  2173 */ "standard error\0"
-/*  2188 */ "write\0"
-/*  2194 */ "%s error:  %s option value %ld is out of range.\n\0"
-/*  2243 */ "%s error:  %s option requires the %s option\n\0"
-/*  2288 */ "%s warning:  cannot save options - %s not regular file\n\0"
-/*  2344 */ "\t\t\t\t- an alternate for '%s'\n\0"
-/*  2373 */ "Version, usage and configuration options:\0"
-/*  2415 */ "\t\t\t\t- default option for unnamed options\n\0"
-/*  2457 */ "\t\t\t\t- disabled as '--%s'\n\0"
-/*  2483 */ " --- %-14s %s\n\0"
-/*  2498 */ "This option has been disabled\0"
-/*  2528 */ "\t\t\t\t- enabled by default\n\0"
-/*  2554 */ "%s error:  only \0"
-/*  2571 */ " - examining environment variables named %s_*\n\0"
-/*  2618 */ "\t\t\t\t- file must not pre-exist\n\0"
-/*  2649 */ "\t\t\t\t- file must pre-exist\n\0"
-/*  2676 */ "Options are specified by doubled hyphens and their name or by a single\n"
+/*  1890 */ "%s error:  '%s' is not a recognizable time duration.\n\0"
+/*  1944 */ "%s error:  The %s option must appear %d times.\n\0"
+/*  1992 */ "%s error:  '%s' is not a recognizable number.\n\0"
+/*  2039 */ "%s error:  %s exceeds %s keyword count\n\0"
+/*  2079 */ "Try '%s %s' for more information.\n\0"
+/*  2114 */ "one %s%s option allowed\n\0"
+/*  2139 */ "standard output\0"
+/*  2155 */ "standard error\0"
+/*  2170 */ "write\0"
+/*  2176 */ "%s error:  %s option value %ld is out of range.\n\0"
+/*  2225 */ "%s error:  %s option requires the %s option\n\0"
+/*  2270 */ "%s warning:  cannot save options - %s not regular file\n\0"
+/*  2326 */ "\t\t\t\t- an alternate for '%s'\n\0"
+/*  2355 */ "Version, usage and configuration options:\0"
+/*  2397 */ "\t\t\t\t- default option for unnamed options\n\0"
+/*  2439 */ "\t\t\t\t- disabled as '--%s'\n\0"
+/*  2465 */ " --- %-14s %s\n\0"
+/*  2480 */ "This option has been disabled\0"
+/*  2510 */ "\t\t\t\t- enabled by default\n\0"
+/*  2536 */ "%s error:  only \0"
+/*  2553 */ " - examining environment variables named %s_*\n\0"
+/*  2600 */ "\t\t\t\t- file must not pre-exist\n\0"
+/*  2631 */ "\t\t\t\t- file must pre-exist\n\0"
+/*  2658 */ "Options are specified by doubled hyphens and their name or by a single\n"
             "hyphen and the flag character.\n\0"
-/*  2779 */ "\n"
+/*  2761 */ "\n"
             "= = = = = = = =\n\n"
             "This incarnation of genshell will produce\n"
             "a shell script to parse the options for %s:\n\n\0"
-/*  2885 */ "  or an integer mask with any of the lower %d bits set\n\0"
-/*  2941 */ "\t\t\t\t- is a set membership option\n\0"
-/*  2975 */ "\t\t\t\t- must appear between %d and %d times\n\0"
-/*  3018 */ "Options are specified by single or double hyphens and their name.\n\0"
-/*  3085 */ "\t\t\t\t- may appear multiple times\n\0"
-/*  3118 */ "\t\t\t\t- may not be preset\n\0"
-/*  3143 */ "   Arg Option-Name    Description\n\0"
-/*  3178 */ "  Flg Arg Option-Name    Description\n\0"
-/*  3216 */ " %3s %s\0"
-/*  3224 */ "The '-#<number>' option may omit the hash char\n\0"
-/*  3272 */ "All arguments are named options.\n\0"
-/*  3306 */ " - reading file %s\0"
-/*  3325 */ "\n"
+/*  2867 */ "  or an integer mask with any of the lower %d bits set\n\0"
+/*  2923 */ "\t\t\t\t- is a set membership option\n\0"
+/*  2957 */ "\t\t\t\t- must appear between %d and %d times\n\0"
+/*  3000 */ "Options are specified by single or double hyphens and their name.\n\0"
+/*  3067 */ "\t\t\t\t- may appear multiple times\n\0"
+/*  3100 */ "\t\t\t\t- may not be preset\n\0"
+/*  3125 */ "   Arg Option-Name    Description\n\0"
+/*  3160 */ "  Flg Arg Option-Name    Description\n\0"
+/*  3198 */ " %3s %s\0"
+/*  3206 */ "The '-#<number>' option may omit the hash char\n\0"
+/*  3254 */ "All arguments are named options.\n\0"
+/*  3288 */ " - reading file %s\0"
+/*  3307 */ "\n"
             "Please send bug reports to:  <%s>\n\0"
-/*  3361 */ "\t\t\t\t- may NOT appear - preset only\n\0"
-/*  3397 */ "\n"
+/*  3343 */ "\t\t\t\t- may NOT appear - preset only\n\0"
+/*  3379 */ "\n"
             "The following option preset mechanisms are supported:\n\0"
-/*  3453 */ "prohibits these options:\n\0"
-/*  3479 */ "prohibits the option '%s'\n\0"
-/*  3506 */ "%s%ld to %ld\0"
-/*  3519 */ "%sgreater than or equal to %ld\0"
-/*  3550 */ "%s%ld exactly\0"
-/*  3564 */ "%sit must lie in one of the ranges:\n\0"
-/*  3601 */ "%sit must be in the range:\n\0"
-/*  3629 */ ", or\n\0"
-/*  3635 */ "%sis scalable with a suffix: k/K/m/M/g/G/t/T\n\0"
-/*  3681 */ "%sless than or equal to %ld\0"
-/*  3709 */ "Operands and options may be intermixed.  They will be reordered.\n\0"
-/*  3775 */ "requires the option '%s'\n\0"
-/*  3801 */ "requires these options:\n\0"
-/*  3826 */ "   Arg Option-Name   Req?  Description\n\0"
-/*  3866 */ "  Flg Arg Option-Name   Req?  Description\n\0"
-/*  3909 */ "or you may use a numeric representation.  Preceding these with a '!'\n"
+/*  3435 */ "prohibits these options:\n\0"
+/*  3461 */ "prohibits the option '%s'\n\0"
+/*  3488 */ "%s%ld to %ld\0"
+/*  3501 */ "%sgreater than or equal to %ld\0"
+/*  3532 */ "%s%ld exactly\0"
+/*  3546 */ "%sit must lie in one of the ranges:\n\0"
+/*  3583 */ "%sit must be in the range:\n\0"
+/*  3611 */ ", or\n\0"
+/*  3617 */ "%sis scalable with a suffix: k/K/m/M/g/G/t/T\n\0"
+/*  3663 */ "%sless than or equal to %ld\0"
+/*  3691 */ "Operands and options may be intermixed.  They will be reordered.\n\0"
+/*  3757 */ "requires the option '%s'\n\0"
+/*  3783 */ "requires these options:\n\0"
+/*  3808 */ "   Arg Option-Name   Req?  Description\n\0"
+/*  3848 */ "  Flg Arg Option-Name   Req?  Description\n\0"
+/*  3891 */ "or you may use a numeric representation.  Preceding these with a '!'\n"
             "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
             "will set them all.  Multiple entries may be passed as an option\n"
             "argument list.\n\0"
-/*  4128 */ "\t\t\t\t- may appear up to %d times\n\0"
-/*  4161 */ "The valid \"%s\" option keywords are:\n\0"
-/*  4198 */ "The next option supports vendor supported extra options:\0"
-/*  4255 */ "These additional options are:";
+/*  4110 */ "\t\t\t\t- may appear up to %d times\n\0"
+/*  4143 */ "The valid \"%s\" option keywords are:\n\0"
+/*  4180 */ "The next option supports vendor supported extra options:\0"
+/*  4237 */ "These additional options are:";
 
 /*
  *  Now, define (and initialize) the structure that contains
@@ -308,7 +306,7 @@ char const option_lib_text[4285] =
  *  Aren't you glad you don't maintain this by hand?
  */
 usage_text_t option_xlateable_txt = {
-  108,
+  107,
   eng_zGnuBoolArg, eng_zGnuKeyArg,  eng_zGnuNumArg,  eng_zGnuStrArg,
     {
     option_lib_text +    0, option_lib_text +   31, option_lib_text +   83,
@@ -325,27 +323,27 @@ usage_text_t option_xlateable_txt = {
     option_lib_text + 1490, option_lib_text + 1528, option_lib_text + 1574,
     option_lib_text + 1619, option_lib_text + 1646, option_lib_text + 1695,
     option_lib_text + 1744, option_lib_text + 1771, option_lib_text + 1804,
-    option_lib_text + 1840, option_lib_text + 1890, option_lib_text + 1908,
-    option_lib_text + 1962, option_lib_text + 2010, option_lib_text + 2057,
-    option_lib_text + 2097, option_lib_text + 2132, option_lib_text + 2157,
-    option_lib_text + 2173, option_lib_text + 2188, option_lib_text + 2194,
-    option_lib_text + 2243, option_lib_text + 2288, option_lib_text + 2344,
-    option_lib_text + 2373, option_lib_text + 2415, option_lib_text + 2457,
-    option_lib_text + 2483, option_lib_text + 2498, option_lib_text + 2528,
-    option_lib_text + 2554, option_lib_text + 2571, option_lib_text + 2618,
-    option_lib_text + 2649, option_lib_text + 2676, option_lib_text + 2779,
-    option_lib_text + 2885, option_lib_text + 2941, option_lib_text + 2975,
-    option_lib_text + 3018, option_lib_text + 3085, option_lib_text + 3118,
-    option_lib_text + 3143, option_lib_text + 3178, option_lib_text + 3216,
-    option_lib_text + 3224, option_lib_text + 3272, option_lib_text + 3306,
-    option_lib_text + 3325, option_lib_text + 3361, option_lib_text + 3397,
-    option_lib_text + 3453, option_lib_text + 3479, option_lib_text + 3506,
-    option_lib_text + 3519, option_lib_text + 3550, option_lib_text + 3564,
-    option_lib_text + 3601, option_lib_text + 3629, option_lib_text + 3635,
-    option_lib_text + 3681, option_lib_text + 3709, option_lib_text + 3775,
-    option_lib_text + 3801, option_lib_text + 3826, option_lib_text + 3866,
-    option_lib_text + 3909, option_lib_text + 4128, option_lib_text + 4161,
-    option_lib_text + 4198, option_lib_text + 4255
+    option_lib_text + 1840, option_lib_text + 1890, option_lib_text + 1944,
+    option_lib_text + 1992, option_lib_text + 2039, option_lib_text + 2079,
+    option_lib_text + 2114, option_lib_text + 2139, option_lib_text + 2155,
+    option_lib_text + 2170, option_lib_text + 2176, option_lib_text + 2225,
+    option_lib_text + 2270, option_lib_text + 2326, option_lib_text + 2355,
+    option_lib_text + 2397, option_lib_text + 2439, option_lib_text + 2465,
+    option_lib_text + 2480, option_lib_text + 2510, option_lib_text + 2536,
+    option_lib_text + 2553, option_lib_text + 2600, option_lib_text + 2631,
+    option_lib_text + 2658, option_lib_text + 2761, option_lib_text + 2867,
+    option_lib_text + 2923, option_lib_text + 2957, option_lib_text + 3000,
+    option_lib_text + 3067, option_lib_text + 3100, option_lib_text + 3125,
+    option_lib_text + 3160, option_lib_text + 3198, option_lib_text + 3206,
+    option_lib_text + 3254, option_lib_text + 3288, option_lib_text + 3307,
+    option_lib_text + 3343, option_lib_text + 3379, option_lib_text + 3435,
+    option_lib_text + 3461, option_lib_text + 3488, option_lib_text + 3501,
+    option_lib_text + 3532, option_lib_text + 3546, option_lib_text + 3583,
+    option_lib_text + 3611, option_lib_text + 3617, option_lib_text + 3663,
+    option_lib_text + 3691, option_lib_text + 3757, option_lib_text + 3783,
+    option_lib_text + 3808, option_lib_text + 3848, option_lib_text + 3891,
+    option_lib_text + 4110, option_lib_text + 4143, option_lib_text + 4180,
+    option_lib_text + 4237
   } };
 #endif /* AUTOOPTS_INTERNAL */
 
@@ -364,234 +362,230 @@ static void dummy_func(void) {
   /* LIBOPTS-MESSAGES: */
 #line 67 "../autoopts.c"
   puts(_("allocation of %d bytes failed\n"));
-#line 93 "../autoopts.c"
+#line 89 "../autoopts.c"
   puts(_("allocation of %d bytes failed\n"));
-#line 53 "../init.c"
+#line 48 "../init.c"
   puts(_("AutoOpts function called without option descriptor\n"));
-#line 86 "../init.c"
+#line 81 "../init.c"
   puts(_("\tThis exceeds the compiled library version:  "));
-#line 84 "../init.c"
+#line 79 "../init.c"
   puts(_("Automated Options Processing Error!\n"
        "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
-#line 80 "../autoopts.c"
+#line 78 "../autoopts.c"
   puts(_("realloc of %d bytes at 0x%p failed\n"));
-#line 88 "../init.c"
+#line 83 "../init.c"
   puts(_("\tThis is less than the minimum library version:  "));
 #line 121 "../version.c"
   puts(_("Automated Options version %s\n"
-       "\tCopyright (C) 1999-2014 by Bruce Korb - all rights reserved\n"));
-#line 87 "../makeshell.c"
+       "\tCopyright (C) 1999-2017 by Bruce Korb - all rights reserved\n"));
+#line 49 "../makeshell.c"
   puts(_("(AutoOpts bug):  %s.\n"));
 #line 90 "../reset.c"
   puts(_("optionResetOpt() called, but reset-option not configured"));
-#line 295 "../usage.c"
+#line 241 "../usage.c"
   puts(_("could not locate the 'help' option"));
-#line 336 "../autoopts.c"
+#line 330 "../autoopts.c"
   puts(_("optionProcess() was called with invalid data"));
-#line 751 "../usage.c"
+#line 697 "../usage.c"
   puts(_("invalid argument type specified"));
-#line 598 "../find.c"
+#line 568 "../find.c"
   puts(_("defaulted to option with optional arg"));
 #line 76 "../alias.c"
   puts(_("aliasing option is out of range."));
-#line 235 "../enum.c"
+#line 210 "../enum.c"
   puts(_("%s error:  the keyword '%s' is ambiguous for %s\n"));
-#line 108 "../find.c"
+#line 78 "../find.c"
   puts(_("  The following options match:\n"));
-#line 293 "../find.c"
+#line 263 "../find.c"
   puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
 #line 161 "../check.c"
   puts(_("%s: Command line arguments required\n"));
 #line 43 "../alias.c"
   puts(_("%d %s%s options allowed\n"));
-#line 94 "../makeshell.c"
+#line 56 "../makeshell.c"
   puts(_("%s error %d (%s) calling %s for '%s'\n"));
-#line 306 "../makeshell.c"
+#line 268 "../makeshell.c"
   puts(_("interprocess pipe"));
-#line 168 "../version.c"
+#line 171 "../version.c"
   puts(_("error: version option argument '%c' invalid.  Use:\n"
        "\t'v' - version only\n"
        "\t'c' - version and copyright\n"
        "\t'n' - version and full copyright notice\n"));
 #line 58 "../check.c"
   puts(_("%s error:  the '%s' and '%s' options conflict\n"));
-#line 217 "../find.c"
+#line 187 "../find.c"
   puts(_("%s: The '%s' option has been disabled."));
-#line 430 "../find.c"
+#line 400 "../find.c"
   puts(_("%s: The '%s' option has been disabled."));
 #line 38 "../alias.c"
   puts(_("-equivalence"));
-#line 469 "../find.c"
+#line 439 "../find.c"
   puts(_("%s: illegal option -- %c\n"));
 #line 110 "../reset.c"
   puts(_("%s: illegal option -- %c\n"));
-#line 271 "../find.c"
+#line 241 "../find.c"
   puts(_("%s: illegal option -- %s\n"));
-#line 755 "../find.c"
+#line 740 "../find.c"
   puts(_("%s: illegal option -- %s\n"));
 #line 118 "../reset.c"
   puts(_("%s: illegal option -- %s\n"));
-#line 335 "../find.c"
+#line 305 "../find.c"
   puts(_("%s: unknown vendor extension option -- %s\n"));
-#line 160 "../enum.c"
+#line 135 "../enum.c"
   puts(_("  or an integer from %d through %d\n"));
-#line 170 "../enum.c"
+#line 145 "../enum.c"
   puts(_("  or an integer from %d through %d\n"));
-#line 750 "../usage.c"
+#line 696 "../usage.c"
   puts(_("%s error:  invalid option descriptor for %s\n"));
-#line 1084 "../usage.c"
+#line 1030 "../usage.c"
   puts(_("%s error:  invalid option descriptor for %s\n"));
-#line 385 "../find.c"
+#line 355 "../find.c"
   puts(_("%s: invalid option name: %s\n"));
-#line 527 "../find.c"
+#line 497 "../find.c"
   puts(_("%s: The '%s' option requires an argument.\n"));
-#line 156 "../autoopts.c"
+#line 150 "../autoopts.c"
   puts(_("(AutoOpts bug):  Equivalenced option '%s' was equivalenced to both\n"
        "\t'%s' and '%s'."));
 #line 94 "../check.c"
   puts(_("%s error:  The %s option is required\n"));
-#line 632 "../find.c"
+#line 602 "../find.c"
   puts(_("%s: The '%s' option cannot have an argument.\n"));
 #line 151 "../check.c"
   puts(_("%s: Command line arguments are not allowed.\n"));
-#line 536 "../save.c"
+#line 568 "../save.c"
   puts(_("error %d (%s) creating %s\n"));
-#line 235 "../enum.c"
+#line 210 "../enum.c"
   puts(_("%s error:  '%s' does not match any %s keywords.\n"));
 #line 93 "../reset.c"
   puts(_("%s error: The '%s' option requires an argument.\n"));
-#line 186 "../save.c"
+#line 122 "../save.c"
   puts(_("error %d (%s) stat-ing %s\n"));
-#line 239 "../save.c"
+#line 175 "../save.c"
   puts(_("error %d (%s) stat-ing %s\n"));
 #line 143 "../restore.c"
   puts(_("%s error: no saved option state\n"));
-#line 231 "../autoopts.c"
+#line 225 "../autoopts.c"
   puts(_("'%s' is not a command line option.\n"));
 #line 113 "../time.c"
   puts(_("%s error:  '%s' is not a recognizable date/time.\n"));
-#line 131 "../save.c"
-  puts(_("'%s' not defined\n"));
 #line 50 "../time.c"
   puts(_("%s error:  '%s' is not a recognizable time duration.\n"));
 #line 92 "../check.c"
   puts(_("%s error:  The %s option must appear %d times.\n"));
 #line 165 "../numeric.c"
   puts(_("%s error:  '%s' is not a recognizable number.\n"));
-#line 201 "../enum.c"
+#line 176 "../enum.c"
   puts(_("%s error:  %s exceeds %s keyword count\n"));
-#line 333 "../usage.c"
+#line 279 "../usage.c"
   puts(_("Try '%s %s' for more information.\n"));
 #line 45 "../alias.c"
   puts(_("one %s%s option allowed\n"));
-#line 208 "../makeshell.c"
+#line 170 "../makeshell.c"
   puts(_("standard output"));
-#line 943 "../makeshell.c"
+#line 905 "../makeshell.c"
   puts(_("standard output"));
-#line 277 "../usage.c"
+#line 223 "../usage.c"
   puts(_("standard output"));
-#line 418 "../usage.c"
+#line 364 "../usage.c"
   puts(_("standard output"));
-#line 628 "../usage.c"
+#line 574 "../usage.c"
   puts(_("standard output"));
-#line 175 "../version.c"
+#line 178 "../version.c"
   puts(_("standard output"));
-#line 277 "../usage.c"
+#line 223 "../usage.c"
   puts(_("standard error"));
-#line 418 "../usage.c"
+#line 364 "../usage.c"
   puts(_("standard error"));
-#line 628 "../usage.c"
+#line 574 "../usage.c"
   puts(_("standard error"));
-#line 175 "../version.c"
+#line 178 "../version.c"
   puts(_("standard error"));
-#line 208 "../makeshell.c"
+#line 170 "../makeshell.c"
   puts(_("write"));
-#line 943 "../makeshell.c"
+#line 905 "../makeshell.c"
   puts(_("write"));
-#line 276 "../usage.c"
+#line 222 "../usage.c"
   puts(_("write"));
-#line 417 "../usage.c"
+#line 363 "../usage.c"
   puts(_("write"));
-#line 627 "../usage.c"
+#line 573 "../usage.c"
   puts(_("write"));
-#line 174 "../version.c"
+#line 177 "../version.c"
   puts(_("write"));
 #line 60 "../numeric.c"
   puts(_("%s error:  %s option value %ld is out of range.\n"));
 #line 44 "../check.c"
   puts(_("%s error:  %s option requires the %s option\n"));
-#line 130 "../save.c"
+#line 121 "../save.c"
   puts(_("%s warning:  cannot save options - %s not regular file\n"));
-#line 185 "../save.c"
+#line 174 "../save.c"
   puts(_("%s warning:  cannot save options - %s not regular file\n"));
-#line 238 "../save.c"
+#line 193 "../save.c"
   puts(_("%s warning:  cannot save options - %s not regular file\n"));
-#line 257 "../save.c"
-  puts(_("%s warning:  cannot save options - %s not regular file\n"));
-#line 535 "../save.c"
+#line 567 "../save.c"
   puts(_("%s warning:  cannot save options - %s not regular file\n"));
   /* END-LIBOPTS-MESSAGES */
 
   /* USAGE-TEXT: */
-#line 876 "../usage.c"
+#line 822 "../usage.c"
   puts(_("\t\t\t\t- an alternate for '%s'\n"));
-#line 1151 "../usage.c"
+#line 1097 "../usage.c"
   puts(_("Version, usage and configuration options:"));
-#line 927 "../usage.c"
+#line 873 "../usage.c"
   puts(_("\t\t\t\t- default option for unnamed options\n"));
-#line 840 "../usage.c"
+#line 786 "../usage.c"
   puts(_("\t\t\t\t- disabled as '--%s'\n"));
-#line 1120 "../usage.c"
+#line 1066 "../usage.c"
   puts(_(" --- %-14s %s\n"));
-#line 1118 "../usage.c"
+#line 1064 "../usage.c"
   puts(_("This option has been disabled"));
-#line 867 "../usage.c"
+#line 813 "../usage.c"
   puts(_("\t\t\t\t- enabled by default\n"));
 #line 40 "../alias.c"
   puts(_("%s error:  only "));
-#line 1197 "../usage.c"
+#line 1143 "../usage.c"
   puts(_(" - examining environment variables named %s_*\n"));
 #line 168 "../file.c"
   puts(_("\t\t\t\t- file must not pre-exist\n"));
 #line 172 "../file.c"
   puts(_("\t\t\t\t- file must pre-exist\n"));
-#line 383 "../usage.c"
+#line 329 "../usage.c"
   puts(_("Options are specified by doubled hyphens and their name or by a single\n"
        "hyphen and the flag character.\n"));
-#line 921 "../makeshell.c"
+#line 882 "../makeshell.c"
   puts(_("\n"
        "= = = = = = = =\n\n"
        "This incarnation of genshell will produce\n"
        "a shell script to parse the options for %s:\n\n"));
-#line 167 "../enum.c"
+#line 142 "../enum.c"
   puts(_("  or an integer mask with any of the lower %d bits set\n"));
-#line 900 "../usage.c"
+#line 846 "../usage.c"
   puts(_("\t\t\t\t- is a set membership option\n"));
-#line 921 "../usage.c"
+#line 867 "../usage.c"
   puts(_("\t\t\t\t- must appear between %d and %d times\n"));
-#line 385 "../usage.c"
+#line 331 "../usage.c"
   puts(_("Options are specified by single or double hyphens and their name.\n"));
-#line 907 "../usage.c"
+#line 853 "../usage.c"
   puts(_("\t\t\t\t- may appear multiple times\n"));
-#line 894 "../usage.c"
+#line 840 "../usage.c"
   puts(_("\t\t\t\t- may not be preset\n"));
-#line 1312 "../usage.c"
+#line 1258 "../usage.c"
   puts(_("   Arg Option-Name    Description\n"));
-#line 1248 "../usage.c"
+#line 1194 "../usage.c"
   puts(_("  Flg Arg Option-Name    Description\n"));
-#line 1306 "../usage.c"
+#line 1252 "../usage.c"
   puts(_("  Flg Arg Option-Name    Description\n"));
-#line 1307 "../usage.c"
+#line 1253 "../usage.c"
   puts(_(" %3s %s"));
-#line 1313 "../usage.c"
+#line 1259 "../usage.c"
   puts(_(" %3s %s"));
-#line 390 "../usage.c"
+#line 336 "../usage.c"
   puts(_("The '-#<number>' option may omit the hash char\n"));
-#line 386 "../usage.c"
+#line 332 "../usage.c"
   puts(_("All arguments are named options.\n"));
-#line 974 "../usage.c"
+#line 920 "../usage.c"
   puts(_(" - reading file %s"));
-#line 412 "../usage.c"
+#line 358 "../usage.c"
   puts(_("\n"
        "Please send bug reports to:  <%s>\n"));
 #line 100 "../version.c"
@@ -600,17 +594,17 @@ static void dummy_func(void) {
 #line 129 "../version.c"
   puts(_("\n"
        "Please send bug reports to:  <%s>\n"));
-#line 906 "../usage.c"
+#line 852 "../usage.c"
   puts(_("\t\t\t\t- may NOT appear - preset only\n"));
-#line 947 "../usage.c"
+#line 893 "../usage.c"
   puts(_("\n"
        "The following option preset mechanisms are supported:\n"));
-#line 1195 "../usage.c"
+#line 1141 "../usage.c"
   puts(_("\n"
        "The following option preset mechanisms are supported:\n"));
-#line 685 "../usage.c"
+#line 631 "../usage.c"
   puts(_("prohibits these options:\n"));
-#line 680 "../usage.c"
+#line 626 "../usage.c"
   puts(_("prohibits the option '%s'\n"));
 #line 81 "../numeric.c"
   puts(_("%s%ld to %ld"));
@@ -628,28 +622,28 @@ static void dummy_func(void) {
   puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
 #line 77 "../numeric.c"
   puts(_("%sless than or equal to %ld"));
-#line 393 "../usage.c"
+#line 339 "../usage.c"
   puts(_("Operands and options may be intermixed.  They will be reordered.\n"));
-#line 655 "../usage.c"
+#line 601 "../usage.c"
   puts(_("requires the option '%s'\n"));
-#line 658 "../usage.c"
+#line 604 "../usage.c"
   puts(_("requires these options:\n"));
-#line 1324 "../usage.c"
+#line 1270 "../usage.c"
   puts(_("   Arg Option-Name   Req?  Description\n"));
-#line 1318 "../usage.c"
+#line 1264 "../usage.c"
   puts(_("  Flg Arg Option-Name   Req?  Description\n"));
-#line 168 "../enum.c"
+#line 143 "../enum.c"
   puts(_("or you may use a numeric representation.  Preceding these with a '!'\n"
        "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
        "will set them all.  Multiple entries may be passed as an option\n"
        "argument list.\n"));
-#line 913 "../usage.c"
+#line 859 "../usage.c"
   puts(_("\t\t\t\t- may appear up to %d times\n"));
-#line 77 "../enum.c"
+#line 52 "../enum.c"
   puts(_("The valid \"%s\" option keywords are:\n"));
-#line 1155 "../usage.c"
+#line 1101 "../usage.c"
   puts(_("The next option supports vendor supported extra options:"));
-#line 776 "../usage.c"
+#line 722 "../usage.c"
   puts(_("These additional options are:"));
   /* END-USAGE-TEXT */
 }

+ 2 - 2
libopts/boolean.c

@@ -13,7 +13,7 @@
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -65,7 +65,7 @@ optionBooleanVal(tOptions * opts, tOptDesc * od)
         if ((val != 0) || (*pz != NUL))
             break;
     }
-    /* fall through */
+    /* FALLTHROUGH */
     case 'N':
     case 'n':
     case 'F':

+ 2 - 2
libopts/check.c

@@ -9,7 +9,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -100,7 +100,7 @@ occurs_enough(tOptions * pOpts, tOptDesc * pOD)
  *
  *  Make sure that the argument list passes our consistency tests.
  */
-LOCAL bool
+static bool
 is_consistent(tOptions * pOpts)
 {
     tOptDesc * pOD   = pOpts->pOptDesc;

+ 4 - 4
libopts/compat/compat.h

@@ -1,9 +1,9 @@
-/*  -*- Mode: C -*- 
+/*  -*- Mode: C -*-
  *
  *  compat.h is free software.
  *  This file is part of AutoGen and AutoOpts.
  *
- *  AutoGen Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ *  AutoGen Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -182,9 +182,9 @@
 #  include <unistd.h>
 #endif
 
-#ifdef HAVE_STDBOOL_H
+#if defined(HAVE_STDBOOL_H)
 #  include <stdbool.h>
-#else
+#elif ! defined(bool)
    typedef enum { false = 0, true = 1 } _Bool;
 #  define bool _Bool
 

+ 1 - 1
libopts/compat/windows-config.h

@@ -9,7 +9,7 @@
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control

+ 25 - 78
libopts/configfile.c

@@ -9,7 +9,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -28,50 +28,6 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-/* = = = START-STATIC-FORWARD = = = */
-static void
-file_preset(tOptions * opts, char const * fname, int dir);
-
-static char *
-handle_comment(char * txt);
-
-static char *
-handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir);
-
-static char *
-handle_directive(tOptions * opts, char * txt);
-
-static char *
-aoflags_directive(tOptions * opts, char * txt);
-
-static char *
-program_directive(tOptions * opts, char * txt);
-
-static char *
-handle_section(tOptions * opts, char * txt);
-
-static int
-parse_xml_encoding(char ** ppz);
-
-static char *
-trim_xml_text(char * intxt, char const * pznm, tOptionLoadMode mode);
-
-static void
-cook_xml_text(char * pzData);
-
-static char *
-handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir);
-
-static char const *
-parse_keyword(tOptions * opts, char const * txt, tOptionValue * typ);
-
-static char const *
-parse_set_mem(tOptions * opts, char const * txt, tOptionValue * typ);
-
-static char const *
-parse_value(char const * txt, tOptionValue * typ);
-/* = = = END-STATIC-FORWARD = = = */
-
 /**
  *  Skip over some unknown attribute
  *  @param[in] txt   start of skpped text
@@ -145,7 +101,7 @@ configFileLoad(char const * fname)
 
 /*=export_func  optionFindValue
  *
- * what:  find a hierarchically valued option instance
+ * what:  find a hierarcicaly valued option instance
  * arg:   + const tOptDesc * + odesc + an option with a nested arg type +
  * arg:   + char const *     + name  + name of value to find +
  * arg:   + char const *     + val   + the matching value    +
@@ -220,7 +176,7 @@ optionFindValue(const tOptDesc * odesc, char const * name, char const * val)
  *
  * FIXME: the handling of 'pzName' and 'pzVal' is just wrong.
  *
- * what:  find a hierarchically valued option instance
+ * what:  find a hierarcicaly valued option instance
  * arg:   + const tOptDesc * + odesc + an option with a nested arg type +
  * arg:   + const tOptionValue * + pPrevVal + the last entry +
  * arg:   + char const *     + name     + name of value to find +
@@ -466,7 +422,8 @@ file_preset(tOptions * opts, char const * fname, int dir)
                 ftext = strchr(ftext + 2, '>');
                 if (ftext++ != NULL)
                     break;
-                /* fall through */
+                /* FALLTHROUGH */
+
             default:
                 ftext = NULL;
             }
@@ -626,9 +583,9 @@ handle_directive(tOptions * opts, char * txt)
 
     for (ix = 0; ix < dir_ct; ix++) {
         size_t len = strlen(dir_names[ix]);
-        if (  (strncmp(txt + 2, dir_names[ix], len) == 0)
-           && (! IS_VALUE_NAME_CHAR(txt[len+2])) )
-            return dir_disp[ix](opts, txt + len + 2);
+        if (  (strncmp(txt, dir_names[ix], len) == 0)
+           && (! IS_VALUE_NAME_CHAR(txt[len])) )
+            return dir_disp[ix](opts, txt + len);
     }
 
     /*
@@ -681,38 +638,28 @@ aoflags_directive(tOptions * opts, char * txt)
 static char *
 program_directive(tOptions * opts, char * txt)
 {
-    static char const ttlfmt[] = "<?";
-    size_t ttl_len  = sizeof(ttlfmt) + strlen(zCfgProg);
-    char * ttl      = AGALOC(ttl_len, "prog title");
     size_t name_len = strlen(opts->pzProgName);
 
-    memcpy(ttl, ttlfmt, sizeof(ttlfmt) - 1);
-    memcpy(ttl + sizeof(ttlfmt) - 1, zCfgProg, ttl_len - (sizeof(ttlfmt) - 1));
-
-    do  {
-        txt = SPN_WHITESPACE_CHARS(txt+1);
+    for (;; txt += zCfgProg_LEN) {
+        txt = SPN_WHITESPACE_CHARS(txt);
 
         if (  (strneqvcmp(txt, opts->pzProgName, (int)name_len) == 0)
-           && (IS_END_XML_TOKEN_CHAR(txt[name_len])) ) {
-            txt += name_len;
-            break;
-        }
+           && (IS_END_XML_TOKEN_CHAR(txt[name_len])) )
 
-        txt = strstr(txt, ttl);
-    } while (txt != NULL);
+            return txt + name_len;
 
-    AGFREE(ttl);
-    if (txt != NULL)
-        for (;;) {
-            if (*txt == NUL) {
-                txt = NULL;
-                break;
-            }
-            if (*(txt++) == '>')
-                break;
-        }
+        txt = strstr(txt, zCfgProg);
+        if (txt == NULL)
+            return txt;
+    }
 
-    return txt;
+    for (;;) {
+        if (*txt == NUL)
+            return NULL;
+
+        if (*(txt++) == '>')
+            return txt;
+    }
 }
 
 /**
@@ -1006,7 +953,7 @@ handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir)
  *  scanning the "homerc" list, or from a specific file request.
  *  (see "optionFileLoad()", the implementation for --load-opts)
  */
-LOCAL void
+static void
 intern_file_load(tOptions * opts)
 {
     uint32_t  svfl;
@@ -1207,7 +1154,7 @@ optionLoadOpt(tOptions * opts, tOptDesc * odesc)
  *
  * @returns NULL on failure, otherwise the scan point
  */
-LOCAL char const *
+static char const *
 parse_attrs(tOptions * opts, char const * txt, tOptionLoadMode * pMode,
             tOptionValue * pType)
 {

+ 1 - 9
libopts/cook.c

@@ -10,7 +10,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -29,14 +29,6 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-/* = = = START-STATIC-FORWARD = = = */
-static char *
-nl_count(char * start, char * end, int * lnct_p);
-
-static bool
-contiguous_quote(char ** pps, char * pq, int * lnct_p);
-/* = = = END-STATIC-FORWARD = = = */
-
 /*=export_func  ao_string_cook_escape_char
  * private:
  *

+ 3 - 27
libopts/enum.c

@@ -14,7 +14,7 @@
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -33,31 +33,6 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-/* = = = START-STATIC-FORWARD = = = */
-static void
-enum_err(tOptions * pOpts, tOptDesc * pOD,
-         char const * const * paz_names, int name_ct);
-
-static uintptr_t
-find_name(char const * name, tOptions * pOpts, tOptDesc * pOD,
-          char const * const *  paz_names, unsigned int name_ct);
-
-static void
-set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
-               unsigned int name_ct);
-
-static void
-set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list,
-               unsigned int nm_ct);
-
-static uintptr_t
-check_membership_start(tOptDesc * od, char const ** argp, bool * invert);
-
-static uintptr_t
-find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len,
-                char const * const * nm_list, unsigned int nm_ct);
-/* = = = END-STATIC-FORWARD = = = */
-
 static void
 enum_err(tOptions * pOpts, tOptDesc * pOD,
          char const * const * paz_names, int name_ct)
@@ -254,7 +229,8 @@ find_name(char const * name, tOptions * pOpts, tOptDesc * pOD,
 char const *
 optionKeywordName(tOptDesc * pOD, unsigned int enum_val)
 {
-    tOptDesc od = { 0 };
+    tOptDesc od;
+    memset(&od, 0, sizeof(od));
     od.optArg.argEnum = enum_val;
 
     (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, &od );

+ 3 - 9
libopts/env.c

@@ -13,7 +13,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -32,19 +32,13 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-/* = = = START-STATIC-FORWARD = = = */
-static void
-do_env_opt(tOptState * os, char * env_name,
-            tOptions * pOpts, teEnvPresetType type);
-/* = = = END-STATIC-FORWARD = = = */
-
 /*
  *  doPrognameEnv - check for preset values from the ${PROGNAME}
  *  environment variable.  This is accomplished by parsing the text into
  *  tokens, temporarily replacing the arg vector and calling
  *  immediate_opts and/or regular_opts.
  */
-LOCAL void
+static void
 doPrognameEnv(tOptions * pOpts, teEnvPresetType type)
 {
     char const *        env_opts = getenv(pOpts->pzPROGNAME);
@@ -187,7 +181,7 @@ do_env_opt(tOptState * os, char * env_name,
  *  env_presets - check for preset values from the envrionment
  *  This routine should process in all, immediate or normal modes....
  */
-LOCAL void
+static void
 env_presets(tOptions * pOpts, teEnvPresetType type)
 {
     int        ct;

+ 1 - 1
libopts/file.c

@@ -10,7 +10,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control

+ 23 - 38
libopts/find.c

@@ -12,7 +12,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -31,36 +31,6 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-/* = = = START-STATIC-FORWARD = = = */
-static int
-parse_opt(char const ** nm_pp, char ** arg_pp, char * buf, size_t bufsz);
-
-static void
-opt_ambiguities(tOptions * opts, char const * name, int nm_len);
-
-static int
-opt_match_ct(tOptions * opts, char const * name, int nm_len,
-             int * ixp, bool * disable);
-
-static tSuccess
-opt_set(tOptions * opts, char * arg, int idx, bool disable, tOptState * st);
-
-static tSuccess
-opt_unknown(tOptions * opts, char const * name, char * arg, tOptState * st);
-
-static tSuccess
-opt_ambiguous(tOptions * opts, char const * name, int match_ct);
-
-static tSuccess
-get_opt_arg_must(tOptions * opts, tOptState * o_st);
-
-static tSuccess
-get_opt_arg_may(tOptions * pOpts, tOptState * o_st);
-
-static tSuccess
-get_opt_arg_none(tOptions * pOpts, tOptState * o_st);
-/* = = = END-STATIC-FORWARD = = = */
-
 /**
  * find the name and name length we are looking for
  */
@@ -367,7 +337,7 @@ optionVendorOption(tOptions * pOpts, tOptDesc * pOD)
  *
  * @return success status
  */
-LOCAL tSuccess
+static tSuccess
 opt_find_long(tOptions * opts, char const * opt_name, tOptState * state)
 {
     char    name_buf[128];
@@ -408,7 +378,7 @@ opt_find_long(tOptions * opts, char const * opt_name, tOptState * state)
  * @param optValue   option flag character
  * @param pOptState  state about current option
  */
-LOCAL tSuccess
+static tSuccess
 opt_find_short(tOptions * pOpts, uint_t optValue, tOptState * pOptState)
 {
     tOptDesc * pRes = pOpts->pOptDesc;
@@ -638,6 +608,7 @@ get_opt_arg_none(tOptions * pOpts, tOptState * o_st)
      */
     else
         pOpts->pzCurOpt = NULL;
+
     return SUCCESS;
 }
 
@@ -648,7 +619,7 @@ get_opt_arg_none(tOptions * pOpts, tOptState * o_st)
  *  @param[in,out] o_st  the option processing state
  *  @returns SUCCESS or FAILURE
  */
-LOCAL tSuccess
+static tSuccess
 get_opt_arg(tOptions * opts, tOptState * o_st)
 {
     o_st->flags |= (o_st->pOD->fOptState & OPTST_PERSISTENT_MASK);
@@ -658,10 +629,24 @@ get_opt_arg(tOptions * opts, tOptState * o_st)
      * are handled with the "none" procedure.  Otherwise, check the
      * optional flag and call either the "may" or "must" function.
      */
-    if (  ((o_st->flags & OPTST_DISABLED) != 0)
-       || (OPTST_GET_ARGTYPE(o_st->flags) == OPARG_TYPE_NONE))
+    if ((o_st->flags & OPTST_DISABLED) != 0)
         return get_opt_arg_none(opts, o_st);
-    
+
+    switch (OPTST_GET_ARGTYPE(o_st->flags)) {
+    case OPARG_TYPE_STATIC:
+    {
+        /*
+         * Propagate the static arg
+         */
+        tSuccess res = get_opt_arg_none(opts, o_st);
+        o_st->pzOptArg = o_st->pOD->optArg.argString;
+        return res;
+    }
+
+    case OPARG_TYPE_NONE:
+        return get_opt_arg_none(opts, o_st);
+    }
+
     if (o_st->flags & OPTST_ARG_OPTIONAL)
         return get_opt_arg_may( opts, o_st);
     
@@ -675,7 +660,7 @@ get_opt_arg(tOptions * opts, tOptState * o_st)
  *  @param[in,out] o_st  the option processing state
  *  @returns SUCCESS or FAILURE
  */
-LOCAL tSuccess
+static tSuccess
 find_opt(tOptions * opts, tOptState * o_st)
 {
     /*

+ 111 - 110
libopts/genshell.c

@@ -6,7 +6,7 @@
  *  From the definitions    genshell.def
  *  and the template file   options
  *
- * Generated from AutoOpts 41:1:16 templates.
+ * Generated from AutoOpts 42:1:17 templates.
  *
  *  AutoOpts is a copyrighted work.  This source file is not encumbered
  *  by AutoOpts licensing, but is provided under the licensing terms chosen
@@ -19,7 +19,7 @@
  * The genshellopt program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1999-2014 Bruce Korb, all rights reserved.
+ *  Copyright (C) 1999-2018 Bruce Korb, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the GNU Lesser General Public License,
  *  version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
@@ -43,10 +43,15 @@
 #define OPTION_CODE_COMPILE 1
 #include "genshell.h"
 #include <sys/types.h>
+#include <sys/stat.h>
 
+#include <errno.h>
+#include <fcntl.h>
 #include <limits.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 
 #ifdef  __cplusplus
 extern "C" {
@@ -66,7 +71,7 @@ extern tUsageProc genshelloptUsage;
  */
 static char const genshellopt_opt_strs[1769] =
 /*     0 */ "genshellopt 1\n"
-            "Copyright (C) 1999-2014 Bruce Korb, all rights reserved.\n"
+            "Copyright (C) 1999-2018 Bruce Korb, all rights reserved.\n"
             "This is free software. It is licensed for use, modification and\n"
             "redistribution under the terms of the GNU Lesser General Public License,\n"
             "version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n\0"
@@ -258,7 +263,7 @@ static tOptDesc optDesc[GENSHELL_OPTION_CT] = {
 #define zDetail         (genshellopt_opt_strs+1534)
 /** The full version string for genshellopt. */
 #define zFullVersion    (genshellopt_opt_strs+1755)
-/* extracted from optcode.tlib near line 364 */
+/* extracted from optcode.tlib near line 342 */
 
 #if defined(ENABLE_NLS)
 # define OPTPROC_BASE OPTPROC_TRANSLATE
@@ -481,19 +486,19 @@ static void bogus_function(void) {
      extract the correct strings.  These strings are actually referenced
      by a field name in the genshelloptOptions structure noted in the
      comments below.  The literal text is defined in genshellopt_opt_strs.
-   
+
      NOTE: the strings below are segmented with respect to the source string
      genshellopt_opt_strs.  The strings above are handed off for translation
      at run time a paragraph at a time.  Consequently, they are presented here
      for translation a paragraph at a time.
-   
+
      ALSO: often the description for an option will reference another option
      by name.  These are set off with apostrophe quotes (I hope).  Do not
      translate option names.
    */
   /* referenced via genshelloptOptions.pzCopyright */
   puts(_("genshellopt 1\n\
-Copyright (C) 1999-2014 Bruce Korb, all rights reserved.\n\
+Copyright (C) 1999-2018 Bruce Korb, all rights reserved.\n\
 This is free software. It is licensed for use, modification and\n\
 redistribution under the terms of the GNU Lesser General Public License,\n\
 version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>\n"));
@@ -551,234 +556,230 @@ by the newly generated text.  The first '#!' line will be regenerated.\n"));
   /* LIBOPTS-MESSAGES: */
 #line 67 "../autoopts.c"
   puts(_("allocation of %d bytes failed\n"));
-#line 93 "../autoopts.c"
+#line 89 "../autoopts.c"
   puts(_("allocation of %d bytes failed\n"));
-#line 53 "../init.c"
+#line 48 "../init.c"
   puts(_("AutoOpts function called without option descriptor\n"));
-#line 86 "../init.c"
+#line 81 "../init.c"
   puts(_("\tThis exceeds the compiled library version:  "));
-#line 84 "../init.c"
+#line 79 "../init.c"
   puts(_("Automated Options Processing Error!\n"
        "\t%s called AutoOpts function with structure version %d:%d:%d.\n"));
-#line 80 "../autoopts.c"
+#line 78 "../autoopts.c"
   puts(_("realloc of %d bytes at 0x%p failed\n"));
-#line 88 "../init.c"
+#line 83 "../init.c"
   puts(_("\tThis is less than the minimum library version:  "));
 #line 121 "../version.c"
   puts(_("Automated Options version %s\n"
-       "\tCopyright (C) 1999-2014 by Bruce Korb - all rights reserved\n"));
-#line 87 "../makeshell.c"
+       "\tCopyright (C) 1999-2017 by Bruce Korb - all rights reserved\n"));
+#line 49 "../makeshell.c"
   puts(_("(AutoOpts bug):  %s.\n"));
 #line 90 "../reset.c"
   puts(_("optionResetOpt() called, but reset-option not configured"));
-#line 295 "../usage.c"
+#line 241 "../usage.c"
   puts(_("could not locate the 'help' option"));
-#line 336 "../autoopts.c"
+#line 330 "../autoopts.c"
   puts(_("optionProcess() was called with invalid data"));
-#line 751 "../usage.c"
+#line 697 "../usage.c"
   puts(_("invalid argument type specified"));
-#line 598 "../find.c"
+#line 568 "../find.c"
   puts(_("defaulted to option with optional arg"));
 #line 76 "../alias.c"
   puts(_("aliasing option is out of range."));
-#line 235 "../enum.c"
+#line 210 "../enum.c"
   puts(_("%s error:  the keyword '%s' is ambiguous for %s\n"));
-#line 108 "../find.c"
+#line 78 "../find.c"
   puts(_("  The following options match:\n"));
-#line 293 "../find.c"
+#line 263 "../find.c"
   puts(_("%s: ambiguous option name: %s (matches %d options)\n"));
 #line 161 "../check.c"
   puts(_("%s: Command line arguments required\n"));
 #line 43 "../alias.c"
   puts(_("%d %s%s options allowed\n"));
-#line 94 "../makeshell.c"
+#line 56 "../makeshell.c"
   puts(_("%s error %d (%s) calling %s for '%s'\n"));
-#line 306 "../makeshell.c"
+#line 268 "../makeshell.c"
   puts(_("interprocess pipe"));
-#line 168 "../version.c"
+#line 171 "../version.c"
   puts(_("error: version option argument '%c' invalid.  Use:\n"
        "\t'v' - version only\n"
        "\t'c' - version and copyright\n"
        "\t'n' - version and full copyright notice\n"));
 #line 58 "../check.c"
   puts(_("%s error:  the '%s' and '%s' options conflict\n"));
-#line 217 "../find.c"
+#line 187 "../find.c"
   puts(_("%s: The '%s' option has been disabled."));
-#line 430 "../find.c"
+#line 400 "../find.c"
   puts(_("%s: The '%s' option has been disabled."));
 #line 38 "../alias.c"
   puts(_("-equivalence"));
-#line 469 "../find.c"
+#line 439 "../find.c"
   puts(_("%s: illegal option -- %c\n"));
 #line 110 "../reset.c"
   puts(_("%s: illegal option -- %c\n"));
-#line 271 "../find.c"
+#line 241 "../find.c"
   puts(_("%s: illegal option -- %s\n"));
-#line 755 "../find.c"
+#line 740 "../find.c"
   puts(_("%s: illegal option -- %s\n"));
 #line 118 "../reset.c"
   puts(_("%s: illegal option -- %s\n"));
-#line 335 "../find.c"
+#line 305 "../find.c"
   puts(_("%s: unknown vendor extension option -- %s\n"));
-#line 160 "../enum.c"
+#line 135 "../enum.c"
   puts(_("  or an integer from %d through %d\n"));
-#line 170 "../enum.c"
+#line 145 "../enum.c"
   puts(_("  or an integer from %d through %d\n"));
-#line 750 "../usage.c"
+#line 696 "../usage.c"
   puts(_("%s error:  invalid option descriptor for %s\n"));
-#line 1084 "../usage.c"
+#line 1030 "../usage.c"
   puts(_("%s error:  invalid option descriptor for %s\n"));
-#line 385 "../find.c"
+#line 355 "../find.c"
   puts(_("%s: invalid option name: %s\n"));
-#line 527 "../find.c"
+#line 497 "../find.c"
   puts(_("%s: The '%s' option requires an argument.\n"));
-#line 156 "../autoopts.c"
+#line 150 "../autoopts.c"
   puts(_("(AutoOpts bug):  Equivalenced option '%s' was equivalenced to both\n"
        "\t'%s' and '%s'."));
 #line 94 "../check.c"
   puts(_("%s error:  The %s option is required\n"));
-#line 632 "../find.c"
+#line 602 "../find.c"
   puts(_("%s: The '%s' option cannot have an argument.\n"));
 #line 151 "../check.c"
   puts(_("%s: Command line arguments are not allowed.\n"));
-#line 536 "../save.c"
+#line 568 "../save.c"
   puts(_("error %d (%s) creating %s\n"));
-#line 235 "../enum.c"
+#line 210 "../enum.c"
   puts(_("%s error:  '%s' does not match any %s keywords.\n"));
 #line 93 "../reset.c"
   puts(_("%s error: The '%s' option requires an argument.\n"));
-#line 186 "../save.c"
+#line 122 "../save.c"
   puts(_("error %d (%s) stat-ing %s\n"));
-#line 239 "../save.c"
+#line 175 "../save.c"
   puts(_("error %d (%s) stat-ing %s\n"));
 #line 143 "../restore.c"
   puts(_("%s error: no saved option state\n"));
-#line 231 "../autoopts.c"
+#line 225 "../autoopts.c"
   puts(_("'%s' is not a command line option.\n"));
 #line 113 "../time.c"
   puts(_("%s error:  '%s' is not a recognizable date/time.\n"));
-#line 131 "../save.c"
-  puts(_("'%s' not defined\n"));
 #line 50 "../time.c"
   puts(_("%s error:  '%s' is not a recognizable time duration.\n"));
 #line 92 "../check.c"
   puts(_("%s error:  The %s option must appear %d times.\n"));
 #line 165 "../numeric.c"
   puts(_("%s error:  '%s' is not a recognizable number.\n"));
-#line 201 "../enum.c"
+#line 176 "../enum.c"
   puts(_("%s error:  %s exceeds %s keyword count\n"));
-#line 333 "../usage.c"
+#line 279 "../usage.c"
   puts(_("Try '%s %s' for more information.\n"));
 #line 45 "../alias.c"
   puts(_("one %s%s option allowed\n"));
-#line 208 "../makeshell.c"
+#line 170 "../makeshell.c"
   puts(_("standard output"));
-#line 943 "../makeshell.c"
+#line 905 "../makeshell.c"
   puts(_("standard output"));
-#line 277 "../usage.c"
+#line 223 "../usage.c"
   puts(_("standard output"));
-#line 418 "../usage.c"
+#line 364 "../usage.c"
   puts(_("standard output"));
-#line 628 "../usage.c"
+#line 574 "../usage.c"
   puts(_("standard output"));
-#line 175 "../version.c"
+#line 178 "../version.c"
   puts(_("standard output"));
-#line 277 "../usage.c"
+#line 223 "../usage.c"
   puts(_("standard error"));
-#line 418 "../usage.c"
+#line 364 "../usage.c"
   puts(_("standard error"));
-#line 628 "../usage.c"
+#line 574 "../usage.c"
   puts(_("standard error"));
-#line 175 "../version.c"
+#line 178 "../version.c"
   puts(_("standard error"));
-#line 208 "../makeshell.c"
+#line 170 "../makeshell.c"
   puts(_("write"));
-#line 943 "../makeshell.c"
+#line 905 "../makeshell.c"
   puts(_("write"));
-#line 276 "../usage.c"
+#line 222 "../usage.c"
   puts(_("write"));
-#line 417 "../usage.c"
+#line 363 "../usage.c"
   puts(_("write"));
-#line 627 "../usage.c"
+#line 573 "../usage.c"
   puts(_("write"));
-#line 174 "../version.c"
+#line 177 "../version.c"
   puts(_("write"));
 #line 60 "../numeric.c"
   puts(_("%s error:  %s option value %ld is out of range.\n"));
 #line 44 "../check.c"
   puts(_("%s error:  %s option requires the %s option\n"));
-#line 130 "../save.c"
-  puts(_("%s warning:  cannot save options - %s not regular file\n"));
-#line 185 "../save.c"
+#line 121 "../save.c"
   puts(_("%s warning:  cannot save options - %s not regular file\n"));
-#line 238 "../save.c"
+#line 174 "../save.c"
   puts(_("%s warning:  cannot save options - %s not regular file\n"));
-#line 257 "../save.c"
+#line 193 "../save.c"
   puts(_("%s warning:  cannot save options - %s not regular file\n"));
-#line 535 "../save.c"
+#line 567 "../save.c"
   puts(_("%s warning:  cannot save options - %s not regular file\n"));
   /* END-LIBOPTS-MESSAGES */
 
   /* USAGE-TEXT: */
-#line 876 "../usage.c"
+#line 822 "../usage.c"
   puts(_("\t\t\t\t- an alternate for '%s'\n"));
-#line 1151 "../usage.c"
+#line 1097 "../usage.c"
   puts(_("Version, usage and configuration options:"));
-#line 927 "../usage.c"
+#line 873 "../usage.c"
   puts(_("\t\t\t\t- default option for unnamed options\n"));
-#line 840 "../usage.c"
+#line 786 "../usage.c"
   puts(_("\t\t\t\t- disabled as '--%s'\n"));
-#line 1120 "../usage.c"
+#line 1066 "../usage.c"
   puts(_(" --- %-14s %s\n"));
-#line 1118 "../usage.c"
+#line 1064 "../usage.c"
   puts(_("This option has been disabled"));
-#line 867 "../usage.c"
+#line 813 "../usage.c"
   puts(_("\t\t\t\t- enabled by default\n"));
 #line 40 "../alias.c"
   puts(_("%s error:  only "));
-#line 1197 "../usage.c"
+#line 1143 "../usage.c"
   puts(_(" - examining environment variables named %s_*\n"));
 #line 168 "../file.c"
   puts(_("\t\t\t\t- file must not pre-exist\n"));
 #line 172 "../file.c"
   puts(_("\t\t\t\t- file must pre-exist\n"));
-#line 383 "../usage.c"
+#line 329 "../usage.c"
   puts(_("Options are specified by doubled hyphens and their name or by a single\n"
        "hyphen and the flag character.\n"));
-#line 921 "../makeshell.c"
+#line 882 "../makeshell.c"
   puts(_("\n"
        "= = = = = = = =\n\n"
        "This incarnation of genshell will produce\n"
        "a shell script to parse the options for %s:\n\n"));
-#line 167 "../enum.c"
+#line 142 "../enum.c"
   puts(_("  or an integer mask with any of the lower %d bits set\n"));
-#line 900 "../usage.c"
+#line 846 "../usage.c"
   puts(_("\t\t\t\t- is a set membership option\n"));
-#line 921 "../usage.c"
+#line 867 "../usage.c"
   puts(_("\t\t\t\t- must appear between %d and %d times\n"));
-#line 385 "../usage.c"
+#line 331 "../usage.c"
   puts(_("Options are specified by single or double hyphens and their name.\n"));
-#line 907 "../usage.c"
+#line 853 "../usage.c"
   puts(_("\t\t\t\t- may appear multiple times\n"));
-#line 894 "../usage.c"
+#line 840 "../usage.c"
   puts(_("\t\t\t\t- may not be preset\n"));
-#line 1312 "../usage.c"
+#line 1258 "../usage.c"
   puts(_("   Arg Option-Name    Description\n"));
-#line 1248 "../usage.c"
+#line 1194 "../usage.c"
   puts(_("  Flg Arg Option-Name    Description\n"));
-#line 1306 "../usage.c"
+#line 1252 "../usage.c"
   puts(_("  Flg Arg Option-Name    Description\n"));
-#line 1307 "../usage.c"
+#line 1253 "../usage.c"
   puts(_(" %3s %s"));
-#line 1313 "../usage.c"
+#line 1259 "../usage.c"
   puts(_(" %3s %s"));
-#line 390 "../usage.c"
+#line 336 "../usage.c"
   puts(_("The '-#<number>' option may omit the hash char\n"));
-#line 386 "../usage.c"
+#line 332 "../usage.c"
   puts(_("All arguments are named options.\n"));
-#line 974 "../usage.c"
+#line 920 "../usage.c"
   puts(_(" - reading file %s"));
-#line 412 "../usage.c"
+#line 358 "../usage.c"
   puts(_("\n"
        "Please send bug reports to:  <%s>\n"));
 #line 100 "../version.c"
@@ -787,17 +788,17 @@ by the newly generated text.  The first '#!' line will be regenerated.\n"));
 #line 129 "../version.c"
   puts(_("\n"
        "Please send bug reports to:  <%s>\n"));
-#line 906 "../usage.c"
+#line 852 "../usage.c"
   puts(_("\t\t\t\t- may NOT appear - preset only\n"));
-#line 947 "../usage.c"
+#line 893 "../usage.c"
   puts(_("\n"
        "The following option preset mechanisms are supported:\n"));
-#line 1195 "../usage.c"
+#line 1141 "../usage.c"
   puts(_("\n"
        "The following option preset mechanisms are supported:\n"));
-#line 685 "../usage.c"
+#line 631 "../usage.c"
   puts(_("prohibits these options:\n"));
-#line 680 "../usage.c"
+#line 626 "../usage.c"
   puts(_("prohibits the option '%s'\n"));
 #line 81 "../numeric.c"
   puts(_("%s%ld to %ld"));
@@ -815,28 +816,28 @@ by the newly generated text.  The first '#!' line will be regenerated.\n"));
   puts(_("%sis scalable with a suffix: k/K/m/M/g/G/t/T\n"));
 #line 77 "../numeric.c"
   puts(_("%sless than or equal to %ld"));
-#line 393 "../usage.c"
+#line 339 "../usage.c"
   puts(_("Operands and options may be intermixed.  They will be reordered.\n"));
-#line 655 "../usage.c"
+#line 601 "../usage.c"
   puts(_("requires the option '%s'\n"));
-#line 658 "../usage.c"
+#line 604 "../usage.c"
   puts(_("requires these options:\n"));
-#line 1324 "../usage.c"
+#line 1270 "../usage.c"
   puts(_("   Arg Option-Name   Req?  Description\n"));
-#line 1318 "../usage.c"
+#line 1264 "../usage.c"
   puts(_("  Flg Arg Option-Name   Req?  Description\n"));
-#line 168 "../enum.c"
+#line 143 "../enum.c"
   puts(_("or you may use a numeric representation.  Preceding these with a '!'\n"
        "will clear the bits, specifying 'none' will clear all bits, and 'all'\n"
        "will set them all.  Multiple entries may be passed as an option\n"
        "argument list.\n"));
-#line 913 "../usage.c"
+#line 859 "../usage.c"
   puts(_("\t\t\t\t- may appear up to %d times\n"));
-#line 77 "../enum.c"
+#line 52 "../enum.c"
   puts(_("The valid \"%s\" option keywords are:\n"));
-#line 1155 "../usage.c"
+#line 1101 "../usage.c"
   puts(_("The next option supports vendor supported extra options:"));
-#line 776 "../usage.c"
+#line 722 "../usage.c"
   puts(_("These additional options are:"));
   /* END-USAGE-TEXT */
 }

+ 18 - 3
libopts/genshell.h

@@ -6,7 +6,7 @@
  *  From the definitions    genshell.def
  *  and the template file   options
  *
- * Generated from AutoOpts 41:1:16 templates.
+ * Generated from AutoOpts 42:1:17 templates.
  *
  *  AutoOpts is a copyrighted work.  This header file is not encumbered
  *  by AutoOpts licensing, but is provided under the licensing terms chosen
@@ -19,7 +19,7 @@
  * The genshellopt program is copyrighted and licensed
  * under the following terms:
  *
- *  Copyright (C) 1999-2014 Bruce Korb, all rights reserved.
+ *  Copyright (C) 1999-2018 Bruce Korb, all rights reserved.
  *  This is free software. It is licensed for use, modification and
  *  redistribution under the terms of the GNU Lesser General Public License,
  *  version 2 or later <http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html>
@@ -47,6 +47,8 @@
 #ifndef AUTOOPTS_GENSHELL_H_GUARD
 #define AUTOOPTS_GENSHELL_H_GUARD 1
 #include <autoopts/options.h>
+#include <stdarg.h>
+#include <stdnoreturn.h>
 
 /**
  *  Ensure that the library used for compiling this generated header is at
@@ -55,13 +57,19 @@
  *  tolerable version is at least as old as what was current when the header
  *  template was released.
  */
-#define AO_TEMPLATE_VERSION 167937
+#define AO_TEMPLATE_VERSION 172033
 #if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
  || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
 # error option template version mismatches autoopts/options.h header
   Choke Me.
 #endif
 
+#if GCC_VERSION > 40400
+#define NOT_REACHED __builtin_unreachable();
+#else
+#define NOT_REACHED
+#endif
+
 /**
  *  Enumeration of each option type for genshellopt
  */
@@ -150,6 +158,12 @@ typedef enum {
 #ifdef  __cplusplus
 extern "C" {
 #endif
+/*
+ *  global exported definitions
+ */
+#define ch_t  unsigned char
+#define cc_t  const unsigned char
+#define cch_t char const
 
 
 /* * * * * *
@@ -201,6 +215,7 @@ static inline char* aoGetsText(char const* pz) {
 # endif
 #endif  /* ENABLE_NLS */
 
+
 #ifdef  __cplusplus
 }
 #endif

+ 7 - 5
libopts/gettext.h

@@ -1,5 +1,5 @@
 /* Convenience header for conditional use of GNU <libintl.h>.
-   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2016 Free Software
+   Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009-2018 Free Software
    Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -13,13 +13,14 @@
    GNU Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public License along
-   with this program; if not, see <http://www.gnu.org/licenses/>.  */
+   with this program; if not, see <https://www.gnu.org/licenses/>.  */
 
 #ifndef _LIBGETTEXT_H
 #define _LIBGETTEXT_H 1
 
-/* NLS can be disabled through the configure --disable-nls option.  */
-#if ENABLE_NLS
+/* NLS can be disabled through the configure --disable-nls option
+   or through "#define ENABLE NLS 0" before including this file.  */
+#if defined ENABLE_NLS && ENABLE_NLS
 
 /* Get declarations of GNU message catalog functions.  */
 # include <libintl.h>
@@ -184,7 +185,8 @@ npgettext_aux (const char *domain,
 #include <string.h>
 
 #if (((__GNUC__ >= 3 || __GNUG__ >= 2) && !defined __STRICT_ANSI__) \
-     /* || __STDC_VERSION__ >= 199901L */ )
+     /* || __STDC_VERSION__ == 199901L
+        || (__STDC_VERSION__ >= 201112L && !defined __STDC_NO_VLA__) */ )
 # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 1
 #else
 # define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS 0

+ 4 - 9
libopts/init.c

@@ -9,7 +9,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -28,11 +28,6 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-/* = = = START-STATIC-FORWARD = = = */
-static tSuccess
-do_presets(tOptions * opts);
-/* = = = END-STATIC-FORWARD = = = */
-
 /**
  *  Make sure the option descriptor is there and that we understand it.
  *  This should be called from any user entry point where one needs to
@@ -46,7 +41,7 @@ do_presets(tOptions * opts);
  *  @param[in]     pname  name of program, from argv[]
  *  @returns SUCCESS or FAILURE
  */
-LOCAL tSuccess
+static tSuccess
 validate_struct(tOptions * opts, char const * pname)
 {
     if (opts == NULL) {
@@ -142,7 +137,7 @@ validate_struct(tOptions * opts, char const * pname)
  *  @param pOpts   program options descriptor
  *  @returns SUCCESS or FAILURE
  */
-LOCAL tSuccess
+static tSuccess
 immediate_opts(tOptions * opts)
 {
     tSuccess  res;
@@ -247,7 +242,7 @@ do_presets(tOptions * opts)
  * @param[in]     a_ct  program argument count
  * @param[in]     a_v   program argument vector
  */
-LOCAL bool
+static bool
 ao_initialize(tOptions * opts, int a_ct, char ** a_v)
 {
     if ((opts->fOptSet & OPTPROC_INITDONE) != 0)

+ 95 - 52
libopts/intprops.h

@@ -1,6 +1,6 @@
 /* intprops.h -- properties of integer types
 
-   Copyright (C) 2001-2016 Free Software Foundation, Inc.
+   Copyright (C) 2001-2018 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published
@@ -13,7 +13,7 @@
    GNU Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 /* Written by Paul Eggert.  */
 
@@ -26,7 +26,7 @@
 #define _GL_INT_CONVERT(e, v) (0 * (e) + (v))
 
 /* Act like _GL_INT_CONVERT (E, -V) but work around a bug in IRIX 6.5 cc; see
-   <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00406.html>.  */
+   <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00406.html>.  */
 #define _GL_INT_NEGATE_CONVERT(e, v) (0 * (e) - (v))
 
 /* The extra casts in the following macros work around compiler bugs,
@@ -46,12 +46,16 @@
 
 /* Minimum and maximum values for integer types and expressions.  */
 
+/* The width in bits of the integer type or expression T.
+   Padding bits are not supported; this is checked at compile-time below.  */
+#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
+
 /* The maximum and minimum values for the integer type T.  */
 #define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
 #define TYPE_MAXIMUM(t)                                                 \
   ((t) (! TYPE_SIGNED (t)                                               \
         ? (t) -1                                                        \
-        : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
+        : ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1)))
 
 /* The maximum and minimum values for the type of the expression E,
    after integer promotion.  E should not have side effects.  */
@@ -64,12 +68,23 @@
    ? _GL_SIGNED_INT_MAXIMUM (e)                                         \
    : _GL_INT_NEGATE_CONVERT (e, 1))
 #define _GL_SIGNED_INT_MAXIMUM(e)                                       \
-  (((_GL_INT_CONVERT (e, 1) << (sizeof ((e) + 0) * CHAR_BIT - 2)) - 1) * 2 + 1)
+  (((_GL_INT_CONVERT (e, 1) << (TYPE_WIDTH ((e) + 0) - 2)) - 1) * 2 + 1)
+
+/* Work around OpenVMS incompatibility with C99.  */
+#if !defined LLONG_MAX && defined __INT64_MAX
+# define LLONG_MAX __INT64_MAX
+# define LLONG_MIN __INT64_MIN
+#endif
 
+/* This include file assumes that signed types are two's complement without
+   padding bits; the above macros have undefined behavior otherwise.
+   If this is a problem for you, please let us know how to fix it for your host.
+   This assumption is tested by the intprops-tests module.  */
 
 /* Does the __typeof__ keyword work?  This could be done by
    'configure', but for now it's easier to do it by hand.  */
-#if (2 <= __GNUC__ || defined __IBM__TYPEOF__ \
+#if (2 <= __GNUC__ \
+     || (1210 <= __IBMC__ && defined __IBM__TYPEOF__) \
      || (0x5110 <= __SUNPRO_C && !__STDC__))
 # define _GL_HAVE___TYPEOF__ 1
 #else
@@ -98,8 +113,7 @@
    signed, this macro may overestimate the true bound by one byte when
    applied to unsigned types of size 2, 4, 16, ... bytes.  */
 #define INT_STRLEN_BOUND(t)                                     \
-  (INT_BITS_STRLEN_BOUND (sizeof (t) * CHAR_BIT                 \
-                          - _GL_SIGNED_TYPE_OR_EXPR (t))        \
+  (INT_BITS_STRLEN_BOUND (TYPE_WIDTH (t) - _GL_SIGNED_TYPE_OR_EXPR (t)) \
    + _GL_SIGNED_TYPE_OR_EXPR (t))
 
 /* Bound on buffer size needed to represent an integer type or expression T,
@@ -165,7 +179,7 @@
 /* Return 1 if A * B would overflow in [MIN,MAX] arithmetic.
    See above for restrictions.  Avoid && and || as they tickle
    bugs in Sun C 5.11 2010/08/13 and other compilers; see
-   <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00401.html>.  */
+   <https://lists.gnu.org/r/bug-gnulib/2011-05/msg00401.html>.  */
 #define INT_MULTIPLY_RANGE_OVERFLOW(a, b, min, max)     \
   ((b) < 0                                              \
    ? ((a) < 0                                           \
@@ -204,24 +218,42 @@
    ? (a) < (min) >> (b)                                 \
    : (max) >> (b) < (a))
 
+/* True if __builtin_add_overflow (A, B, P) works when P is non-null.  */
+#if 5 <= __GNUC__ && !defined __ICC
+# define _GL_HAS_BUILTIN_OVERFLOW 1
+#else
+# define _GL_HAS_BUILTIN_OVERFLOW 0
+#endif
+
+/* True if __builtin_add_overflow_p (A, B, C) works.  */
+#define _GL_HAS_BUILTIN_OVERFLOW_P (7 <= __GNUC__)
 
 /* The _GL*_OVERFLOW macros have the same restrictions as the
    *_RANGE_OVERFLOW macros, except that they do not assume that operands
    (e.g., A and B) have the same type as MIN and MAX.  Instead, they assume
    that the result (e.g., A + B) has that type.  */
-#define _GL_ADD_OVERFLOW(a, b, min, max)                                \
-  ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max)                  \
-   : (a) < 0 ? (b) <= (a) + (b)                                         \
-   : (b) < 0 ? (a) <= (a) + (b)                                         \
-   : (a) + (b) < (b))
-#define _GL_SUBTRACT_OVERFLOW(a, b, min, max)                           \
-  ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max)             \
-   : (a) < 0 ? 1                                                        \
-   : (b) < 0 ? (a) - (b) <= (a)                                         \
-   : (a) < (b))
-#define _GL_MULTIPLY_OVERFLOW(a, b, min, max)                           \
-  (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a))))       \
-   || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#if _GL_HAS_BUILTIN_OVERFLOW_P
+# define _GL_ADD_OVERFLOW(a, b, min, max)                               \
+   __builtin_add_overflow_p (a, b, (__typeof__ ((a) + (b))) 0)
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max)                          \
+   __builtin_sub_overflow_p (a, b, (__typeof__ ((a) - (b))) 0)
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max)                          \
+   __builtin_mul_overflow_p (a, b, (__typeof__ ((a) * (b))) 0)
+#else
+# define _GL_ADD_OVERFLOW(a, b, min, max)                                \
+   ((min) < 0 ? INT_ADD_RANGE_OVERFLOW (a, b, min, max)                  \
+    : (a) < 0 ? (b) <= (a) + (b)                                         \
+    : (b) < 0 ? (a) <= (a) + (b)                                         \
+    : (a) + (b) < (b))
+# define _GL_SUBTRACT_OVERFLOW(a, b, min, max)                           \
+   ((min) < 0 ? INT_SUBTRACT_RANGE_OVERFLOW (a, b, min, max)             \
+    : (a) < 0 ? 1                                                        \
+    : (b) < 0 ? (a) - (b) <= (a)                                         \
+    : (a) < (b))
+# define _GL_MULTIPLY_OVERFLOW(a, b, min, max)                           \
+   (((min) == 0 && (((a) < 0 && 0 < (b)) || ((b) < 0 && 0 < (a))))       \
+    || INT_MULTIPLY_RANGE_OVERFLOW (a, b, min, max))
+#endif
 #define _GL_DIVIDE_OVERFLOW(a, b, min, max)                             \
   ((min) < 0 ? (b) == _GL_INT_NEGATE_CONVERT (min, 1) && (a) < - (max)  \
    : (a) < 0 ? (b) <= (a) + (b) - 1                                     \
@@ -286,8 +318,12 @@
   _GL_BINARY_OP_OVERFLOW (a, b, _GL_ADD_OVERFLOW)
 #define INT_SUBTRACT_OVERFLOW(a, b) \
   _GL_BINARY_OP_OVERFLOW (a, b, _GL_SUBTRACT_OVERFLOW)
-#define INT_NEGATE_OVERFLOW(a) \
-  INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#if _GL_HAS_BUILTIN_OVERFLOW_P
+# define INT_NEGATE_OVERFLOW(a) INT_SUBTRACT_OVERFLOW (0, a)
+#else
+# define INT_NEGATE_OVERFLOW(a) \
+   INT_NEGATE_RANGE_OVERFLOW (a, _GL_INT_MINIMUM (a), _GL_INT_MAXIMUM (a))
+#endif
 #define INT_MULTIPLY_OVERFLOW(a, b) \
   _GL_BINARY_OP_OVERFLOW (a, b, _GL_MULTIPLY_OVERFLOW)
 #define INT_DIVIDE_OVERFLOW(a, b) \
@@ -307,7 +343,7 @@
                       _GL_INT_MINIMUM (0 * (b) + (a)),          \
                       _GL_INT_MAXIMUM (0 * (b) + (a)))
 
-/* Compute A + B, A - B, A * B, respectively, storing the result into *R.
+/* Store the low-order bits of A + B, A - B, A * B, respectively, into *R.
    Return 1 if the result overflows.  See above for restrictions.  */
 #define INT_ADD_WRAPV(a, b, r) \
   _GL_INT_OP_WRAPV (a, b, r, +, __builtin_add_overflow, INT_ADD_OVERFLOW)
@@ -316,10 +352,6 @@
 #define INT_MULTIPLY_WRAPV(a, b, r) \
   _GL_INT_OP_WRAPV (a, b, r, *, __builtin_mul_overflow, INT_MULTIPLY_OVERFLOW)
 
-#ifndef __has_builtin
-# define __has_builtin(x) 0
-#endif
-
 /* Nonzero if this compiler has GCC bug 68193 or Clang bug 25390.  See:
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68193
    https://llvm.org/bugs/show_bug.cgi?id=25390
@@ -332,20 +364,21 @@
 # define _GL__GENERIC_BOGUS 0
 #endif
 
-/* Store A <op> B into *R, where OP specifies the operation.
-   BUILTIN is the builtin operation, and OVERFLOW the overflow predicate.
-   See above for restrictions.  */
-#if 5 <= __GNUC__ || __has_builtin (__builtin_add_overflow)
+/* Store the low-order bits of A <op> B into *R, where OP specifies
+   the operation.  BUILTIN is the builtin operation, and OVERFLOW the
+   overflow predicate.  Return 1 if the result overflows.  See above
+   for restrictions.  */
+#if _GL_HAS_BUILTIN_OVERFLOW
 # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) builtin (a, b, r)
 #elif 201112 <= __STDC_VERSION__ && !_GL__GENERIC_BOGUS
 # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
    (_Generic \
     (*(r), \
      signed char: \
-       _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
+       _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
                         signed char, SCHAR_MIN, SCHAR_MAX), \
      short int: \
-       _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
+       _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
                         short int, SHRT_MIN, SHRT_MAX), \
      int: \
        _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
@@ -359,10 +392,10 @@
 #else
 # define _GL_INT_OP_WRAPV(a, b, r, op, builtin, overflow) \
    (sizeof *(r) == sizeof (signed char) \
-    ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned char, \
+    ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
                        signed char, SCHAR_MIN, SCHAR_MAX) \
     : sizeof *(r) == sizeof (short int) \
-    ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned short int, \
+    ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
                        short int, SHRT_MIN, SHRT_MAX) \
     : sizeof *(r) == sizeof (int) \
     ? _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned int, \
@@ -378,14 +411,14 @@
 # else
 #  define _GL_INT_OP_WRAPV_LONGISH(a, b, r, op, overflow) \
     _GL_INT_OP_CALC (a, b, r, op, overflow, unsigned long int, \
-                     long int, LONG_MIN, LONG_MAX))
+                     long int, LONG_MIN, LONG_MAX)
 # endif
 #endif
 
 /* Store the low-order bits of A <op> B into *R, where the operation
    is given by OP.  Use the unsigned type UT for calculation to avoid
-   overflow problems.  *R's type is T, with extremal values TMIN and
-   TMAX.  T must be a signed integer type.  */
+   overflow problems.  *R's type is T, with extrema TMIN and TMAX.
+   T must be a signed integer type.  Return 1 if the result overflows.  */
 #define _GL_INT_OP_CALC(a, b, r, op, overflow, ut, t, tmin, tmax) \
   (sizeof ((a) op (b)) < sizeof (t) \
    ? _GL_INT_OP_CALC1 ((t) (a), (t) (b), r, op, overflow, ut, t, tmin, tmax) \
@@ -394,17 +427,27 @@
   ((overflow (a, b) \
     || (EXPR_SIGNED ((a) op (b)) && ((a) op (b)) < (tmin)) \
     || (tmax) < ((a) op (b))) \
-   ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 1) \
-   : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t, tmin, tmax), 0))
-
-/* Return A <op> B, where the operation is given by OP.  Use the
-   unsigned type UT for calculation to avoid overflow problems.
-   Convert the result to type T without overflow by subtracting TMIN
-   from large values before converting, and adding it afterwards.
-   Compilers can optimize all the operations except OP.  */
-#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t, tmin, tmax) \
-  (((ut) (a) op (ut) (b)) <= (tmax) \
-   ? (t) ((ut) (a) op (ut) (b)) \
-   : ((t) (((ut) (a) op (ut) (b)) - (tmin)) + (tmin)))
+   ? (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 1) \
+   : (*(r) = _GL_INT_OP_WRAPV_VIA_UNSIGNED (a, b, op, ut, t), 0))
+
+/* Return the low-order bits of A <op> B, where the operation is given
+   by OP.  Use the unsigned type UT for calculation to avoid undefined
+   behavior on signed integer overflow, and convert the result to type T.
+   UT is at least as wide as T and is no narrower than unsigned int,
+   T is two's complement, and there is no padding or trap representations.
+   Assume that converting UT to T yields the low-order bits, as is
+   done in all known two's-complement C compilers.  E.g., see:
+   https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html
+
+   According to the C standard, converting UT to T yields an
+   implementation-defined result or signal for values outside T's
+   range.  However, code that works around this theoretical problem
+   runs afoul of a compiler bug in Oracle Studio 12.3 x86.  See:
+   https://lists.gnu.org/r/bug-gnulib/2017-04/msg00049.html
+   As the compiler bug is real, don't try to work around the
+   theoretical problem.  */
+
+#define _GL_INT_OP_WRAPV_VIA_UNSIGNED(a, b, op, ut, t) \
+  ((t) ((ut) (a) op (ut) (b)))
 
 #endif /* _GL_INTPROPS_H */

+ 4 - 2
libopts/libopts.c

@@ -1,9 +1,9 @@
 #define  AUTOOPTS_INTERNAL 1
 #include "autoopts/project.h"
-#define  LOCAL static
+
 #include "ao-strs.h"
 static char const ao_ver_string[] =
-    "41:1:16\n";
+    "42:1:17\n";
 #include "autoopts/options.h"
 #include "autoopts/usage-txt.h"
 #include "genshell.h"
@@ -11,12 +11,14 @@ static char const ao_ver_string[] =
 #include "option-value-type.h"
 #include "ao-strs.h"
 #include "ag-char-map.h"
+#include "save-flags.h"
 #include "autoopts.h"
 #include "proto.h"
 #include "parse-duration.c"
 #include "ao-strs.c"
 #include "option-value-type.c"
 #include "option-xat-attribute.c"
+#include "save-flags.c"
 #include "autoopts.c"
 #include "alias.c"
 #include "boolean.c"

+ 5 - 25
libopts/load.c

@@ -12,7 +12,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -31,26 +31,6 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-/* = = = START-STATIC-FORWARD = = = */
-static bool
-get_realpath(char * buf, size_t b_sz);
-
-static bool
-add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path);
-
-static bool
-add_env_val(char * buf, int buf_sz, char const * name);
-
-static char *
-assemble_arg_val(char * txt, tOptionLoadMode mode);
-
-static char *
-trim_quotes(char * arg);
-
-static bool
-direction_ok(opt_state_mask_t f, int dir);
-/* = = = END-STATIC-FORWARD = = = */
-
 static bool
 get_realpath(char * buf, size_t b_sz)
 {
@@ -314,7 +294,7 @@ add_env_val(char * buf, int buf_sz, char const * name)
  * @param[in,out] txt  the input and output string
  * @param[in]     mode the handling mode (cooking method)
  */
-LOCAL void
+static void
 munge_str(char * txt, tOptionLoadMode mode)
 {
     char * end;
@@ -445,7 +425,7 @@ direction_ok(opt_state_mask_t f, int dir)
         if (PRESETTING(dir)) {
             /*
              *  We are in the presetting direction with an option we handle
-             *  immediately for disablement, but normally for disablement.
+             *  immediately for disablement, but normally for handling.
              *  Therefore, skip if NOT disabled.
              */
             if ((f & OPTST_DISABLED) != 0)
@@ -453,7 +433,7 @@ direction_ok(opt_state_mask_t f, int dir)
         } else {
             /*
              *  We are in the processing direction with an option we handle
-             *  immediately for disablement, but normally for disablement.
+             *  immediately for disablement, but normally for handling.
              *  Therefore, skip if disabled.
              */
             if ((f & OPTST_DISABLED) == 0)
@@ -486,7 +466,7 @@ direction_ok(opt_state_mask_t f, int dir)
  * @param[in]     direction  current processing direction (preset or not)
  * @param[in]     load_mode  option loading mode (OPTION_LOAD_*)
  */
-LOCAL void
+static void
 load_opt_line(tOptions * opts, tOptState * opt_state, char * line,
               tDirection direction, tOptionLoadMode load_mode )
 {

+ 17 - 19
libopts/m4/libopts.m4

@@ -1,14 +1,8 @@
-dnl  -*- buffer-read-only: t -*- vi: set ro:
-dnl
-dnl DO NOT EDIT THIS FILE   (libopts.m4)
-dnl
-dnl It has been AutoGen-ed
-dnl From the definitions    libopts.def
-dnl and the template file   conftest.tpl
-dnl
+
 dnl do always before generated macros:
 dnl
 AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
+  AC_REQUIRE([AC_HEADER_STDC])
   AC_HEADER_DIRENT
 
   # =================
@@ -113,6 +107,7 @@ AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
   AC_PROG_SED
   [while :
   do
+      test -x "$POSIX_SHELL" && break
       POSIX_SHELL=`which bash`
       test -x "$POSIX_SHELL" && break
       POSIX_SHELL=`which dash`
@@ -234,9 +229,9 @@ int main() {
     fputs( "error: regex -->.<-- did not match\n", stderr );
     return 1;
   }
-  return 0; }])],
+  return 0; }] )],
     [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
-    [libopts_cv_with_libregex=no]) # end of AC_RUN_IFELSE 
+    [libopts_cv_with_libregex=no]) # end of AC_RUN_IFELSE
   ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
   fi ## disabled by request
   AC_MSG_RESULT([${libopts_cv_with_libregex}])
@@ -264,7 +259,7 @@ AC_DEFUN([LIBOPTS_RUN_PATHFIND],[
 int main (int argc, char ** argv) {
    char * pz = pathfind( getenv( "PATH" ), "sh", "x" );
    return (pz == 0) ? 1 : 0;
-}])],
+}] )],
     [libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
   ) # end of RUN_IFELSE
   ]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
@@ -312,7 +307,7 @@ choke me!!
 @%:@endif
    char *pz = realpath(argv@<:@0@:>@, zPath);
    return (pz == zPath) ? 0 : 1;
-}])],
+}] )],
     [libopts_cv_run_realpath=yes],[libopts_cv_run_realpath=no],[libopts_cv_run_realpath=no]
   ) # end of RUN_IFELSE
   ]) # end of AC_CACHE_VAL for libopts_cv_run_realpath
@@ -345,7 +340,7 @@ int main() {
   tm.tm_yday  = 239; /* days since January 1 @<:@0, 365@:>@ */
   tm.tm_isdst =  1;  /* flag for daylight savings time */
   strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
-  return (strcmp( t_buf, z ) != 0); }])],
+  return (strcmp( t_buf, z ) != 0); }] )],
     [libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
   ) # end of RUN_IFELSE
   ]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
@@ -365,7 +360,7 @@ AC_DEFUN([LIBOPTS_RUN_FOPEN_BINARY],[
   AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
 int main (int argc, char ** argv) {
 FILE * fp = fopen("conftest.@S|@ac_ext", "rb");
-return (fp == NULL) ? 1 : fclose(fp); }])],
+return (fp == NULL) ? 1 : fclose(fp); }] )],
     [libopts_cv_run_fopen_binary=yes],[libopts_cv_run_fopen_binary=no],[libopts_cv_run_fopen_binary=no]
   ) # end of RUN_IFELSE
   ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
@@ -388,7 +383,7 @@ AC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
   AC_RUN_IFELSE([AC_LANG_SOURCE([@%:@include <stdio.h>
 int main (int argc, char ** argv) {
 FILE * fp = fopen("conftest.@S|@ac_ext", "rt");
-return (fp == NULL) ? 1 : fclose(fp); }])],
+return (fp == NULL) ? 1 : fclose(fp); }] )],
     [libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
   ) # end of RUN_IFELSE
   ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
@@ -460,7 +455,7 @@ dnl the config tests that the library needs.  Invoke the
 dnl "INVOKE_LIBOPTS_MACROS" macro iff we are building libopts.
 dnl
 dnl  This file is part of AutoGen.
-dnl  AutoGen Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+dnl  AutoGen Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
 dnl
 dnl  AutoGen is free software: you can redistribute it and/or modify it
 dnl  under the terms of the GNU General Public License as published by the
@@ -483,7 +478,8 @@ AC_DEFUN([LIBOPTS_CHECK_COMMON],[
   m4_pushdef([AO_Libopts_Dir],
 	    [ifelse($1, , [libopts], [$1])])
   AC_ARG_ENABLE([local-libopts],
-    AS_HELP_STRING([--enable-local-libopts],[Use the supplied libopts tearoff code]),[
+    AS_HELP_STRING([--enable-local-libopts],
+       [Use the supplied libopts tearoff code]),[
     if test x$enableval = xyes ; then
        AC_MSG_NOTICE([Using supplied libopts tearoff])
        LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir'
@@ -492,13 +488,15 @@ AC_DEFUN([LIBOPTS_CHECK_COMMON],[
     fi])
 
   AC_ARG_ENABLE([libopts-install],
-    AS_HELP_STRING([--enable-libopts-install],[Install libopts with client installation]))
+    AS_HELP_STRING([--enable-libopts-install],
+       [Install libopts with client installation]))
   AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" = Xyes])
 
   [if test -z "${NEED_LIBOPTS_DIR}" ; then]
      AC_MSG_CHECKING([whether autoopts-config can be found])
      AC_ARG_WITH([autoopts-config],
-        AS_HELP_STRING([--with-autoopts-config],[specify the config-info script]),
+        AS_HELP_STRING([--with-autoopts-config],
+             [specify the config-info script]),
         [lo_cv_with_autoopts_config=${with_autoopts_config}],
         AC_CACHE_CHECK([whether autoopts-config is specified],
              [lo_cv_with_autoopts_config],

+ 1 - 1
libopts/m4/liboptschk.m4

@@ -1,5 +1,5 @@
 # liboptschk.m4 serial 2 (autogen - 5.11.4)
-dnl Copyright (C) 2005-2015 by Bruce Korb - all rights reserved
+dnl Copyright (C) 2005-2018 by Bruce Korb - all rights reserved
 dnl
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,

+ 38 - 28
libopts/m4/stdnoreturn.m4

@@ -1,6 +1,6 @@
 # Check for stdnoreturn.h that conforms to C11.
 
-dnl Copyright 2012-2016 Free Software Foundation, Inc.
+dnl Copyright 2012-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -9,33 +9,43 @@ dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_STDNORETURN_H],
 [
-  AC_CACHE_CHECK([for working stdnoreturn.h],
-    [gl_cv_header_working_stdnoreturn_h],
-    [AC_COMPILE_IFELSE(
-       [AC_LANG_PROGRAM(
-          [[#include <stdlib.h>
-            #include <stdnoreturn.h>
-            /* Do not check for 'noreturn' after the return type.
-               C11 allows it, but it's rarely done that way
-               and circa-2012 bleeding-edge GCC rejects it when given
-               -Werror=old-style-declaration.  */
-            noreturn void foo1 (void) { exit (0); }
-            _Noreturn void foo2 (void) { exit (0); }
-            int testit (int argc, char **argv) {
-              if (argc & 1)
-                return 0;
-              (argv[0][0] ? foo1 : foo2) ();
-            }
-          ]])],
-       [gl_cv_header_working_stdnoreturn_h=yes],
-       [gl_cv_header_working_stdnoreturn_h=no])])
-
-  if test $gl_cv_header_working_stdnoreturn_h = yes; then
-    STDNORETURN_H=''
-  else
-    STDNORETURN_H='stdnoreturn.h'
-  fi
-
+  AC_REQUIRE([AC_CANONICAL_HOST])
+  case "$host_os" in
+    cygwin*)
+      dnl Regardless whether a working <stdnoreturn.h> exists or not,
+      dnl we need our own <stdnoreturn.h>, because of the definition
+      dnl of _Noreturn done by gnulib-common.m4.
+      STDNORETURN_H='stdnoreturn.h'
+      ;;
+    *)
+      AC_CACHE_CHECK([for working stdnoreturn.h],
+        [gl_cv_header_working_stdnoreturn_h],
+        [AC_COMPILE_IFELSE(
+           [AC_LANG_PROGRAM(
+              [[#include <stdlib.h>
+                #include <stdnoreturn.h>
+                /* Do not check for 'noreturn' after the return type.
+                   C11 allows it, but it's rarely done that way
+                   and circa-2012 bleeding-edge GCC rejects it when given
+                   -Werror=old-style-declaration.  */
+                noreturn void foo1 (void) { exit (0); }
+                _Noreturn void foo2 (void) { exit (0); }
+                int testit (int argc, char **argv)
+                {
+                  if (argc & 1)
+                    return 0;
+                  (argv[0][0] ? foo1 : foo2) ();
+                }
+              ]])],
+           [gl_cv_header_working_stdnoreturn_h=yes],
+           [gl_cv_header_working_stdnoreturn_h=no])])
+      if test $gl_cv_header_working_stdnoreturn_h = yes; then
+        STDNORETURN_H=''
+      else
+        STDNORETURN_H='stdnoreturn.h'
+      fi
+      ;;
+  esac
   AC_SUBST([STDNORETURN_H])
   AM_CONDITIONAL([GL_GENERATE_STDNORETURN_H], [test -n "$STDNORETURN_H"])
 ])

+ 15 - 54
libopts/makeshell.c

@@ -11,7 +11,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -35,45 +35,7 @@
 #define UPPER(_c) (toupper(to_uchar(_c)))
 #define LOWER(_c) (tolower(to_uchar(_c)))
 
-/* = = = START-STATIC-FORWARD = = = */
-static void
-emit_var_text(char const * prog, char const * var, int fdin);
-
-static void
-text_to_var(tOptions * opts, teTextTo which, tOptDesc * od);
-
-static void
-emit_usage(tOptions * opts);
-
-static void
-emit_wrapup(tOptions * opts);
-
-static void
-emit_setup(tOptions * opts);
-
-static void
-emit_action(tOptions * opts, tOptDesc * od);
-
-static void
-emit_inaction(tOptions * opts, tOptDesc * od);
-
-static void
-emit_flag(tOptions * opts);
-
-static void
-emit_match_expr(char const * name, tOptDesc * cod, tOptions * opts);
-
-static void
-emit_long(tOptions * opts);
-
-static char *
-load_old_output(char const * fname, char const * pname);
-
-static void
-open_out(char const * fname, char const * pname);
-/* = = = END-STATIC-FORWARD = = = */
-
-LOCAL noreturn void
+noreturn static void
 option_exits(int exit_code)
 {
     if (print_exit)
@@ -81,21 +43,21 @@ option_exits(int exit_code)
     exit(exit_code);
 }
 
-LOCAL noreturn void
+noreturn static void
 ao_bug(char const * msg)
 {
     fprintf(stderr, zao_bug_msg, msg);
     option_exits(EX_SOFTWARE);
 }
 
-LOCAL void
+static void
 fserr_warn(char const * prog, char const * op, char const * fname)
 {
     fprintf(stderr, zfserr_fmt, prog, errno, strerror(errno),
             op, fname);
 }
 
-LOCAL noreturn void
+noreturn static void
 fserr_exit(char const * prog, char const * op, char const * fname)
 {
     fserr_warn(prog, op, fname);
@@ -322,11 +284,11 @@ text_to_var(tOptions * opts, teTextTo which, tOptDesc * od)
         switch (which) {
         case TT_LONGUSAGE:
             (*(opts->pUsageProc))(opts, EXIT_SUCCESS);
-            /* fall through */
+            /* FALLTHROUGH */ /* NOTREACHED */
 
         case TT_USAGE:
             (*(opts->pUsageProc))(opts, EXIT_FAILURE);
-            /* fall through */
+            /* FALLTHROUGH */ /* NOTREACHED */
 
         case TT_VERSION:
             if (od->fOptState & OPTST_ALLOC_ARG) {
@@ -335,13 +297,13 @@ text_to_var(tOptions * opts, teTextTo which, tOptDesc * od)
             }
             od->optArg.argString = "c";
             optionPrintVersion(opts, od);
-            /* fall through */
+            /* FALLTHROUGH */ /* NOTREACHED */
 
         default:
             option_exits(EXIT_FAILURE);
-            /* fall through */
+            /* FALLTHROUGH */ /* NOTREACHED */
         }
-        /* fall through */
+        /* FALLTHROUGH */ /* NOTREACHED */
 
     default:
         close(fdpair[1]);
@@ -885,14 +847,12 @@ genshelloptUsage(tOptions * opts, int exit_cd)
     switch (fork()) {
     case -1:
         optionUsage(opts, EXIT_FAILURE);
-        /* fall through */
+        /* FALLTHROUGH */ /* NOTREACHED */
 
     case 0:
         pagerState = PAGER_STATE_CHILD;
         optionUsage(opts, EXIT_SUCCESS);
-        /* NOTREACHED */
-        _exit(EXIT_FAILURE);
-        /* fall through */
+        /* FALLTHROUGH */ /* NOTREACHED */
 
     default:
     {
@@ -928,10 +888,11 @@ genshelloptUsage(tOptions * opts, int exit_cd)
     switch (fork()) {
     case 0:
         pagerState = PAGER_STATE_CHILD;
-        /* fall through */
+        /*FALLTHROUGH*/
     case -1:
         optionUsage(optionParseShellOptions, EXIT_FAILURE);
-        /* fall through */
+        /* FALLTHROUGH */ /* NOTREACHED */
+
     default:
     {
         int  sts;

+ 6 - 48
libopts/nested.c

@@ -12,7 +12,7 @@
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -37,7 +37,7 @@ typedef struct {
     char    xml_txt[8];
 } xml_xlate_t;
 
-static xml_xlate_t const xml_xlate[] = {
+  static xml_xlate_t const xml_xlate[] = {
     { '&', 4, "amp;"  },
     { '<', 3, "lt;"   },
     { '>', 3, "gt;"   },
@@ -49,48 +49,6 @@ static xml_xlate_t const xml_xlate[] = {
 #define ENOMSG ENOENT
 #endif
 
-/* = = = START-STATIC-FORWARD = = = */
-static void
-remove_continuation(char * src);
-
-static char const *
-scan_q_str(char const * pzTxt);
-
-static tOptionValue *
-add_string(void ** pp, char const * name, size_t nm_len,
-           char const * val, size_t d_len);
-
-static tOptionValue *
-add_bool(void ** pp, char const * name, size_t nm_len,
-         char const * val, size_t d_len);
-
-static tOptionValue *
-add_number(void ** pp, char const * name, size_t nm_len,
-           char const * val, size_t d_len);
-
-static tOptionValue *
-add_nested(void ** pp, char const * name, size_t nm_len,
-           char * val, size_t d_len);
-
-static char const *
-scan_name(char const * name, tOptionValue * res);
-
-static char const *
-unnamed_xml(char const * txt);
-
-static char const *
-scan_xml_name(char const * name, size_t * nm_len, tOptionValue * val);
-
-static char const *
-find_end_xml(char const * src, size_t nm_len, char const * val, size_t * len);
-
-static char const *
-scan_xml(char const * xml_name, tOptionValue * res_val);
-
-static void
-sort_list(tArgList * arg_list);
-/* = = = END-STATIC-FORWARD = = = */
-
 /**
  *  Backslashes are used for line continuations.  We keep the newline
  *  characters, but trim out the backslash:
@@ -638,7 +596,7 @@ bail_scan_xml:
  *  an internal call, so it is not validated.  The caller is responsible for
  *  knowing what they are doing.
  */
-LOCAL void
+static void
 unload_arg_list(tArgList * arg_list)
 {
     int ct = arg_list->useCt;
@@ -743,7 +701,7 @@ sort_list(tArgList * arg_list)
  *  @code{ENOMSG} no configuration values were found
  *  @end itemize
 =*/
-LOCAL tOptionValue *
+static tOptionValue *
 optionLoadNested(char const * text, char const * name, size_t nm_len)
 {
     tOptionValue * res_val;
@@ -866,7 +824,7 @@ optionNestedVal(tOptions * opts, tOptDesc * od)
 /**
  * get_special_char
  */
-LOCAL int
+static int
 get_special_char(char const ** ppz, int * ct)
 {
     char const * pz = *ppz;
@@ -918,7 +876,7 @@ get_special_char(char const ** ppz, int * ct)
 /**
  * emit_special_char
  */
-LOCAL void
+static void
 emit_special_char(FILE * fp, int ch)
 {
     int ctr = sizeof(xml_xlate) / sizeof(xml_xlate[0]);

+ 7 - 13
libopts/numeric.c

@@ -10,7 +10,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -136,20 +136,14 @@ optionNumericVal(tOptions * opts, tOptDesc * od)
     if ((od->fOptState & OPTST_SCALED_NUM) != 0)
         switch (*(pz++)) {
         case NUL:  pz--; break;
-        case 't':  val *= 1000;
-        /* fall through */
-        case 'g':  val *= 1000;
-        /* fall through */
-        case 'm':  val *= 1000;
-        /* fall through */
+        case 't':  val *= 1000; /* FALLTHROUGH */
+        case 'g':  val *= 1000; /* FALLTHROUGH */
+        case 'm':  val *= 1000; /* FALLTHROUGH */
         case 'k':  val *= 1000; break;
 
-        case 'T':  val *= 1024;
-        /* fall through */
-        case 'G':  val *= 1024;
-        /* fall through */
-        case 'M':  val *= 1024;
-        /* fall through */
+        case 'T':  val *= 1024; /* FALLTHROUGH */
+        case 'G':  val *= 1024; /* FALLTHROUGH */
+        case 'M':  val *= 1024; /* FALLTHROUGH */
         case 'K':  val *= 1024; break;
 
         default:   goto bad_number;

+ 5 - 5
libopts/option-value-type.c

@@ -31,7 +31,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "option-value-type.h"
-/* ANSI-C code produced by gperf version 3.0.4 */
+/* ANSI-C code produced by gperf version 3.1 */
 /* Command-line: gperf option-value-type.gp  */
 /* Computed positions: -k'1' */
 
@@ -64,7 +64,7 @@ typedef struct {
 /* maximum key range = 15, duplicates = 0 */
 
 static unsigned int
-option_value_type_hash (register const char *str, register unsigned int len)
+option_value_type_hash (register const char *str, register size_t len)
 {
   static const unsigned char asso_values[] =
     {
@@ -119,13 +119,13 @@ static const option_value_type_map_t option_value_type_table[] =
   };
 
 static inline const option_value_type_map_t *
-find_option_value_type_name (register const char *str, register unsigned int len)
+find_option_value_type_name (register const char *str, register size_t len)
 {
   if (len <= 14 && len >= 3)
     {
-      register int key = (int)option_value_type_hash (str, len);
+      register unsigned int key = (int)option_value_type_hash (str, len);
 
-      if (key <= 17 && key >= 0)
+      if (key <= 17)
         {
           register const char *s = option_value_type_table[key].vtp_name;
 

+ 5 - 5
libopts/option-xat-attribute.c

@@ -31,7 +31,7 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "option-xat-attribute.h"
-/* ANSI-C code produced by gperf version 3.0.4 */
+/* ANSI-C code produced by gperf version 3.1 */
 /* Command-line: gperf option-xat-attribute.gp  */
 /* Computed positions: -k'1' */
 
@@ -64,7 +64,7 @@ typedef struct {
 /* maximum key range = 6, duplicates = 0 */
 
 static unsigned int
-option_xat_attribute_hash (register const char *str, register unsigned int len)
+option_xat_attribute_hash (register const char *str, register size_t len)
 {
   static const unsigned char asso_values[] =
     {
@@ -111,13 +111,13 @@ static const option_xat_attribute_map_t option_xat_attribute_table[] =
   };
 
 static inline const option_xat_attribute_map_t *
-find_option_xat_attribute_name (register const char *str, register unsigned int len)
+find_option_xat_attribute_name (register const char *str, register size_t len)
 {
   if (len <= 8 && len >= 4)
     {
-      register int key = (int)option_xat_attribute_hash (str, len);
+      register unsigned int key = (int)option_xat_attribute_hash (str, len);
 
-      if (key <= 9 && key >= 0)
+      if (key <= 9)
         {
           register const char *s = option_xat_attribute_table[key].xat_name;
 

+ 2 - 2
libopts/parse-duration.c

@@ -1,5 +1,5 @@
 /* Parse a time duration and return a seconds count
-   Copyright (C) 2008-2016 Free Software Foundation, Inc.
+   Copyright (C) 2008-2018 Free Software Foundation, Inc.
    Written by Bruce Korb <bkorb@gnu.org>, 2008.
 
    This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
    GNU Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #include <config.h>
 

+ 3 - 3
libopts/parse-duration.h

@@ -1,5 +1,5 @@
 /* Parse a time duration and return a seconds count
-   Copyright (C) 2008-2016 Free Software Foundation, Inc.
+   Copyright (C) 2008-2018 Free Software Foundation, Inc.
    Written by Bruce Korb <bkorb@gnu.org>, 2008.
 
    This program is free software: you can redistribute it and/or modify
@@ -13,7 +13,7 @@
    GNU Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 /*
 
@@ -22,7 +22,7 @@
 
   At the time of writing, this worked:
 
-  http://en.wikipedia.org/wiki/ISO_8601#Durations
+  https://en.wikipedia.org/wiki/ISO_8601#Durations
 
   The string must start with a 'P', 'T' or a digit.
 

+ 1 - 1
libopts/pgusage.c

@@ -13,7 +13,7 @@
  *
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control

+ 491 - 17
libopts/proto.h

@@ -1,19 +1,20 @@
 /* -*- buffer-read-only: t -*- vi: set ro:
  *
  * Prototypes for autoopts
- * Generated Mon Aug 29 14:35:37 PDT 2016
+ * Generated Sun Aug 26 10:44:39 PDT 2018
  */
 #ifndef AUTOOPTS_PROTO_H_GUARD
 #define AUTOOPTS_PROTO_H_GUARD 1
 
+
 /*
- *  Extracted from alias.c
+ * Static declarations from alias.c
  */
 static tSuccess
 too_many_occurrences(tOptions * opts, tOptDesc * od);
 
 /*
- *  Extracted from autoopts.c
+ * Static declarations from autoopts.c
  */
 static void *
 ao_malloc(size_t sz);
@@ -34,33 +35,151 @@ static tSuccess
 regular_opts(tOptions * opts);
 
 /*
- *  Extracted from check.c
+ * Static declarations from check.c
  */
 static bool
+has_conflict(tOptions * pOpts, tOptDesc * od);
+
+static bool
+occurs_enough(tOptions * pOpts, tOptDesc * pOD);
+
+static bool
 is_consistent(tOptions * pOpts);
 
 /*
- *  Extracted from configfile.c
+ * Static declarations from configfile.c
  */
 static void
+file_preset(tOptions * opts, char const * fname, int dir);
+
+static char *
+handle_comment(char * txt);
+
+static char *
+handle_cfg(tOptions * opts, tOptState * ost, char * txt, int dir);
+
+static char *
+handle_directive(tOptions * opts, char * txt);
+
+static char *
+aoflags_directive(tOptions * opts, char * txt);
+
+static char *
+program_directive(tOptions * opts, char * txt);
+
+static char *
+handle_section(tOptions * opts, char * txt);
+
+static int
+parse_xml_encoding(char ** ppz);
+
+static char *
+trim_xml_text(char * intxt, char const * pznm, tOptionLoadMode mode);
+
+static void
+cook_xml_text(char * pzData);
+
+static char *
+handle_struct(tOptions * opts, tOptState * ost, char * txt, int dir);
+
+static void
 intern_file_load(tOptions * opts);
 
 static char const *
 parse_attrs(tOptions * opts, char const * txt, tOptionLoadMode * pMode,
             tOptionValue * pType);
 
+static char const *
+parse_keyword(tOptions * opts, char const * txt, tOptionValue * typ);
+
+static char const *
+parse_set_mem(tOptions * opts, char const * txt, tOptionValue * typ);
+
+static char const *
+parse_value(char const * txt, tOptionValue * typ);
+
+/*
+ * Static declarations from cook.c
+ */
+static char *
+nl_count(char * start, char * end, int * lnct_p);
+
+static bool
+contiguous_quote(char ** pps, char * pq, int * lnct_p);
+
+/*
+ * Static declarations from enum.c
+ */
+static void
+enum_err(tOptions * pOpts, tOptDesc * pOD,
+         char const * const * paz_names, int name_ct);
+
+static uintptr_t
+find_name(char const * name, tOptions * pOpts, tOptDesc * pOD,
+          char const * const *  paz_names, unsigned int name_ct);
+
+static void
+set_memb_shell(tOptions * pOpts, tOptDesc * pOD, char const * const * paz_names,
+               unsigned int name_ct);
+
+static void
+set_memb_names(tOptions * opts, tOptDesc * od, char const * const * nm_list,
+               unsigned int nm_ct);
+
+static uintptr_t
+check_membership_start(tOptDesc * od, char const ** argp, bool * invert);
+
+static uintptr_t
+find_member_bit(tOptions * opts, tOptDesc * od, char const * pz, int len,
+                char const * const * nm_list, unsigned int nm_ct);
+
 /*
- *  Extracted from env.c
+ * Static declarations from env.c
  */
 static void
 doPrognameEnv(tOptions * pOpts, teEnvPresetType type);
 
 static void
+do_env_opt(tOptState * os, char * env_name,
+            tOptions * pOpts, teEnvPresetType type);
+
+static void
 env_presets(tOptions * pOpts, teEnvPresetType type);
 
 /*
- *  Extracted from find.c
+ * Static declarations from file.c
  */
+static void
+check_existence(teOptFileType ftype, tOptions * pOpts, tOptDesc * pOD);
+
+static void
+open_file_fd(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode);
+
+static void
+fopen_file_fp(tOptions * pOpts, tOptDesc * pOD, tuFileMode mode);
+
+/*
+ * Static declarations from find.c
+ */
+static int
+parse_opt(char const ** nm_pp, char ** arg_pp, char * buf, size_t bufsz);
+
+static void
+opt_ambiguities(tOptions * opts, char const * name, int nm_len);
+
+static int
+opt_match_ct(tOptions * opts, char const * name, int nm_len,
+             int * ixp, bool * disable);
+
+static tSuccess
+opt_set(tOptions * opts, char * arg, int idx, bool disable, tOptState * st);
+
+static tSuccess
+opt_unknown(tOptions * opts, char const * name, char * arg, tOptState * st);
+
+static tSuccess
+opt_ambiguous(tOptions * opts, char const * name, int match_ct);
+
 static tSuccess
 opt_find_long(tOptions * opts, char const * opt_name, tOptState * state);
 
@@ -68,13 +187,22 @@ static tSuccess
 opt_find_short(tOptions * pOpts, uint_t optValue, tOptState * pOptState);
 
 static tSuccess
+get_opt_arg_must(tOptions * opts, tOptState * o_st);
+
+static tSuccess
+get_opt_arg_may(tOptions * pOpts, tOptState * o_st);
+
+static tSuccess
+get_opt_arg_none(tOptions * pOpts, tOptState * o_st);
+
+static tSuccess
 get_opt_arg(tOptions * opts, tOptState * o_st);
 
 static tSuccess
 find_opt(tOptions * opts, tOptState * o_st);
 
 /*
- *  Extracted from init.c
+ * Static declarations from init.c
  */
 static tSuccess
 validate_struct(tOptions * opts, char const * pname);
@@ -82,40 +210,137 @@ validate_struct(tOptions * opts, char const * pname);
 static tSuccess
 immediate_opts(tOptions * opts);
 
+static tSuccess
+do_presets(tOptions * opts);
+
 static bool
 ao_initialize(tOptions * opts, int a_ct, char ** a_v);
 
 /*
- *  Extracted from load.c
+ * Static declarations from load.c
  */
+static bool
+get_realpath(char * buf, size_t b_sz);
+
+static bool
+add_prog_path(char * buf, int b_sz, char const * fname, char const * prg_path);
+
+static bool
+add_env_val(char * buf, int buf_sz, char const * name);
+
 static void
 munge_str(char * txt, tOptionLoadMode mode);
 
+static char *
+assemble_arg_val(char * txt, tOptionLoadMode mode);
+
+static char *
+trim_quotes(char * arg);
+
+static bool
+direction_ok(opt_state_mask_t f, int dir);
+
 static void
 load_opt_line(tOptions * opts, tOptState * opt_state, char * line,
               tDirection direction, tOptionLoadMode load_mode );
 
 /*
- *  Extracted from makeshell.c
+ * Static declarations from makeshell.c
  */
-static noreturn void
+noreturn static void
 option_exits(int exit_code);
 
-static noreturn void
+noreturn static void
 ao_bug(char const * msg);
 
 static void
 fserr_warn(char const * prog, char const * op, char const * fname);
 
-static noreturn void
+noreturn static void
 fserr_exit(char const * prog, char const * op, char const * fname);
 
+static void
+emit_var_text(char const * prog, char const * var, int fdin);
+
+static void
+text_to_var(tOptions * opts, teTextTo which, tOptDesc * od);
+
+static void
+emit_usage(tOptions * opts);
+
+static void
+emit_wrapup(tOptions * opts);
+
+static void
+emit_setup(tOptions * opts);
+
+static void
+emit_action(tOptions * opts, tOptDesc * od);
+
+static void
+emit_inaction(tOptions * opts, tOptDesc * od);
+
+static void
+emit_flag(tOptions * opts);
+
+static void
+emit_match_expr(char const * name, tOptDesc * cod, tOptions * opts);
+
+static void
+emit_long(tOptions * opts);
+
+static char *
+load_old_output(char const * fname, char const * pname);
+
+static void
+open_out(char const * fname, char const * pname);
+
 /*
- *  Extracted from nested.c
+ * Static declarations from nested.c
  */
 static void
+remove_continuation(char * src);
+
+static char const *
+scan_q_str(char const * pzTxt);
+
+static tOptionValue *
+add_string(void ** pp, char const * name, size_t nm_len,
+           char const * val, size_t d_len);
+
+static tOptionValue *
+add_bool(void ** pp, char const * name, size_t nm_len,
+         char const * val, size_t d_len);
+
+static tOptionValue *
+add_number(void ** pp, char const * name, size_t nm_len,
+           char const * val, size_t d_len);
+
+static tOptionValue *
+add_nested(void ** pp, char const * name, size_t nm_len,
+           char * val, size_t d_len);
+
+static char const *
+scan_name(char const * name, tOptionValue * res);
+
+static char const *
+unnamed_xml(char const * txt);
+
+static char const *
+scan_xml_name(char const * name, size_t * nm_len, tOptionValue * val);
+
+static char const *
+find_end_xml(char const * src, size_t nm_len, char const * val, size_t * len);
+
+static char const *
+scan_xml(char const * xml_name, tOptionValue * res_val);
+
+static void
 unload_arg_list(tArgList * arg_list);
 
+static void
+sort_list(tArgList * arg_list);
+
 static tOptionValue *
 optionLoadNested(char const * text, char const * name, size_t nm_len);
 
@@ -126,21 +351,270 @@ static void
 emit_special_char(FILE * fp, int ch);
 
 /*
- *  Extracted from sort.c
+ * Static declarations from parse-duration.c
  */
+static unsigned long
+str_const_to_ul (cch_t * str, cch_t ** ppz, int base);
+
+static long
+str_const_to_l (cch_t * str, cch_t ** ppz, int base);
+
+static time_t
+scale_n_add (time_t base, time_t val, int scale);
+
+static time_t
+parse_hr_min_sec (time_t start, cch_t * pz);
+
+static time_t
+parse_scaled_value (time_t base, cch_t ** ppz, cch_t * endp, int scale);
+
+static time_t
+parse_year_month_day (cch_t * pz, cch_t * ps);
+
+static time_t
+parse_yearmonthday (cch_t * in_pz);
+
+static time_t
+parse_YMWD (cch_t * pz);
+
+static time_t
+parse_hour_minute_second (cch_t * pz, cch_t * ps);
+
+static time_t
+parse_hourminutesecond (cch_t * in_pz);
+
+static time_t
+parse_HMS (cch_t * pz);
+
+static time_t
+parse_time (cch_t * pz);
+
+static char *
+trim (char * pz);
+
+static time_t
+parse_period (cch_t * in_pz);
+
+static time_t
+parse_non_iso8601 (cch_t * pz);
+
+/*
+ * Static declarations from pgusage.c
+ */
+static inline FILE *
+open_tmp_usage(char ** buf);
+
+static inline char *
+mk_pager_cmd(char const * fname);
+
+/*
+ * Static declarations from putshell.c
+ */
+static size_t
+string_size(char const * scan, size_t nl_len);
+
+static char const *
+print_quoted_apostrophes(char const * str);
+
+static void
+print_quot_str(char const * str);
+
+static void
+print_enumeration(tOptions * pOpts, tOptDesc * pOD);
+
+static void
+print_membership(tOptions * pOpts, tOptDesc * pOD);
+
+static void
+print_stacked_arg(tOptions * pOpts, tOptDesc * pOD);
+
+static void
+print_reordering(tOptions * opts);
+
+/*
+ * Static declarations from reset.c
+ */
+static void
+optionReset(tOptions * pOpts, tOptDesc * pOD);
+
+static void
+optionResetEverything(tOptions * pOpts);
+
+/*
+ * Static declarations from restore.c
+ */
+static void
+fixupSavedOptionArgs(tOptions * pOpts);
+
+/*
+ * Static declarations from save.c
+ */
+static char const *
+find_dir_name(tOptions * opts, int * p_free);
+
+static char const *
+find_file_name(tOptions * opts, int * p_free_name);
+
+static void
+prt_entry(FILE * fp, tOptDesc * od, char const * l_arg, save_flags_mask_t save_fl);
+
+static void
+prt_value(FILE * fp, int depth, tOptDesc * od, tOptionValue const * ovp);
+
+static void
+prt_string(FILE * fp, char const * name, char const * pz);
+
+static void
+prt_val_list(FILE * fp, char const * name, tArgList * al);
+
+static void
+prt_nested(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
+
+static void
+remove_settings(tOptions * opts, char const * fname);
+
+static FILE *
+open_sv_file(tOptions * opts, save_flags_mask_t save_fl);
+
+static void
+prt_no_arg_opt(FILE * fp, tOptDesc * vod, tOptDesc * pod, save_flags_mask_t save_fl);
+
+static void
+prt_str_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
+
+static void
+prt_enum_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
+
+static void
+prt_set_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl);
+
+static void
+prt_file_arg(FILE * fp, tOptDesc * od, tOptions * opts, save_flags_mask_t save_fl);
+
+/*
+ * Static declarations from sort.c
+ */
+static tSuccess
+must_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
+         char ** opt_txt, uint32_t * opt_idx);
+
+static tSuccess
+maybe_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
+          char ** opt_txt, uint32_t * opt_idx);
+
+static tSuccess
+short_opt_ck(tOptions * opts, char * arg_txt, tOptState * pOS,
+             char ** opt_txt, uint32_t * opt_idx);
+
 static void
 optionSort(tOptions * opts);
 
 /*
- *  Extracted from stack.c
+ * Static declarations from stack.c
  */
 static void
 addArgListEntry(void ** ppAL, void * entry);
 
 /*
- *  Extracted from usage.c
+ * Static declarations from text_mmap.c
  */
 static void
+load_text_file(tmap_info_t * mapinfo, char const * pzFile);
+
+static void
+validate_mmap(char const * fname, int prot, int flags, tmap_info_t * mapinfo);
+
+static void
+close_mmap_files(tmap_info_t * mi);
+
+/*
+ * Static declarations from tokenize.c
+ */
+static void
+copy_cooked(ch_t ** ppDest, char const ** ppSrc);
+
+static void
+copy_raw(ch_t ** ppDest, char const ** ppSrc);
+
+static token_list_t *
+alloc_token_list(char const * str);
+
+/*
+ * Static declarations from usage.c
+ */
+static unsigned int
+parse_usage_flags(ao_flag_names_t const * fnt, char const * txt);
+
+static void
 set_usage_flags(tOptions * opts, char const * flg_txt);
 
+static inline bool
+do_gnu_usage(tOptions * pOpts);
+
+static inline bool
+skip_misuse_usage(tOptions * pOpts);
+
+static void
+print_offer_usage(tOptions * opts);
+
+static void
+print_usage_details(tOptions * opts, int exit_code);
+
+static void
+print_one_paragraph(char const * text, bool plain, FILE * fp);
+
+static void
+prt_conflicts(tOptions * opts, tOptDesc * od);
+
+static void
+prt_one_vendor(tOptions *    opts,  tOptDesc *   od,
+               arg_types_t * argtp, char const * usefmt);
+
+static void
+prt_vendor_opts(tOptions * opts, char const * title);
+
+static void
+prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title);
+
+static void
+prt_ini_list(char const * const * papz, char const * ini_file,
+             char const * path_nm);
+
+static void
+prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at);
+
+static void
+prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at);
+
+static void
+prt_opt_usage(tOptions * opts, int ex_code, char const * title);
+
+static void
+prt_prog_detail(tOptions * opts);
+
+static int
+setGnuOptFmts(tOptions * opts, char const ** ptxt);
+
+static int
+setStdOptFmts(tOptions * opts, char const ** ptxt);
+
+/*
+ * Static declarations from version.c
+ */
+static void
+emit_first_line(
+    FILE * fp, char const * alt1, char const * alt2, char const * alt3);
+
+static void
+emit_simple_ver(tOptions * o, FILE * fp);
+
+static void
+emit_copy_full(tOptions * o, FILE * fp);
+
+static void
+emit_copy_note(tOptions * opts, FILE * fp);
+
+static void
+print_ver(tOptions * opts, tOptDesc * od, FILE * fp, bool call_exit);
+
 #endif /* AUTOOPTS_PROTO_H_GUARD */

+ 1 - 24
libopts/putshell.c

@@ -12,7 +12,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -31,29 +31,6 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-/* = = = START-STATIC-FORWARD = = = */
-static size_t
-string_size(char const * scan, size_t nl_len);
-
-static char const *
-print_quoted_apostrophes(char const * str);
-
-static void
-print_quot_str(char const * str);
-
-static void
-print_enumeration(tOptions * pOpts, tOptDesc * pOD);
-
-static void
-print_membership(tOptions * pOpts, tOptDesc * pOD);
-
-static void
-print_stacked_arg(tOptions * pOpts, tOptDesc * pOD);
-
-static void
-print_reordering(tOptions * opts);
-/* = = = END-STATIC-FORWARD = = = */
-
 /**
  * Count the number of bytes required to represent a string as a
  * compilable string.

+ 1 - 1
libopts/reset.c

@@ -10,7 +10,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control

+ 2 - 2
libopts/restore.c

@@ -12,7 +12,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -34,7 +34,7 @@
 /*
  *  optionFixupSavedOpts  Really, it just wipes out option state for
  *  options that are troublesome to copy.  viz., stacked strings and
- *  hierarchically valued option args.  We do duplicate string args that
+ *  hierarcicaly valued option args.  We do duplicate string args that
  *  have been marked as allocated though.
  */
 static void

+ 248 - 0
libopts/save-flags.c

@@ -0,0 +1,248 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *
+ *  DO NOT EDIT THIS FILE   (save-flags.c)
+ *
+ *  It has been AutoGen-ed
+ *  From the definitions    /tmp/.ag-ufBbQe/save-flags.def
+ *  and the template file   str2enum
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Bruce Korb'' nor the name of any other
+ *    contributor may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#include "save-flags.h"
+#include <sys/types.h>
+#ifndef MISSING_INTTYPES_H
+# include <inttypes.h>
+#endif
+
+typedef enum {
+    SVFL_BNM_DEFAULT  = 0,
+    SVFL_BNM_USAGE    = 1,
+    SVFL_BNM_UPDATE   = 2,
+    SVFL_COUNT_BNM
+} save_flags_enum_t;
+
+static save_flags_enum_t
+find_save_flags_bnm(char const * str, size_t len);
+
+
+#include <sys/types.h>
+#include <string.h>
+#ifndef NUL
+#define NUL '\0'
+#endif
+
+/* ANSI-C code produced by gperf version 3.1 */
+/* Command-line: gperf save-flags.gp  */
+/* Computed positions: -k'' */
+
+
+# if 0 /* gperf build options: */
+// %struct-type
+// %language=ANSI-C
+// %includes
+// %global-table
+// %omit-struct-type
+// %readonly-tables
+// %compare-strncmp
+//
+// %define slot-name               svfl_name
+// %define hash-function-name      save_flags_hash
+// %define lookup-function-name    find_save_flags_name
+// %define word-array-name         save_flags_table
+// %define initializer-suffix      ,SVFL_COUNT_BNM
+//
+# endif
+
+#include "save-flags.h"
+typedef struct {
+    char const *    svfl_name;
+    save_flags_enum_t svfl_id;
+} save_flags_map_t;
+#include <string.h>
+
+/* maximum key range = 3, duplicates = 0 */
+
+static unsigned int
+save_flags_hash (register const char *str, register size_t len)
+{
+  (void)str;
+  (void)len;
+  return len;
+}
+
+static const save_flags_map_t save_flags_table[] =
+  {
+    {"",SVFL_COUNT_BNM}, {"",SVFL_COUNT_BNM},
+    {"",SVFL_COUNT_BNM}, {"",SVFL_COUNT_BNM},
+    {"",SVFL_COUNT_BNM},
+    {"usage",    SVFL_BNM_USAGE},
+    {"update",   SVFL_BNM_UPDATE},
+    {"default",  SVFL_BNM_DEFAULT}
+  };
+
+static inline const save_flags_map_t *
+find_save_flags_name (register const char *str, register size_t len)
+{
+  if (len <= 7 && len >= 5)
+    {
+      register unsigned int key = (int)save_flags_hash (str, len);
+
+      if (key <= 7)
+        {
+          register const char *s = save_flags_table[key].svfl_name;
+
+          if (*str == *s && !strncmp (str + 1, s + 1, len - 1) && s[len] == '\0')
+            return &save_flags_table[key];
+        }
+    }
+  return 0;
+}
+
+/**
+ * Convert a command (keyword) to a save_flags_enum_t enumeration value.
+ *
+ * @param[in] str   a string that should start with a known key word.
+ * @param[in] len   the provided length of the keyword at \a str.
+ * @returns the enumeration value.
+ * If not found, that value is SVFL_COUNT_BNM.
+ */
+static save_flags_enum_t
+find_save_flags_bnm(char const * str, size_t len)
+{
+    save_flags_map_t const * map;
+
+    map = find_save_flags_name(str, (unsigned int)len);
+    if (map != NULL)
+        return map->svfl_id;
+    /* Check for a partial match */
+    {
+        /*
+         * Indexes of valid save_flags_table entries in sorted order:
+         */
+        static unsigned int const ix_map[] = {
+            7, 6, 5 };
+        save_flags_enum_t res = SVFL_COUNT_BNM;
+        static int const HI = (sizeof(ix_map) / sizeof(ix_map[0])) - 1;
+        int lo = 0;
+        int hi = HI;
+        int av;
+        int cmp;
+
+        for (;;) {
+            av  = (hi + lo) / 2;
+            map = save_flags_table + ix_map[av];
+            cmp = strncmp(map->svfl_name, str, len);
+            if (cmp == 0) break;
+            if (cmp > 0)
+                 hi = av - 1;
+            else lo = av + 1;
+            if (lo > hi)
+                return SVFL_COUNT_BNM;
+        }
+        res = map->svfl_id;
+        /*
+         * If we have an exact match, accept it.
+         */
+        if (map->svfl_name[len] == NUL)
+            return res;
+        /*
+         * Check for a duplicate partial match (a partial match
+         * with a higher or lower index than "av".
+         */
+        if (av < HI) {
+            map = save_flags_table + ix_map[av + 1];
+            if (strncmp(map->svfl_name, str, len) == 0)
+                return SVFL_COUNT_BNM;
+        }
+        if (av > 0) {
+            map = save_flags_table + ix_map[av - 1];
+            if (strncmp(map->svfl_name, str, len) == 0)
+                return SVFL_COUNT_BNM;
+        }
+        return res;
+    }
+}
+
+/**
+ * Convert a string to a save_flags_mask_t mask.
+ * Bit names prefixed with a hyphen have the bit removed from the mask.
+ * If the string starts with a '-', '+' or '|' character, then
+ * the old value is used as a base, otherwise the result mask
+ * is initialized to zero.  Separating bit names with '+' or '|'
+ * characters is optional.  By default, the bits are "or"-ed into the
+ * result.
+ *
+ * @param[in] str string with a list of bit names
+ * @param[in] old previous value, used if \a str starts with a '+' or '-'.
+ *
+ * @returns an unsigned integer with the bits set.
+ */
+save_flags_mask_t
+save_flags_str2mask(char const * str, save_flags_mask_t old)
+{
+    static char const white[] = ", \t\f";
+    static char const name_chars[] =
+        "adefglpstu"
+        "ADEFGLPSTU";
+
+    save_flags_mask_t res = 0;
+    int have_data = 0;
+
+    for (;;) {
+        save_flags_enum_t val;
+        unsigned int val_len;
+        unsigned int invert = 0;
+
+        str += strspn(str, white);
+        switch (*str) {
+        case NUL: return res;
+        case '-': case '~':
+            invert = 1;
+            /* FALLTHROUGH */
+
+        case '+': case '|':
+            if (have_data == 0)
+                res = old;
+
+            str += 1 + strspn(str + 1, white);
+            if (*str == NUL)
+                return 0;
+        }
+
+        val_len = strspn(str, name_chars);
+        if (val_len == 0)
+            return 0;
+        val = find_save_flags_bnm(str, val_len);
+        if (val == SVFL_COUNT_BNM)
+            return 0;
+        if (invert)
+            res &= ~((save_flags_mask_t)1 << val);
+        else
+            res |= (save_flags_mask_t)1 << val;
+        have_data = 1;
+        str += val_len;
+    }
+}
+/* end of save-flags.c */

+ 68 - 0
libopts/save-flags.h

@@ -0,0 +1,68 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *
+ *  DO NOT EDIT THIS FILE   (save-flags.h)
+ *
+ *  It has been AutoGen-ed
+ *  From the definitions    /tmp/.ag-ufBbQe/save-flags.def
+ *  and the template file   str2enum
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name ``Bruce Korb'' nor the name of any other
+ *    contributor may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * str2enum IS PROVIDED BY Bruce Korb ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL Bruce Korb OR ANY OTHER CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Command/Keyword Dispatcher
+ */
+#ifndef STR2ENUM_SAVE_FLAGS_H_GUARD
+#define STR2ENUM_SAVE_FLAGS_H_GUARD 1
+#include <sys/types.h>
+#include <inttypes.h>
+
+/** integral type for holding save_flags masks */
+typedef uint32_t save_flags_mask_t;
+
+/** bits defined for save_flags_mask_t */
+/** include default values in commentary */
+#define SVFL_DEFAULT            0x0001U
+/** include usage text in commentary */
+#define SVFL_USAGE              0x0002U
+/** replace or append state */
+#define SVFL_UPDATE             0x0004U
+
+/** bits in USAGE_DEFAULT mask:
+ *  usage   default */
+#define SVFL_USAGE_DEFAULT_MASK 0x0003U
+
+/** all bits in save_flags_mask_t masks */
+#define SVFL_MASK_ALL           0x0007U
+
+/** no bits in save_flags_mask_t */
+#define SVFL_NONE               0x0000U
+
+/** buffer size needed to hold all bit names for save_flags_mask_t masks */
+#define MAX_SAVE_FLAGS_NAME_SIZE 21
+
+extern save_flags_mask_t
+save_flags_str2mask(char const * str, save_flags_mask_t old);
+
+#endif /* STR2ENUM_SAVE_FLAGS_H_GUARD */
+/* end of save-flags.h */

+ 313 - 206
libopts/save.c

@@ -12,7 +12,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -30,133 +30,70 @@
  *  4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b  COPYING.lgplv3
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
-
-/* = = = START-STATIC-FORWARD = = = */
-static char const *
-find_dir_name(tOptions * opts, int * p_free);
-
-static char const *
-find_file_name(tOptions * opts, int * p_free_name);
-
-static void
-prt_entry(FILE * fp, tOptDesc * od, char const * l_arg);
-
-static void
-prt_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp);
-
-static void
-prt_string(FILE * fp, char const * name, char const * pz);
-
-static void
-prt_val_list(FILE * fp, char const * name, tArgList * al);
-
-static void
-prt_nested(FILE * fp, tOptDesc * p);
-
-static FILE *
-open_sv_file(tOptions * opts);
-
-static void
-prt_no_arg_opt(FILE * fp, tOptDesc * p, tOptDesc * pOD);
-
-static void
-prt_str_arg(FILE * fp, tOptDesc * pOD);
-
-static void
-prt_enum_arg(FILE * fp, tOptDesc * od);
-
-static void
-prt_set_arg(FILE * fp, tOptDesc * od);
-
-static void
-prt_file_arg(FILE * fp, tOptDesc * od, tOptions * opts);
-/* = = = END-STATIC-FORWARD = = = */
+#include "save-flags.h"
 
 /**
+ * find the config file directory name
+ *
+ * @param opts    the options descriptor
+ * @param p_free  tell caller if name was allocated or not
  */
 static char const *
 find_dir_name(tOptions * opts, int * p_free)
 {
     char const * dir;
+    int idx;
 
     if (  (opts->specOptIdx.save_opts == NO_EQUIVALENT)
        || (opts->specOptIdx.save_opts == 0))
         return NULL;
 
     dir = opts->pOptDesc[ opts->specOptIdx.save_opts ].optArg.argString;
-    if ((dir != NULL) && (*dir != NUL))
-        return dir;
+    if ((dir != NULL) && (*dir != NUL)) {
+        char const * pz = strchr(dir, '>');
+        if (pz == NULL)
+            return dir;
+        while (*(++pz) == '>')  ;
+        pz += strspn(pz, " \t");
+        dir = pz;
+        if (*dir != NUL)
+            return dir;
+    }
+
+    if (opts->papzHomeList == NULL)
+        return NULL;
 
     /*
      *  This function only works if there is a directory where
      *  we can stash the RC (INI) file.
      */
-    {
-        char const * const * papz = opts->papzHomeList;
-        if (papz == NULL)
-            return NULL;
-
-        while (papz[1] != NULL) papz++;
-        dir = *papz;
-    }
-
-    /*
-     *  IF it does not require deciphering an env value, then just copy it
-     */
-    if (*dir != '$')
-        return dir;
-
-    {
-        char const * end = strchr(++dir, DIRCH);
-        char * env;
+    for (idx = 0;; idx++) {
+        char f_name[ AG_PATH_MAX+1 ];
 
-        if (end != NULL) {
-            char z[ AO_NAME_SIZE ];
-            if ((end - dir) > AO_NAME_LIMIT )
-                return NULL;
-            memcpy(z, dir, (size_t)(end - dir));
-            z[end - dir] = NUL;
-            env = getenv(z);
-        } else {
-
-            /*
-             *  Make sure we can get the env value (after stripping off
-             *  any trailing directory or file names)
-             */
-            env = getenv(dir);
-        }
+        dir = opts->papzHomeList[idx];
 
-        if (env == NULL) {
-            fprintf(stderr, zsave_warn, opts->pzProgName);
-            fprintf(stderr, zNotDef, dir);
-            return NULL;
+        switch (*dir) {
+        case '$':
+            break;
+        case NUL:
+            continue;
+        default:
+            return dir;
         }
-
-        if (end == NULL)
-            return env;
-
-        /*
-         * we will be returning an allocated result
-         */
-        *p_free = 1;
-
-        {
-            size_t env_len = strlen(env);
-            size_t end_len = strlen(end);
-            char * p;
-            char * res = p = (char *)AGALOC(env_len + end_len + 2, "dir name");
-
-            memcpy(p, env, env_len);
-            p += env_len;
-            *(p++) = '/';
-            memcpy(p, end, end_len + 1);
-
-            return res;
+        if (optionMakePath(f_name, (int)sizeof(f_name), dir, opts->pzProgPath)) {
+            *p_free = true;
+            AGDUPSTR(dir, f_name, "homerc");
+            return dir;
         }
     }
+    return NULL;
 }
 
 /**
+ * Find the name of the save-the-options file
+ *
+ * @param opts         the options descriptor
+ * @param p_free_name  tell caller if name was allocated or not
  */
 static char const *
 find_file_name(tOptions * opts, int * p_free_name)
@@ -164,15 +101,15 @@ find_file_name(tOptions * opts, int * p_free_name)
     struct stat stBuf;
     int    free_dir_name = 0;
 
-    char const * pzDir = find_dir_name(opts, &free_dir_name);
-    if (pzDir == NULL)
-        return NULL;
+    char const * res = find_dir_name(opts, &free_dir_name);
+    if (res == NULL)
+        return res;
 
     /*
      *  See if we can find the specified directory.  We use a once-only loop
      *  structure so we can bail out early.
      */
-    if (stat(pzDir, &stBuf) != 0) do {
+    if (stat(res, &stBuf) != 0) do {
         char z[AG_PATH_MAX];
         char * dirchp;
 
@@ -182,10 +119,10 @@ find_file_name(tOptions * opts, int * p_free_name)
          */
         if (errno != ENOENT) {
         bogus_name:
-            fprintf(stderr, zsave_warn, opts->pzProgName);
-            fprintf(stderr, zNoStat, errno, strerror(errno), pzDir);
+            fprintf(stderr, zsave_warn, opts->pzProgName, res);
+            fprintf(stderr, zNoStat, errno, strerror(errno), res);
             if (free_dir_name)
-                AGFREE(pzDir);
+                AGFREE(res);
             return NULL;
         }
 
@@ -193,17 +130,17 @@ find_file_name(tOptions * opts, int * p_free_name)
          *  Strip off the last component, stat the remaining string and
          *  that string must name a directory
          */
-        dirchp = strrchr(pzDir, DIRCH);
+        dirchp = strrchr(res, DIRCH);
         if (dirchp == NULL) {
             stBuf.st_mode = S_IFREG;
             break; /* found directory -- viz.,  "." */
         }
 
-        if ((size_t)(dirchp - pzDir) >= sizeof(z))
+        if ((size_t)(dirchp - res) >= sizeof(z))
             goto bogus_name;
 
-        memcpy(z, pzDir, (size_t)(dirchp - pzDir));
-        z[dirchp - pzDir] = NUL;
+        memcpy(z, res, (size_t)(dirchp - res));
+        z[dirchp - res] = NUL;
 
         if ((stat(z, &stBuf) != 0) || ! S_ISDIR(stBuf.st_mode))
             goto bogus_name;
@@ -217,15 +154,15 @@ find_file_name(tOptions * opts, int * p_free_name)
     if (S_ISDIR(stBuf.st_mode)) {
 
         {
-            size_t sz = strlen(pzDir) + strlen(opts->pzRcName) + 2;
+            size_t sz = strlen(res) + strlen(opts->pzRcName) + 2;
             char * pzPath = (char *)AGALOC(sz, "file name");
-            if (   snprintf(pzPath, sz, "%s/%s", pzDir, opts->pzRcName)
+            if (   snprintf(pzPath, sz, "%s/%s", res, opts->pzRcName)
                 >= (int)sz)
                 option_exits(EXIT_FAILURE);
 
             if (free_dir_name)
-                AGFREE(pzDir);
-            pzDir = pzPath;
+                AGFREE(res);
+            res = pzPath;
             free_dir_name = 1;
         }
 
@@ -233,12 +170,12 @@ find_file_name(tOptions * opts, int * p_free_name)
          *  IF we cannot stat the object for any reason other than
          *     it does not exist, then we bail out
          */
-        if (stat(pzDir, &stBuf) != 0) {
+        if (stat(res, &stBuf) != 0) {
             if (errno != ENOENT) {
-                fprintf(stderr, zsave_warn, opts->pzProgName);
+                fprintf(stderr, zsave_warn, opts->pzProgName, res);
                 fprintf(stderr, zNoStat, errno, strerror(errno),
-                        pzDir);
-                AGFREE(pzDir);
+                        res);
+                AGFREE(res);
                 return NULL;
             }
 
@@ -254,32 +191,37 @@ find_file_name(tOptions * opts, int * p_free_name)
      *  or will soon be a file.
      */
     if (! S_ISREG(stBuf.st_mode)) {
-        fprintf(stderr, zsave_warn, opts->pzProgName, pzDir);
+        fprintf(stderr, zsave_warn, opts->pzProgName, res);
         if (free_dir_name)
-            AGFREE(pzDir);
+            AGFREE(res);
         return NULL;
     }
 
     /*
      *  Get rid of the old file
      */
-    unlink(pzDir);
     *p_free_name = free_dir_name;
-    return pzDir;
+    return res;
 }
 
 /**
  * print one option entry to the save file.
  *
- * @param[in] fp    the file pointer for the save file
- * @param[in] od    the option descriptor to print
- * @param[in] l_arg the last argument for the option
+ * @param[in] fp       the file pointer for the save file
+ * @param[in] od       the option descriptor to print
+ * @param[in] l_arg    the last argument for the option
+ * @param[in] save_fl  include usage in comments
  */
 static void
-prt_entry(FILE * fp, tOptDesc * od, char const * l_arg)
+prt_entry(FILE * fp, tOptDesc * od, char const * l_arg, save_flags_mask_t save_fl)
 {
     int space_ct;
 
+    if (save_fl & SVFL_USAGE)
+        fprintf(fp, ao_name_use_fmt, od->pz_Name, od->pzText);
+    if (UNUSED_OPT(od) && (save_fl & SVFL_DEFAULT))
+        fputs(ao_default_use, fp);
+
     /*
      *  There is an argument.  Pad the name so values line up.
      *  Not disabled *OR* this got equivalenced to another opt,
@@ -288,9 +230,14 @@ prt_entry(FILE * fp, tOptDesc * od, char const * l_arg)
      */
     {
         char const * pz =
-            (! DISABLED_OPT(od) || (od->optEquivIndex != NO_EQUIVALENT))
+            (od->pz_DisableName == NULL)
             ? od->pz_Name
-            : od->pz_DisableName;
+            : (DISABLED_OPT(od)
+               ? od->pz_DisableName
+               : ((od->optEquivIndex == NO_EQUIVALENT)
+                  ? od->pz_Name : od->pz_DisableName)
+              );
+        
         space_ct = 17 - strlen(pz);
         fputs(pz, fp);
     }
@@ -339,9 +286,13 @@ end_entry:
 }
 
 /**
+ * print an option's value
+ *
+ * @param[in] fp          the file pointer for the save file
+ * @param[in] od          the option descriptor to print
  */
 static void
-prt_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp)
+prt_value(FILE * fp, int depth, tOptDesc * od, tOptionValue const * ovp)
 {
     while (--depth >= 0)
         putc(' ', fp), putc(' ', fp);
@@ -358,9 +309,9 @@ prt_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp)
 
     case OPARG_TYPE_ENUMERATION:
     case OPARG_TYPE_MEMBERSHIP:
-        if (pOD != NULL) {
-            uint32_t  opt_state = pOD->fOptState;
-            uintptr_t val = pOD->optArg.argEnum;
+        if (od != NULL) {
+            uint32_t  opt_state = od->fOptState;
+            uintptr_t val = od->optArg.argEnum;
             char const * typ = (ovp->valType == OPARG_TYPE_ENUMERATION)
                 ? "keyword" : "set-membership";
 
@@ -370,20 +321,20 @@ prt_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp)
              *  This is a magic incantation that will convert the
              *  bit flag values back into a string suitable for printing.
              */
-            (*(pOD->pOptProc))(OPTPROC_RETURN_VALNAME, pOD );
-            if (pOD->optArg.argString != NULL) {
-                fputs(pOD->optArg.argString, fp);
+            (*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od );
+            if (od->optArg.argString != NULL) {
+                fputs(od->optArg.argString, fp);
 
                 if (ovp->valType != OPARG_TYPE_ENUMERATION) {
                     /*
                      *  set membership strings get allocated
                      */
-                    AGFREE(pOD->optArg.argString);
+                    AGFREE(od->optArg.argString);
                 }
             }
 
-            pOD->optArg.argEnum = val;
-            pOD->fOptState = opt_state;
+            od->optArg.argEnum = val;
+            od->fOptState = opt_state;
             fprintf(fp, END_XML_FMT, ovp->pzName);
             break;
         }
@@ -405,6 +356,9 @@ prt_value(FILE * fp, int depth, tOptDesc * pOD, tOptionValue const * ovp)
 }
 
 /**
+ * Print a string value in XML format
+ *
+ * @param[in] fp          the file pointer for the save file
  */
 static void
 prt_string(FILE * fp, char const * name, char const * pz)
@@ -441,6 +395,9 @@ prt_string(FILE * fp, char const * name, char const * pz)
 }
 
 /**
+ * Print an option that can have multiple values in XML format
+ *
+ * @param[in] fp          file pointer
  */
 static void
 prt_val_list(FILE * fp, char const * name, tArgList * al)
@@ -477,15 +434,26 @@ prt_val_list(FILE * fp, char const * name, tArgList * al)
 }
 
 /**
+ * printed a nested/hierarchical value
+ *
+ * @param[in] fp       file pointer
+ * @param[in] od       option descriptor
+ * @param[in] save_fl  include usage in comments
  */
 static void
-prt_nested(FILE * fp, tOptDesc * p)
+prt_nested(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl)
 {
     int opt_ct;
-    tArgList * al = p->optCookie;
+    tArgList * al = od->optCookie;
     void ** opt_list;
 
-    if (al == NULL)
+    if (save_fl & SVFL_USAGE)
+        fprintf(fp, ao_name_use_fmt, od->pz_Name, od->pzText);
+
+    /*
+     * Never show a default value if a hierarchical value is empty.
+     */
+    if (UNUSED_OPT(od) || (al == NULL))
         return;
 
     opt_ct   = al->useCt;
@@ -501,48 +469,128 @@ prt_nested(FILE * fp, tOptDesc * p)
         if (ovp == NULL)
             continue;
 
-        fprintf(fp, NESTED_OPT_FMT, p->pz_Name);
+        fprintf(fp, NESTED_OPT_FMT, od->pz_Name);
 
         do  {
-            prt_value(fp, 1, p, ovp);
+            prt_value(fp, 1, od, ovp);
 
         } while (ovp = optionNextValue(base, ovp),
                  ovp != NULL);
 
-        fprintf(fp, "</%s>\n", p->pz_Name);
+        fprintf(fp, "</%s>\n", od->pz_Name);
     } while (--opt_ct > 0);
 }
 
 /**
- * open the file for saving option state.
+ * remove the current program settings
  *
  * @param[in] opts  the program options structure
+ * @param[in] fname the save file name
+ */
+static void
+remove_settings(tOptions * opts, char const * fname)
+{
+    size_t const name_len = strlen(opts->pzProgName);
+    tmap_info_t  map_info;
+    char *       text = text_mmap(fname, PROT_READ|PROT_WRITE, MAP_PRIVATE, &map_info);
+    char *       scan = text;
+
+    for (;;) {
+        char * next = scan = strstr(scan, zCfgProg);
+        if (scan == NULL)
+            goto leave;
+
+        scan = SPN_WHITESPACE_CHARS(scan + zCfgProg_LEN);
+        if (  (strneqvcmp(scan, opts->pzProgName, (int)name_len) == 0)
+           && (IS_END_XML_TOKEN_CHAR(scan[name_len])) )  {
+
+            scan = next;
+            break;
+        }
+    }
+
+    /*
+     * If not NULL, "scan" points to the "<?program" string introducing
+     * the program segment we are to remove. See if another segment follows.
+     * If so, copy text. If not se trim off this segment.
+     */
+    {
+        char * next = strstr(scan + zCfgProg_LEN, zCfgProg);
+        size_t new_sz;
+
+        if (next == NULL)
+            new_sz = map_info.txt_size - strlen(scan);
+        else {
+            int fd = open(fname, O_RDWR);
+            if (fd < 0) return;
+            if (lseek(fd, (scan - text), SEEK_SET) < 0)
+                scan = next;
+            else if (write(fd, next, strlen(next)) < 0)
+                scan = next;
+            if (close(fd) < 0)
+                scan = next;
+            new_sz = map_info.txt_size - (next - scan);
+        }
+        if (new_sz != map_info.txt_size)
+            if (truncate(fname, new_sz) < 0)
+                scan = next; // we removed it, so shorten file
+    }
+
+ leave:
+    text_munmap(&map_info);
+}
+
+/**
+ * open the file for saving option state.
+ *
+ * @param[in] opts     the program options structure
+ * @param[in] save_fl  flags for saving data
  * @returns the open file pointer.  It may be NULL.
  */
 static FILE *
-open_sv_file(tOptions * opts)
+open_sv_file(tOptions * opts, save_flags_mask_t save_fl)
 {
     FILE * fp;
 
     {
         int   free_name = 0;
-        char const * pzFName = find_file_name(opts, &free_name);
-        if (pzFName == NULL)
+        char const * fname = find_file_name(opts, &free_name);
+        if (fname == NULL)
             return NULL;
 
-        fp = fopen(pzFName, "w" FOPEN_BINARY_FLAG);
+        if (save_fl == 0)
+            unlink(fname);
+        else
+            remove_settings(opts, fname);
+
+        fp = fopen(fname, "a" FOPEN_BINARY_FLAG);
         if (fp == NULL) {
-            fprintf(stderr, zsave_warn, opts->pzProgName);
-            fprintf(stderr, zNoCreat, errno, strerror(errno), pzFName);
+            fprintf(stderr, zsave_warn, opts->pzProgName, fname);
+            fprintf(stderr, zNoCreat, errno, strerror(errno), fname);
             if (free_name)
-                AGFREE(pzFName);
+                AGFREE(fname);
             return fp;
         }
 
         if (free_name)
-            AGFREE(pzFName);
+            AGFREE(fname);
     }
 
+    do {
+        struct stat sbuf;
+        if (fstat(fileno(fp), &sbuf) < 0)
+            break;
+
+        if (sbuf.st_size > zPresetFile_LEN) {
+            /* non-zero size implies save_fl is non-zero */
+            fprintf(fp, zFmtProg, opts->pzProgName);
+            return fp;
+        }
+    } while (false);
+
+    /*
+     * We have a new file. Insert a header
+     */
     fputs("#  ", fp);
     {
         char const * e = strchr(opts->pzUsageTitle, NL);
@@ -564,40 +612,63 @@ open_sv_file(tOptions * opts)
         AGFREE(time_str);
 #endif
     }
-
+    if (save_fl != 0)
+        fprintf(fp, zFmtProg, opts->pzProgName);
     return fp;
 }
 
 /**
+ * print option without an arg
+ *
+ * @param[in] fp       file pointer
+ * @param[in] vod      value option descriptor
+ * @param[in] pod      primary option descriptor
+ * @param[in] save_fl  include usage in comments
  */
 static void
-prt_no_arg_opt(FILE * fp, tOptDesc * p, tOptDesc * pOD)
+prt_no_arg_opt(FILE * fp, tOptDesc * vod, tOptDesc * pod, save_flags_mask_t save_fl)
 {
     /*
      * The aliased to argument indicates whether or not the option
      * is "disabled".  However, the original option has the name
-     * string, so we get that there, not with "p".
+     * string, so we get that there, not with "vod".
      */
     char const * pznm =
-        (DISABLED_OPT(p)) ? pOD->pz_DisableName : pOD->pz_Name;
+        (DISABLED_OPT(vod)) ? pod->pz_DisableName : pod->pz_Name;
     /*
      *  If the option was disabled and the disablement name is NULL,
      *  then the disablement was caused by aliasing.
      *  Use the name as the string to emit.
      */
     if (pznm == NULL)
-        pznm = pOD->pz_Name;
+        pznm = pod->pz_Name;
+
+    if (save_fl & SVFL_USAGE)
+        fprintf(fp, ao_name_use_fmt, pod->pz_Name, pod->pzText);
+    if (UNUSED_OPT(pod) && (save_fl & SVFL_DEFAULT))
+        fputs(ao_default_use, fp);
 
     fprintf(fp, "%s\n", pznm);
 }
 
 /**
+ * print the string valued argument(s).
+ *
+ * @param[in] fp       file pointer
+ * @param[in] od       value option descriptor
+ * @param[in] save_fl  include usage in comments
  */
 static void
-prt_str_arg(FILE * fp, tOptDesc * pOD)
+prt_str_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl)
 {
-    if (pOD->fOptState & OPTST_STACKED) {
-        tArgList * pAL = (tArgList *)pOD->optCookie;
+    if (UNUSED_OPT(od) || ((od->fOptState & OPTST_STACKED) == 0)) {
+        char const * arg = od->optArg.argString;
+        if (arg == NULL)
+            arg = "''";
+        prt_entry(fp, od, arg, save_fl);
+
+    } else {
+        tArgList * pAL = (tArgList *)od->optCookie;
         int        uct = pAL->useCt;
         char const ** ppz = pAL->apzArgs;
 
@@ -605,23 +676,24 @@ prt_str_arg(FILE * fp, tOptDesc * pOD)
          *  un-disable multiple copies of disabled options.
          */
         if (uct > 1)
-            pOD->fOptState &= ~OPTST_DISABLED;
+            od->fOptState &= ~OPTST_DISABLED;
 
-        while (uct-- > 0)
-            prt_entry(fp, pOD, *(ppz++));
-    } else {
-        prt_entry(fp, pOD, pOD->optArg.argString);
+        while (uct-- > 0) {
+            prt_entry(fp, od, *(ppz++), save_fl);
+            save_fl &= ~SVFL_USAGE;
+        }
     }
 }
 
 /**
  * print the string value of an enumeration.
  *
- * @param[in] fp  the file pointer to write to
- * @param[in] od  the option descriptor with the enumerated value
+ * @param[in] fp       the file pointer to write to
+ * @param[in] od       the option descriptor with the enumerated value
+ * @param[in] save_fl  include usage in comments
  */
 static void
-prt_enum_arg(FILE * fp, tOptDesc * od)
+prt_enum_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl)
 {
     uintptr_t val = od->optArg.argEnum;
 
@@ -630,29 +702,31 @@ prt_enum_arg(FILE * fp, tOptDesc * od)
      *  bit flag values back into a string suitable for printing.
      */
     (*(od->pOptProc))(OPTPROC_RETURN_VALNAME, od);
-    prt_entry(fp, od, VOIDP(od->optArg.argString));
+    prt_entry(fp, od, VOIDP(od->optArg.argString), save_fl);
 
     od->optArg.argEnum = val;
 }
 
 /**
  * Print the bits set in a bit mask option.
+ *
  * We call the option handling function with a magic value for
  * the options pointer and it allocates and fills in the string.
  * We print that with a call to prt_entry().
  *
- * @param[in] fp  the file pointer to write to
- * @param[in] od  the option descriptor with a bit mask value type
+ * @param[in] fp       the file pointer to write to
+ * @param[in] od       the option descriptor with a bit mask value type
+ * @param[in] save_fl  include usage in comments
  */
 static void
-prt_set_arg(FILE * fp, tOptDesc * od)
+prt_set_arg(FILE * fp, tOptDesc * od, save_flags_mask_t save_fl)
 {
     char * list = optionMemberList(od);
     size_t len  = strlen(list);
     char * buf  = (char *)AGALOC(len + 3, "dir name");
     *buf= '=';
     memcpy(buf+1, list, len + 1);
-    prt_entry(fp, od, buf);
+    prt_entry(fp, od, buf, save_fl);
     AGFREE(buf);
     AGFREE(list);
 }
@@ -661,29 +735,35 @@ prt_set_arg(FILE * fp, tOptDesc * od)
  * figure out what the option file name argument is.
  * If one can be found, call prt_entry() to emit it.
  *
- * @param[in] fp   the file pointer to write to.
- * @param[in] od   the option descriptor with a bit mask value type
- * @param[in] opts the program options descriptor
+ * @param[in] fp       the file pointer to write to.
+ * @param[in] od       the option descriptor with a bit mask value type
+ * @param[in] opts     the program options descriptor
+ * @param[in] save_fl  include usage in comments
  */
 static void
-prt_file_arg(FILE * fp, tOptDesc * od, tOptions * opts)
+prt_file_arg(FILE * fp, tOptDesc * od, tOptions * opts, save_flags_mask_t save_fl)
 {
     /*
      *  If the cookie is not NULL, then it has the file name, period.
      *  Otherwise, if we have a non-NULL string argument, then....
      */
     if (od->optCookie != NULL)
-        prt_entry(fp, od, od->optCookie);
+        prt_entry(fp, od, od->optCookie, save_fl);
 
     else if (HAS_originalOptArgArray(opts)) {
         char const * orig =
             opts->originalOptArgArray[od->optIndex].argString;
 
-        if (od->optArg.argString == orig)
+        if (od->optArg.argString == orig) {
+            if (save_fl)
+                fprintf(fp, ao_name_use_fmt, od->pz_Name, od->pzText);
             return;
+        }
 
-        prt_entry(fp, od, od->optArg.argString);
-    }
+        prt_entry(fp, od, od->optArg.argString, save_fl);
+
+    } else if (save_fl)
+        fprintf(fp, ao_name_use_fmt, od->pz_Name, od->pzText);
 }
 
 /*=export_func  optionSaveFile
@@ -720,8 +800,32 @@ optionSaveFile(tOptions * opts)
 {
     tOptDesc *  od;
     int         ct;
-    FILE *      fp = open_sv_file(opts);
+    FILE *      fp;
+    save_flags_mask_t save_flags = SVFL_NONE;
+
+    do {
+        char * temp_str;
+        char const * dir = opts->pOptDesc[ opts->specOptIdx.save_opts ].optArg.argString;
+        size_t flen;
 
+        if (dir == NULL)
+            break;
+        temp_str = strchr(dir, '>');
+        if (temp_str == NULL)
+            break;
+        if (temp_str[1] == '>')
+            save_flags = SVFL_UPDATE;
+        flen = (temp_str - dir);
+        if (flen == 0)
+            break;
+        temp_str = AGALOC(flen + 1, "flag search str");
+        memcpy(temp_str, dir, flen);
+        temp_str[flen] = NUL;
+        save_flags |= save_flags_str2mask(temp_str, SVFL_NONE);
+        AGFREE(temp_str);
+    } while (false);
+
+    fp = open_sv_file(opts, save_flags & SVFL_UPDATE);
     if (fp == NULL)
         return;
 
@@ -731,20 +835,20 @@ optionSaveFile(tOptions * opts)
     ct = opts->presetOptCt;
     od = opts->pOptDesc;
     do  {
-        tOptDesc * p;
+        tOptDesc * vod;
 
         /*
-         *  IF    the option has not been defined
-         *     OR it does not take an initialization value
-         *     OR it is equivalenced to another option
-         *  THEN continue (ignore it)
-         *
          *  Equivalenced options get picked up when the equivalenced-to
-         *  option is processed.
+         *  option is processed. And do not save options with any state
+         *  bits in the DO_NOT_SAVE collection
+         *
+         * ** option cannot be preset
+         * #define OPTST_NO_INIT          0x0000100U
+         * ** disable from cmd line
+         * #define OPTST_NO_COMMAND       0x2000000U
+         * ** alias for other option
+         * #define OPTST_ALIAS            0x8000000U
          */
-        if (UNUSED_OPT(od))
-            continue;
-
         if ((od->fOptState & OPTST_DO_NOT_SAVE_MASK) != 0)
             continue;
 
@@ -752,45 +856,48 @@ optionSaveFile(tOptions * opts)
            && (od->optEquivIndex != od->optIndex))
             continue;
 
+        if (UNUSED_OPT(od) && ((save_flags & SVFL_USAGE_DEFAULT_MASK) == SVFL_NONE))
+            continue;
+
         /*
          *  The option argument data are found at the equivalenced-to option,
          *  but the actual option argument type comes from the original
          *  option descriptor.  Be careful!
          */
-        p = ((od->fOptState & OPTST_EQUIVALENCE) != 0)
-            ? (opts->pOptDesc + od->optActualIndex) : od;
+        vod = ((od->fOptState & OPTST_EQUIVALENCE) != 0)
+              ? (opts->pOptDesc + od->optActualIndex) : od;
 
         switch (OPTST_GET_ARGTYPE(od->fOptState)) {
         case OPARG_TYPE_NONE:
-            prt_no_arg_opt(fp, p, od);
+            prt_no_arg_opt(fp, vod, od, save_flags);
             break;
 
         case OPARG_TYPE_NUMERIC:
-            prt_entry(fp, p, VOIDP(p->optArg.argInt));
+            prt_entry(fp, vod, VOIDP(vod->optArg.argInt), save_flags);
             break;
 
         case OPARG_TYPE_STRING:
-            prt_str_arg(fp, p);
+            prt_str_arg(fp, vod, save_flags);
             break;
 
         case OPARG_TYPE_ENUMERATION:
-            prt_enum_arg(fp, p);
+            prt_enum_arg(fp, vod, save_flags);
             break;
 
         case OPARG_TYPE_MEMBERSHIP:
-            prt_set_arg(fp, p);
+            prt_set_arg(fp, vod, save_flags);
             break;
 
         case OPARG_TYPE_BOOLEAN:
-            prt_entry(fp, p, p->optArg.argBool ? "true" : "false");
+            prt_entry(fp, vod, vod->optArg.argBool ? "true" : "false", save_flags);
             break;
 
         case OPARG_TYPE_HIERARCHY:
-            prt_nested(fp, p);
+            prt_nested(fp, vod, save_flags);
             break;
 
         case OPARG_TYPE_FILE:
-            prt_file_arg(fp, p, opts);
+            prt_file_arg(fp, vod, opts, save_flags);
             break;
 
         default:

+ 2 - 16
libopts/sort.c

@@ -10,7 +10,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -29,20 +29,6 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-/* = = = START-STATIC-FORWARD = = = */
-static tSuccess
-must_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
-         char ** opt_txt, uint32_t * opt_idx);
-
-static tSuccess
-maybe_arg(tOptions * opts, char * arg_txt, tOptState * pOS,
-          char ** opt_txt, uint32_t * opt_idx);
-
-static tSuccess
-short_opt_ck(tOptions * opts, char * arg_txt, tOptState * pOS,
-             char ** opt_txt, uint32_t * opt_idx);
-/* = = = END-STATIC-FORWARD = = = */
-
 /*
  *  "must_arg" and "maybe_arg" are really similar.  The biggest
  *  difference is that "may" will consume the next argument only if it
@@ -178,7 +164,7 @@ short_opt_ck(tOptions * opts, char * arg_txt, tOptState * pOS,
  *  If the program wants sorted options (separated operands and options),
  *  then this routine will to the trick.
  */
-LOCAL void
+static void
 optionSort(tOptions * opts)
 {
     char **  opt_txt;

+ 2 - 2
libopts/stack.c

@@ -11,7 +11,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -176,7 +176,7 @@ optionUnstackArg(tOptions * opts, tOptDesc * od)
  *  a pointer to the argument list structure.  It gets passed around
  *  as an opaque address.
  */
-LOCAL void
+static void
 addArgListEntry(void ** ppAL, void * entry)
 {
     tArgList * pAL = *(void **)ppAL;

+ 21 - 11
libopts/stdnoreturn.in.h

@@ -1,6 +1,6 @@
 /* A substitute for ISO C11 <stdnoreturn.h>.
 
-   Copyright 2012-2016 Free Software Foundation, Inc.
+   Copyright 2012-2018 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
@@ -13,7 +13,7 @@
    GNU Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public License
-   along with this program; if not, see <http://www.gnu.org/licenses/>.  */
+   along with this program; if not, see <https://www.gnu.org/licenses/>.  */
 
 /* Written by Paul Eggert.  */
 
@@ -28,15 +28,25 @@
 
 /* The definition of _Noreturn is copied here.  */
 
-#if 1200 <= _MSC_VER
-/* Standard include files on this platform contain declarations like
-   "__declspec (noreturn) void abort (void);".  "#define noreturn
-   _Noreturn" would cause this declaration to be rewritten to the
-   invalid "__declspec (__declspec (noreturn)) void abort (void);".
-   Instead, define noreturn to empty, so that such declarations are
-   rewritten to "__declspec () void abort (void);", which is
-   equivalent to "void abort (void);"; this gives up on noreturn's
-   advice to the compiler but at least it is valid code.  */
+#if 1200 <= _MSC_VER || defined __CYGWIN__
+/* On MSVC, standard include files contain declarations like
+     __declspec (noreturn) void abort (void);
+   "#define noreturn _Noreturn" would cause this declaration to be rewritten
+   to the invalid
+     __declspec (__declspec (noreturn)) void abort (void);
+
+   Similarly, on Cygwin, standard include files contain declarations like
+     void __cdecl abort (void) __attribute__ ((noreturn));
+   "#define noreturn _Noreturn" would cause this declaration to be rewritten
+   to the invalid
+     void __cdecl abort (void) __attribute__ ((__attribute__ ((__noreturn__))));
+
+   Instead, define noreturn to empty, so that such declarations are rewritten to
+     __declspec () void abort (void);
+   or
+     void __cdecl abort (void) __attribute__ (());
+   respectively.  This gives up on noreturn's advice to the compiler but at
+   least it is valid code.  */
 # define noreturn /*empty*/
 #else
 # define noreturn _Noreturn

+ 2 - 2
libopts/streqvcmp.c

@@ -15,7 +15,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2016 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -37,7 +37,7 @@
  * together for a case independent comparison.  The mappings are
  * based upon ascii character sequences.
  */
-static unsigned char charmap[] = {
+  static unsigned char charmap[] = {
     NUL,  0x01, 0x02, 0x03,  0x04, 0x05, 0x06, '\a',
     '\b', '\t', NL,   '\v',  '\f', '\r', 0x0E, 0x0F,
     0x10, 0x11, 0x12, 0x13,  0x14, 0x15, 0x16, 0x17,

+ 2 - 2
libopts/text_mmap.c

@@ -9,7 +9,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -189,7 +189,7 @@ validate_mmap(char const * fname, int prot, int flags, tmap_info_t * mapinfo)
 #ifdef _WIN32
             O_BINARY |
 #endif
-            ((FILE_WRITABLE(prot, flags)) ? O_RDWR : O_RDONLY);
+            FILE_WRITABLE(prot, flags) ? O_RDWR : O_RDONLY;
 
         /*
          *  If you're not sharing the file and you are writing to it,

+ 1 - 1
libopts/time.c

@@ -8,7 +8,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control

+ 1 - 18
libopts/tokenize.c

@@ -9,7 +9,7 @@
  *  This file defines the string_tokenize interface
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -28,23 +28,6 @@
  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
  */
 
-#include <errno.h>
-#include <stdlib.h>
-
-#define cc_t   const unsigned char
-#define ch_t   unsigned char
-
-/* = = = START-STATIC-FORWARD = = = */
-static void
-copy_cooked(ch_t ** ppDest, char const ** ppSrc);
-
-static void
-copy_raw(ch_t ** ppDest, char const ** ppSrc);
-
-static token_list_t *
-alloc_token_list(char const * str);
-/* = = = END-STATIC-FORWARD = = = */
-
 static void
 copy_cooked(ch_t ** ppDest, char const ** ppSrc)
 {

+ 8 - 62
libopts/usage.c

@@ -18,7 +18,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -40,61 +40,6 @@
 #define GRAPH_CH(_ch) \
     ((((unsigned)_ch) <= 0x7E) && (((unsigned)_ch) > ' '))
 
-/* = = = START-STATIC-FORWARD = = = */
-static unsigned int
-parse_usage_flags(ao_flag_names_t const * fnt, char const * txt);
-
-static inline bool
-do_gnu_usage(tOptions * pOpts);
-
-static inline bool
-skip_misuse_usage(tOptions * pOpts);
-
-static void
-print_offer_usage(tOptions * opts);
-
-static void
-print_usage_details(tOptions * opts, int exit_code);
-
-static void
-print_one_paragraph(char const * text, bool plain, FILE * fp);
-
-static void
-prt_conflicts(tOptions * opts, tOptDesc * od);
-
-static void
-prt_one_vendor(tOptions *    opts,  tOptDesc *   od,
-               arg_types_t * argtp, char const * usefmt);
-
-static void
-prt_vendor_opts(tOptions * opts, char const * title);
-
-static void
-prt_extd_usage(tOptions * opts, tOptDesc * od, char const * title);
-
-static void
-prt_ini_list(char const * const * papz, char const * ini_file,
-             char const * path_nm);
-
-static void
-prt_preamble(tOptions * opts, tOptDesc * od, arg_types_t * at);
-
-static void
-prt_one_usage(tOptions * opts, tOptDesc * od, arg_types_t * at);
-
-static void
-prt_opt_usage(tOptions * opts, int ex_code, char const * title);
-
-static void
-prt_prog_detail(tOptions * opts);
-
-static int
-setGnuOptFmts(tOptions * opts, char const ** ptxt);
-
-static int
-setStdOptFmts(tOptions * opts, char const ** ptxt);
-/* = = = END-STATIC-FORWARD = = = */
-
 /**
  * Parse the option usage flags string.  Any parsing problems yield
  * a zero (no flags set) result.  This function is internal to
@@ -154,6 +99,7 @@ parse_usage_flags(ao_flag_names_t const * fnt, char const * txt)
         case ',':
             txt = SPN_WHITESPACE_CHARS(txt + 1);
             /* Something must follow the comma */
+            /* FALLTHROUGH */
 
         default:
             continue;
@@ -170,7 +116,7 @@ parse_usage_flags(ao_flag_names_t const * fnt, char const * txt)
  *                      environment variable is parsed.
  * @param[in,out] opts  the program option descriptor
  */
-LOCAL void
+static void
 set_usage_flags(tOptions * opts, char const * flg_txt)
 {
 #   define _aof_(_n, _f)   { sizeof(#_n)-1, _f, #_n },
@@ -307,7 +253,7 @@ print_offer_usage(tOptions * opts)
             help[0] = help[1] = '-';
             strncpy(help + 2, od->pz_Name, 20);
             break;
-        
+
         case 0:
             strncpy(help, od->pz_Name, 20);
             break;
@@ -323,7 +269,7 @@ print_offer_usage(tOptions * opts)
         case (OPTPROC_LONGOPT | OPTPROC_SHORTOPT):
             strcpy(help, "--help");
             break;
-        
+
         case 0:
             strcpy(help, "help");
             break;
@@ -441,7 +387,7 @@ print_one_paragraph(char const * text, bool plain, FILE * fp)
         AGFREE(t);
     }
 }
- 
+
 /*=export_func  optionPrintParagraphs
  * private:
  *
@@ -568,7 +514,7 @@ optionPrintParagraphs(char const * text, bool plain, FILE * fp)
  *  If "exitCode" is "AO_EXIT_REQ_USAGE" (normally 64), then output will to
  *  to stdout and the actual exit code will be "EXIT_SUCCESS".
 =*/
-void
+noreturn void
 optionUsage(tOptions * opts, int usage_exit_code)
 {
     int exit_code = (usage_exit_code == AO_EXIT_REQ_USAGE)
@@ -620,7 +566,7 @@ optionUsage(tOptions * opts, int usage_exit_code)
         print_usage_details(opts, usage_exit_code);
     else
         print_offer_usage(opts);
-    
+
  flush_and_exit:
     fflush(option_usage_fp);
     if (ferror(option_usage_fp) != 0)

+ 7 - 4
libopts/version.c

@@ -10,7 +10,7 @@
 /*
  *  This file is part of AutoOpts, a companion to AutoGen.
  *  AutoOpts is free software.
- *  AutoOpts is Copyright (C) 1992-2015 by Bruce Korb - all rights reserved
+ *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
  *
  *  AutoOpts is available under any one of two licenses.  The license
  *  in use must be one of these two and the choice is under the control
@@ -90,7 +90,7 @@ emit_copy_full(tOptions * o, FILE * fp)
 
     else
         emit_first_line(fp, o->pzUsageTitle, NULL, NULL);
-    
+
     if (HAS_pzPkgDataDir(o) && (o->pzPackager != NULL)) {
         fputc(NL, fp);
         fputs(o->pzPackager, fp);
@@ -119,7 +119,7 @@ emit_copy_note(tOptions * opts, FILE * fp)
 
     fputc(NL, fp);
     fprintf(fp, zao_ver_fmt, optionVersion());
-    
+
     if (HAS_pzPkgDataDir(opts) && (opts->pzPackager != NULL)) {
         fputc(NL, fp);
         fputs(opts->pzPackager, fp);
@@ -153,7 +153,10 @@ print_ver(tOptions * opts, tOptDesc * od, FILE * fp, bool call_exit)
 
         ch = od->optArg.argString[0];
 
-    else {
+    else if (OPTST_GET_ARGTYPE(od->fOptState) == OPARG_TYPE_STATIC) {
+        ch = od->optArg.argString[0];
+
+    } else {
         set_usage_flags(opts, NULL);
         ch = (opts->fOptSet & OPTPROC_GNUUSAGE) ? 'c' : 'v';
     }

+ 11 - 5
m4/libtool.m4

@@ -1041,8 +1041,8 @@ int forced_loaded() { return 2;}
 _LT_EOF
       echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
       $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
-      echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
-      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
+      echo "$AR cr libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
+      $AR cr libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
       echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
       $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
       cat > conftest.c << _LT_EOF
@@ -1071,11 +1071,11 @@ _LT_EOF
       # to the OS version, if on x86, and 10.4, the deployment
       # target defaults to 10.4. Don't you love it?
       case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
-	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+	10.0,*86*-darwin8*|10.0,*-darwin[[912]]*)
 	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
 	10.[[012]][[,.]]*)
 	  _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
-	10.*)
+	10.*|11.*)
 	  _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
       esac
     ;;
@@ -1492,7 +1492,7 @@ need_locks=$enable_libtool_lock
 m4_defun([_LT_PROG_AR],
 [AC_CHECK_TOOLS(AR, [ar], false)
 : ${AR=ar}
-: ${AR_FLAGS=cru}
+: ${AR_FLAGS=cr}
 _LT_DECL([], [AR], [1], [The archiver])
 _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
 
@@ -4704,6 +4704,12 @@ m4_if([$1], [CXX], [
 	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
 	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
         ;;
+      # flang / f18. f95 an alias for gfortran or flang on Debian
+      flang* | f18* | f95*)
+	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
       # icc used to be incompatible with GCC.
       # ICC 10 doesn't accept -KPIC any more.
       icc* | ifort*)

+ 3 - 2
scripts/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -240,6 +240,7 @@ build_alias = @build_alias@
 build_asan = @build_asan@
 build_cpu = @build_cpu@
 build_os = @build_os@
+build_tsan = @build_tsan@
 build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@

+ 3 - 3
src/Makefile.am

@@ -41,10 +41,10 @@ tcpreplay.1: tcpreplay_opts.def
 tcpbridge.1: tcpbridge_opts.def
 	@AUTOGEN@ -T agman-cmd.tpl $(opts_list) $<
 
-tcpliveplay.1: tcpliveplay_opts.def 
+tcpliveplay.1: tcpliveplay_opts.def
 	@AUTOGEN@ -T agman-cmd.tpl $(opts_list) $<
 
-tcpcapinfo.1: tcpcapinfo_opts.def 
+tcpcapinfo.1: tcpcapinfo_opts.def
 	@AUTOGEN@ -T agman-cmd.tpl $(opts_list) $<
 
 man_MANS = tcpreplay.1 tcpprep.1 tcprewrite.1 tcpreplay-edit.1 tcpcapinfo.1
@@ -58,7 +58,7 @@ man_MANS += tcpbridge.1
 endif
 
 if COMPILE_TCPLIVEPLAY
-bin_PROGRAMS += tcpliveplay 
+bin_PROGRAMS += tcpliveplay
 man_MANS += tcpliveplay.1
 endif
 

+ 11 - 9
src/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -95,7 +95,7 @@ bin_PROGRAMS = tcpreplay$(EXEEXT) tcpprep$(EXEEXT) tcprewrite$(EXEEXT) \
 	$(am__EXEEXT_2)
 @COMPILE_TCPBRIDGE_TRUE@am__append_1 = tcpbridge 
 @COMPILE_TCPBRIDGE_TRUE@am__append_2 = tcpbridge.1
-@COMPILE_TCPLIVEPLAY_TRUE@am__append_3 = tcpliveplay 
+@COMPILE_TCPLIVEPLAY_TRUE@am__append_3 = tcpliveplay
 @COMPILE_TCPLIVEPLAY_TRUE@am__append_4 = tcpliveplay.1
 subdir = src
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -312,8 +312,8 @@ am__recursive_targets = \
   $(am__extra_recursive_targets)
 AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
 	distdir distdir-am
-am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
-	$(LISP)config.h.in
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \
+	config.h.in
 # Read a list of newline-separated strings from the standard input,
 # and print each of them once, without duplicates.  Input order is
 # *not* preserved.
@@ -476,6 +476,7 @@ build_alias = @build_alias@
 build_asan = @build_asan@
 build_cpu = @build_cpu@
 build_os = @build_os@
+build_tsan = @build_tsan@
 build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@
@@ -1384,7 +1385,8 @@ installdirs-am:
 	done
 install: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) install-recursive
-install-exec: install-exec-recursive
+install-exec: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) install-exec-recursive
 install-data: install-data-recursive
 uninstall: uninstall-recursive
 
@@ -1541,7 +1543,7 @@ uninstall-am: uninstall-binPROGRAMS uninstall-man
 uninstall-man: uninstall-man1
 
 .MAKE: $(am__recursive_targets) all check install install-am \
-	install-strip
+	install-exec install-strip
 
 .PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
 	am--depfiles check check-am clean clean-binPROGRAMS \
@@ -1583,10 +1585,10 @@ tcpreplay.1: tcpreplay_opts.def
 tcpbridge.1: tcpbridge_opts.def
 	@AUTOGEN@ -T agman-cmd.tpl $(opts_list) $<
 
-tcpliveplay.1: tcpliveplay_opts.def 
+tcpliveplay.1: tcpliveplay_opts.def
 	@AUTOGEN@ -T agman-cmd.tpl $(opts_list) $<
 
-tcpcapinfo.1: tcpcapinfo_opts.def 
+tcpcapinfo.1: tcpcapinfo_opts.def
 	@AUTOGEN@ -T agman-cmd.tpl $(opts_list) $<
 tcpreplay_edit_OBJECTS: tcpreplay_opts.h
 tcpreplay_edit_opts.h: tcpreplay_edit_opts.c

+ 56 - 95
src/bridge.c

@@ -2,11 +2,11 @@
 
 /*
  *   Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
- *   Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
+ *   Copyright (c) 2013-2024 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  *
- *   The Tcpreplay Suite of tools 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 
+ *   The Tcpreplay Suite of tools 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 with the authors permission any later version.
  *
  *   The Tcpreplay Suite is distributed in the hope that it will be useful,
@@ -18,27 +18,17 @@
  *   along with the Tcpreplay Suite.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "bridge.h"
 #include "config.h"
-#include "defines.h"
 #include "common.h"
-
-#include <sys/time.h>
-#include <signal.h>
-#include <string.h>
-#include <netinet/in.h>
-#include <time.h>
+#include "tcpbridge.h"
 #include <errno.h>
+#include <signal.h>
 #include <stdlib.h>
+#include <string.h>
+#include <sys/time.h>
 
-#include "tcpbridge.h"
-#include "bridge.h"
-#include "tcpedit/tcpedit.h"
-
-extern tcpbridge_opt_t options;
 extern tcpreplay_stats_t stats;
-#ifdef DEBUG
-extern int debug;
-#endif
 volatile bool didsig;
 
 static void live_callback(u_char *, const struct pcap_pkthdr *, const u_char *);
@@ -64,15 +54,6 @@ RB_PROTOTYPE(macsrc_tree, macsrc_t, node, rbmacsrc_comp)
 RB_GENERATE(macsrc_tree, macsrc_t, node, rbmacsrc_comp)
 
 /**
- * redblack init
- */
-void
-rbinit(void)
-{
-    RB_INIT(&macsrc_root);
-}
-
-/**
  * create a new node... Malloc's memory
  */
 struct macsrc_t *
@@ -86,7 +67,6 @@ new_node(void)
     return (node);
 }
 
-
 /**
  * main loop for bridging in only one direction
  * optimized to not use poll(), but rather libpcap's builtin pcap_loop()
@@ -105,9 +85,8 @@ do_bridge_unidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
     livedata.pcap = options->pcap1;
     livedata.options = options;
 
-    if ((retcode = pcap_loop(options->pcap1, options->limit_send,
-            live_callback, (u_char*)&livedata)) < 0) {
-        warnx("Error in pcap_loop(): %s", pcap_geterr(options->pcap1));
+    if ((retcode = pcap_loop(options->pcap1, (int)options->limit_send, live_callback, (u_char *)&livedata)) < 0) {
+        warnx("Error in %d pcap_loop(): %s", retcode, pcap_geterr(options->pcap1));
     }
 }
 
@@ -118,7 +97,7 @@ do_bridge_unidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
 static void
 do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
 {
-    struct pollfd polls[2];     /* one for left & right pcap */
+    struct pollfd polls[2]; /* one for left & right pcap */
     int pollresult, pollcount, timeout;
     struct live_data_t livedata;
 
@@ -128,8 +107,7 @@ do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
     livedata.tcpedit = tcpedit;
     livedata.options = options;
 
-
-    /* 
+    /*
      * loop until ctrl-C or we've sent enough packets
      * note that if -L wasn't specified, limit_send is
      * set to 0 so this will loop infinately
@@ -138,8 +116,7 @@ do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
         if (didsig)
             break;
 
-        dbgx(3, "limit_send: " COUNTER_SPEC " \t pkts_sent: " COUNTER_SPEC, 
-            options->limit_send, stats.pkts_sent);
+        dbgx(3, "limit_send: " COUNTER_SPEC " \t pkts_sent: " COUNTER_SPEC, options->limit_send, stats.pkts_sent);
 
         /* reset the result codes */
         polls[PCAP_INT1].revents = 0;
@@ -165,8 +142,7 @@ do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
                 dbg(5, "Processing first interface");
                 livedata.source = PCAP_INT1;
                 livedata.pcap = options->pcap1;
-                pcap_dispatch(options->pcap1, -1, (pcap_handler) live_callback,
-                              (u_char *) &livedata);
+                pcap_dispatch(options->pcap1, -1, (pcap_handler)live_callback, (u_char *)&livedata);
             }
 
             /* check the other interface?? */
@@ -174,16 +150,13 @@ do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
                 dbg(5, "Processing second interface");
                 livedata.source = PCAP_INT2;
                 livedata.pcap = options->pcap2;
-                pcap_dispatch(options->pcap2, -1, (pcap_handler) live_callback,
-                              (u_char *) &livedata);
+                pcap_dispatch(options->pcap2, -1, (pcap_handler)live_callback, (u_char *)&livedata);
             }
 
-        }
-        else if (pollresult == 0) {
+        } else if (pollresult == 0) {
             dbg(3, "poll timeout exceeded...");
             /* do something here? */
-        }
-        else {
+        } else {
             /* poll error, probably a Ctrl-C */
             warnx("poll() error: %s", strerror(errno));
         }
@@ -193,9 +166,8 @@ do_bridge_bidirectional(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
 
 } /* do_bridge_bidirectional() */
 
-
 /**
- * Main entry point to bridging.  Does some initial setup and then calls the 
+ * Main entry point to bridging.  Does some initial setup and then calls the
  * correct loop (unidirectional or bidirectional)
  */
 void
@@ -217,7 +189,8 @@ do_bridge(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
         if (options->unidir == 0) {
             /* compile filter */
             dbgx(2, "Try to compile pcap bpf filter: %s", options->bpf.filter);
-            if (pcap_compile(options->pcap2, &options->bpf.program, options->bpf.filter, options->bpf.optimize, 0) != 0) {
+            if (pcap_compile(options->pcap2, &options->bpf.program, options->bpf.filter, options->bpf.optimize, 0) !=
+                0) {
                 errx(-1, "Error compiling BPF filter: %s", pcap_geterr(options->pcap2));
             }
 
@@ -231,38 +204,35 @@ do_bridge(tcpbridge_opt_t *options, tcpedit_t *tcpedit)
     didsig = 0;
     (void)signal(SIGINT, signal_catcher);
 
-
     if (options->unidir == 1) {
         do_bridge_unidirectional(options, tcpedit);
     } else {
         do_bridge_bidirectional(options, tcpedit);
     }
 
-    if (gettimeofday(&stats.end_time, NULL) < 0)
-        errx(-1, "gettimeofday() failed: %s",  strerror(errno));
+    if (get_current_time(&stats.end_time) < 0)
+        errx(-1, "get_current_time() failed: %s", strerror(errno));
     packet_stats(&stats);
 }
 
-
 /**
  * This is the callback we use with pcap_dispatch to process
  * each packet received by libpcap on the two interfaces.
  * Need to return > 0 to denote success
  */
 static void
-live_callback(u_char *usr_data, const struct pcap_pkthdr *const_pkthdr,
-              const u_char * nextpkt)
+live_callback(u_char *usr_data, const struct pcap_pkthdr *const_pkthdr, const u_char *nextpkt)
 {
-    struct live_data_t *livedata = (struct live_data_t*)usr_data;
+    struct live_data_t *livedata = (struct live_data_t *)usr_data;
     struct pcap_pkthdr pkthdr_buf = *const_pkthdr;
     struct pcap_pkthdr *pkthdr = &pkthdr_buf;
     ipv4_hdr_t *ip_hdr = NULL;
     ipv6_hdr_t *ip6_hdr = NULL;
     pcap_t *send = NULL;
-    static u_char *pktdata = NULL;     /* full packet buffer */
-    int cache_mode, retcode;
+    static u_char *pktdata = NULL; /* full packet buffer */
+    int cache_mode;
     static unsigned long packetnum = 0;
-    struct macsrc_t *node, finder;  /* rb tree nodes */
+    struct macsrc_t *node, finder; /* rb tree nodes */
 #ifdef DEBUG
     u_char dstmac[ETHER_ADDR_LEN];
 #endif
@@ -283,28 +253,24 @@ live_callback(u_char *usr_data, const struct pcap_pkthdr *const_pkthdr,
     /* copy the packet to our buffer */
     memcpy(pktdata, nextpkt, pkthdr->caplen);
 
-
 #ifdef ENABLE_VERBOSE
     /* decode packet? */
     if (livedata->options->verbose)
         tcpdump_print(livedata->options->tcpdump, pkthdr, nextpkt);
 #endif
 
-
     /* lookup our source MAC in the tree */
     memcpy(&finder.key, &pktdata[ETHER_ADDR_LEN], ETHER_ADDR_LEN);
 #ifdef DEBUG
     memcpy(&dstmac, pktdata, ETHER_ADDR_LEN);
-    dbgx(1, "SRC MAC: " MAC_FORMAT "\tDST MAC: " MAC_FORMAT,
-        MAC_STR(finder.key), MAC_STR(dstmac));
+    dbgx(1, "SRC MAC: " MAC_FORMAT "\tDST MAC: " MAC_FORMAT, MAC_STR(finder.key), MAC_STR(dstmac));
 #endif
 
     /* first, is this a packet sent locally?  If so, ignore it */
     if ((memcmp(livedata->options->intf1_mac, &finder.key, ETHER_ADDR_LEN)) == 0) {
         dbgx(1, "Packet matches the MAC of %s, skipping.", livedata->options->intf1);
         return;
-    }
-    else if ((memcmp(livedata->options->intf2_mac, &finder.key, ETHER_ADDR_LEN)) == 0) {
+    } else if ((memcmp(livedata->options->intf2_mac, &finder.key, ETHER_ADDR_LEN)) == 0) {
         dbgx(1, "Packet matches the MAC of %s, skipping.", livedata->options->intf2);
         return;
     }
@@ -333,27 +299,25 @@ live_callback(u_char *usr_data, const struct pcap_pkthdr *const_pkthdr,
     /* what is our cache mode? */
     cache_mode = livedata->source == PCAP_INT1 ? TCPR_DIR_C2S : TCPR_DIR_S2C;
 
-    l2proto = tcpedit_l3proto(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len);
+    l2proto = tcpedit_l3proto(livedata->tcpedit, BEFORE_PROCESS, pktdata, (int)pkthdr->len);
     dbgx(2, "Packet protocol: %04hx", l2proto);
 
     /* should we skip this packet based on CIDR match? */
     if (l2proto == ETHERTYPE_IP) {
         dbg(3, "Packet is IPv4");
-        ip_hdr = (ipv4_hdr_t *)tcpedit_l3data(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len);
+        ip_hdr = (ipv4_hdr_t *)tcpedit_l3data(livedata->tcpedit, BEFORE_PROCESS, pktdata, (int)pkthdr->len);
 
         /* look for include or exclude CIDR match */
         if (livedata->options->xX.cidr != NULL) {
-            if (!ip_hdr ||
-                    !process_xX_by_cidr_ipv4(livedata->options->xX.mode, livedata->options->xX.cidr, ip_hdr)) {
+            if (!ip_hdr || !process_xX_by_cidr_ipv4(livedata->options->xX.mode, livedata->options->xX.cidr, ip_hdr)) {
                 dbg(2, "Skipping IPv4 packet due to CIDR match");
                 return;
             }
         }
 
-    }
-    else if (l2proto == ETHERTYPE_IP6) {
+    } else if (l2proto == ETHERTYPE_IP6) {
         dbg(3, "Packet is IPv6");
-        ip6_hdr = (ipv6_hdr_t *)tcpedit_l3data(livedata->tcpedit, BEFORE_PROCESS, pktdata, pkthdr->len);
+        ip6_hdr = (ipv6_hdr_t *)tcpedit_l3data(livedata->tcpedit, BEFORE_PROCESS, pktdata, (int)pkthdr->len);
 
         /* look for include or exclude CIDR match */
         if (livedata->options->xX.cidr != NULL) {
@@ -362,40 +326,38 @@ live_callback(u_char *usr_data, const struct pcap_pkthdr *const_pkthdr,
                 return;
             }
         }
-
     }
 
-    if ((retcode = tcpedit_packet(livedata->tcpedit, &pkthdr, &pktdata, cache_mode)) < 0)
+    if (tcpedit_packet(livedata->tcpedit, &pkthdr, &pktdata, cache_mode) < 0)
         return;
 
-    /* 
+    /*
      * send packets out the OTHER interface
      * and update the dst mac if necessary
      */
-    switch(node->source) {
-        case PCAP_INT1:
-            dbgx(2, "Packet source was %s... sending out on %s", livedata->options->intf1, 
-                livedata->options->intf2);
-            send = livedata->options->pcap2;
-            break;
-
-        case PCAP_INT2:
-            dbgx(2, "Packet source was %s... sending out on %s", livedata->options->intf2, 
-                livedata->options->intf1);
-            send = livedata->options->pcap1;
-            break;
-
-        default:
-            errx(-1, "wtf?  our node->source != PCAP_INT1 and != PCAP_INT2: %c", 
-                 node->source);
+    switch (node->source) {
+    case PCAP_INT1:
+        dbgx(2, "Packet source was %s... sending out on %s", livedata->options->intf1, livedata->options->intf2);
+        send = livedata->options->pcap2;
+        break;
+
+    case PCAP_INT2:
+        dbgx(2, "Packet source was %s... sending out on %s", livedata->options->intf2, livedata->options->intf1);
+        send = livedata->options->pcap1;
+        break;
+
+    default:
+        errx(-1, "wtf?  our node->source != PCAP_INT1 and != PCAP_INT2: %c", node->source);
     }
 
     /*
-     * write packet out on the network 
+     * write packet out on the network
      */
-     if (pcap_sendpacket(send, pktdata, pkthdr->caplen) < 0)
-         errx(-1, "Unable to send packet out %s: %s", 
-            send == livedata->options->pcap1 ? livedata->options->intf1 : livedata->options->intf2, pcap_geterr(send));
+    if (pcap_sendpacket(send, pktdata, (int)pkthdr->caplen) < 0)
+        errx(-1,
+             "Unable to send packet out %s: %s",
+             send == livedata->options->pcap1 ? livedata->options->intf1 : livedata->options->intf2,
+             pcap_geterr(send));
 
     stats.bytes_sent += pkthdr->caplen;
     stats.pkts_sent++;
@@ -409,5 +371,4 @@ signal_catcher(int signo)
     /* stdio in signal handlers causes a race condition, instead set a flag */
     if (signo == SIGINT)
         didsig = true;
-
 }

+ 11 - 15
src/bridge.h

@@ -2,11 +2,11 @@
 
 /*
  *   Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
- *   Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
+ *   Copyright (c) 2013-2024 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  *
- *   The Tcpreplay Suite of tools 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 
+ *   The Tcpreplay Suite of tools 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 with the authors permission any later version.
  *
  *   The Tcpreplay Suite is distributed in the hope that it will be useful,
@@ -18,23 +18,22 @@
  *   along with the Tcpreplay Suite.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-
-#ifndef __BRIDGE_H__
-#define __BRIDGE_H__
+#pragma once
 
 #include "config.h"
-#include "lib/tree.h"
-#include "tcpedit/tcpedit.h"
+#include "tcpbridge.h"
+#include <lib/tree.h>
+#include <tcpedit/tcpedit.h>
 
 /*
- * RBTree node object for tracking which side of tcpreplay where 
+ * RBTree node object for tracking which side of tcpreplay where
  * each source MAC address lives
  */
 struct macsrc_t {
     RB_ENTRY(macsrc_t) node;
     u_char key[ETHER_ADDR_LEN];
-    u_char source;              /* interface device name we first saw the source MAC */
-    sendpacket_t *sp;           /* sendpacket handle to send packets out */
+    u_char source;    /* interface device name we first saw the source MAC */
+    sendpacket_t *sp; /* sendpacket handle to send packets out */
 };
 
 /* pri and secondary pcap interfaces */
@@ -55,6 +54,3 @@ struct live_data_t {
 
 void rbinit(void);
 void do_bridge(tcpbridge_opt_t *, tcpedit_t *);
-
-
-#endif

+ 24 - 28
src/common.h

@@ -2,11 +2,11 @@
 
 /*
  *   Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
- *   Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
+ *   Copyright (c) 2013-2024 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  *
- *   The Tcpreplay Suite of tools 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 
+ *   The Tcpreplay Suite of tools 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 with the authors permission any later version.
  *
  *   The Tcpreplay Suite is distributed in the hope that it will be useful,
@@ -18,40 +18,36 @@
  *   along with the Tcpreplay Suite.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#pragma once
 
-#ifndef __COMMON_H__
-#define __COMMON_H__
-#include <assert.h>
 #include "config.h"
+#include <assert.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#include "common/pcap_dlt.h"
-#include "common/cache.h"
-#include "common/cidr.h"
-#include "common/err.h"
-#include "common/get.h"
-#include "common/fakepcap.h"
-#include "common/fakepcapnav.h"
-#include "common/fakepoll.h"
-#include "common/list.h"
-#include "common/mac.h"
-#include "common/services.h"
-#include "common/utils.h"
-#include "common/xX.h"
-#include "common/tcpdump.h"
-#include "common/timer.h"
-#include "common/sendpacket.h"
-#include "common/interface.h"
-#include "common/flows.h"
+#include <common/cache.h>
+#include <common/cidr.h>
+#include <common/err.h>
+#include <common/fakepcap.h>
+#include <common/fakepcapnav.h>
+#include <common/fakepoll.h>
+#include <common/flows.h>
+#include <common/get.h>
+#include <common/interface.h>
+#include <common/list.h>
+#include <common/mac.h>
+#include <common/pcap_dlt.h>
+#include <common/sendpacket.h>
+#include <common/services.h>
+#include <common/tcpdump.h>
+#include <common/timer.h>
+#include <common/utils.h>
+#include <common/xX.h>
 
 const char *git_version(void); /* git_version.c */
 
 #ifdef __cplusplus
 }
 #endif
-
-#endif
-

+ 6 - 4
src/common/Makefile.in

@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.16.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.3 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994-2018 Free Software Foundation, Inc.
+# Copyright (C) 1994-2020 Free Software Foundation, Inc.
 
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -322,6 +322,7 @@ build_alias = @build_alias@
 build_asan = @build_asan@
 build_cpu = @build_cpu@
 build_os = @build_os@
+build_tsan = @build_tsan@
 build_vendor = @build_vendor@
 builddir = @builddir@
 datadir = @datadir@
@@ -590,7 +591,8 @@ all-am: Makefile $(LIBRARIES) $(HEADERS)
 installdirs:
 install: $(BUILT_SOURCES)
 	$(MAKE) $(AM_MAKEFLAGS) install-am
-install-exec: install-exec-am
+install-exec: $(BUILT_SOURCES)
+	$(MAKE) $(AM_MAKEFLAGS) install-exec-am
 install-data: install-data-am
 uninstall: uninstall-am
 
@@ -733,7 +735,7 @@ ps-am:
 
 uninstall-am:
 
-.MAKE: all check install install-am install-strip
+.MAKE: all check install install-am install-exec install-strip
 
 .PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
 	clean-generic clean-libtool clean-noinstLIBRARIES \

+ 63 - 77
src/common/cache.c

@@ -2,11 +2,11 @@
 
 /*
  *   Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
- *   Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
+ *   Copyright (c) 2013-2024 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  *
- *   The Tcpreplay Suite of tools 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 
+ *   The Tcpreplay Suite of tools 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 with the authors permission any later version.
  *
  *   The Tcpreplay Suite is distributed in the hope that it will be useful,
@@ -18,23 +18,16 @@
  *   along with the Tcpreplay Suite.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "config.h"
 #include "defines.h"
+#include "config.h"
 #include "common.h"
-
-
+#include <errno.h>
 #include <fcntl.h>
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
-#include <sys/stat.h>
 #include <unistd.h>
-#include <errno.h>
-
-#ifdef DEBUG
-extern int debug;
-#endif
 
 static tcpr_cache_t *new_cache(void);
 
@@ -44,8 +37,9 @@ static tcpr_cache_t *new_cache(void);
  */
 #ifdef DEBUG
 static char *
-byte2bits(char byte, char *bitstring) {
-    int i = 1, j = 7;
+byte2bits(char byte, char *bitstring)
+{
+    int i, j = 7;
 
     for (i = 1; i <= 255; i = i << 1) {
         if (byte & i)
@@ -61,7 +55,7 @@ byte2bits(char byte, char *bitstring) {
  * simple function to read in a cache file created with tcpprep this let's us
  * be really damn fast in picking an interface to send the packet out returns
  * number of cache entries read
- * 
+ *
  * now also checks for the cache magic and version
  */
 
@@ -70,8 +64,8 @@ read_cache(char **cachedata, const char *cachefile, char **comment)
 {
     int cachefd;
     tcpr_cache_file_hdr_t header;
-    ssize_t read_size = 0;
-    COUNTER cache_size = 0;
+    ssize_t read_size;
+    COUNTER cache_size;
 
     assert(cachedata);
     assert(comment);
@@ -92,50 +86,48 @@ read_cache(char **cachedata, const char *cachefile, char **comment)
         errx(-1, "Unable to process %s: not a tcpprep cache file", cachefile);
 
     /* verify version */
-    if (atoi(header.version) != atoi(CACHEVERSION))
-        errx(-1, "Unable to process %s: cache file version mismatch",
-             cachefile);
+    if (strtol(header.version, NULL, 10) != strtol(CACHEVERSION, NULL, 10))
+        errx(-1, "Unable to process %s: cache file version mismatch", cachefile);
 
     /* read the comment */
     header.comment_len = ntohs(header.comment_len);
     if (header.comment_len > 65534)
-        errx(-1, "Unable to process %s: invalid comment length %u",
-                cachefile, header.comment_len);
+        errx(-1, "Unable to process %s: invalid comment length %u", cachefile, header.comment_len);
 
     *comment = (char *)safe_malloc(header.comment_len + 1);
 
     dbgx(1, "Comment length: %d", header.comment_len);
-    
+
     if ((read_size = read(cachefd, *comment, header.comment_len)) < 0)
         errx(-1, "Error reading comment: %s", strerror(errno));
 
     if (read_size != (ssize_t)header.comment_len)
-        errx(-1, "Invalid comment read: expected=%u actual=%zd bytes",
-            header.comment_len, read_size);
+        errx(-1, "Invalid comment read: expected=%u actual=%zd bytes", header.comment_len, read_size);
 
     dbgx(1, "Cache file comment: %s", *comment);
 
     /* malloc our cache block */
     header.num_packets = ntohll(header.num_packets);
-    header.packets_per_byte = ntohs(header.packets_per_byte);    
+    header.packets_per_byte = ntohs(header.packets_per_byte);
     cache_size = header.num_packets / header.packets_per_byte;
-        
+
     /* deal with any remainder, because above division is integer */
     if (header.num_packets % header.packets_per_byte)
-      cache_size ++;
+        cache_size++;
 
-    dbgx(1, "Cache file contains %" PRIu64 " packets in " COUNTER_SPEC " bytes",
-        header.num_packets, cache_size);
+    dbgx(1, "Cache file contains %" PRIu64 " packets in " COUNTER_SPEC " bytes", header.num_packets, cache_size);
 
     dbgx(1, "Cache uses %d packets per byte", header.packets_per_byte);
 
     *cachedata = (char *)safe_malloc(cache_size);
 
     /* read in the cache */
-    if ((COUNTER)(read_size = read(cachefd, *cachedata, cache_size)) 
-            != cache_size)
-        errx(-1, "Cache data length (%zu bytes) doesn't match "
-            "cache header (" COUNTER_SPEC " bytes)", read_size, cache_size);
+    if ((COUNTER)(read_size = read(cachefd, *cachedata, cache_size)) != cache_size)
+        errx(-1,
+             "Cache data length (%zu bytes) doesn't match "
+             "cache header (" COUNTER_SPEC " bytes)",
+             read_size,
+             cache_size);
 
     dbgx(1, "Loaded in %" PRIu64 " packets from cache.", header.num_packets);
 
@@ -143,29 +135,26 @@ read_cache(char **cachedata, const char *cachefile, char **comment)
     return (header.num_packets);
 }
 
-
 /**
  * writes out the cache file header, comment and then the
- * contents of *cachedata to out_file and then returns the number 
+ * contents of *cachedata to out_file and then returns the number
  * of cache entries written
  */
 COUNTER
-write_cache(tcpr_cache_t * cachedata, const int out_file, COUNTER numpackets, 
-    char *comment)
+write_cache(tcpr_cache_t *cachedata, const int out_file, COUNTER numpackets, char *comment)
 {
     tcpr_cache_t *mycache = NULL;
     tcpr_cache_file_hdr_t *cache_header = NULL;
     uint32_t chars, last = 0;
     COUNTER packets = 0;
-    ssize_t written = 0;
+    ssize_t written;
 
     assert(out_file);
 
     /* write a header to our file */
-    cache_header = (tcpr_cache_file_hdr_t *)
-        safe_malloc(sizeof(tcpr_cache_file_hdr_t));
-    strncpy(cache_header->magic, CACHEMAGIC, strlen(CACHEMAGIC)+1);
-    strncpy(cache_header->version, CACHEVERSION, strlen(CACHEVERSION)+1);
+    cache_header = (tcpr_cache_file_hdr_t *)safe_malloc(sizeof(tcpr_cache_file_hdr_t));
+    strncpy(cache_header->magic, CACHEMAGIC, strlen(CACHEMAGIC) + 1);
+    strncpy(cache_header->version, CACHEVERSION, strlen(CACHEVERSION) + 1);
     cache_header->packets_per_byte = htons(CACHE_PACKETS_PER_BYTE);
     cache_header->num_packets = htonll((u_int64_t)numpackets);
 
@@ -180,18 +169,22 @@ write_cache(tcpr_cache_t * cachedata, const int out_file, COUNTER numpackets,
     dbgx(1, "Wrote %zu bytes of cache file header", written);
 
     if (written != sizeof(tcpr_cache_file_hdr_t))
-        errx(-1, "Only wrote %zu of %zu bytes of the cache file header!\n%s",
-             written, sizeof(tcpr_cache_file_hdr_t),
+        errx(-1,
+             "Only wrote %zu of %zu bytes of the cache file header!\n%s",
+             written,
+             sizeof(tcpr_cache_file_hdr_t),
              written == -1 ? strerror(errno) : "");
 
     /* don't write comment if there is none */
     if (comment != NULL) {
         written = write(out_file, comment, strlen(comment));
         dbgx(1, "Wrote %zu bytes of comment", written);
-        
+
         if (written != (ssize_t)strlen(comment))
-            errx(-1, "Only wrote %zu of %zu bytes of the comment!\n%s",
-                 written, strlen(comment), 
+            errx(-1,
+                 "Only wrote %zu of %zu bytes of the comment!\n%s",
+                 written,
+                 strlen(comment),
                  written == -1 ? strerror(errno) : "");
     }
 
@@ -206,8 +199,7 @@ write_cache(tcpr_cache_t * cachedata, const int out_file, COUNTER numpackets,
             chars = mycache->packets / CACHE_PACKETS_PER_BYTE;
             if (mycache->packets % CACHE_PACKETS_PER_BYTE) {
                 chars++;
-                dbgx(1, "Bumping up to the next byte: %d %% %d", mycache->packets,
-                        CACHE_PACKETS_PER_BYTE);
+                dbgx(1, "Bumping up to the next byte: %d %% %d", mycache->packets, CACHE_PACKETS_PER_BYTE);
             }
 
             /* write to file, and verify it wrote properly */
@@ -222,8 +214,7 @@ write_cache(tcpr_cache_t * cachedata, const int out_file, COUNTER numpackets,
              */
             if (mycache->next != NULL) {
                 mycache = mycache->next;
-            }
-            else {
+            } else {
                 last = 1;
             }
         }
@@ -252,10 +243,10 @@ new_cache(void)
  */
 
 tcpr_dir_t
-add_cache(tcpr_cache_t ** cachedata, const int send, const tcpr_dir_t interface)
+add_cache(tcpr_cache_t **cachedata, const int send, const tcpr_dir_t interface)
 {
     static tcpr_cache_t *lastcache = NULL;
-    tcpr_dir_t result = TCPR_DIR_ERROR;
+    tcpr_dir_t result;
 #ifdef DEBUG
     char bitstring[9] = EIGHT_ZEROS;
 #endif
@@ -266,8 +257,7 @@ add_cache(tcpr_cache_t ** cachedata, const int send, const tcpr_dir_t interface)
     if (*cachedata == NULL || lastcache == NULL) {
         *cachedata = new_cache();
         lastcache = *cachedata;
-    }
-    else {
+    } else {
         /* check to see if this is the last bit in this struct */
         if ((lastcache->packets + 1) > (CACHEDATASIZE * CACHE_PACKETS_PER_BYTE)) {
             /*
@@ -290,12 +280,11 @@ add_cache(tcpr_cache_t ** cachedata, const int send, const tcpr_dir_t interface)
         u_char *byte;
 
         index = (lastcache->packets - 1) / (COUNTER)CACHE_PACKETS_PER_BYTE;
-        bit = (((lastcache->packets - 1) % (COUNTER)CACHE_PACKETS_PER_BYTE) * 
-               (COUNTER)CACHE_BITS_PER_PACKET) + 1;
+        bit = (((lastcache->packets - 1) % (COUNTER)CACHE_PACKETS_PER_BYTE) * (COUNTER)CACHE_BITS_PER_PACKET) + 1;
         dbgx(3, "Bit: %d", bit);
 
-        byte = (u_char *) & lastcache->data[index];
-        *byte += (u_char) (1 << bit);
+        byte = (u_char *)&lastcache->data[index];
+        *byte += (u_char)(1 << bit);
 
         dbgx(2, "set send bit: byte " COUNTER_SPEC " = 0x%x", index, *byte);
 
@@ -305,19 +294,17 @@ add_cache(tcpr_cache_t ** cachedata, const int send, const tcpr_dir_t interface)
 
             dbgx(2, "set interface bit: byte " COUNTER_SPEC " = 0x%x", index, *byte);
             result = TCPR_DIR_C2S;
-        }
-        else {
+        } else {
             dbgx(2, "don't set interface bit: byte " COUNTER_SPEC " = 0x%x", index, *byte);
             result = TCPR_DIR_S2C;
         }
 
 #ifdef DEBUG
-        /* 
+        /*
          * only build the byte string when not in debug mode since
          * the calculation is a bit expensive
          */
-        dbgx(3, "Current cache byte: %c%c%c%c%c%c%c%c",
-            BIT_STR(byte2bits(*byte, bitstring)));
+        dbgx(3, "Current cache byte: %c%c%c%c%c%c%c%c", BIT_STR(byte2bits(*byte, bitstring)));
 #endif
     } else {
         dbg(1, "not setting send bit");
@@ -327,14 +314,13 @@ add_cache(tcpr_cache_t ** cachedata, const int send, const tcpr_dir_t interface)
     return result;
 }
 
-
 /**
  * returns the action for a given packet based on the CACHE
  */
 tcpr_dir_t
 check_cache(char *cachedata, COUNTER packetid)
 {
-    COUNTER index = 0;
+    COUNTER index;
     uint32_t bit;
 
     assert(cachedata);
@@ -343,12 +329,15 @@ check_cache(char *cachedata, COUNTER packetid)
         err(-1, "packetid must be > 0");
 
     index = (packetid - 1) / (COUNTER)CACHE_PACKETS_PER_BYTE;
-    bit = (uint32_t)(((packetid - 1) % (COUNTER)CACHE_PACKETS_PER_BYTE) * 
-        (COUNTER)CACHE_BITS_PER_PACKET) + 1;
+    bit = (uint32_t)(((packetid - 1) % (COUNTER)CACHE_PACKETS_PER_BYTE) * (COUNTER)CACHE_BITS_PER_PACKET) + 1;
 
 #ifdef DEBUG
-    dbgx(3, "Index: " COUNTER_SPEC "\tBit: %d\tByte: %hhu\tMask: %hhu", index, bit,
-        cachedata[index], (uint8_t)(cachedata[index] & (char)(1 << bit)));
+    dbgx(3,
+         "Index: " COUNTER_SPEC "\tBit: %d\tByte: %hhu\tMask: %hhu",
+         index,
+         bit,
+         cachedata[index],
+         (uint8_t)(cachedata[index] & (char)(1 << bit)));
 #endif
 
     if (!(cachedata[index] & (char)(1 << bit))) {
@@ -359,10 +348,7 @@ check_cache(char *cachedata, COUNTER packetid)
     bit--;
     if (cachedata[index] & (char)(1 << bit)) {
         return TCPR_DIR_C2S;
-    }
-    else {
+    } else {
         return TCPR_DIR_S2C;
     }
-
-    return TCPR_DIR_ERROR;
 }

+ 4 - 5
src/common/cache.h

@@ -2,7 +2,7 @@
 
 /*
  *   Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
- *   Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
+ *   Copyright (c) 2013-2024 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  *
  *   The Tcpreplay Suite of tools is free software: you can redistribute it 
  *   and/or modify it under the terms of the GNU General Public License as 
@@ -18,8 +18,9 @@
  *   along with the Tcpreplay Suite.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef __CACHE_H__
-#define __CACHE_H__
+#pragma once
+
+#include "defines.h"
 
 #define CACHEMAGIC "tcpprep"
 #define CACHEVERSION "04"
@@ -99,5 +100,3 @@ tcpr_dir_t check_cache(char *, COUNTER);
 
 /* string of 8 zeros */
 #define EIGHT_ZEROS "\060\060\060\060\060\060\060\060"
-
-#endif

+ 70 - 165
src/common/cidr.c

@@ -2,11 +2,11 @@
 
 /*
  *   Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
- *   Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
+ *   Copyright (c) 2013-2024 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  *
- *   The Tcpreplay Suite of tools 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 
+ *   The Tcpreplay Suite of tools 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 with the authors permission any later version.
  *
  *   The Tcpreplay Suite is distributed in the hope that it will be useful,
@@ -18,22 +18,15 @@
  *   along with the Tcpreplay Suite.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "config.h"
 #include "defines.h"
+#include "config.h"
 #include "common.h"
-
+#include <arpa/inet.h>
+#include <netinet/in.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-/* required for inet_aton() */
 #include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-
-#ifdef DEBUG
-extern int debug;
-#endif
 
 static tcpr_cidr_t *cidr2cidr(char *);
 
@@ -41,7 +34,7 @@ static tcpr_cidr_t *cidr2cidr(char *);
  * prints to the given fd all the entries in mycidr
  */
 void
-print_cidr(tcpr_cidr_t * mycidr)
+print_cidr(tcpr_cidr_t *mycidr)
 {
     tcpr_cidr_t *cidr_ptr;
 
@@ -50,14 +43,12 @@ print_cidr(tcpr_cidr_t * mycidr)
     cidr_ptr = mycidr;
     while (cidr_ptr != NULL) {
         /* print it */
-        fprintf(stderr, "%s/%d, ", get_cidr2name(cidr_ptr, RESOLVE),
-                cidr_ptr->masklen);
+        fprintf(stderr, "%s/%d, ", get_cidr2name(cidr_ptr, RESOLVE), cidr_ptr->masklen);
 
         /* go to the next */
         if (cidr_ptr->next != NULL) {
             cidr_ptr = cidr_ptr->next;
-        }
-        else {
+        } else {
             break;
         }
     }
@@ -68,24 +59,21 @@ print_cidr(tcpr_cidr_t * mycidr)
  * deletes all entries in a cidr and destroys the datastructure
  */
 void
-destroy_cidr(tcpr_cidr_t * cidr)
+destroy_cidr(tcpr_cidr_t *cidr)
 {
-
     if (cidr != NULL) {
         if (cidr->next != NULL)
             destroy_cidr(cidr->next);
 
         safe_free(cidr);
     }
-    return;
-
 }
 
 /**
  * adds a new tcpr_cidr_t entry to cidrdata
  */
 void
-add_cidr(tcpr_cidr_t ** cidrdata, tcpr_cidr_t ** newcidr)
+add_cidr(tcpr_cidr_t **cidrdata, tcpr_cidr_t **newcidr)
 {
     tcpr_cidr_t *cidr_ptr;
     dbg(1, "Running new_cidr()");
@@ -103,30 +91,6 @@ add_cidr(tcpr_cidr_t ** cidrdata, tcpr_cidr_t ** newcidr)
 }
 
 /**
- * takes in an IP and masklen, and returns a string in
- * cidr format: x.x.x.x/y.  This malloc's memory.
- */
-u_char *
-ip2cidr(const unsigned long ip, const int masklen)
-{
-    u_char *network;
-    char mask[32];
-
-    network = (u_char *)safe_malloc(20);
-
-    strlcpy((char *)network, (char *)get_addr2name4(ip, RESOLVE), 20);
-
-    strcat((char *)network, "/");
-    snprintf(mask, sizeof(mask), "%d", masklen);
-    if (masklen < 10)
-        strncat((char *)network, mask, 1);
-    else
-        strncat((char *)network, mask, 2);
-
-    return (network);
-}
-
-/**
  * Mallocs and sets to sane defaults a tcpr_cidr_t structure
  */
 
@@ -136,7 +100,7 @@ new_cidr(void)
     tcpr_cidr_t *newcidr;
 
     newcidr = (tcpr_cidr_t *)safe_malloc(sizeof(tcpr_cidr_t));
-    
+
     memset(newcidr, '\0', sizeof(tcpr_cidr_t));
     newcidr->masklen = 99;
     newcidr->next = NULL;
@@ -153,14 +117,13 @@ new_cidr_map(void)
     tcpr_cidrmap_t *new;
 
     new = (tcpr_cidrmap_t *)safe_malloc(sizeof(tcpr_cidrmap_t));
-    
+
     memset(new, '\0', sizeof(tcpr_cidrmap_t));
     new->next = NULL;
 
     return (new);
 }
 
-
 /**
  * Converts a single cidr (string) in the form of x.x.x.x/y into a
  * tcpr_cidr_t structure.  Will malloc the tcpr_cidr_t structure.
@@ -168,12 +131,12 @@ new_cidr_map(void)
 static tcpr_cidr_t *
 cidr2cidr(char *cidr)
 {
-    int count = 0;
-    unsigned int octets[4];     /* used in sscanf */
+    int count;
+    unsigned int octets[4]; /* used in sscanf */
     tcpr_cidr_t *newcidr;
     char networkip[16], tempoctet[4];
     int family;
-    char* p;
+    char *p;
 
     assert(cidr);
 
@@ -192,8 +155,7 @@ cidr2cidr(char *cidr)
      * scan it, and make sure it scanned correctly, also copy over the
      * masklen
      */
-    count = sscanf(cidr, "%u.%u.%u.%u/%d", &octets[0], &octets[1],
-        &octets[2], &octets[3], &newcidr->masklen);
+    count = sscanf(cidr, "%u.%u.%u.%u/%d", &octets[0], &octets[1], &octets[2], &octets[3], &newcidr->masklen);
 
     if (count == 4) {
         newcidr->masklen = 32;
@@ -215,7 +177,7 @@ cidr2cidr(char *cidr)
 
         /* skip past the opening [ */
         if (*cidr == '[')
-            cidr ++;
+            cidr++;
 
         if (get_name2addr6(cidr, RESOLVE, &newcidr->u.network6) > 0) {
             family = AF_INET6;
@@ -248,10 +210,8 @@ cidr2cidr(char *cidr)
 #elif HAVE_INET_ADDR
         newcidr->network = inet_addr(networkip);
 #endif
-    } else if (family == AF_INET6) {
-        /* Everything's done */
     } else {
-        goto error;
+        /* Everything's done */
     }
 
     newcidr->family = family;
@@ -260,20 +220,18 @@ cidr2cidr(char *cidr)
     /* we only get here on error parsing input */
 error:
     errx(-1, "%s: %s", "Unable to parse as a valid CIDR", cidr);
-    return NULL;
 }
 
-static void 
-mask_cidr6(char **cidrin, char* delim)
+static void
+mask_cidr6(char **cidrin, const char *delim)
 {
     if (**cidrin == '[' && *delim == ':') {
         char *p;
         ++*cidrin;
         /* make strtok happy */
         for (p = *cidrin; *p && *p != ']'; ++p) {
-            if (*p == ':') {
+            if (*p == ':')
                 *p = '#';
-            }
         }
     }
 }
@@ -285,16 +243,22 @@ mask_cidr6(char **cidrin, char* delim)
  * since we use strtok to process cidr, it gets zeroed out.
  */
 int
-parse_cidr(tcpr_cidr_t ** cidrdata, char *cidrin, char *delim)
+parse_cidr(tcpr_cidr_t **cidrdata, char *cidrin, char *delim)
 {
-    tcpr_cidr_t *cidr_ptr;             /* ptr to current cidr record */
+    tcpr_cidr_t *cidr_ptr; /* ptr to current cidr record */
     char *network;
     char *token = NULL;
 
+    if (cidrin == NULL) {
+        errx(-1, "%s", "Unable to parse empty CIDR");
+    }
+
     mask_cidr6(&cidrin, delim);
 
     /* first iteration of input using strtok */
     network = strtok_r(cidrin, delim, &token);
+    if (network == NULL)
+        return 0;
 
     *cidrdata = cidr2cidr(network);
     cidr_ptr = *cidrdata;
@@ -313,8 +277,8 @@ parse_cidr(tcpr_cidr_t ** cidrdata, char *cidrin, char *delim)
         cidr_ptr->next = cidr2cidr(network);
         cidr_ptr = cidr_ptr->next;
     }
-    return 1;
 
+    return 1;
 }
 
 /**
@@ -324,7 +288,7 @@ parse_cidr(tcpr_cidr_t ** cidrdata, char *cidrin, char *delim)
  * since we use strtok to process optarg, it gets zeroed out
  */
 int
-parse_endpoints(tcpr_cidrmap_t ** cidrmap1, tcpr_cidrmap_t ** cidrmap2, const char *optarg)
+parse_endpoints(tcpr_cidrmap_t **cidrmap1, tcpr_cidrmap_t **cidrmap2, const char *optarg)
 {
 #define NEWMAP_LEN (INET6_ADDRSTRLEN * 2)
     char *map = NULL, newmap[NEWMAP_LEN];
@@ -341,13 +305,13 @@ parse_endpoints(tcpr_cidrmap_t ** cidrmap1, tcpr_cidrmap_t ** cidrmap2, const ch
         p = strstr(string, "]:[");
         if (!p)
             goto done;
-            
+
         *p = 0;
         strlcpy(newmap, "[::/0]:", NEWMAP_LEN);
         strlcat(newmap, string, NEWMAP_LEN);
         strlcat(newmap, "]", NEWMAP_LEN);
-        
-        if (! parse_cidr_map(cidrmap1, newmap))
+
+        if (!parse_cidr_map(cidrmap1, newmap))
             goto done;
 
         /* do again with the second IP */
@@ -355,29 +319,33 @@ parse_endpoints(tcpr_cidrmap_t ** cidrmap1, tcpr_cidrmap_t ** cidrmap2, const ch
         strlcpy(newmap, "[::/0]:", NEWMAP_LEN);
         strlcat(newmap, p + 2, NEWMAP_LEN);
 
-        if (! parse_cidr_map(cidrmap2, newmap))
+        if (!parse_cidr_map(cidrmap2, newmap))
             goto done;
 
     } else {
         /* ipv4 mode */
         memset(newmap, '\0', NEWMAP_LEN);
         map = strtok_r(string, ":", &token);
+        if (map == NULL)
+            goto done;
 
         strlcpy(newmap, "0.0.0.0/0:", NEWMAP_LEN);
         strlcat(newmap, map, NEWMAP_LEN);
-        if (! parse_cidr_map(cidrmap1, newmap))
+        if (!parse_cidr_map(cidrmap1, newmap))
             goto done;
-    
+
         /* do again with the second IP */
         memset(newmap, '\0', NEWMAP_LEN);
         map = strtok_r(NULL, ":", &token);
-    
+        if (map == NULL)
+            goto done;
+
         strlcpy(newmap, "0.0.0.0/0:", NEWMAP_LEN);
         strlcat(newmap, map, NEWMAP_LEN);
-        if (! parse_cidr_map(cidrmap2, newmap))
+        if (!parse_cidr_map(cidrmap2, newmap))
             goto done;
     }
-    
+
     /* success */
     res = 1;
 
@@ -386,7 +354,6 @@ done:
     return res;
 }
 
-
 /**
  * parses a list of tcpr_cidrmap_t's input from the user which should be in the form
  * of x.x.x.x/y:x.x.x.x/y,...
@@ -402,12 +369,12 @@ parse_cidr_map(tcpr_cidrmap_t **cidrmap, const char *optarg)
     char *token = NULL, *string;
     tcpr_cidrmap_t *ptr;
     int res = 0;
-    
+
     string = safe_strdup(optarg);
 
     /* first iteration */
     map = strtok_r(string, ",", &token);
-    if (! parse_cidr(&cidr, map, ":"))
+    if (!parse_cidr(&cidr, map, ":"))
         goto done;
 
     /* must return a linked list of two */
@@ -423,12 +390,12 @@ parse_cidr_map(tcpr_cidrmap_t **cidrmap, const char *optarg)
     ptr->from->next = NULL;
 
     /* do the same with the reset of the input */
-    while(1) {
+    while (1) {
         map = strtok_r(NULL, ",", &token);
         if (map == NULL)
             break;
 
-        if (! parse_cidr(&cidr, map, ":"))
+        if (!parse_cidr(&cidr, map, ":"))
             goto done;
 
         /* must return a linked list of two */
@@ -456,14 +423,14 @@ done:
  * returns 1 for true, 0 for false
  */
 int
-ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip)
+ip_in_cidr(const tcpr_cidr_t *mycidr, const unsigned long ip)
 {
-    unsigned long ipaddr = 0, network = 0, mask = 0;
-    int ret = 0;
+    unsigned long ipaddr, network, mask;
+    int ret;
 #ifdef DEBUG
     char netstr[20];
 #endif
-    
+
     if (mycidr->family != AF_INET)
         return 0;
 
@@ -471,7 +438,7 @@ ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip)
     if (mycidr->masklen == 0 && mycidr->u.network == 0)
         return 1;
 
-    mask = ~0;                  /* turn on all the bits */
+    mask = ~0; /* turn on all the bits */
 
     /* shift over by the correct number of bits */
     mask = mask << (32 - mycidr->masklen);
@@ -481,7 +448,6 @@ ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip)
 
     network = htonl(mycidr->u.network) & mask;
 
-
 #ifdef DEBUG
     /* copy this for debug purposes, since it's not re-entrant */
     strlcpy(netstr, get_addr2name4(mycidr->u.network, RESOLVE), 20);
@@ -490,32 +456,29 @@ ip_in_cidr(const tcpr_cidr_t * mycidr, const unsigned long ip)
     /* if they're the same, then ip is in network */
     if (network == ipaddr) {
 #ifdef DEBUG
-        dbgx(1, "The ip %s is inside of %s/%d",
-            get_addr2name4(ip, RESOLVE), netstr, mycidr->masklen);
+        dbgx(1, "The ip %s is inside of %s/%d", get_addr2name4(ip, RESOLVE), netstr, mycidr->masklen);
 #endif
         ret = 1;
     } else {
 #ifdef DEBUG
-        dbgx(1, "The ip %s is not inside of %s/%d",
-            get_addr2name4(ip, RESOLVE), netstr, mycidr->masklen);
+        dbgx(1, "The ip %s is not inside of %s/%d", get_addr2name4(ip, RESOLVE), netstr, mycidr->masklen);
 #endif
         ret = 0;
     }
     return ret;
-
 }
 
 static int
 ip6_addr_is_unspec(const struct tcpr_in6_addr *addr)
 {
-    return addr->tcpr_s6_addr32[0] == 0 && addr->tcpr_s6_addr32[1] == 0 &&
-      addr->tcpr_s6_addr32[2] == 0 && addr->tcpr_s6_addr32[3] == 0;
+    return addr->tcpr_s6_addr32[0] == 0 && addr->tcpr_s6_addr32[1] == 0 && addr->tcpr_s6_addr32[2] == 0 &&
+           addr->tcpr_s6_addr32[3] == 0;
 }
 
 int
-ip6_in_cidr(const tcpr_cidr_t * mycidr, const struct tcpr_in6_addr *addr)
+ip6_in_cidr(const tcpr_cidr_t *mycidr, const struct tcpr_in6_addr *addr)
 {
-    int ret = 0;
+    int ret;
 #ifdef DEBUG
     char netstr[INET6_ADDRSTRLEN];
 #endif
@@ -536,7 +499,7 @@ ip6_in_cidr(const tcpr_cidr_t * mycidr, const struct tcpr_in6_addr *addr)
             goto out;
         }
     }
-    
+
     if ((k = mycidr->masklen % 8) == 0) {
         ret = 1;
         goto out;
@@ -556,47 +519,42 @@ out:
     /* if they're the same, then ip is in network */
     if (ret) {
 #ifdef DEBUG
-        dbgx(1, "The ip %s is inside of %s/%d",
-            get_addr2name6(addr, RESOLVE), netstr, mycidr->masklen);
+        dbgx(1, "The ip %s is inside of %s/%d", get_addr2name6(addr, RESOLVE), netstr, mycidr->masklen);
 #endif
     } else {
 #ifdef DEBUG
-        dbgx(1, "The ip %s is not inside of %s/%d",
-            get_addr2name6(addr, RESOLVE), netstr, mycidr->masklen);
+        dbgx(1, "The ip %s is not inside of %s/%d", get_addr2name6(addr, RESOLVE), netstr, mycidr->masklen);
 #endif
     }
     return ret;
-
 }
 
-
 /**
  * iterates over cidrdata to find if a given ip matches
  * returns 1 for true, 0 for false
  */
 
 int
-check_ip_cidr(tcpr_cidr_t * cidrdata, const unsigned long ip)
+check_ip_cidr(tcpr_cidr_t *cidrdata, const unsigned long ip)
 {
     tcpr_cidr_t *mycidr;
 
-    /* if we have no cidrdata, of course it isn't in there 
+    /* if we have no cidrdata, of course it isn't in there
      * this actually should happen occasionally, so don't put an assert here
      */
     if (cidrdata == NULL)
         return 1;
-        
+
     mycidr = cidrdata;
 
     /* loop through cidr */
     while (1) {
-
         /* if match, return 1 */
         if (ip_in_cidr(mycidr, ip)) {
             dbgx(3, "Found %s in cidr", get_addr2name4(ip, RESOLVE));
             return 1;
         }
-        
+
         /* check for next record */
         if (mycidr->next != NULL) {
             mycidr = mycidr->next;
@@ -611,7 +569,7 @@ check_ip_cidr(tcpr_cidr_t * cidrdata, const unsigned long ip)
 }
 
 int
-check_ip6_cidr(tcpr_cidr_t * cidrdata, const struct tcpr_in6_addr *addr)
+check_ip6_cidr(tcpr_cidr_t *cidrdata, const struct tcpr_in6_addr *addr)
 {
     tcpr_cidr_t *mycidr;
 
@@ -626,13 +584,12 @@ check_ip6_cidr(tcpr_cidr_t * cidrdata, const struct tcpr_in6_addr *addr)
 
     /* loop through cidr */
     while (1) {
-
         /* if match, return 1 */
         if (ip6_in_cidr(mycidr, addr)) {
             dbgx(3, "Found %s in cidr", get_addr2name6(addr, RESOLVE));
             return 1;
         }
-        
+
         /* check for next record */
         if (mycidr->next != NULL) {
             mycidr = mycidr->next;
@@ -645,55 +602,3 @@ check_ip6_cidr(tcpr_cidr_t * cidrdata, const struct tcpr_in6_addr *addr)
     dbgx(3, "Didn't find %s in cidr", get_addr2name6(addr, RESOLVE));
     return 0;
 }
-
-
-/**
- * cidr2ip takes a tcpr_cidr_t and a delimiter
- * and returns a string which lists all the IP addresses in the cidr
- * deliminated by the given char
- */
-char *
-cidr2iplist(tcpr_cidr_t * cidr, char delim)
-{
-    char *list = NULL;
-    char ipaddr[18], tempbuff[20];
-    u_int32_t size, addr, first, last, numips;
-    struct in_addr in;
-    int i;
-
-    /* 
-     * 16 bytes per IP + delim
-     * # of IP's = 2^(32-masklen)
-     */
-    numips = 2;
-    for (i = 2; i <= (32 - cidr->masklen); i++)
-        numips *= 2;
-
-    size = 17 * numips - 1;
-
-    list = (char *)safe_malloc(size);
-
-    memset(list, 0, size);
-
-    /* first and last should not include network or broadcast */
-    first = ntohl(cidr->u.network) + 1;
-    last = first + numips - 3;
-
-    dbgx(1, "First: %u\t\tLast: %u", first, last);
-
-    /* loop through all but the last one */
-    for (addr = first; addr < last; addr++) {
-        in.s_addr = htonl(addr);
-        snprintf(tempbuff, 17, "%s%c", inet_ntoa(in), delim);
-        memcpy(ipaddr, tempbuff, 16);
-        dbgx(2, "%s", ipaddr);
-        strlcat(list, ipaddr, size);
-    }
-
-    /* last is a special case, end in \0 */
-    in.s_addr = htonl(addr);
-    snprintf(ipaddr, 17, "%s", inet_ntoa(in));
-    strlcat(list, ipaddr, size);
-
-    return list;
-}

+ 8 - 13
src/common/cidr.h

@@ -2,11 +2,11 @@
 
 /*
  *   Copyright (c) 2001-2010 Aaron Turner <aturner at synfin dot net>
- *   Copyright (c) 2013-2022 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
+ *   Copyright (c) 2013-2024 Fred Klassen <tcpreplay at appneta dot com> - AppNeta
  *
- *   The Tcpreplay Suite of tools 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 
+ *   The Tcpreplay Suite of tools 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 with the authors permission any later version.
  *
  *   The Tcpreplay Suite is distributed in the hope that it will be useful,
@@ -18,13 +18,12 @@
  *   along with the Tcpreplay Suite.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "cache.h"
+#pragma once
 
-#ifndef __CIDR_H__
-#define __CIDR_H__
+#include "cache.h"
 
 struct tcpr_cidr_s {
-    int family;                 /* AF_INET or AF_INET6 */
+    int family; /* AF_INET or AF_INET6 */
     union {
         u_int32_t network;
         struct tcpr_in6_addr network6;
@@ -48,15 +47,11 @@ int check_ip6_cidr(tcpr_cidr_t *, const struct tcpr_in6_addr *addr);
 int parse_cidr(tcpr_cidr_t **, char *, char *delim);
 int parse_cidr_map(tcpr_cidrmap_t **, const char *);
 int parse_endpoints(tcpr_cidrmap_t **, tcpr_cidrmap_t **, const char *);
-u_char *ip2cidr(const unsigned long, const int);
 void add_cidr(tcpr_cidr_t **, tcpr_cidr_t **);
 tcpr_cidr_t *new_cidr(void);
 tcpr_cidrmap_t *new_cidr_map(void);
 void destroy_cidr(tcpr_cidr_t *);
 void print_cidr(tcpr_cidr_t *);
-char *cidr2iplist(tcpr_cidr_t *, char);
 
-int ip6_in_cidr(const tcpr_cidr_t * mycidr, const struct tcpr_in6_addr *addr);
+int ip6_in_cidr(const tcpr_cidr_t *mycidr, const struct tcpr_in6_addr *addr);
 int check_ip6_cidr(tcpr_cidr_t *, const struct tcpr_in6_addr *addr);
-
-#endif

+ 22 - 0
src/common/dlt_names.c

@@ -506,6 +506,28 @@ char *dlt2name[] = {
         "Unknown",
         "Unknown",
         "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "Unknown",
+        "DLT_LINUX_SLL2",
         NULL
 };
 

+ 4 - 0
src/common/dlt_names.h

@@ -186,6 +186,10 @@ extern const char *dlt2name[];
 #define DLT_LINUX_SLL 113
 #endif
 
+#ifndef DLT_LINUX_SLL2
+#define DLT_LINUX_SLL2 276
+#endif
+
 #ifndef DLT_LTALK
 #define DLT_LTALK 114
 #endif

+ 0 - 0
src/common/err.c


この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません