login-utils: use libc error printing facility

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
textual: improve error messages

Use error printing facilities that add command name in front of the error
message, and add explanation that is part of existing translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
line: use util-linux conventions

This change add --help and --version print outs, checking at exit the
stdout write was successful, and as a minor thing the command is made to
use wide char functions to read and write inputs.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: sync with 1.1.6 release

Reference: http://www.spinics.net/lists/util-linux-ng/msg10556.html
CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
tests: copy test-suite from Frodo Looijaard's getopt

The test cases and their names are the same, but the surrounding testing
facility with Frodo's svn and util-linux are pretty different so this is
not exactly 1:1 copy.

Reference: svn://svn.frodo.looijaard.name/public/getopt/trunk/tests
CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
tests: add more getopt tests

After importing Frodo's tests I ran coverage to see if something had
remained unchecked, and there were couple tests that could be done.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: make nonoptions optstring comment correct

From manual page: 'If the first character of optstring is '-', then each
nonoption argv-element is handled as if it were the argument of an option
with character code 1.'

Reference: http://man7.org/linux/man-pages/man3/getopt.3.html
CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: remove function prototypes

Functions are in right order so they do not need prototypes, with effect
of not needing to keep function argument changes in sync in two locations.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: add struct getopt_control and remove global variables

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: use xstrdup rather than malloc + strcpy

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: make normalize() print strings

A change towards less indirection, and a change to free allocated memory.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: remove unnecessary code

The control structure is initialized in main().

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: prefer switch-case rather than long if statement

And avoid testing same thing time after time.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: change --shell argument parsing function

Avoid passing getopt_control stucture in when returning a value is enough.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
getopt: avoid re-terminating long_option list at every update

Terminating the ctl->long_options list once when adding options is
completed is enough.  This also allows moving ctl->long_options_nr
increment to more appropriate location.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils: use libc error printing facility

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
textual: improve error messages

Use error printing facilities that add command name in front of the error
message, and add explanation that is part of existing translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
line: use util-linux conventions

This change add --help and --version print outs, checking at exit the
stdout write was successful, and as a minor thing the command is made to
use wide char functions to read and write inputs.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
build-sys: hwclock requires -lm

hwclock uses fabs and therefore needs libm, otherwise a linking
error ocurrs when building with -fno-builtin.
lslogins: fix assertion failure for none existing logins

This cange makes the following to retun none-zero value instead of a core
dump.

$ lslogins qwertyuiopasdfghjklzxcvbnm1234567
lslogins: libsmartcols/src/line.c:362: scols_line_get_cell: Assertion `ln' failed.
Aborted (core dumped)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>