summaryrefslogtreecommitdiffstats
path: root/text-utils
diff options
context:
space:
mode:
Diffstat (limited to 'text-utils')
-rw-r--r--text-utils/col.114
-rw-r--r--text-utils/col.c17
-rw-r--r--text-utils/column.c4
-rw-r--r--text-utils/display.c15
-rw-r--r--text-utils/hexdump.c9
-rw-r--r--text-utils/hexdump.h2
-rw-r--r--text-utils/more.13
-rw-r--r--text-utils/more.c81
-rw-r--r--text-utils/odsyntax.c4
-rw-r--r--text-utils/parse.c4
-rw-r--r--text-utils/rev.c27
-rw-r--r--text-utils/ul.c18
12 files changed, 93 insertions, 105 deletions
diff --git a/text-utils/col.1 b/text-utils/col.1
index 1bf985277..141512111 100644
--- a/text-utils/col.1
+++ b/text-utils/col.1
@@ -42,7 +42,7 @@
.Nd filter reverse line feeds from input
.Sh SYNOPSIS
.Nm col
-.Op Fl bfx
+.Op Fl bfpx
.Op Fl l Ar num
.Sh DESCRIPTION
.Nm Col
@@ -66,6 +66,12 @@ written to each column position.
Forward half line feeds are permitted (``fine'' mode).
Normally characters printed on a half line boundary are printed
on the following line.
+.It Fl p
+Force unknown control sequences to be passed through unchanged.
+Normally,
+.Nm col
+will filter out any control sequences from the input other than those
+recognized and interpreted by itself, which are listed below.
.It Fl x
Output multiple spaces instead of tabs.
.It Fl l Ns Ar num
@@ -119,6 +125,12 @@ will display a warning message.
.Xr expand 1 ,
.Xr nroff 1 ,
.Xr tbl 1
+.Sh STANDARDS
+The
+.Nm col
+utility conforms to the Single UNIX Specification, Version 2. The
+.Fl l
+option is an extension to the standard.
.Sh HISTORY
A
.Nm col
diff --git a/text-utils/col.c b/text-utils/col.c
index 81026bfd4..1f740f425 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -45,7 +45,6 @@
*/
#include <stdlib.h>
-#include <malloc.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
@@ -109,6 +108,7 @@ int fine; /* if `fine' resolution (half lines) */
int max_bufd_lines; /* max # lines to keep in memory */
int nblank_lines; /* # blanks after last flushed line */
int no_backspaces; /* if not to output any backspaces */
+int pass_unknown_seqs; /* whether to pass unknown control sequences */
#define PUTC(ch) \
if (putwchar(ch) == WEOF) \
@@ -136,7 +136,8 @@ int main(int argc, char **argv)
max_bufd_lines = 128;
compress_spaces = 1; /* compress spaces into tabs */
- while ((opt = getopt(argc, argv, "bfhl:x")) != EOF)
+ pass_unknown_seqs = 0; /* remove unknown escape sequences */
+ while ((opt = getopt(argc, argv, "bfhl:px")) != -1)
switch (opt) {
case 'b': /* do not output backspaces */
no_backspaces = 1;
@@ -154,6 +155,9 @@ int main(int argc, char **argv)
exit(1);
}
break;
+ case 'p':
+ pass_unknown_seqs = 1;
+ break;
case 'x': /* do not compress spaces into tabs */
compress_spaces = 0;
break;
@@ -221,7 +225,8 @@ int main(int argc, char **argv)
cur_line -= 2;
continue;
}
- continue;
+ if (!pass_unknown_seqs)
+ continue;
}
/* Must stuff ch in a line - are we at the right one? */
@@ -403,7 +408,7 @@ void flush_line(LINE *l)
count = (int *)xmalloc((void *)count,
(unsigned)sizeof(int) * count_size);
}
- bzero((char *)count, sizeof(int) * l->l_max_col + 1);
+ memset(count, 0, sizeof(int) * l->l_max_col + 1);
for (i = nchars, c = l->l_line; --i >= 0; c++)
count[c->c_column]++;
@@ -491,7 +496,7 @@ alloc_line()
l = line_freelist;
line_freelist = l->l_next;
- bzero(l, sizeof(LINE));
+ memset(l, 0, sizeof(LINE));
return(l);
}
@@ -513,7 +518,7 @@ xmalloc(void *p, size_t size)
void usage()
{
- (void)fprintf(stderr, _("usage: col [-bfx] [-l nline]\n"));
+ (void)fprintf(stderr, _("usage: col [-bfpx] [-l nline]\n"));
exit(1);
}
diff --git a/text-utils/column.c b/text-utils/column.c
index 1ad7b8dd4..cfea89fb7 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -80,9 +80,7 @@ wchar_t default_separator[] = { '\t', ' ', 0 };
wchar_t *separator = default_separator; /* field separator for table option */
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{
struct winsize win;
FILE *fp;
diff --git a/text-utils/display.c b/text-utils/display.c
index 27d4e7245..481d2b1ae 100644
--- a/text-utils/display.c
+++ b/text-utils/display.c
@@ -42,6 +42,7 @@
#include "hexdump.h"
static void doskip(char *, int);
+static u_char *get(void);
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
@@ -133,7 +134,7 @@ static off_t savaddress; /* saved address/offset in stream */
} \
}
-void bpad(PR *pr)
+static void bpad(PR *pr)
{
static char *spec = " -0+#";
register char *p1, *p2;
@@ -149,7 +150,7 @@ void bpad(PR *pr)
while ((*p2++ = *p1++) != 0) ;
}
-void display()
+void display(void)
{
extern FU *endfu;
register FS *fs;
@@ -158,7 +159,7 @@ void display()
register int cnt;
register u_char *bp;
off_t saveaddress;
- u_char savech = 0, *savebp, *get();
+ u_char savech = 0, *savebp;
while ((bp = get()) != NULL)
for (fs = fshead, savebp = bp, saveaddress = address; fs;
@@ -205,8 +206,8 @@ void display()
static char **_argv;
-u_char *
-get()
+static u_char *
+get(void)
{
extern enum _vflag vflag;
extern int length;
@@ -276,7 +277,7 @@ get()
int next(char **argv)
{
- extern int errno, exitval;
+ extern int exitval;
static int done;
int statok;
@@ -312,7 +313,6 @@ int next(char **argv)
static void
doskip(char *fname, int statok)
{
- extern int errno;
struct stat sbuf;
if (statok) {
@@ -353,7 +353,6 @@ emalloc(int size)
void nomem()
{
- extern int errno;
(void)fprintf(stderr, "hexdump: %s.\n", strerror(errno));
exit(1);
diff --git a/text-utils/hexdump.c b/text-utils/hexdump.c
index a2be19038..c18c61505 100644
--- a/text-utils/hexdump.c
+++ b/text-utils/hexdump.c
@@ -37,6 +37,7 @@
#include <sys/types.h>
#include <stdio.h>
+#include <string.h>
#include "hexdump.h"
#include "nls.h"
@@ -45,18 +46,16 @@ int blocksize; /* data block size */
int exitval; /* final exit value */
int length = -1; /* max bytes to read */
-int main(argc, argv)
- int argc;
- char **argv;
+int main(int argc, char **argv)
{
register FS *tfs;
- char *p, *rindex();
+ char *p;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
- if (!(p = rindex(argv[0], 'o')) || strcmp(p, "od"))
+ if (!(p = strrchr(argv[0], 'o')) || strcmp(p, "od"))
newsyntax(argc, &argv);
else
oldsyntax(argc, &argv);
diff --git a/text-utils/hexdump.h b/text-utils/hexdump.h
index 3ca46b910..445312231 100644
--- a/text-utils/hexdump.h
+++ b/text-utils/hexdump.h
@@ -77,7 +77,7 @@ extern int deprecated;
extern off_t skip; /* bytes to skip */
enum _vflag { ALL, DUP, FIRST, WAIT }; /* -v values */
-char *emalloc();
+char *emalloc(int);
int size(FS *);
void add(char *);
void rewrite(FS *);
diff --git a/text-utils/more.1 b/text-utils/more.1
index 2f08b38a1..0853dcd90 100644
--- a/text-utils/more.1
+++ b/text-utils/more.1
@@ -101,12 +101,13 @@ each file is displayed.
.It Ic +num
Start at line number
.Ic num .
+.El
.Sh COMMANDS
Interactive commands for
.Nm more
are based on
.Xr vi 1 .
-Some commands may be preceeded by a decimal number, called k in the
+Some commands may be preceded by a decimal number, called k in the
descriptions below.
In the following descriptions, ^X means control-X.
.Pp
diff --git a/text-utils/more.c b/text-utils/more.c
index 771c8d2ae..b7c9d76a2 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -57,6 +57,10 @@
#include <locale.h>
#include "nls.h"
+#define _REGEX_RE_COMP
+#include <regex.h>
+#undef _REGEX_RE_COMP
+
/* #define MOREHELPFILE "/usr/lib/more.help" */
#define VI "/usr/bin/vi"
@@ -102,6 +106,7 @@ int xprintf (char *fmt, ...);
void execute (char *filename, char *cmd, ...);
void errwrite (char *txt);
void errwrite1 (char *sym);
+FILE *checkf (char *, int *);
#define TBUFSIZ 1024
#define LINSIZ 256
@@ -114,7 +119,7 @@ struct termios otty, savetty0;
long file_pos, file_size;
int fnum, no_intty, no_tty, slow_tty;
int dum_opt, dlines;
-void onquit(), onsusp(), chgwinsz(), end_it();
+void onquit(int), onsusp(int), chgwinsz(int), end_it(int);
int nscroll = 11; /* Number of lines scrolled by 'd' */
int fold_opt = 1; /* Fold long lines */
int stop_opt = 1; /* Stop after form feeds */
@@ -151,14 +156,12 @@ char *Home; /* go to home */
char *cursorm; /* cursor movement */
char cursorhome[40]; /* contains cursor movement to home */
char *EodClr; /* clear rest of screen */
-char *tgetstr();
int Mcol = 80; /* number of columns */
int Wrap = 1; /* set if automargins */
int soglitch; /* terminal has standout mode glitch */
int ulglitch; /* terminal has underline mode glitch */
int pstate = 0; /* current UL state */
-char *getenv();
-static int magic();
+static int magic(FILE *, char *);
struct {
long chrctr, line;
} context, screen_start;
@@ -177,32 +180,32 @@ extern char PC; /* pad character */
#endif
#include <term.h> /* include after <curses.h> */
-void
+static void
my_putstring(char *s) {
putp(s);
}
-void
+static void
my_setupterm(const char *term, int fildes, int *errret) {
setupterm(term, fildes, errret);
}
-int
+static int
my_tgetnum(char *s, char *ss) {
return tigetnum(ss);
}
-int
+static int
my_tgetflag(char *s, char *ss) {
return tigetflag(ss);
}
-char *
+static char *
my_tgetstr(char *s, char *ss) {
return tigetstr(ss);
}
-char *
+static char *
my_tgoto(const char *cap, int col, int row) {
return tparm(cap, col, row);
}
@@ -214,32 +217,32 @@ char termbuffer[4096];
char tcbuffer[4096];
char *strbuf = termbuffer;
-void
+static void
my_putstring(char *s) {
tputs (s, 1, putchar);
}
-void
+static void
my_setupterm(const char *term, int fildes, int *errret) {
*errret = tgetent(tcbuffer, term);
}
-int
+static int
my_tgetnum(char *s, char *ss) {
return tgetnum(s);
}
-int
+static int
my_tgetflag(char *s, char *ss) {
return tgetflag(s);
}
-char *
+static char *
my_tgetstr(char *s, char *ss) {
return tgetstr(s, &strbuf);
}
-char *
+static char *
my_tgoto(const char *cap, int col, int row) {
return tgoto(cap, col, row);
}
@@ -247,10 +250,10 @@ my_tgoto(const char *cap, int col, int row) {
#endif /* USE_CURSES */
-void
+static void
idummy(int *kk) {}
-void
+static void
Fdummy(FILE **ff) {}
int main(int argc, char **argv) {
@@ -265,7 +268,6 @@ int main(int argc, char **argv) {
int clearit = 0;
int initline = 0;
char initbuf[80];
- FILE *checkf();
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -631,8 +633,7 @@ void screen (register FILE *f, register int num_lines)
** Come here if a quit signal is received
*/
-void onquit()
-{
+void onquit(int dummy) {
signal(SIGQUIT, SIG_IGN);
if (!inwait) {
putchar ('\n');
@@ -656,8 +657,7 @@ void onquit()
*/
#ifdef SIGWINCH
-void chgwinsz()
-{
+void chgwinsz(int dummy) {
struct winsize win;
(void) signal(SIGWINCH, SIG_IGN);
@@ -680,9 +680,7 @@ void chgwinsz()
** Clean up terminal state and exit. Also come here if interrupt signal received
*/
-void end_it ()
-{
-
+void end_it (int dummy) {
reset_tty ();
if (clreol) {
putchar ('\r');
@@ -764,7 +762,7 @@ int printd (int n)
/* Put the print representation of an integer into a string */
static char *sptr;
-void Sprintf (int n) {
+static void Sprintf (int n) {
int a;
if ((a = n/10) != 0)
@@ -772,7 +770,7 @@ void Sprintf (int n) {
*sptr++ = n % 10 + '0';
}
-void scanstr (int n, char *str)
+static void scanstr (int n, char *str)
{
sptr = str;
Sprintf (n);
@@ -798,9 +796,7 @@ char *s;
** string "string"
*/
-int tailequ (path, string)
-char *path;
-register char *string;
+static int tailequ (char *path, register char *string)
{
register char *tail;
@@ -815,8 +811,7 @@ register char *string;
return(0);
}
-void prompt (filename)
-char *filename;
+static void prompt (char *filename)
{
if (clreol)
cleareol ();
@@ -1171,7 +1166,7 @@ int command (char *filename, register FILE *f)
ret (nscroll);
case 'q':
case 'Q':
- end_it ();
+ end_it (0);
case 's':
case 'f':
if (nlines == 0) nlines++;
@@ -1329,7 +1324,7 @@ int colon (char *filename, int cmd, int nlines)
case 'n':
if (nlines == 0) {
if (fnum >= nfiles - 1)
- end_it ();
+ end_it (0);
nlines++;
}
putchar ('\r');
@@ -1352,7 +1347,7 @@ int colon (char *filename, int cmd, int nlines)
return (-1);
case 'q':
case 'Q':
- end_it ();
+ end_it (0);
default:
ringbell();
return (-1);
@@ -1433,8 +1428,8 @@ void search(char buf[], FILE *file, register int n)
register long line2 = startline;
register long line3 = startline;
register int lncount;
- int saveln, rv, re_exec();
- char *s, *re_comp();
+ int saveln, rv;
+ char *s;
context.line = saveln = Currline;
context.chrctr = startline;
@@ -1497,7 +1492,7 @@ void search(char buf[], FILE *file, register int n)
}
else {
pr (_("\nPattern not found\n"));
- end_it ();
+ end_it (0);
}
error (_("Pattern not found"));
}
@@ -1746,12 +1741,11 @@ retry:
int readch ()
{
char ch;
- extern int errno;
errno = 0;
if (read (2, &ch, 1) <= 0) {
if (errno != EINTR)
- end_it();
+ end_it(0);
else
ch = otty.c_cc[VKILL];
}
@@ -1958,7 +1952,7 @@ void set_tty ()
stty(fileno(stderr), &otty);
}
-int ourputch(int ch) {
+static int ourputch(int ch) {
return putc(ch, stdout);
}
@@ -1992,8 +1986,7 @@ void rdline (register FILE *f)
/* Come here when we get a suspend signal from the terminal */
-void onsusp ()
-{
+void onsusp (int dummy) {
sigset_t signals, oldmask;
/* ignore SIGTTOU so we don't get stopped if csh grabs the tty */
diff --git a/text-utils/odsyntax.c b/text-utils/odsyntax.c
index c22e71d01..74d724e19 100644
--- a/text-utils/odsyntax.c
+++ b/text-utils/odsyntax.c
@@ -44,6 +44,7 @@
#include "nls.h"
static void odoffset(int, char ***);
+static void odprecede(void);
int deprecated;
@@ -55,7 +56,6 @@ oldsyntax(int argc, char ***argvp)
extern int optind;
int ch;
char **argv;
- static void odprecede();
deprecated = 1;
argv = *argvp;
@@ -244,7 +244,7 @@ odoffset(int argc, char ***argvp)
}
static void
-odprecede()
+odprecede(void)
{
static int first = 1;
diff --git a/text-utils/parse.c b/text-utils/parse.c
index 1102e975d..f96a68e81 100644
--- a/text-utils/parse.c
+++ b/text-utils/parse.c
@@ -84,7 +84,7 @@ void add(char *fmt)
static FS **nextfs;
FS *tfs;
FU *tfu, **nextfu;
- char *savep, *emalloc();
+ char *savep;
/* start new linked list of format units */
/* NOSTRICT */
@@ -491,7 +491,7 @@ static void badcnt(char *s)
exit(1);
}
-static void badsfmt()
+static void badsfmt(void)
{
(void)fprintf(stderr,
_("hexdump: %%s requires a precision or a byte count.\n"));
diff --git a/text-utils/rev.c b/text-utils/rev.c
index 82b674f25..a5697b462 100644
--- a/text-utils/rev.c
+++ b/text-utils/rev.c
@@ -44,6 +44,7 @@
*
*/
+#include <stdarg.h>
#include <sys/types.h>
#include <errno.h>
#include <stdio.h>
@@ -54,13 +55,11 @@
#include "widechar.h"
-void usage __P((void));
-void warn __P((const char *, ...));
+void usage(void);
+void warn(const char *, ...);
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
register char *filename;
register wchar_t *t;
@@ -140,27 +139,11 @@ main(argc, argv)
exit(rval);
}
-#if __STDC__
-#include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
-
void
-#if __STDC__
warn(const char *fmt, ...)
-#else
-warn(fmt, va_alist)
- char *fmt;
- va_dcl
-#endif
{
va_list ap;
-#if __STDC__
va_start(ap, fmt);
-#else
- va_start(ap);
-#endif
(void)fprintf(stderr, "rev: ");
(void)vfprintf(stderr, fmt, ap);
va_end(ap);
@@ -168,7 +151,7 @@ warn(fmt, va_alist)
}
void
-usage()
+usage(void)
{
(void)fprintf(stderr, _("usage: rev [file ...]\n"));
exit(1);
diff --git a/text-utils/ul.c b/text-utils/ul.c
index 7745cce4d..419efc938 100644
--- a/text-utils/ul.c
+++ b/text-utils/ul.c
@@ -282,7 +282,7 @@ void filter(FILE *f)
flushln();
}
-void flushln()
+void flushln(void)
{
int lastmode;
int i;
@@ -321,7 +321,7 @@ void flushln()
* For terminals that can overstrike, overstrike underlines and bolds.
* We don't do anything with halfline ups and downs, or Greek.
*/
-void overstrike()
+void overstrike(void)
{
register int i;
#ifdef __GNUC__
@@ -362,7 +362,7 @@ void overstrike()
}
}
-void iattr()
+void iattr(void)
{
register int i;
#ifdef __GNUC__
@@ -389,7 +389,7 @@ void iattr()
putwchar('\n');
}
-void initbuf()
+void initbuf(void)
{
if (obuf == NULL) { /* First time. */
obuflen = INITBUF;
@@ -401,13 +401,13 @@ void initbuf()
}
/* assumes NORMAL == 0 */
- bzero((char *)obuf, sizeof(struct CHAR) * obuflen);
+ memset(obuf, 0, sizeof(struct CHAR) * obuflen);
setcol(0);
maxcol = 0;
mode &= ALTSET;
}
-void fwd()
+void fwd(void)
{
int oldcol, oldmax;
@@ -418,7 +418,7 @@ void fwd()
maxcol = oldmax;
}
-void reverse()
+void reverse(void)
{
upln++;
fwd();
@@ -427,10 +427,8 @@ void reverse()
upln++;
}
-void initinfo()
+void initinfo(void)
{
- char *tigetstr();
-
CURS_UP = tigetstr("cuu1");
CURS_RIGHT = tigetstr("cuf1");
CURS_LEFT = tigetstr("cub1");