Commit graph

693 commits

Author SHA1 Message Date
Karel Zak
53b22add73 build-sys: add --disable-{more,ul,pg}
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-24 19:23:56 +01:00
Ondrej Oprala
f1107b4a87 hexdump: do not segfault when iterating over an empty format string
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2013-01-10 11:08:51 +01:00
Sami Kerola
cdd2cf46c8 more: remove unnecessary variable
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-12-19 11:38:46 +01:00
Karel Zak
2a31396a9c include/c: move usleep() fallback to c.h
To make it available everywhere in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-22 11:03:09 +02:00
Sami Kerola
53078e0887 more: remove few memory leaks
The remaining memory leaks are related to ncurses internals, or the one
open file descriptor when user users 'q' to exit.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:53:59 +02:00
Sami Kerola
1ee762370d more: align void in functions with prototypes, and remove void casts
If there is void in argument list at function prototype it is reasonable
to expect to see it also where the function is wrote.  This change also
removes unnecessary return value void casting.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:53:59 +02:00
Sami Kerola
4eaab145eb more: fix coding style
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:53:59 +02:00
Sami Kerola
bb7ae5bfa7 pg: fix coding style
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:53:59 +02:00
Sami Kerola
7d35cf4e57 pg: do not turn off warnigns artificially
Compiler warnings often mean something, fiddling with them is not good
practise.  Besides the 'proglem' removed macro tried to 'fix' does not
even occur when compiling with modern gcc.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:47:43 +02:00
Sami Kerola
69f3ff5e7e pg: use unistd.h STDOUT_FILENO
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:47:42 +02:00
Sami Kerola
f494ef65e0 pg: add noreturn function attributes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:47:40 +02:00
Sami Kerola
8b8f3fa5d9 pg: add const qualifiers where suitable
Includes a fix also to one assignment warning (see below).

text-utils/pg.c:1477:24: warning: assignment discards 'const' qualifier \
from pointer target type [enabled by default]

[kzak@redhat.com: - use const char rather than xstrdup() for static /bin/sh string]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-15 16:34:59 +02:00
Sami Kerola
5ad961719d pg: use libc error printing facilities
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:19:35 +02:00
Sami Kerola
f2d2af5e3c pg: refactor argument handing
Add function parse_arguments(), which has the same code block that was in
over long, and too deeply intended, main().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:19:35 +02:00
Sami Kerola
3295cde4af docs: fix column.1 groff syntax error
Quote backslash which user is expected to see.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:19:35 +02:00
Sami Kerola
47bd8ddc5b column: add --output-separator option
The --output-separator option will allow user to define table column
separator.  This will allow for example to write back same delimeter as
which was used as input separator, for example

column -t -s : -o : /etc/passwd

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-15 16:19:35 +02:00
Sami Kerola
2e472189c1 pg: check numeric user inputs
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-15 15:54:25 +02:00
Sami Kerola
018dfb0fe7 column: describe change of separator behavior in man page bugs section
Add to manual page how to achieve old behavior, just in case someone
relies on buggy behavior of the command.

[kzak@redhat.com: - remove unnecessary info from the man page :-)]

Reported-by:  Padraig Brady <P@draigBrady.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-02 10:43:33 +02:00
Pádraig Brady
a38dc987ca column: clarify the --separator option
Indicate that the string is a set,
which also clarifies that it's only
significant when parsing the input.
2012-10-02 10:24:55 +02:00
Sami Kerola
732e3dec7d column: make defined separator to be non-greedy
This patch changes interpretation of subsequent delimeter interpretation.
Earlier version merged columns that had null string as content together,
which lead to output as visualized below.

$ printf "a🅱️c\n1::3\n" | column  -t -s ':'
a  b  c
1  3

The number 3 has wrong column, which this patch takes care of, and alters
the output following way.

$ printf "a🅱️c\n1::3\n" | column  -t -s ':'
a  b  c
1     3

This patch does not alter the default case, e.g., subsequent white spaces
are understood as separator of the same field, and the beginning of line
white spaces are being ignored together.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-10-02 10:24:48 +02:00
Karel Zak
67757329cc mark expected fallthrough for static analysers
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-07 12:05:56 +02:00
Yuri Chornoivan
bbac757b1e textual: fix typos in messages 2012-09-04 17:26:31 +02:00
Karel Zak
0825179f47 col: fix compiler warning [-Wstrict-prototypes]
text-utils/col.c:142:43: warning: function declaration isn’t a prototype [-Wstrict-prototypes]

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-04 16:49:28 +02:00
B Watson
43f8915c51 column: --separator segfaults
The --separator and --columns long options in util-linux-2.21.2 and in
a git clone from 5 minutes ago, don't work:

$ echo foobar | column -s x
foobar

$ echo foobar | column -c 10
foobar

$ echo foobar | column --separator=x
column: option '--separator' doesn't allow an argument

$ echo foobar | column --separator x
Segmentation fault

$ echo foobar | column --columns 10
column: bad columns width value: '(null)': Invalid argument

$ echo foobar | column --columns=10
column: option '--columns' doesn't allow an argument

Looks like a simple case of missing has_arg flag in the "struct
option" initialization for these two options. The patch just adds the
flag. I haven't done thorough testing of the patched code, but it
seems to work OK and it no longer segfaults or tries to dereference a
null pointer.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-14 18:27:09 +02:00
Sami Kerola
77cf6e7021 more: add noreturn function attribute
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:35 +02:00
Sami Kerola
89a13b46bd hexdump: fix shadow declaration
text-utils/hexdump.h:84:5: warning: shadowed declaration is here [-Wshadow]
./include/xalloc.h:23:28: warning: declaration of 'size' shadows a global declaration [-Wshadow]
./include/xalloc.h:33:40: warning: declaration of 'size' shadows a global declaration [-Wshadow]
./include/xalloc.h:43:49: warning: declaration of 'size' shadows a global declaration [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:22 +02:00
Sami Kerola
7285104410 ul: fix shadow declaration
text-utils/ul.c:641:25: warning: declaration of 'col' shadows a global declaration [-Wshadow]
text-utils/ul.c:126:5: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:20 +02:00
Sami Kerola
9c35d79ad8 more: fix shadow declaration
text-utils/more.c:1123:13: warning: declaration of 'state' shadows a previous local [-Wshadow]
text-utils/more.c:1095:18: warning: shadowed declaration is here [-Wshadow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:18 +02:00
Karel Zak
81481b5a91 tailf: fix compiler warning [-Wmissing-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-16 18:47:29 +02:00
Karel Zak
a4b8ce8223 colrm: fix compiler warning [-Wmissing-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-16 18:46:44 +02:00
Sami Kerola
289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Sami Kerola
add1b8afd0 translation: unify stat error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +02:00
Karel Zak
dcdb349be7 build-sys: always use default $(LDADD)
The global variable $(LDADD) is always used if program_LDADD is
not specified. Let's use $LDADD everywhere to avoid exceptions for
people who need to specify global $LDADD.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-09 16:23:51 +02:00
Karel Zak
f38e5ff355 build-sys: cleanup .gitignore files
- move all binaries to top-level .gitignore
 - remove unnecessary */.gitignore files

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:50:54 +02:00
Karel Zak
d77ab74af7 build-sys: convert lib/ to libcommon.la
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:50:53 +02:00
Karel Zak
22d2322eb1 build-sys: convert term-utils/ to module
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 17:53:09 +02:00
Karel Zak
f3e03db330 build-sys: convert text-utils/ to module
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 17:51:41 +02:00
Sami Kerola
327b7c5bfb more: fix pointer wrap around compiler warnings
more.c:318:5: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]
more.c:362:3: warning: assuming pointer wraparound does not occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 18:00:00 +02:00
Sami Kerola
02206bfbd7 more: fix search repetition regression
Commit 596007ef6a introduced a bug
crashing more always when a text search was repeated with 'n' command.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 18:00:00 +02:00
Sami Kerola
3c44e03f8c hexdump: print sensible message when all input file arguments fail
Earlier hexdump printed unnecessary, and perhaps even misleading, 'bad
file descriptor' message.

$ hexdump foobar
hexdump: foobar: No such file or directory
hexdump: foobar: Bad file descriptor

The message is changed to

$ hexdump foobar
hexdump: foobar: No such file or directory
hexdump: all input file arguments failed

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +02:00
Bernhard Voelker
871ffd0960 Fix typos in comments and wall's man page
Culprits identified again by (newer) misspellings:

  $ git ls-files | misspellings -f - | grep -v '^po/'

* wall: Fix typo in man page.
* Fix typos in source code comments.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-06-05 14:37:26 +02:00
Andreas Bießmann
3339f0daab text-utils/hexsyntax.c: fix for missing program_invocation_short_name
Some libc do not expose program_invocation_short_name. Therefore util-linux
comes with helpers in 'c.h'. Use the 'c.h' in hexsyntax.c where it was missed.

This patch fixes following error for me:
---8<---
hexsyntax.c: In function 'newsyntax':
hexsyntax.c:115: error: 'program_invocation_short_name' undeclared (first use in this function)
hexsyntax.c:115: error: (Each undeclared identifier is reported only once
hexsyntax.c:115: error: for each function it appears in.)
--->8---

Signed-off-by: Andreas Bießmann <biessmann@corscience.de>
2012-06-05 14:31:13 +02:00
Karel Zak
eecbb2cfee more: fix regex error messages printing
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-05 14:19:13 +02:00
Jeremy Huntwork
7f84e4440f more: remove a meaningless test
regexec only returns 0 or REG_NOMATCH so remove a meaningless test

Signed-off-by: Jeremy Huntwork <jhuntwork@lightcubesolutions.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-05 14:09:36 +02:00
Karel Zak
b6b0ea094b hexdump: fix comparison of distinct pointer types
display.c: In function ‘get’:
display.c:262:117: warning: comparison of distinct pointer types lacks
a cast [enabled by default]

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-23 10:20:19 +02:00
Petr Uzel
3bbef0769e text-utils: use min() from c.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-23 09:56:51 +02:00
Karel Zak
495b13983e Merge branch 'master' of https://github.com/jhuntwork/util-linux 2012-05-23 09:39:40 +02:00
Karel Zak
3b56eea7c9 text-utils: cleanup strtoxx_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:46:20 +02:00
Petr Uzel
e12c9866b5 include: rename writeall.h to all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:27 +02:00
Petr Uzel
5821dbe328 rev: mention tac(1) in 'SEE ALSO' man page section
Cc: James R. Van Zandt <jrv@debian.org>
From: James R. Van Zandt <jrv@debian.org>
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=568709
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:19:53 +02:00