summaryrefslogtreecommitdiffstats
path: root/text-utils/more.c
Commit message (Collapse)AuthorAgeFilesLines
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-6/+4Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* more: rename functionsSami Kerola2018-09-021-85/+86
| | | | | | This clarifies what various function calls are doing. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: rename variable namesSami Kerola2018-09-021-558/+556Star
| | | | | | | | Try to make variable names to tell what they do. Earlier names have been in more(1) since the command was first wrote, and it looks like coding practices has changed since late 70's. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove unnecessary ifdef preprosessor directivesSami Kerola2018-09-021-8/+0Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: do not call fileno() for std{in,out,err} streamsSami Kerola2018-09-021-6/+6
| | | | | | These file descriptor numbers are well known, use them from unistd.h Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove 'register' keywordsSami Kerola2018-09-021-29/+29
| | | | | | | | One can only assume someone tried to make more(1) to run quicker. More up to date assumption is that compilers are fully capable optimizing binaries without these sort of hints. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove pointless functionsSami Kerola2018-09-021-61/+34Star
| | | | | | | The curs_terminfo(3X) defines putp() as tputs(str, 1, putchar), so all of these five functions can be replaced with putp(). Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: return is statement not a functionSami Kerola2018-09-021-20/+20
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove dead code and useless commentsSami Kerola2018-09-021-74/+24Star
| | | | | | | | | | | Removal of STOP requires explanation. Looking unix-history-repo getline() function in first BSD-3 version could return STOP. By next tag BSD-4 the return STOP had disappeared. If I read this correctly that was a partial removal, and second part has waited to be completed since 1980-11-16 when BSD-4 was released. Reference: https://github.com/dspinellis/unix-history-repo/blob/BSD-3-Snapshot-Development/usr/src/cmd/more.c#L501 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove function like preprocessor definesSami Kerola2018-06-181-104/+134
| | | | | | | | | Inlining code using preprocessor function like macros is bad for readability, and prone to errors. Besides this is a pager, who cares if code is few milliseconds slower. Requestee-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove global variables, add struct more_controlSami Kerola2018-06-181-639/+671
| | | | | | | | This is rather big change, but that is the only way to do this sort job. To keep this change relatively understandable only moves global variables to a state structure. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: move couple functionsSami Kerola2018-06-181-123/+123
| | | | | | | | Earlier commit moved lots of functions to work without declarations, but to be able to get rid of global variables few more moves is needed. Reference: a8f98304e6d2f4627ca31f6c661934c92b1095f7 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: reorder global declarationsSami Kerola2018-05-231-48/+48
| | | | | | | Group include, defines and such together, and move items inbetween functions on top of the source file so that everything can be seen easily. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: remove function prototypesSami Kerola2018-05-231-998/+968Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* text-utils: use errexec()Karel Zak2018-02-011-1/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-1/+1
| | | | | | | | | 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: consolidate all --help option descriptionsRuediger Meier2017-06-271-2/+2
| | | | | | | | Now we are always using the same text also for commands which had still hardcoded descriptions or where we can't use the standard print_usage_help_options macro. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* more: add --help and --versionRuediger Meier2017-06-221-7/+22
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* more: remove unused variableRuediger Meier2017-06-151-2/+1Star
| | | | | | | | | slow_tty is at least unused since util-linux 2.2. FYI here is another derived more.c where slow_tty is still used: https://github.com/sergev/LiteBSD/blob/master/old/more/more.c Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* misc: fix ggc-7 fallthrough warningsSami Kerola2017-06-141-2/+3
| | | | | | | | | | | | | | | | | | | (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/+7
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-53/+53
| | | | | | | 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-2/+2
| | | | | | | | | | 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>
* more: avoid double free() on exitKarel Zak2016-12-151-0/+8
| | | | | | | | | | | | | On 'q' command more(1) calls end_it() function with _exit(). The _exit() may suspend program execution due to pending I/O on very loaded server. In this time SIGINT may be delivered due to impatient user who will press ^C. And then end_it() cleanup function may be executed by signal handler too. The result is double free()... Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1403971 Signed-off-by: Karel Zak <kzak@redhat.com>
* more: don't include ncurses.h, fix for non-widecharKarel Zak2016-06-031-5/+2Star
| | | | | | | | It seems our crazy widechar.h is in conflict with ncurses, but it seems that nothing in more.c requires anything from ncurses. All we need is probably <term.h>. Signed-off-by: Karel Zak <kzak@redhat.com>
* more: remove unnecessary compatibility layerKarel Zak2016-01-261-66/+41Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: remove libtermcap supportSami Kerola2016-01-261-87/+23Star
| | | | | | | | | | It is unlikely anyone is going to build this project on system where libtermcap is available. Fedora project obsoleted libtermcap 2007-12-12 in favour of ncurses. Debian made same move 2005. Reference: https://fedoraproject.org/wiki/Deprecated_packages Reference: https://www.debian.org/doc/manuals/debian-faq/ch-compat.en.html#s-termcap Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: improve ugly macroKarel Zak2015-08-051-10/+17
| | | | | | no comment, just F*CK YOU to the original author of this crap... Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: grammarize and harmonize the stat error messageBenno Schulenberg2015-02-021-1/+1
| | | | | | | | | The message "stat failed %s" seems to say that stat() failed to do something, or failed to pass a test, but of course it means that the statting of something failed. So say so. Also make two very similar messages equal to this one. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* more: fix repeat search crashSami Kerola2015-01-281-0/+3
| | | | | | | | | Repeating a search for a pattern that did not found made more(1) to crash. To reproduce 'more /etc/services' and search for 'doom'; you will find a service in port 666 - pressing '.' after that result used to cause core dump. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* 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>
* more: fix compiler warningsKarel Zak2014-12-191-2/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* more: blacklist unsigned integer overflow [AddressSanitizer]Sami Kerola2014-12-191-4/+11
| | | | | | The mbrtowc() return values are overflowing by design. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: improve error messagesSami Kerola2014-12-091-6/+4Star
| | | | | | | 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>
* more: replace ad-hoc support for plurals with gettext plurals.Lauri Nurmi2014-07-281-8/+6Star
|
* more: fix double free crashSami Kerola2014-02-211-1/+0Star
| | | | | | | | Commit b9579f1f44b46c9f12f1e01b01c02d82ae1cf728 moved fclose() to checkf(), but missed removing file closure in magic(). Ironically the cause of regression is in previous commit message. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: improve formatting and wording of man page and help textBenno Schulenberg2014-02-211-16/+15Star
| | | | | | | Also, slice up the usage text for ease of translation. Reported-by: Phillip Susi <psusi@ubuntu.com> Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* more: fix mem leak [coverity scan]Karel Zak2014-01-141-1/+3
| | | | | | ... the code is so soo ugly. Signed-off-by: Karel Zak <kzak@redhat.com>
* more: fix warning when compiled --without-ncursesKarel Zak2013-10-151-1/+1
| | | | | Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* more: make output redirection more efficientSami Kerola2013-08-051-3/+4
| | | | | | | | | | | | | Especially with large inputs the change improves performance considerably. old> time more /boot/vmlinuz >/dev/null real 0m0.224s new> more /boot/vmlinuz >/dev/null real 0m0.009s Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: guarantee space for multibyteKarel Zak2013-08-011-0/+6
| | | | | | .. to make the code more robust. Signed-off-by: Karel Zak <kzak@redhat.com>
* more: check for buffer size when write multibyte charKarel Zak2013-08-011-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* more: fix buffer overflowKarel Zak2013-08-011-1/+2
| | | | | | | | | The bug has been probably introduced by commit 1ac300932deab8dea2c43050921bbbdb36d62ff1. Reported-by: "Dr. David Alan Gilbert" <dave@treblig.org> References: https://bugzilla.novell.com/show_bug.cgi?id=829720 Signed-off-by: Karel Zak <kzak@redhat.com>
* more: use variable lenght printf field width to print blanksSami Kerola2013-07-091-2/+1Star
| | | | | | This makes program to run a little faster. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* more: assigned value is never read [clang-analyzer]Sami Kerola2013-07-091-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* Fix various typosYuri Chornoivan2013-04-261-1/+1
|
* a pointer should not be compared to zero [coccinelle]Sami Kerola2013-02-061-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: spell and encode the name of Arkadiusz Miƛkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: standardize the reporting of program name plus package versionBenno Schulenberg2013-01-301-2/+1Star
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>