summaryrefslogtreecommitdiffstats
path: root/text-utils/rev.c
Commit message (Collapse)AuthorAgeFilesLines
* rev: be careful with close()Karel Zak2019-06-131-1/+2
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/807 Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* rev: move a global variable to local scopeSami Kerola2018-05-281-3/+2Star
| | | | | | Mark also file names read-only. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* 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-3/+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: add static keyword to where needed [smatch scan]Sami Kerola2017-02-201-1/+1
| | | | | | | 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-3/+3
| | | | | | | | | | 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>
* rev: Avoid out of boundary readTobias Stoeckmann2016-10-061-0/+3
| | | | | Check if the length of the parsed string is at least 1, otherwise an out of boundary read would occur.
* rev: Avoid calling free in a signal handlerTobias Stoeckmann2016-10-061-1/+0Star
| | | | | | free() is not a safe function for a signal handler. The next line calls _exit() anyway, so there is no need for resource management.
* 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>
* textual: use usage() text element macrosSami Kerola2014-10-011-5/+3Star
| | | | | | | Translating these text elements should happen only once, which is more likely when the text macros are used properly. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: use manual tail usage() macroSami Kerola2014-10-011-1/+1
| | | | 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>
* rev: fix new line regressionSami Kerola2013-09-121-1/+3
| | | | | | | | | | | Commit 4b4eb34004378fe70259acd8f2f859e7b5cc3726 made output incorrect for input lines that does not have new line. For example $ printf "a b c\n1 2 3" | rev c b a 2 13 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: use string printing rather than character outputSami Kerola2013-08-011-8/+13
| | | | | | | Fliping a string in memory, and printing it with multibyte output function makes the command about 1/3 quicker. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: reduce stream checking when closing read-only file descriptorSami Kerola2013-06-071-4/+1Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: simplify new line detection and impossible testSami Kerola2013-06-071-5/+4Star
| | | | | | | | | | | The new line detection is earlier using only '\n' so there should not be need to search for '\r' later. The detection whether allocated address is pointing to null seems to be unnecessary. Assuming xmalloc() returned valid address space the address should never be 0. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: stop adding new line at the end when input does not have itSami Kerola2013-06-071-1/+2
| | | | | | | | | | When the rev(1) is executed twice outcome is expected to be exactly what it was originally. That includes not adding new line at the end of the output. The oneliner below demonstrates earlier issue. $ printf "abc\n123" | rev | rev Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* various: fix variable and function declarations [smatch scan]Sami Kerola2013-04-091-6/+6
| | | | | | | | | | | | | | | | | disk-utils/fsck.minix.c:511:9: warning: mixing declarations and code fdisks/sfdisk.c:982:5: warning: mixing declarations and code fdisks/sfdisk.c:1254:5: warning: mixing declarations and code fdisks/sfdisk.c:1564:5: warning: mixing declarations and code lib/mbsalign.c:279:7: warning: mixing declarations and code libblkid/src/devname.c:378:17: warning: mixing declarations and code libfdisk/src/alignment.c:219:9: warning: mixing declarations and code term-utils/wall.c:111:9: warning: mixing declarations and code text-utils/col.c:418:19: warning: non-ANSI function declaration of function 'flush_blanks' text-utils/col.c:553:12: warning: non-ANSI function declaration of function 'alloc_line' text-utils/rev.c:105:9: warning: mixing declarations and code text-utils/tailf.c:245:9: warning: mixing declarations and code 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>
* translation: unify file open error messagesSami Kerola2012-07-161-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* text-utils: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: mark signo unused in sig_handlerSami Kerola2011-06-011-1/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: option parsing bug fixed & long options addedSami Kerola2011-04-061-5/+19
| | | | | | | | | | | | | The former getopts segment gave impression unknown options will cause the program to exit with error and help is available with -h. Neither work quite as designed, all unknown options made the program to exit with success; and none of the options where known. The fix also has support for long options, and new --version switch. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: memory leak fixSami Kerola2011-04-061-2/+2
| | | | | | | | Moving the malloc out of loop will make leak to disappear, and the command might run few jiffie quicker when there are 1+N arguments. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* rev: use xrealloc from xalloc.hSami Kerola2011-04-061-9/+1Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* 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>
* rev: use xalloc for memory allocationDavidlohr Bueso2010-11-011-3/+2Star
| | | | Signed-off-by: Davidlohr Bueso <dave@gnu.org>
* use _exit() instead of exit() in sighandlersMarek Polacek2010-10-291-1/+1
| | | | Signed-off-by: Marek Polacek <mmpolacek@gmail.com>
* rev: coding style, various fixesDavidlohr Bueso2010-08-201-85/+110
| | | | | | | | | | | | | | * Change indentation to 8 characters and coding style, for better reading the code. * Add some memory allocation error handling. * Fix memory leaks. In cases when Ctrl-C is used to exit the program, 'p' cannot be freed, so made it a global var, to share between main() and sig_handler(). Signal handing is necessary to fix some leaks, so added a very basic, non invasive, mechanism. Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
* rev: use warn() in errs.hLi Zefan2007-10-251-21/+8Star
| | | | | | | | The function warn() in rev.c is actually duplicate code, so here we remove it. Signed-off-by: Li Zefan <lizf@cn.fujitsu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* Imported from util-linux-2.11o tarball.Karel Zak2006-12-071-1/+1
|
* Imported from util-linux-2.11b tarball.Karel Zak2006-12-071-1/+1
|
* Imported from util-linux-2.10m tarball.Karel Zak2006-12-071-22/+5Star
|
* Imported from util-linux-2.10f tarball.Karel Zak2006-12-071-15/+21
|
* Imported from util-linux-2.9v tarball.Karel Zak2006-12-071-2/+10
|
* Imported from util-linux-2.8 tarball.Karel Zak2006-12-071-70/+72
|
* Imported from util-linux-2.7.1 tarball.Karel Zak2006-12-071-4/+4
|
* Imported from util-linux-2.5 tarball.Karel Zak2006-12-071-2/+2
|
* Imported from util-linux-2.2 tarball.Karel Zak2006-12-071-0/+159