summaryrefslogtreecommitdiffstats
path: root/text-utils/ul.c
Commit message (Collapse)AuthorAgeFilesLines
* ul: make sure buffers are zeroized [coverity scan]Karel Zak2019-05-281-2/+2
|
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+3
| | | | 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: cosmetics, remove argument from usage(FILE*)Ruediger Meier2017-06-261-4/+4
| | | | | | | | | | | | | | This patch is trivial and changes nothing, because we were always using usage(stdout) Now all our usage() functions look very similar. If wanted we could auto-generate another big cosmetical patch to remove all the useless "FILE *out" constants and use printf and puts rather than their f* friends. Such patch could be automatically synchronized with the translation project (newlines!) to not make the translators sick. 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-4/+4
| | | | | | | | | * 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-1/+8
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-23/+22Star
| | | | | | | 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: do not use plain 0 as NULL [smatch scan]Sami Kerola2017-02-201-5/+5
| | | | | | | | | | text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer Since many 'struct option' has used zero as NULL make them more readable in same go by reindenting, and using named argument requirements. Reference: https://lwn.net/Articles/93577/ Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-1/+1
| | | | | | | | The current default is to print all usage() output. This is overkill in many case. Addresses: https://github.com/karelzak/util-linux/issues/338 Signed-off-by: Karel Zak <kzak@redhat.com>
* ul: Fix buffer overflowTobias Stoeckmann2016-09-291-10/+4Star
| | | | | | | | | | | | | | | | | | | | | | | The text-utility ul can run into a buffer overflow on very long lines. See this proof of concept how to reproduce the issue: $ dd if=/dev/zero bs=1M count=10 | tr '\000' '\041' > poc.txt $ echo -ne '\xe\x5f\x8\x5f\x61\x2\xf\x5f\x8\x5f' | dd of=poc.txt conv=notrunc $ ul -i poc.txt > /dev/null # output would take ages Segmentation fault $ _ The problem manifests by using alloca with "maxcol", which can be as large as INT_MAX, based on the input line. A very long line (> 8 MB) with modes must be supplied to ul, as seen in my proof of concept byte sequence above. It is rather easy to fix this issue: allocate space on the heap instead. maxcol could overflow here, but in that case no system will have enough space to handle the request, properly ending ul through an err() call. Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* lib: rename strmode() and setmode()Ruediger Meier2016-02-181-5/+5
| | | | | | On BSD they are part of the standard C library. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* ul: remove unexplained TERM=lpr overrideSami Kerola2015-01-071-9/+0Star
| | | | | | | The FIXME item has been in place since 2011-04-30, and the code has never made sense, so remove it. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-1/+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>
* ul: fix filter() indentationSami Kerola2014-10-201-85/+75Star
| | | | | | Content of the while() loop missed one indentation step. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: use version printing macro everywhereSami Kerola2014-10-011-2/+1Star
| | | | | | | Only mount, umount, and blkid remains not using the macro because they are print also library references. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul: use string printing functionSami Kerola2013-07-091-4/+2Star
| | | | | | | Use of for loop and printing a string character by character is slower than to print whole string with single function. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul: use correct typesSami Kerola2013-07-091-3/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul: enhance command performanceSami Kerola2013-07-011-4/+4
| | | | | | | | | | | | | | | | | | | | Avoid reseting, time after time, the memory which was not used. Effect of the change is below in before and after timings. $ time ./ul </etc/services >/dev/null real 0m0.320s user 0m0.307s sys 0m0.010s $ time ./ul </etc/services >/dev/null real 0m0.068s user 0m0.050s sys 0m0.017s [kzak@redhat.com: - add "else" and use maxcol] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* ul: cleanup usage() and man pageKarel Zak2013-04-051-10/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: spell and encode the name of Arkadiusz Miƛkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* ul: fix shadow declarationSami Kerola2012-07-261-3/+3
| | | | | | | 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>
* translation: unify file open error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Fix typos found by misspellingsBernhard Voelker2012-04-231-1/+1
| | | | | | | | | | | | | | | The tool misspellings (https://github.com/lyda/misspell-check) detected several typos. Command used: $ git ls-files | grep -v ^po/ | misspellings -f - * isosize: Fix typo in usage string. * configure.ac: Fix typo in help string of --enable-most-builds option. * fdisk: Fix typo in man page. * libblkid, blkid, mount: Likewise. * Fix various typos in docs and in source code comments. Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
* text-utils: verify writing to streams was successfulSami Kerola2012-04-041-3/+2Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul: remove superfluous return as usage() does not returnBenno Schulenberg2011-08-151-2/+1Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* ul: make usage() say that more than one input file is allowedBenno Schulenberg2011-08-151-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* ul: in usage() not overwriting but overriding is meantBenno Schulenberg2011-08-151-2/+2
| | | | | | Also always use lowercase. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* ul.c: warn user when command chooses term typeSami Kerola2011-05-171-2/+5
| | | | | | | Happens usually when user specifies garbage as -t argument. Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* ul.c: escape handling refactoredSami Kerola2011-05-171-34/+42
| | | | | | | Separate function for escape handling to make switch statement more readable. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul.c: close files and free memory after usageSami Kerola2011-05-171-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul.c: code style and comment fixesSami Kerola2011-05-171-72/+94
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul.c: fix compier warningsSami Kerola2011-05-171-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul.c: magic constant removalSami Kerola2011-05-171-8/+7Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul.c: use long optionsSami Kerola2011-05-171-5/+35
| | | | | | This commit introduces help & version options. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ul.c: convert definition to functionSami Kerola2011-05-171-16/+22
| | | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: provide alternatives for err, errx, warn and warnxFabian Groffen2011-02-141-1/+1
| | | | | | | | Solaris lacks err, errx, warn and warnx. This also means the err.h header doesn't exist. Removed err.h include from all files, and included err.h from c.h instead if it exists, otherwise alternatives are provided. Signed-off-by: Fabian Groffen <grobian@gentoo.org>
* ul: use xalloc for memory allocationDavidlohr Bueso2010-11-011-7/+4Star
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* remove free() from atexit() callbacksKarel Zak2010-10-291-7/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* use _exit() instead of exit() in sighandlersMarek Polacek2010-10-291-1/+1
| | | | Signed-off-by: Marek Polacek <mmpolacek@gmail.com>
* ul: use atexit() to deallocate buffer, print errors by err()Karel Zak2010-09-171-35/+25Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* ul: fix memory leak.Davidlohr Bueso2010-09-171-1/+22
| | | | | | | | | | The 'obuf' variable is not being freed after usage and this includes when SIGINTs occur, hence add some basic signal handling. [kzak@redhat.com - remove if-before-free ] Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* replace bcopy,bzero,index and rindexDaniel Mierswa2009-08-171-1/+1
| | | | | | | | | Those 4 functions are marked as LEGACY in POSIX.1-2001 and removed in POSIX.1-2008. Replaced with memmove,memset,strchr and strrchr. Signed-off-by: Daniel Mierswa <impulze@impulze.org>
* build-sys: fix ifdef ENABLE_WIDECHAR usageKarel Zak2007-01-301-1/+1
| | | | | | | | 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.11o tarball.Karel Zak2006-12-071-3/+1Star
|
* Imported from util-linux-2.11b tarball.Karel Zak2006-12-071-1/+1
|
* Imported from util-linux-2.10s tarball.Karel Zak2006-12-071-47/+81
|
* Imported from util-linux-2.10m tarball.Karel Zak2006-12-071-10/+8Star
|