Commit Graph

35 Commits

Author SHA1 Message Date
Sami Kerola 7d2600e2d0 docs: update deprecation banners
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:11 +02:00
Karel Zak 938029c668 pg: use LC_ALL
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-18 11:38:02 +02:00
Jari Aalto 34e38ad0c3 pg.c: Add --help and --version
[kzak@redhat.com: - use USAGE_{HELP,VERISON} macros]

Signed-off-by: Jari Aalto <jari.aalto@cante.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-06-18 10:49:35 +02:00
Sami Kerola 944ab4b931 pg: check writing to a file was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-26 13:26:06 +02:00
Karel Zak 765056b372 pg: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:16:46 +01:00
Sami Kerola 07ff972eb6 translation: unify exec error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06 11:51:17 +01: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 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 289dcc9023 translation: unify file open error messages
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-16 18:18:22 +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
Sami Kerola b87cbe8486 text-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:45:41 +02:00
Sami Kerola 397f499613 pg: align with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-30 16:48:12 +02:00
Sami Kerola b6415f1243 pg: correct version printing in help screen
Commit also adds -V option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-30 16:48:12 +02:00
Karel Zak f144a2f543 pg: fix write_all() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-17 00:30:13 +02:00
Karel Zak ba14e04d72 pg: fix compiler warnings [-Wunused-result]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-02 13:55:30 +02:00
Sami Kerola a699625d79 pg: return value warning fix
void function 'makeprint' should not return void expression

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-01 09:07:54 +02:00
Sami Kerola f13616a064 pg: use size_t for wcstombs() return code
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-01 09:07:47 +02:00
Davidlohr Bueso f3a342a429 pg: use xalloc for memory allocation
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2010-11-01 14:03:08 +01:00
Mike Frysinger 45b1087e74 pg: command enters infinite loop
In a multibyte locale such as en_GB.UTF-8, the pg command cannot handle files
containing a form feed character (ASCII 0x0c) at the start of a line. The
program enters an infinite loop.

I've traced the problem to the function endline_for_mb in file pg.c. The code
assumes that the libc function wcwidth will return a nonnegative value, which
is not true for a form feed character. wcwidth returns -1 and the unsigned
variable "pos" goes into underflow.

I'll attach a patch which tests whether the character is printable before
calling wcwidth. If not, it uses instead the width of the constant L'?' which
is later used to replace nonprintable characters. I trust that we can assume
printability of this constant :-)

Steps to Reproduce:
1. Select a multibyte locale (tested with en_GB.UTF-8)
2. Create a file with a form feed character (0x0c) at the start of a line.
3. Try to display this file using the pg command.

Reported-by: Mark Calderbank <m.calderbank@iname.com>
Reported-by: Mike Frysinger <vapier@gentoo.org>
Addresses: https://bugs.gentoo.org/297717
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-01-04 09:49:23 +01:00
Peter Breitenlohner d5004be1f5 pg: compiler warning with NLS disabled
Signed-off-by: Peter Breitenlohner <peb@mppmu.mpg.de>
2009-07-20 15:23:40 +02:00
Karel Zak 126836e852 pg: add gettext call for the help string
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-12-12 15:13:44 +01:00
Pedro Ribeiro 7c7f4ff8e0 pg: several strings without gettext calls
Signed-off-by: Pedro Ribeiro <p.m42.ribeiro@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-10-03 09:31:44 +02:00
Rajeev V. Pillai 2b00dd6d54 pg: fix segfault on search
Run pg(1) and type '/<CR>' which is supposed to forward search for the
previously remembered search string. pg(1) will segfault after printing
"No remembered search string:".

Signed-off-by: Rajeev V. Pillai <rajeevvp@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2007-10-03 22:39:27 +02:00
Mike Frysinger 8b7f16fc37 build-sys: nls/locale handling in util-linux-ng general
On Monday 03 September 2007, Karel Zak wrote:
> http://thread.gmane.org/gmane.linux.utilities.util-linux-ng/590/focus=592
>
>  I agree that we need a better support for compilation without
>  locales, but from my point of view NLS != all locales stuff. The NLS
>  support is subset only.

thinking about the input from everyone, i'd propose the attached ...

Only pull in locale.h as needed and move it to the common nls.h.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2007-09-19 23:15:21 +02:00
Karel Zak 06b04b23cd build-sys: fix ifdef ENABLE_WIDECHAR usage
There has been unexpected mix of HAVE_WIDECHAR and ENABLE_WIDECHAR macros. The
ENABLE_WIDECHAR is old version and has to be replaced everywhere otherwise we
will see bugs with multibyte stuff.

Signed-off-by: Karel Zak <kzak@redhat.com>
2007-01-30 13:49:50 +01:00
Karel Zak 48d7b13a1e Imported from util-linux-2.13-pre1 tarball. 2006-12-07 00:26:54 +01:00
Karel Zak a5a16c6853 Imported from util-linux-2.11y tarball. 2006-12-07 00:26:08 +01:00
Karel Zak 0e6f4a203d Imported from util-linux-2.11v tarball. 2006-12-07 00:26:02 +01:00
Karel Zak 63cccae468 Imported from util-linux-2.11t tarball. 2006-12-07 00:25:58 +01:00