summaryrefslogtreecommitdiff
path: root/text-utils
diff options
context:
space:
mode:
Diffstat (limited to 'text-utils')
-rw-r--r--text-utils/Makemodule.am28
-rw-r--r--text-utils/col.14
-rw-r--r--text-utils/colcrt.14
-rw-r--r--text-utils/colrm.14
-rw-r--r--text-utils/column.121
-rw-r--r--text-utils/column.c13
-rw-r--r--text-utils/display.c1
-rw-r--r--text-utils/hexdump.124
-rw-r--r--text-utils/hexdump.h1
-rw-r--r--text-utils/hexsyntax.c61
-rw-r--r--text-utils/more.138
-rw-r--r--text-utils/more.c59
-rw-r--r--text-utils/pg.c28
-rw-r--r--text-utils/rev.14
-rw-r--r--text-utils/rev.c28
-rw-r--r--text-utils/tailf.14
-rw-r--r--text-utils/ul.12
-rw-r--r--text-utils/ul.c20
18 files changed, 198 insertions, 146 deletions
diff --git a/text-utils/Makemodule.am b/text-utils/Makemodule.am
index d3ebfdc5b..970b452e9 100644
--- a/text-utils/Makemodule.am
+++ b/text-utils/Makemodule.am
@@ -53,11 +53,8 @@ if BUILD_PG
usrbin_exec_PROGRAMS += pg
dist_man_MANS += text-utils/pg.1
pg_SOURCES = text-utils/pg.c
-pg_CFLAGS = $(AM_CFLAGS) $(BSD_WARN_CFLAGS)
-pg_LDADD = $(LDADD) libcommon.la @NCURSES_LIBS@
-if HAVE_TINFO
-pg_LDADD += -ltinfo
-endif
+pg_CFLAGS = $(AM_CFLAGS) $(BSD_WARN_CFLAGS) $(NCURSES_CFLAGS) $(TINFO_CFLAGS)
+pg_LDADD = $(LDADD) libcommon.la $(NCURSES_LIBS) $(TINFO_LIBS)
endif # BUILD_PG
@@ -65,11 +62,14 @@ if BUILD_UL
usrbin_exec_PROGRAMS += ul
dist_man_MANS += text-utils/ul.1
ul_SOURCES = text-utils/ul.c
+ul_CFLAGS = $(AM_CFLAGS)
ul_LDADD = $(LDADD)
if HAVE_TINFO
-ul_LDADD += -ltinfo
-else
-ul_LDADD += @NCURSES_LIBS@
+ul_LDADD += $(TINFO_LIBS)
+ul_LDADD += $(TINFO_CFLAGS)
+else
+ul_CFLAGS += $(NCURSES_CFLAGS)
+ul_LDADD += $(NCURSES_LIBS)
endif
endif # BUILD_UL
@@ -81,13 +81,15 @@ more_SOURCES = text-utils/more.c
more_CFLAGS = $(AM_CFLAGS) $(BSD_WARN_CFLAGS)
more_LDADD = $(LDADD)
if HAVE_TINFO
-more_LDADD += -ltinfo
-else
-if HAVE_NCURSES
-more_LDADD += @NCURSES_LIBS@
+more_LDADD += $(TINFO_LIBS)
+more_LDADD += $(TINFO_CFLAGS)
else
-more_LDADD += -ltermcap
+more_CFLAGS += $(NCURSES_CFLAGS)
+more_LDADD += $(NCURSES_LIBS)
endif
+
+if HAVE_TERMCAP
+more_LDADD += -ltermcap
endif
check_PROGRAMS += test_more
diff --git a/text-utils/col.1 b/text-utils/col.1
index 2b36c8503..c6aa8c4fa 100644
--- a/text-utils/col.1
+++ b/text-utils/col.1
@@ -84,10 +84,10 @@ lines in memory. By default, 128 lines are buffered.
.It Fl V, Fl Fl version
.TP
\fB\-V\fR, \fB\-\-version\fR
-Output version information and exit.
+Display version information and exit.
.TP
\fB\-H\fR, \fB\-\-help\fR
-Output help and exit.
+Display help text and exit.
.SH NOTES
The control sequences for carriage motion that
.B col
diff --git a/text-utils/colcrt.1 b/text-utils/colcrt.1
index f8a5420a3..cf9f23921 100644
--- a/text-utils/colcrt.1
+++ b/text-utils/colcrt.1
@@ -61,10 +61,10 @@ option is useful for sending output to the line printer when the output
contains superscripts and subscripts which would otherwise be invisible.
.TP
\fB\-V\fR, \fB\-\-version\fR
-Output version information and exit.
+Display version information and exit.
.TP
\fB\-h\fR, \fB\-\-help\fR
-Output help and exit.
+Display help text and exit.
.SH EXAMPLES
A typical use of
.B colcrt
diff --git a/text-utils/colrm.1 b/text-utils/colrm.1
index 03c7f13cf..fdb2fbca1 100644
--- a/text-utils/colrm.1
+++ b/text-utils/colrm.1
@@ -55,10 +55,10 @@ Column numbering starts with column 1.
.SH OPTIONS
.TP
\fB\-V\fR, \fB\-\-version\fR
-Output version information and exit.
+Display version information and exit.
.TP
\fB\-h\fR, \fB\-\-help\fR
-Output help and exit.
+Display help text and exit.
.SH SEE ALSO
.BR awk (1),
.BR column (1),
diff --git a/text-utils/column.1 b/text-utils/column.1
index b6da45f4a..33c09e4b1 100644
--- a/text-utils/column.1
+++ b/text-utils/column.1
@@ -36,14 +36,14 @@
column - columnate lists
.SH SYNOPSIS
.B column
-.RI [ options ]
-.IR file ...
+.RB [ options ]
+.RI [ file ...]
.SH DESCRIPTION
The
.B column
-utility formats its input into multiple columns. Rows
-are filled before columns. Input is taken from \fIfile\fR or, by
-default, from standard input. Empty lines are ignored.
+utility formats its input into multiple columns. By default, rows
+are filled before columns. Input is taken from \fIfile\fR, or
+otherwise from standard input. Empty lines are ignored.
.PP
.SH OPTIONS
.IP "\fB\-c, \-\-columns\fP \fIwidth\fP"
@@ -51,15 +51,16 @@ Output is formatted to a width specified as number of characters.
.IP "\fB\-t, \-\-table\fP"
Determine the number of columns the input contains and create a table.
Columns are delimited with whitespace, by default, or with the characters
-supplied using the separator. Table output is useful for pretty-printing.
+supplied using the \fB\-\-output-separator\fP option.
+Table output is useful for pretty-printing.
.IP "\fB\-s, \-\-separator\fP \fIseparators\fP"
-Specify possible table delimiters (default is whitespace).
-.IP "\fB\-o, \-\-output-separator\fP \fIseparators\fP"
-Specify table output delimiter (default is two whitespaces).
+Specify the possible input item delimiters (default is whitespace).
+.IP "\fB\-o, \-\-output-separator\fP \fIstring\fP"
+Specify the columns delimiter for table output (default is two spaces).
.IP "\fB\-x, \-\-fillrows\fP"
Fill columns before filling rows.
.IP "\fB\-h, \-\-help\fP"
-Print help and exit.
+Display help text and exit.
.SH ENVIRONMENT
The environment variable COLUMNS is used to determine the size of
the screen if no other information is available.
diff --git a/text-utils/column.c b/text-utils/column.c
index 2649fecee..2430ede9e 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -89,13 +89,13 @@ static void __attribute__((__noreturn__)) usage(int rc)
FILE *out = rc == EXIT_FAILURE ? stderr : stdout;
fputs(USAGE_HEADER, out);
- fprintf(out, _(" %s [options] [file ...]\n"), program_invocation_short_name);
+ fprintf(out, _(" %s [options] [<file>...]\n"), program_invocation_short_name);
fputs(USAGE_OPTIONS, out);
fputs(_(" -c, --columns <width> width of output in number of characters\n"), out);
fputs(_(" -t, --table create a table\n"), out);
fputs(_(" -s, --separator <string> possible table delimiters\n"), out);
- fputs(_(" -o, --output-separator <string>\n"), out);
- fputs(_(" table output column separator, default is two spaces\n"), out);
+ fputs(_(" -o, --output-separator <string>\n"
+ " columns separator for table output; default is two spaces\n"), out);
fputs(_(" -x, --fillrows fill rows before columns\n"), out);
fputs(USAGE_SEPARATOR, out);
fputs(USAGE_HELP, out);
@@ -308,7 +308,7 @@ wchar_t *local_wcstok(wchar_t * p, const wchar_t * separator, int greedy,
static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy, wchar_t *colsep)
{
TBL *t;
- int cnt, i;
+ int cnt;
wchar_t *p, **lp;
ssize_t *lens;
ssize_t maxcols = DEFCOLS, coloff;
@@ -347,8 +347,7 @@ static void maketbl(wchar_t **list, int entries, wchar_t *separator, int greedy,
for (t = tbl, cnt = 0; cnt < entries; ++cnt, ++t) {
for (coloff = 0; coloff < t->cols - 1; ++coloff) {
fputws(t->list[coloff], stdout);
- for (i = lens[coloff] - t->len[coloff]; i > 0; i--)
- putwchar(' ');
+ wprintf(L"%*s", lens[coloff] - t->len[coloff], "");
fputws(colsep, stdout);
}
if (coloff < t->cols) {
@@ -392,7 +391,7 @@ static int input(FILE *fp, int *maxlength, wchar_t ***list, int *entries)
continue;
}
lineno++;
- if (!feof(fp))
+ if (!feof(fp) && p)
*p = '\0';
len = wcs_width(buf); /* len = p - buf; */
if (*maxlength < len)
diff --git a/text-utils/display.c b/text-utils/display.c
index 1f9a11b4c..11303667e 100644
--- a/text-utils/display.c
+++ b/text-utils/display.c
@@ -33,6 +33,7 @@
#include <sys/param.h>
#include <sys/stat.h>
+#include <sys/types.h>
#include <unistd.h>
#include <errno.h>
#include <ctype.h>
diff --git a/text-utils/hexdump.1 b/text-utils/hexdump.1
index 903100dfc..e8afdbac8 100644
--- a/text-utils/hexdump.1
+++ b/text-utils/hexdump.1
@@ -31,7 +31,7 @@
.\"
.\" from: @(#)hexdump.1 8.2 (Berkeley) 4/18/94
.\"
-.TH HEXDUMP "1" "September 2011" "util-linux" "User Commands"
+.TH HEXDUMP "1" "April 2013" "util-linux" "User Commands"
.SH NAME
hexdump \- display file contents in ascii, decimal, hexadecimal, or octal
.SH SYNOPSIS
@@ -49,17 +49,17 @@ suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, PiB, EiB, ZiB and YiB
(the "iB" is optional, e.g. "K" has the same meaning as "KiB") or the suffixes
KB=1000, MB=1000*1000, and so on for GB, TB, PB, EB, ZB and YB.
.TP
-.B \-b
+\fB\-b\fR, \fB\-\-one\-byte\-octal\fR
\fIOne-byte octal display\fR. Display the input offset in hexadecimal,
followed by sixteen space-separated, three-column, zero-filled bytes of input
data, in octal, per line.
.TP
-.B \-c
+\fB\-c\fR, \fB\-\-one\-byte\-char\fR
\fIOne-byte character display\fR. Display the input offset in hexadecimal,
followed by sixteen space-separated, three-column, space-filled characters of
input data per line.
.TP
-.B \-C
+\fB\-C\fR, \fB\-\-canonical\fR
\fICanonical hex+ASCII display\fR. Display the input offset in hexadecimal,
followed by sixteen space-separated, two-column, hexadecimal bytes, followed
by the same sixteen bytes in
@@ -68,35 +68,35 @@ format enclosed in
.RB ' | '
characters.
.TP
-.B \-d
+\fB\-d\fR, \fB\-\-two\-bytes\-decimal\fR
\fITwo-byte decimal display\fR. Display the input offset in hexadecimal,
followed by eight space-separated, five-column, zero-filled, two-byte units
of input data, in unsigned decimal, per line.
.TP
-.BI \-e \ format_string
+\fB\-e\fR, \fB\-\-format\fR \fIformat_string\fR
Specify a format string to be used for displaying data.
.TP
-.BI \-f \ format_file
+\fB\-r\fR, \fB\-\-format\-file\fR \fIfile\fR
Specify a file that contains one or more newline separated format strings.
Empty lines and lines whose first non-blank character is a hash mark (\&#)
are ignored.
.TP
-.BI \-n \ length
+\fB\-n\fR, \fB\-\-length\fR \fIlength\fR
Interpret only
.I length
bytes of input.
.TP
-.B \-o
+\fB\-o\fR, \fB\-\-two\-bytes\-octal\fR
\fITwo-byte octal display\fR. Display the input offset in hexadecimal,
followed by eight space-separated, six-column, zero-filled, two-byte
quantities of input data, in octal, per line.
.TP
-.BI \-s \ offset
+\fB\-s\fR, \fB\-\-skip\fR \fIoffset\fR
Skip
.I offset
bytes from the beginning of the input.
.TP
-.B \-v
+\fB\-v\fR, \fB\-\-no\-squeezing\fR
The
.B \-v
option causes
@@ -107,7 +107,7 @@ option, any number of groups of output lines which would be identical to the
immediately preceding group of output lines (except for the input offsets),
are replaced with a line comprised of a single asterisk.
.TP
-.B \-x
+\fB\-x\fR, \fB\-\-two\-bytes\-hex\fR
\fITwo-byte hexadecimal display\fR. Display the input offset in hexadecimal,
followed by eight space-separated, four-column, zero-filled, two-byte
quantities of input data, in hexadecimal, per line.
diff --git a/text-utils/hexdump.h b/text-utils/hexdump.h
index b9e67a1ba..fa8f632c1 100644
--- a/text-utils/hexdump.h
+++ b/text-utils/hexdump.h
@@ -73,7 +73,6 @@ typedef struct _fs { /* format strings */
extern FU *endfu;
extern FS *fshead; /* head of format strings list */
extern ssize_t blocksize; /* data block size */
-extern int deprecated; /* od compatibility */
extern int exitval; /* final exit value */
extern ssize_t length; /* max bytes to read */
extern off_t skip; /* bytes to skip */
diff --git a/text-utils/hexsyntax.c b/text-utils/hexsyntax.c
index b0e4fb7b4..b37e46e0d 100644
--- a/text-utils/hexsyntax.c
+++ b/text-utils/hexsyntax.c
@@ -42,6 +42,7 @@
#include <errno.h>
#include <err.h>
#include <limits.h>
+#include <getopt.h>
#include "hexdump.h"
#include "nls.h"
#include "strutils.h"
@@ -56,8 +57,25 @@ newsyntax(int argc, char ***argvp)
int ch;
char **argv;
+ static const struct option longopts[] = {
+ {"one-byte-octal", no_argument, NULL, 'b'},
+ {"one-byte-char", required_argument, NULL, 'c'},
+ {"canonical", required_argument, NULL, 'C'},
+ {"two-bytes-decimal", no_argument, NULL, 'd'},
+ {"two-bytes-octal", required_argument, NULL, 'o'},
+ {"two-bytes-hex", no_argument, NULL, 'x'},
+ {"format", required_argument, NULL, 'e'},
+ {"format-file", required_argument, NULL, 'f'},
+ {"length", required_argument, NULL, 'n'},
+ {"skip", required_argument, NULL, 's'},
+ {"no-squeezing", no_argument, NULL, 'v'},
+ {"help", no_argument, NULL, 'h'},
+ {"version", no_argument, NULL, 'V'},
+ {NULL, no_argument, NULL, 0}
+ };
+
argv = *argvp;
- while ((ch = getopt(argc, argv, "bcCde:f:n:os:vxV")) != -1) {
+ while ((ch = getopt_long(argc, argv, "bcCde:f:n:os:vxhV", longopts, NULL)) != -1) {
switch (ch) {
case 'b':
add("\"%07.7_Ax\n\"");
@@ -99,10 +117,10 @@ newsyntax(int argc, char ***argvp)
add("\"%07.7_Ax\n\"");
add("\"%07.7_ax \" 8/2 \" %04x \" \"\\n\"");
break;
+ case 'h':
+ usage(stdout);
case 'V':
- printf(_("%s from %s\n"),
- program_invocation_short_name,
- PACKAGE_STRING);
+ printf(UTIL_LINUX_VERSION);
exit(EXIT_SUCCESS);
break;
default:
@@ -120,23 +138,24 @@ newsyntax(int argc, char ***argvp)
void __attribute__((__noreturn__)) usage(FILE *out)
{
- fprintf(out, _("\nUsage:\n"
- " %s [options] file...\n"),
- program_invocation_short_name);
- fprintf(out, _(
- "\nOptions:\n"
- " -b one-byte octal display\n"
- " -c one-byte character display\n"
- " -C canonical hex+ASCII display\n"
- " -d two-byte decimal display\n"
- " -o two-byte octal display\n"
- " -x two-byte hexadecimal display\n"
- " -e format format string to be used for displaying data\n"
- " -f format_file file that contains format strings\n"
- " -n length interpret only length bytes of input\n"
- " -s offset skip offset bytes from the beginning\n"
- " -v display without squeezing similar lines\n"
- " -V output version information and exit\n\n"));
+ fputs(USAGE_HEADER, out);
+ fprintf(out, _(" %s [options] <file>...\n"), program_invocation_short_name);
+ fputs(USAGE_OPTIONS, out);
+ fputs(_(" -b, --one-byte-octal one-byte octal display\n"), out);
+ fputs(_(" -c, --one-byte-char one-byte character display\n"), out);
+ fputs(_(" -C, --canonical canonical hex+ASCII display\n"), out);
+ fputs(_(" -d, --two-bytes-decimal two-byte decimal display\n"), out);
+ fputs(_(" -o, --two-bytes-octal two-byte octal display\n"), out);
+ fputs(_(" -x, --two-bytes-hex two-byte hexadecimal display\n"), out);
+ fputs(_(" -e, --format <format> format string to be used for displaying data\n"), out);
+ fputs(_(" -f, --format-file <file> file that contains format strings\n"), out);
+ fputs(_(" -n, --length <length> interpret only length bytes of input\n"), out);
+ fputs(_(" -s, --skip <offset> skip offset bytes from the beginning\n"), out);
+ fputs(_(" -v, --no-squeezing output identical lines\n"), out);
+ fputs(USAGE_SEPARATOR, out);
+ fputs(USAGE_HELP, out);
+ fputs(USAGE_VERSION, out);
+ fprintf(out, USAGE_MAN_TAIL("hexdump(1)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
diff --git a/text-utils/more.1 b/text-utils/more.1
index 479f037f0..0cf3892a2 100644
--- a/text-utils/more.1
+++ b/text-utils/more.1
@@ -37,12 +37,13 @@
.\" conform with the more 5.19 currently in use by the Linux community.
.\"
.\" .Dd July 29, 1991 (Modified December 25, 1992)
-.TH MORE "1" "September 2011" "util-linux" "User Commands"
+.TH MORE "1" "February 2014" "util-linux" "User Commands"
.SH NAME
more \- file perusal filter for crt viewing
.SH SYNOPSIS
.B more
-[options] file [...]
+[options]
+.IR file ...
.SH DESCRIPTION
.B more
is a filter for paging through text one screenful at a time. This version is
@@ -59,11 +60,6 @@ environment variable
override them.
.It Fl num
.TP
-.B \-number
-This option specifies an integer
-.I number
-which is the screen size (in lines).
-.TP
.B \-d
.B more
will prompt the user with the message "[Press space to continue, 'q' to
@@ -100,15 +96,19 @@ Squeeze multiple blank lines into one.
.B \-u
Suppress underlining.
.TP
-.B +/
-The
-.B +/
-option specifies a string that will be searched for before each file is
-displayed.
+.BI \- number
+The screen size to use, in
+.I number
+of lines.
.TP
-.B +number
-Start at line
+.BI + number
+Start displaying each file at line
.IR number .
+.TP
+.BI +/ string
+The
+.I string
+to be searched in each file before starting to display it.
.SH COMMANDS
Interactive commands for
.B more
@@ -203,7 +203,9 @@ Display current file name and line number.
.B \&.
Repeat previous command.
.SH ENVIRONMENT
-More utilizes the following environment variables, if they exist:
+The
+.B more
+command respects the following environment variables, if they exist:
.TP
.B MORE
This variable may be set with favored options to
@@ -213,16 +215,16 @@ This variable may be set with favored options to
Current shell in use (normally set by the shell at login time).
.TP
.B TERM
-Specifies terminal type, used by more to get the terminal
+The terminal type used by \fBmore\fR to get the terminal
characteristics necessary to manipulate the screen.
.TP
.B VISUAL
-Editor the user is preferring. Used when key command
+The editor the user prefers. Invoked when command key
.I v
is pressed.
.TP
.B EDITOR
-Editor of choise when
+The editor of choice when
.B VISUAL
is not specified.
.SH SEE ALSO
diff --git a/text-utils/more.c b/text-utils/more.c
index 496b1168f..638522b77 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -286,7 +286,7 @@ static void my_putstring(char *s)
tputs(s, fileno(stdout), putchar);
}
-static void my_setupterm(char *term, int fildes, int *errret)
+static void my_setupterm(char *term, int fildes __attribute__((__unused__)), int *errret)
{
*errret = tgetent(tcbuffer, term);
}
@@ -315,22 +315,21 @@ static char *my_tgoto(char *cap, int col, int row)
static void __attribute__((__noreturn__)) usage(FILE *out)
{
- fprintf(out,
- _("Usage: %s [options] file...\n\n"),
- program_invocation_short_name);
- fprintf(out,
- _("Options:\n"
- " -d display help instead of ring bell\n"
- " -f count logical, rather than screen lines\n"
- " -l suppress pause after form feed\n"
- " -p do not scroll, clean screen and display text\n"
- " -c do not scroll, display text and clean line ends\n"
- " -u suppress underlining\n"
- " -s squeeze multiple blank lines into one\n"
- " -NUM specify the number of lines per screenful\n"
- " +NUM display file beginning from line number NUM\n"
- " +/STRING display file beginning from search string match\n"
- " -V output version information and exit\n"));
+ fputs(USAGE_HEADER, out);
+ fprintf(out, _(" %s [options] <file>...\n"), program_invocation_short_name);
+ fputs(USAGE_OPTIONS, out);
+ fputs(_(" -d display help instead of ringing bell\n"), out);
+ fputs(_(" -f count logical rather than screen lines\n"), out);
+ fputs(_(" -l suppress pause after form feed\n"), out);
+ fputs(_(" -c do not scroll, display text and clean line ends\n"), out);
+ fputs(_(" -p do not scroll, clean screen and display text\n"), out);
+ fputs(_(" -s squeeze multiple blank lines into one\n"), out);
+ fputs(_(" -u suppress underlining\n"), out);
+ fputs(_(" -<number> the number of lines per screenful\n"), out);
+ fputs(_(" +<number> display file beginning from line number\n"), out);
+ fputs(_(" +/<string> display file beginning from search string match\n"), out);
+ fputs(_(" -V display version information and exit\n"), out);
+ fprintf(out, USAGE_MAN_TAIL("more(1)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
@@ -780,10 +779,11 @@ void __attribute__((__noreturn__)) end_it(int dummy __attribute__((__unused__)))
void copy_file(register FILE *f)
{
- register int c;
+ char buf[BUFSIZ];
+ size_t sz;
- while ((c = getc(f)) != EOF)
- putchar(c);
+ while ((sz = fread(&buf, sizeof(char), sizeof(buf), f)) > 0)
+ fwrite(&buf, sizeof(char), sz, stdout);
}
#define ringbell() putcerr('\007')
@@ -835,7 +835,8 @@ void prepare_line_buffer(void)
if (nsz < LINSIZ)
nsz = LINSIZ;
- nline = xrealloc(Line, nsz);
+ /* alloc nsz and extra space for \n\0 */
+ nline = xrealloc(Line, nsz + 2);
Line = nline;
LineLen = nsz;
}
@@ -911,7 +912,8 @@ int get_line(register FILE *f, int *length)
Fseek(f, file_pos_bak);
break_flag = 1;
} else {
- for (i = 0; i < mbc_pos; i++)
+ for (i = 0; p < &Line[LineLen - 1] &&
+ i < mbc_pos; i++)
*p++ = mbc[i];
if (wc_width > 0)
column += wc_width;
@@ -1028,6 +1030,12 @@ int get_line(register FILE *f, int *length)
if (column >= Mcol && fold_opt)
break;
+#ifdef HAVE_WIDECHAR
+ if (use_mbc_buffer_flag == 0 && p >= &Line[LineLen - 1 - 4])
+ /* don't read another char if there is no space for
+ * whole multibyte sequence */
+ break;
+#endif
c = Getc(f);
}
if (column >= Mcol && Mcol > 0) {
@@ -1058,8 +1066,7 @@ void erasep(register int col)
if (!dumb && eraseln)
my_putstring(eraseln);
else
- for (col = promptlen - col; col > 0; col--)
- putchar(' ');
+ printf("%*s", promptlen - col, "");
}
promptlen = 0;
}
@@ -1580,7 +1587,7 @@ void search(char buf[], FILE *file, register int n)
long startline = Ftell(file);
register long line1 = startline;
register long line2 = startline;
- register long line3 = startline;
+ register long line3;
register int lncount;
int saveln, rc;
regex_t re;
@@ -1774,7 +1781,7 @@ void initterm(void)
{
int tgrp;
/* Wait until we're in the foreground before we
- * save the the terminal modes. */
+ * save the terminal modes. */
if ((tgrp = tcgetpgrp(fileno(stdout))) < 0) {
perror("tcgetpgrp");
exit(EXIT_FAILURE);
diff --git a/text-utils/pg.c b/text-utils/pg.c
index c00b7371f..e9156c3a1 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -224,8 +224,11 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
fputs(_(" -s print messages to stdout\n"), out);
fputs(_(" +number start at the given line\n"), out);
fputs(_(" +/pattern/ start at the line containing pattern\n"), out);
- fputs(_(" -h display this help and exit\n"), out);
- fputs(_(" -V output version information and exit\n"), out);
+
+ fputs(USAGE_SEPARATOR, out);
+ fputs(USAGE_HELP, out);
+ fputs(USAGE_VERSION, out);
+
fprintf(out, USAGE_MAN_TAIL("pg(1)"));
quit(out == stderr ? 2 : 0);
}
@@ -1228,7 +1231,14 @@ static void pgfile(FILE *f, const char *name)
/* No error check for compat. */
fwrite_all(b, sizeof *b, sz, save);
}
- fclose(save);
+ if (close_stream(save) != 0) {
+ cmd.count = errno;
+ mesg(_("write failed"));
+ mesg(": ");
+ mesg(p);
+ mesg(strerror(cmd.count));
+ goto newcmd;
+ }
fseeko(fbuf, (off_t)0, SEEK_END);
mesg(_("saved"));
goto newcmd;
@@ -1512,7 +1522,7 @@ int main(int argc, char **argv)
_("%s %s Copyright (c) 2000-2001 Gunnar Ritter. All rights reserved.\n"),
program_invocation_short_name, PACKAGE_VERSION);
- setlocale(LC_MESSAGES, "");
+ setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
atexit(close_stdout);
@@ -1535,6 +1545,16 @@ int main(int argc, char **argv)
if (*argv[arg] != '-' || argv[arg][1] == '\0')
break;
argc--;
+
+ if (!strcmp(argv[arg], "--help")) {
+ usage(stdout);
+ }
+
+ if (!strcmp(argv[arg], "--version")) {
+ printf(UTIL_LINUX_VERSION);
+ return EXIT_SUCCESS;
+ }
+
for (i = 1; argv[arg][i]; i++) {
switch (argv[arg][i]) {
case '-':
diff --git a/text-utils/rev.1 b/text-utils/rev.1
index a50a4c56d..4b0bd7af3 100644
--- a/text-utils/rev.1
+++ b/text-utils/rev.1
@@ -47,10 +47,10 @@ characters in every line. If no files are specified, standard input is read.
.SH OPTIONS
.TP
\fB\-V\fR, \fB\-\-version\fR
-Output version information and exit.
+Display version information and exit.
.TP
\fB\-h\fR, \fB\-\-help\fR
-Output help and exit.
+Display help text and exit.
.SH SEE ALSO
.BR tac (1)
.SH AVAILABILITY
diff --git a/text-utils/rev.c b/text-utils/rev.c
index 95545064a..f1341cb3d 100644
--- a/text-utils/rev.c
+++ b/text-utils/rev.c
@@ -86,10 +86,20 @@ static void __attribute__ ((__noreturn__)) usage(FILE * out)
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
+static void reverse_str(wchar_t *str, size_t n)
+{
+ size_t i;
+
+ for (i = 0; i < n / 2; ++i) {
+ wchar_t tmp = str[i];
+ str[i] = str[n - 1 - i];
+ str[n - 1 - i] = tmp;
+ }
+}
+
int main(int argc, char *argv[])
{
char *filename = "stdin";
- wchar_t *t;
size_t len, bufsiz = BUFSIZ;
FILE *fp = stdin;
int ch, rval = EXIT_SUCCESS;
@@ -153,22 +163,16 @@ int main(int argc, char *argv[])
len = wcslen(buf);
}
-
- t = buf + len - 1 - (*(buf+len-1)=='\r' || *(buf+len-1)=='\n');
- for ( ; t >= buf; --t) {
- if (*t != 0)
- putwchar(*t);
- }
- putwchar('\n');
+ if (buf[len - 1] == '\n')
+ buf[len--] = '\0';
+ reverse_str(buf, len);
+ fputws(buf, stdout);
}
-
- fflush(fp);
if (ferror(fp)) {
warn("%s", filename);
rval = EXIT_FAILURE;
}
- if (fclose(fp))
- rval = EXIT_FAILURE;
+ fclose(fp);
} while(*argv);
free(buf);
diff --git a/text-utils/tailf.1 b/text-utils/tailf.1
index 49eda0b45..1cdbff16d 100644
--- a/text-utils/tailf.1
+++ b/text-utils/tailf.1
@@ -50,10 +50,10 @@ output the last
lines, instead of the last 10.
.TP
\fB\-V\fR, \fB\-\-version
-Output version information and exit.
+Display version information and exit.
.TP
\fB\-h\fR, \fB\-\-help
-Display help and exit.
+Display help text and exit.
.SH AUTHOR
This program was originally written by Rik Faith (faith@acm.org) and may be freely
diff --git a/text-utils/ul.1 b/text-utils/ul.1
index 9ed93790a..78fdd5fc9 100644
--- a/text-utils/ul.1
+++ b/text-utils/ul.1
@@ -73,7 +73,7 @@ type specified in the environment with
Display version information and exit.
.TP
\fB\-h\fR, \fB\-\-help\fR
-Display a help text and exit.
+Display help text and exit.
.SH ENVIRONMENT
The following environment variable is used:
.TP
diff --git a/text-utils/ul.c b/text-utils/ul.c
index 5710a5547..b3b3dc354 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -447,8 +447,7 @@ static void overstrike(void)
putwchar('\r');
for (*cp = ' '; *cp == ' '; cp--)
*cp = 0;
- for (cp = lbuf; *cp; cp++)
- putwchar(*cp);
+ fputws(lbuf, stdout);
if (hadbold) {
putwchar('\r');
for (cp = lbuf; *cp; cp++)
@@ -463,11 +462,11 @@ static void iattr(void)
{
register int i;
#ifdef __GNUC__
- register char *lbuf = __builtin_alloca((maxcol+1)*sizeof(char));
+ register wchar_t *lbuf = __builtin_alloca((maxcol+1)*sizeof(wchar_t));
#else
- char lbuf[BUFSIZ];
+ wchar_t lbuf[BUFSIZ];
#endif
- register char *cp = lbuf;
+ register wchar_t *cp = lbuf;
for (i = 0; i < maxcol; i++)
switch (obuf[i].c_mode) {
@@ -481,8 +480,7 @@ static void iattr(void)
}
for (*cp = ' '; *cp == ' '; cp--)
*cp = 0;
- for (cp = lbuf; *cp; cp++)
- putwchar(*cp);
+ fputws(lbuf, stdout);
putwchar('\n');
}
@@ -491,11 +489,11 @@ static void initbuf(void)
if (obuf == NULL) {
/* First time. */
obuflen = BUFSIZ;
- obuf = xmalloc(sizeof(struct CHAR) * obuflen);
- }
+ obuf = xcalloc(obuflen, sizeof(struct CHAR));
+ } else
+ /* assumes NORMAL == 0 */
+ memset(obuf, 0, sizeof(struct CHAR) * maxcol);
- /* assumes NORMAL == 0 */
- memset(obuf, 0, sizeof(struct CHAR) * obuflen);
setcol(0);
maxcol = 0;
mode &= ALTSET;