While fixing #14, what pointed me to check parsing validity (and not
local issues as I thought at first) was that `-v -v` was showing empty
mode definitions, despite claiming parse success. So let's add a test
that mode parsing does do things, not just empty claims.
The GCC in xenial is old (5.x), and something seems to trip it
compared to the clang build, when checking the default options, see
https://travis-ci.org/iustin/mt-st/jobs/597087158.
Switch to bionic which has GCC 7, which is recent enough.
Left-shifting of negative values is undefined behaviour according to
the C standard, because it depends on the exact representation. This
code, copied from the Linux kernel, is intended for 2's complement and
can be replaced by well-defined behaviour: ~(-1<<N) is equivalent
to (1<<N)-1.
Signed-off-by: Iustin Pop <iustin@k1024.org>
Right now stinit ignores leftover chars in strings such as '9a'; let's
make sure we don't miss these (at least the warning message might give
a hint)..
Commit b48a427 removed the actual kernel version checks, but forgot
the calls to populate the values themselves. Remove them as we don't
do anything with those values.
The source code seems to have, over time, become less self-consistent
in style. In order to not have to keep this up manually, switch over
indenting to clang-format. A .clang-format file is provided to give
repeatable results.
The main difference is switching from tabs to non-tabs
usage. Otherwise the changes are mostly minor and leading to more
consistency. Contributions to the format style welcome!
Nota bene: this should have had no code impact. Any actual code
changes (beyond indenting) are bugs in the re-indent process.
There are three "tables" with structure initialization lists in mt.c,
which look like they were intended to be nicely-aligned, but over time
they got out of alignment.
Redo the alignment by unwrapping the lines and using Emacs'
align-regex, even though this leads to an exception of ~130 line
length for the 'cmds' table, since it leads to a very readable table
(on large terminals). Also protect these regions from clang-format, in
preparation for full file re-indents.
I can't find any mention of looking up stinit.def in the current
directory first, at least not since version 0.7. Correct the man page
to mention only `/etc/stinit.def'.
Instead of assuming all passed buffers are DEFMAX, use the given
buflen. Also change some types (int→size_t) since these are all
related to string sizes.
There is a long-standing (it was already present in 0.7, so around 15
years) bug in stinit's find_pars function, related to parsing per-mode
configurations. Due to the way the temporary buffers are used, at one
point a strcat() is called on overlapping strings. This is documented
not to work, but it seems the behaviour is not deterministic: for some
pairs of strings it works, for some not (possibly related to distance
between strings, etc.). This results in the fact that parsing the
provided example file fails for _some_ entries, but not for all, with
a seemingly wrong error message (showing snippets of the input file
that do not exist).
Fix this issue in a trivial way by simply using a different (new)
buffer during the mode parsing.
Since we still have copies of files from the kernel sources, keep the
kernel version instead of moving to 'plain' GPL-v2 (only trivial
differences exist).
Fixes#5.
This would have found earlier things such as issue #6, and since it's
only done in distcheck, doesn't impact normal users (for whom
`-Werror` is a bit too strict).
This is much more comprehensive than just 'make' since it actually
runs the binaries (--version mode) and checks that the distributed
archive is complete.
This patch reworks the directory-related variables to allow
installation of binaries under `/usr/[s]bin`, instead of directly
under `/[s]bin`. It also allows installing the man pages under a
different prefix (e.g. `/usr/local`).
Example:
$ make install EXEC_PREFIX=/usr
will install binaries under `/usr/bin`, respectively `/usr/sbin`. A
full "local" installation under `/usr/local` is accomplished by:
$ make install EXEC_PREFIX=/usr/local PREFIX=/usr/local
This patch points once again that an autoconf/automake conversion
would make a lot of sense…
Closes#3. Additionally, it fixes a previous bug with installation of
the manual pages.