summaryrefslogtreecommitdiffstats
path: root/usr.bin/cut/cut.c
diff options
context:
space:
mode:
authoreivind <eivind@FreeBSD.org>1999-02-02 15:48:04 +0000
committereivind <eivind@FreeBSD.org>1999-02-02 15:48:04 +0000
commit62b47b1e633a781b6f0b1e4ca26770684f349121 (patch)
tree09bd6d3305a2a85ad8d2bbd46054d0a73055217f /usr.bin/cut/cut.c
parenteac18e1b61921f00296eb85595f676b5410fadb8 (diff)
downloadFreeBSD-src-62b47b1e633a781b6f0b1e4ca26770684f349121.zip
FreeBSD-src-62b47b1e633a781b6f0b1e4ca26770684f349121.tar.gz
Merge from NetBSD: cut.1 rev 1.6 to 1.8
cut.c rev 1.9 to 1.13 * Man page internal cleanups * 8-bit characters cast to unsigned for is*() * Misc cleanups for egcs -Wall compatibility
Diffstat (limited to 'usr.bin/cut/cut.c')
-rw-r--r--usr.bin/cut/cut.c35
1 files changed, 21 insertions, 14 deletions
diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c
index 11e9513..1dfd3b0 100644
--- a/usr.bin/cut/cut.c
+++ b/usr.bin/cut/cut.c
@@ -63,7 +63,8 @@ int sflag;
void c_cut __P((FILE *, char *));
void f_cut __P((FILE *, char *));
void get_list __P((char *));
-static void usage __P((void));
+int main __P((int, char **));
+static void usage __P((void));
int
main(argc, argv)
@@ -74,6 +75,7 @@ main(argc, argv)
void (*fcn) __P((FILE *, char *)) = NULL;
int ch;
+ fcn = NULL;
setlocale (LC_ALL, "");
dchar = '\t'; /* default delimiter is \t */
@@ -135,8 +137,8 @@ void
get_list(list)
char *list;
{
- register int setautostart, start, stop;
- register char *pos;
+ int setautostart, start, stop;
+ char *pos;
char *p;
/*
@@ -147,19 +149,19 @@ get_list(list)
* overlapping lists. We also handle "-3-5" although there's no
* real reason too.
*/
- for (; (p = strsep(&list, ", \t"));) {
+ for (; (p = strsep(&list, ", \t")) != NULL;) {
setautostart = start = stop = 0;
if (*p == '-') {
++p;
setautostart = 1;
}
- if (isdigit(*p)) {
+ if (isdigit((unsigned char)*p)) {
start = stop = strtol(p, &p, 10);
if (setautostart && start > autostart)
autostart = start;
}
if (*p == '-') {
- if (isdigit(p[1]))
+ if (isdigit((unsigned char)p[1]))
stop = strtol(p + 1, &p, 10);
if (*p == '-') {
++p;
@@ -194,9 +196,10 @@ c_cut(fp, fname)
FILE *fp;
char *fname;
{
- register int ch = 0, col;
- register char *pos;
+ int ch, col;
+ char *pos;
+ ch = 0;
for (;;) {
pos = positions + 1;
for (col = maxval; col; --col) {
@@ -207,12 +210,13 @@ c_cut(fp, fname)
if (*pos++)
(void)putchar(ch);
}
- if (ch != '\n')
+ if (ch != '\n') {
if (autostop)
while ((ch = getc(fp)) != EOF && ch != '\n')
(void)putchar(ch);
else
while ((ch = getc(fp)) != EOF && ch != '\n');
+ }
(void)putchar('\n');
}
}
@@ -222,8 +226,8 @@ f_cut(fp, fname)
FILE *fp;
char *fname;
{
- register int ch, field, isdelim;
- register char *pos, *p, sep;
+ int ch, field, isdelim;
+ char *pos, *p, sep;
int output;
char lbuf[_POSIX2_LINE_MAX + 1];
@@ -251,12 +255,14 @@ f_cut(fp, fname)
(void)putchar(sep);
while ((ch = *p++) != '\n' && ch != sep)
(void)putchar(ch);
- } else
- while ((ch = *p++) != '\n' && ch != sep);
+ } else {
+ while ((ch = *p++) != '\n' && ch != sep)
+ continue;
+ }
if (ch == '\n')
break;
}
- if (ch != '\n')
+ if (ch != '\n') {
if (autostop) {
if (output)
(void)putchar(sep);
@@ -264,6 +270,7 @@ f_cut(fp, fname)
(void)putchar(ch);
} else
for (; (ch = *p) != '\n'; ++p);
+ }
(void)putchar('\n');
}
}
OpenPOWER on IntegriCloud