tfortune.git
2 months agodebian: Remove hard-coded dependency on liblopsub1. master
Andre Noll [Fri, 2 Feb 2024 10:10:21 +0000 (11:10 +0100)]
debian: Remove hard-coded dependency on liblopsub1.

The lopsub package was recently renamed to liblopsub1t64 to deal with
the upcoming 64-bit time_t transition in Debian. Drop the dependency
rather than renaming it, since this is what shlibs are for.

Suggested-by: Steve Langasek <vorlon@debian.org>
13 months agoFix cross build.
Helmut Grohne [Wed, 1 Mar 2023 16:03:24 +0000 (17:03 +0100)]
Fix cross build.

The cross build fails to find the lopsub library since it configures
for the build architecture. This happens as no --build nor --host is
passed which would have happened automatically if dh_auto_configure
could be used. Thus it'll have to be passed manually. Then configure
fails finding config.h.in, which for some reason is not created (nor
asked for) by the override_dh_autoreconf. And finally, the actual
Makefile does not pick up the compiler detected by configure and
rather uses plain cc, so we'll have to tell it as well.

Signed-off-by: Andre Noll <maan@tuebingen.mpg.de>
4 years agotfortune-1.0.1. v1.0.1
Andre Noll [Thu, 5 Sep 2019 10:30:28 +0000 (12:30 +0200)]
tfortune-1.0.1.

We've had a couple of improvements and fixes since version 1.0.0,
so here is tfortune-1.0.1. A new version number is also needed for
the package to migrate to Debian testing because the system would
not accept a package with the same version number.

4 years agoAdd a few sample epigrams and the fortunes package.
Andre Noll [Sun, 16 Jun 2019 11:06:44 +0000 (13:06 +0200)]
Add a few sample epigrams and the fortunes package.

This adds a single file containing ~200 tagged epigrams in English
language. The debian/control file is extended to provide the new
"tfortunes" package which ships this data file. The new package is
Recommended: by the tfortune package but tfortune works without it
if epigrams are provided locally.

The debian/copyright file also needs to be adjusted because the
epigrams are under the public domain while the source code remains
GPLv3.

The epigrams were created by running

tfortune -- print -atx pub

on the author's epigram database with "pub" being a tag expression
that filters out epigrams not suitable for public exposure.

Suggested-by: Adam Borowski <kilobyte@angband.pl>
v2 -> v3
~~~~~~~~
Apply fixes provided by Adam Borowski:
 * Fix bogus date in debian/changelog (s/Mon/Tue)
 * Make the data package Arch:all, since it is truly arch-independent
 * Add Multi-Arch header to debian/control

v1 -> v2
~~~~~~~~
Incorporate feedback from Adam Borowski:
 * Fix typo in description of the tfortunes package
 * Update debian/changelog and increase debian version number

4 years agoFall back to system-wide epigram directory.
Andre Noll [Sun, 16 Jun 2019 11:46:45 +0000 (13:46 +0200)]
Fall back to system-wide epigram directory.

If the per-user directory can not be opened, we currently print an
error message and exit. As pointed out by Adam Borowski, this is not
especially user-friendly.

This commit teaches tfortune to look in a second, system-wide location
in this case.  This location can be controlled with the --datadir
option of configure. The man page is updated accordingly.

4 years agoMake errors from regfile_iter_new() non-fatal.
Andre Noll [Sun, 16 Jun 2019 12:04:44 +0000 (14:04 +0200)]
Make errors from regfile_iter_new() non-fatal.

The callers of the regfile iter API already handle the case of no
epigrams or tag expressions just fine. In particular, the stats
command can still print meaningful output if the tag expression
directory does not exist, which is a perfectly valid setup.

This patch modifies regfile_iter_new() to no longer abort but merely
print a log message and return NULL if opendir() fails. The various
accessors of the regfile iter API have to be adjusted to deal with
NULL pointers but no changes to tfortune.c are required.

4 years agocom_stats(): Fix memory leak.
Andre Noll [Tue, 18 Jun 2019 17:45:30 +0000 (19:45 +0200)]
com_stats(): Fix memory leak.

We currently leak one allocation per tag. Not a big deal since
"stats" is a short-running subcommand. But at least valgrind no
longer complains.

4 years agocom_stats(): Work around bogus gcc warning.
Andre Noll [Tue, 18 Jun 2019 17:07:24 +0000 (19:07 +0200)]
com_stats(): Work around bogus gcc warning.

For some versions of gcc (7.4.0, 8.3.0, and 8.3.0-7 as shipped with
Debian-11, but not gcc-7.4.0-1ubuntu1~18.04.1), the previous patch
introduced the following warning:

tfortune.c:912:3: warning: 'lh_stats' may be used uninitialized in this function [-Wmaybe-uninitialized]
   free(lh_stats);
   ^~~~~~~~~~~~~~

We only assign to lh_stats when --verbose is given, and only free the
memory if --verbose is given.  Apparently gcc has started to believe
that the value of the "verbose" boolean variable might change, which is
impossible. Therefore, the warning is believed to be a false positive.

However, gcc has a point: There is no need to check for --verbose
twice, as a single branch is sufficient. This not only gets rid of
the warning but also makes the boolean variable pointless and removes
more lines than it adds.

4 years agocom_stats(): Avoid division by zero.
Andre Noll [Mon, 17 Jun 2019 11:27:36 +0000 (13:27 +0200)]
com_stats(): Avoid division by zero.

If no epigrams are defined yet, the arguments to printf() contain
a division by zero which results in output like:

average number of epigrams per file     -nan
average number of tags per epigram.     -nan
average number of tag recurrence...     -nan

This is not a wrong per se, but it seems to be safer to special case
this and print zero.

4 years agoAdd infrastructure to build debian packages.
Andre Noll [Mon, 20 May 2019 14:58:20 +0000 (16:58 +0200)]
Add infrastructure to build debian packages.

This commit adds the usual files below debian/ so that debian source
and binary packages can be made with a command like

    dpkg-buildpackage

The debian/rules file relies on dh but overrides the dh_auto_configure
and the dh_autoreconf targets. The default recipe for dh_auto_configure
results in warnings because tfortune's configure does not implement
some of the options which dh appends to the configure command. The
override for autoreconf is needed because the default recipe would
remove our configure wrapper and replace it with the generated script.

This has been tested on debian-9, debian-10 and debian-11. On all
systems, lintian(1) reports no warnings and no errors.

v3 -> v4
~~~~~~~~
* Fix Bug ID in debian/changelog (pointed out by Adam Borowski)

v2 -> v3
~~~~~~~~
* Switch to a simple debian/rules file as suggested by Alexis Murzeau
  and Adam Borowski.

v1 -> v2
~~~~~~~~
Incorporate feedback from Adam Borowski:
 * Use dh_installchangelogs instead of open-coding it
 * Use gzip -n to avoid rendering the build non-reproducible
 * Fix the installation path of debian/copyright by running dh_install,
 * Create md5sums file

4 years agoMakefile: Avoid warning when config.mak is not present.
Andre Noll [Tue, 4 Jun 2019 14:22:05 +0000 (16:22 +0200)]
Makefile: Avoid warning when config.mak is not present.

Without the leading dash, make(1) complains if, for example,

make config.mak

is run on a pristine tree. The dash instructs make(1) to not emit
a warning if the file to include does not exist or cannot be remade.

4 years agoRun gzip with -n.
Andre Noll [Fri, 31 May 2019 18:23:02 +0000 (20:23 +0200)]
Run gzip with -n.

It is generally a good idea to not save the local file name and
timestamp in the compressed file, as this thwarts reproducible builds.

Suggested-by: Adam Borowski <kilobyte@angband.pl>
4 years agoNew make targets: exe, build-arch, man and build-indep.
Andre Noll [Wed, 22 May 2019 13:56:31 +0000 (15:56 +0200)]
New make targets: exe, build-arch, man and build-indep.

It's good practice to provide separate make targets for generating
arch-dependent files (e.g., executables) and for arch-independent files
(e.g., manual pages). Currently there is only one file of either type
which gets installed by the make target, but this might change.

4 years agomake distclean: Remove also configure.sh.
Andre Noll [Mon, 20 May 2019 22:09:51 +0000 (00:09 +0200)]
make distclean: Remove also configure.sh.

All derived files should be removed by the distclean target.

4 years agoInstall man pages in compressed form.
Andre Noll [Tue, 21 May 2019 09:54:25 +0000 (11:54 +0200)]
Install man pages in compressed form.

This is generally a good idea since all versions of man(1) support
at least gzip-compressed manual pages.

4 years agoInstall man page in section 6.
Andre Noll [Mon, 20 May 2019 17:09:30 +0000 (19:09 +0200)]
Install man page in section 6.

The manual page of the standard fortune program is part of section 6
(Games Manuals), so the tfortune man page should be installed there
as well rather than in section 1.

5 years agoAvoid duplication in version, README, man page.
Andre Noll [Sun, 17 Feb 2019 11:39:40 +0000 (12:39 +0100)]
Avoid duplication in version, README, man page.

URLs and the email address are currently spread out over multiple
files.  This commit cleans up the mess by defining everything in
Makefile and adjusting other places to use the information from there.
We use the opportunity to add a link to the author's home page.

version-gen.sh is made generic, i.e., it does not refer to tfortune
any more.

5 years agoFix --basedir completion.
Andre Noll [Sun, 20 Jan 2019 21:01:35 +0000 (22:01 +0100)]
Fix --basedir completion.

Silly braino.

5 years agoUpdate copyright year.
Andre Noll [Sat, 19 Jan 2019 23:17:36 +0000 (00:17 +0100)]
Update copyright year.

5 years agocom_help(): Fix comma placement.
Andre Noll [Sun, 13 May 2018 17:23:33 +0000 (19:23 +0200)]
com_help(): Fix comma placement.

We never want to print a comma at the beginning of the line.

5 years agoepi_iter_new(): Use xrealloc().
Andre Noll [Sun, 13 May 2018 15:27:07 +0000 (17:27 +0200)]
epi_iter_new(): Use xrealloc().

This way we get proper error checking.

5 years agotxt2ast(): Mark iovec structure as const.
Andre Noll [Sun, 13 May 2018 10:51:00 +0000 (12:51 +0200)]
txt2ast(): Mark iovec structure as const.

The function does not modify the fields of "tx".

6 years agoInitial commit. v1.0.0
Andre Noll [Mon, 19 Mar 2018 17:37:28 +0000 (18:37 +0100)]
Initial commit.

Tfortune was maintained in a non-public git repository between 2016-04
and 2018-01. By then it was moved to a dedicated repository, rewritten
to support the tag expression grammar and made scalable by introducing
linear hashing. At the same time command line parsing was switched
to the lopsub library, the command line options were redesigned and
properly documented, and the nifty logo was added.

In 2018-03 tfortune reached version 1.0 and was finally made public. All
commits that led to version 1.0 have been discarded, so this repository
contains only the final result as a single commit.

Many thanks to Effie Symeonidi who gave valuable feedback regarding the
installation instructions.