summaryrefslogtreecommitdiffstats
path: root/text-utils/pg.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-4/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* text-utils: use errexec()Karel Zak2018-02-011-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-2/+2
| | | | | | | | | changed in include/c.h and applied via sed: sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c") sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c") Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | Consolidate --help and --version descriptions. We are now able to align them to the other options. We changed include/c.h. The rest of this patch was generated by sed, plus manually setting the right alignment numbers. We do not change anything but white spaces in the --help output. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: cleanup and fix --unknownopt issuesRuediger Meier2017-06-261-6/+7
| | | | | | | | | | | | | | | | Fixed checkusage.sh warnings: rtcwake: --unknownopt, non-empty stdout rtcwake: --unknownopt, stderr too long: 21 blockdev: --unknownopt, stderr too long: 28 lsipc: --unknownopt, stderr too long: 77 pg: --unknownopt, stderr too long: 23 renice: --unknownopt, stderr too long: 18 sulogin: --unknownopt, stderr too long: 17 write: --unknownopt, stderr too long: 12 Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix ggc-7 fallthrough warningsSami Kerola2017-06-141-2/+2
| | | | | | | | | | | | | | | | | | | (Original patch and commit message edited by Rudi.) gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra. This warning can be silenced by using comment /* fallthrough */ which is also recognized by other tools like coverity. There are also other valid comments (see man gcc-7) but we consolidate this style now. We could have also used __attribute__((fallthrough)) but the comment looks nice and does not need to be ifdef'ed for compatibility. Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652 Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/ Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl> Suggested-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* build-sys: ncurses headers cleanupKarel Zak2017-05-311-9/+7Star
| | | | | | | | | * assume ncursesw headers in ncursesw/ directory only * prefer long paths, <term.h> and <ncurses.h> should be last possibility * fix typos Signed-off-by: Karel Zak <kzak@redhat.com>
* text-utils: use proper paths to term.hKarel Zak2017-05-301-2/+12
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-32/+32
| | | | | | | text-utils/rev.c:68:9: warning: symbol 'buf' was not declared. Should it be static? Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: fix some compiler warningsRuediger Meier2016-10-271-4/+4
| | | | | | | | | | libsmartcols/samples/fromfile.c:59:2: warning: passing argument 3 of 'string_to_bitmask' from incompatible pointer type text-utils/pg.c:79:0: warning: "TABSIZE" redefined libblkid/src/read.c:455:13: warning: 'debug_dump_dev' defined but not used [-Wunused-function] libblkid/src/probe.c:769:13: warning: unused function 'cdrom_size_correction' [-Wunused-function] /usr/include/sys/termios.h:3:2: warning: "this file includes <sys/termios.h> which is deprecated, use <termios.h> instead" [-W#warnings] Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: Fix various typosSebastian Rasmussen2016-05-311-3/+3
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* misc: fix some includesRuediger Meier2016-02-291-1/+0Star
| | | | | | | | | features.h: any glibc header includes this already libgen.h: was unused there sys/uio.h: for writev(3p) sys/queue.h seems like it was never used Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+4
| | | | | | | | | This adds a concise description of a tool to its usage text. A first form of this patch was proposed by Steven Honeyman (see http://www.spinics.net/lists/util-linux-ng/msg09994.html). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* docs: update deprecation bannersSami Kerola2014-10-011-0/+9
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: use LC_ALLKarel Zak2013-10-181-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* pg.c: Add --help and --versionJari Aalto2013-06-181-2/+15
| | | | | | | [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>
* pg: check writing to a file was successfulSami Kerola2013-04-261-1/+8
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: fix memory leak [coverity scan]Karel Zak2013-03-271-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify exec error messagesSami Kerola2013-02-061-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: fix coding styleSami Kerola2012-10-151-399/+287Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: do not turn off warnigns artificiallySami Kerola2012-10-151-21/+0Star
| | | | | | | | 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>
* pg: use unistd.h STDOUT_FILENOSami Kerola2012-10-151-26/+26
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: add noreturn function attributesSami Kerola2012-10-151-5/+5
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: add const qualifiers where suitableSami Kerola2012-10-151-10/+13
| | | | | | | | | | | | 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>
* pg: use libc error printing facilitiesSami Kerola2012-10-151-27/+12Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: refactor argument handingSami Kerola2012-10-151-75/+84
| | | | | | | 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>
* pg: check numeric user inputsSami Kerola2012-10-151-2/+5
| | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* translation: unify file open error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* include: rename writeall.h to all-io.hPetr Uzel2012-05-151-1/+1
| | | | Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
* text-utils: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: align with howto-usage-function.txtSami Kerola2012-03-301-8/+24
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: correct version printing in help screenSami Kerola2012-03-301-4/+9
| | | | | | Commit also adds -V option. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: fix write_all() usageKarel Zak2011-08-171-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* pg: fix compiler warnings [-Wunused-result]Karel Zak2011-08-021-21/+22
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* pg: return value warning fixSami Kerola2011-06-011-2/+4
| | | | | | void function 'makeprint' should not return void expression Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: use size_t for wcstombs() return codeSami Kerola2011-06-011-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* pg: use xalloc for memory allocationDavidlohr Bueso2010-11-011-17/+3Star
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* pg: command enters infinite loopMike Frysinger2010-01-041-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* pg: compiler warning with NLS disabledPeter Breitenlohner2009-07-201-2/+2
| | | | Signed-off-by: Peter Breitenlohner <peb@mppmu.mpg.de>
* pg: add gettext call for the help stringKarel Zak2008-12-121-2/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* pg: several strings without gettext callsPedro Ribeiro2008-10-031-5/+5
| | | | | Signed-off-by: Pedro Ribeiro <p.m42.ribeiro@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* pg: fix segfault on searchRajeev V. Pillai2007-10-031-1/+1
| | | | | | | | | 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>
* build-sys: nls/locale handling in util-linux-ng generalMike Frysinger2007-09-191-2/+0Star
| | | | | | | | | | | | | | | 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>
* build-sys: fix ifdef ENABLE_WIDECHAR usageKarel Zak2007-01-301-7/+7
| | | | | | | | 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>
* Imported from util-linux-2.13-pre1 tarball.Karel Zak2006-12-071-48/+28Star
|
* Imported from util-linux-2.11y tarball.Karel Zak2006-12-071-0/+4
|
* Imported from util-linux-2.11v tarball.Karel Zak2006-12-071-0/+7
|
* Imported from util-linux-2.11t tarball.Karel Zak2006-12-071-0/+1775