Andre Noll [Sat, 25 Apr 2020 21:09:41 +0000 (23:09 +0200)]
Fix build target www.
This target is supposed to create the html files of the home page.
This broke one year ago when the build system was instructed to create
compressed man pages. Fortunately, the fix is trivial.
Andre Noll [Fri, 12 Jul 2019 18:34:45 +0000 (20:34 +0200)]
Makefile: Get rid of superfluous '+' character in date.
Commit bb3a974325f (Don't embed compile-time timestamps into generated
files) from a couple of weeks ago introduced a leading '+' in case
SOURCE_DATE_EPOCH is not set because DATE_FMT already contains the
'+' character for the argument to date(1), The superfluous '+'
becomes part of the generated man pages, which looks a bit weird.
Chris Lamb [Fri, 12 Jul 2019 05:59:50 +0000 (07:59 +0200)]
lsg.c: Make the output of lopsubgen reproducible.
Whilst working on the Reproducible Builds effort [0], we noticed that
liblopsub generates output that is not reproducible. The lopsubgen
utility does not respect SOURCE_DATE_EPOCH [1] and thus packages such
as src:tfortune are rendered unreproducible as they then encode the
build date and time.
This patch makes lopsubgen honour SOURCE_DATE_EPOCH.
Chris Lamb [Fri, 31 May 2019 17:54:04 +0000 (19:54 +0200)]
Don't embed compile-time timestamps into generated files.
Currently the build is not reproducible because make(1) runs
date(1) to provide the month and the year for the man page. Fix
this by honouring SOURCE_DATE_EPOCH as described in
Andre Noll [Fri, 17 May 2019 08:26:56 +0000 (10:26 +0200)]
Merge branches 't/debian', 't/dynamic-lib', 't/lls_check_arg_count' and 't/news'
This octopus merge combines four branches, two of which were created
with the aim of making the package acceptable for inclusion into
Debian: The t/dynamic-lib branch instructs make to create a dynamic
library instead of the static one, the t/debian branch adds the usual
files below debian/.
The remaining two branches, t/lls_check_arg_count and t/news, contain
only a single commit each. The first improves the wording of an error
message while the second introduces the NEWS file, respectively.
The tree which corresponds to this commit was accepted for Debian
unstable on May 15 2019 as version 1.0.2-1.
Andre Noll [Sat, 2 Mar 2019 15:48:46 +0000 (16:48 +0100)]
Add infrastructure to build debian packages.
This commit adds the usual files below debian/ so that two debian
binary packages, liblopsub1 and liblopsub1-dev, can be made with a
command like
dpkg-buildpackage
The bulk of the recipes in debian/rules employ debhelper(7).
This has been tested on debian-9 and debian-10. On both systems,
lintian(1) reports no warnings and no errors.
v4 -> v5
~~~~~~~~
Avoid the term "all-permissive license" to address copyright concerns
pointed out by Thorsten Alteholz.
v3 -> v4
~~~~~~~~
Next round of feedback from Adam Borowski:
* soname-less source package
* Full description for liblopsub-dev
* debian/changelog: UNRELEASED -> unstable
v2 -> v3
~~~~~~~~
Incorporate more feedback from Adam Borowski:
* version-gen.sh now works also without a git repository
* The soname has been dropped from the name of the development package
* library files are installed in the multiarch dir /usr/lib/$triplet
v1 -> v2
~~~~~~~~
Incorporate review comments from Adam Borowski:
* Rename package name from lopsub to liblopsub1 to make lintian happy.
* Append "-1" to the debian version to make it a non-native package.
* Switch source format from "3.0 (native)" to "3.0 (quilt)".
* Mention what parts are GPLv3-ed and which are LGPLv3-ed.
* Adjustments for building a shared library.
* Squash remaining lintian warnings.
Andre Noll [Sat, 11 May 2019 11:28:21 +0000 (13:28 +0200)]
lopsub.7: Avoid the term "all-permissive license".
As pointed out by Thorsten Alteholz, we use the term without really
explaining it. Replace it with "public domain", which is well-defined
and conveys the intended meaning.
Andre Noll [Sun, 31 Mar 2019 13:32:42 +0000 (15:32 +0200)]
Create a dynamic library.
As pointed out by Adam Borowski, static linking makes updates tedious.
This patch switches the package over to create a dynamic library
instead.
We have to specify -fPIC for compiling and --shared for linking. The
shared object is called liblopsub.so.X.Y.Z, where X, Y, and Z are
the digits of the version string as created from the git revision by
the version-gen.sh script. The soname for the linker to put into each
executable which is linked against lopsub is liblopsub.so.$X.
The install target is modified to install liblopsub.so.X.Y.Z instead
of liblopsub.a, and it also creates the usual symbolic links for
shared libraries. It does not run ldconfig, though.
Andre Noll [Mon, 22 Apr 2019 12:48:50 +0000 (12:48 +0000)]
lopsub.7: Move installation instructions from man page to README.
As pointed out by Adam Borowski, installation instructions don't
really belong in the man page. This commit converts the instructions
from roff format to plain text which is added at the bottom of the
existing README file.
We keep the link to the git repository though, and add a few more
links to related resources.
Andre Noll [Sun, 31 Mar 2019 10:59:39 +0000 (12:59 +0200)]
lopsub.7: Add NAME section.
Lintian complains about this because the NAME sections of all man
pages are parsed to generate the index for apropos(1) and co.
Each manual page should start with a "NAME" section, which lists the
name and a brief description of the page separated by "\-". The "NAME"
section is parsed by lexgrog and used to generate a database that's
queried by commands like apropos and whatis. This tag indicates that
lexgrog was unable to parse the NAME section of this manual page.
Andre Noll [Wed, 6 Feb 2019 17:49:06 +0000 (18:49 +0100)]
Improve diagnostics of lls_check_arg_count().
The old code could return an error message like
at least 1 non-option args required, 0 given
even if exactly 1 arg is required. So check this case and print
exactly 1 non-option args required, 0 given
instead. The check for the upper bound has the same issue. It is
considered a bug in the application if min_argc > max_argc, so check
for this case as well.
Andre Noll [Sun, 3 Mar 2019 20:58:45 +0000 (21:58 +0100)]
build: Compress man pages.
Man pages should always be installed in compressed form, so run gzip
on all four man pages. We always specify -f so that gzip won't ask
questions, and use the highest compression level because the pages
are compressed only once and decompressed every time the man page
is opened.
Andre Noll [Sat, 2 Mar 2019 13:32:24 +0000 (14:32 +0100)]
build: Provide target distclean.
All software packages should at least provide the "clean" and "distclean"
targets. So far we only supported the former, which removed all generated
files.
This commit adds the distclean target and modifies the clean target
to only remove files generated by the compiler, but not the files
that were generated by lopsubgen.
Andre Noll [Sat, 2 Mar 2019 13:32:01 +0000 (14:32 +0100)]
build: Activate ONESHELL.
This instructs "make" to pass all the lines in the recipe to a single
invocation of the shell, which is generally a good idea since it
speeds up the build a bit.
Andre Noll [Wed, 12 Jul 2017 09:23:48 +0000 (11:23 +0200)]
config_file.l: Make the scanner reentrant.
This replaces the three global variables by a structure and modifies
lls_convert_config() to call yylex_init_extra() instead of yy_init()
to make a reference to the structure available to the actions.
Andre Noll [Wed, 12 Jul 2017 09:43:25 +0000 (11:43 +0200)]
config_file.l: Instruct flex to create a reentrant scanner.
This requires some modifications:
* Most functions take an additional yyscan_t argument.
* We must call yylex_init and yylex_destroy().
* Accessor methods must be used to get yytext and yylen.
We used to set the initial start condition in lls_convert_config(),
before the call to yylex(). For reentrant scanners, however,
the BEGIN macro can not be used in the user code section where
lls_convert_config() is located. But pushing a state works and should
be equivalent.
The generated scanner is not reentrant yet because it still has global
variables. This issue will be addressed in a subsequent patch.
Andre Noll [Tue, 11 Jul 2017 20:24:10 +0000 (22:24 +0200)]
config_file.l: Move helper functions to user code section.
These functions refer to the global variables yytext and yylen.
Reentrant scanners need to use accessor methods instead of accessing
the global variables directly. But these methods are not available
in the definitions section.
As a preparation for making the scanner reentrant, this patch moves
the three helper functions from the definitions section to the user
code section. Since the functions are called from the actions of the
pattern rules, we need to provide forward declarations.
Andre Noll [Tue, 11 Jul 2017 19:41:47 +0000 (21:41 +0200)]
config_file.l: Change default prefix for global symbols.
Without this, applications which use flex for their own work might run
into problems due to duplicate symbols when linking against liblopsub.
Since this is an ABI change, we have to increment the ABI version
number.
No changes in the source code are necessary since flex provides macros
which allow to still refer to the variables and functions with the
usual yy prefixed names. However, the command
nm -e liblopsub.a
shows that the external symbols are now prefixed with lls_yy.
Note that the patch only changes config_file.l. We don't bother to
adjust lopsubgen.l in the same way because the object file which
is derived from lopsubgen.l is not part of the library. It is only
linked into the lopsubgen executable.
Andre Noll [Wed, 12 Jul 2017 09:33:48 +0000 (11:33 +0200)]
version-gen.sh: Make it work in conflicted state.
If the working tree contains unmerged paths, git update-index -q
prints a "file: needs merge" message to stdout. This message confuses
the build system which runs this git command via version-gen.sh and
expects it to output a git version string.
This commit redirects stdout of the git command to /dev/null to make
sure that version-gen.sh outputs only the version string.
Andre Noll [Fri, 21 Apr 2017 22:02:05 +0000 (00:02 +0200)]
lopsub.c: Fix a NULL pointer dereference and a double free.
The error path of lls_deserialize_parse_result() has two issues:
* if the allocation of lor->value fails, we dereference a NULL pointer
in the cleanup part after label free_options because in
free(lor->value[j].string_val);
lor->value is NULL.
* if the strdup() for a multiple option fails in the inner loop, we
deallocate all previously allocated strings, jump to the free_options
label, and attempt to free the same values again.
The root of both bugs is that we start the cleanup in the error case
using the current value of the outer loop index i. The fix is to
perform cleanup of the allocated memory for option i already in the
allocation loop and let the cleanup loop iterate downwards from i - 1.
Andre Noll [Fri, 21 Apr 2017 00:55:53 +0000 (02:55 +0200)]
Avoid warning about yywrap being redefined.
The flex documentation says
If you do not supply your own version of 'yywrap()', then you must
either use '%option noyywrap' (in which case the scanner behaves as
though 'yywrap()' returned 1), or you must link with '-lfl' to obtain
the default version of the routine, which always returns 1.
Unfortunately, if noyywrap is given, gcc-5.4.0 complains with
config_file.c:417:0: warning: "yywrap" redefined
^
config_file.c:74:0: note: this is the location of the previous definition
Just provide our own yywrap() to silence the warning.
Andre Noll [Sat, 22 Oct 2016 13:47:12 +0000 (15:47 +0200)]
The long option parser for subcommands (lopsub).
This library was under development for over a year and is now ready
for prime time. The code is believed to be mature and no bugs are
known at this time. The API is fully documented and stable, and no
new features are planned. Future fixes and enhancements will take
backwards compatibility into account.
The code used to be part of the paraslash package, but has been
moved to its own repository. All prior commits have been discarded,
so this repository contains only the final result as a single commit.
The input files for the lopsubgen utility and the config file parser
are based on flex. The API documentation is created with gendoc.m4,
a simple m4 file which is part of this repository.
Documentation includes the three man pages lopsub.7, lopsubgen.1 and
lopsub.suite.5 which describe different aspects of the library. There
is also an example application called lopsubex which illustrates
various features of the library.