diff options
author | eivind <eivind@FreeBSD.org> | 1999-02-02 14:56:55 +0000 |
---|---|---|
committer | eivind <eivind@FreeBSD.org> | 1999-02-02 14:56:55 +0000 |
commit | eac18e1b61921f00296eb85595f676b5410fadb8 (patch) | |
tree | 2cb16e1848f07d8a2deb52f599342fdda051d00a /usr.bin/cut | |
parent | 040ae947ad12478255f12f72bfbf6dee22b0b036 (diff) | |
download | FreeBSD-src-eac18e1b61921f00296eb85595f676b5410fadb8.zip FreeBSD-src-eac18e1b61921f00296eb85595f676b5410fadb8.tar.gz |
Bring in use of strsep() to handle bad input better, and clean up
some text.
Obtained from: Merge from OpenBSD
(cut.1 up to OpenBSD rev 1.3, cut.c up to OpenBSD rev 1.6)
Diffstat (limited to 'usr.bin/cut')
-rw-r--r-- | usr.bin/cut/cut.1 | 9 | ||||
-rw-r--r-- | usr.bin/cut/cut.c | 6 |
2 files changed, 8 insertions, 7 deletions
diff --git a/usr.bin/cut/cut.1 b/usr.bin/cut/cut.1 index 80d36fa..fd1c92d 100644 --- a/usr.bin/cut/cut.1 +++ b/usr.bin/cut/cut.1 @@ -67,11 +67,11 @@ The items specified by can be in terms of column position or in terms of fields delimited by a special character. Column numbering starts from 1. .Pp -.Ar List +.Ar list is a comma or whitespace separated set of increasing numbers and/or number ranges. Number ranges consist of a number, a dash -.Pq Li \- , +.Pq Sq \- , and a second number and select the fields or columns from the first number to the second, inclusive. @@ -109,8 +109,9 @@ Suppresses lines with no field delimiter characters. Unless specified, lines with no delimiters are passed through unmodified. .El .Pp -.Nm Cut -exits 0 on success, 1 if an error occurred. +The +.Nm cut +utility exits 0 on success or 1 if an error occurred. .Sh SEE ALSO .Xr paste 1 .Sh STANDARDS diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c index 1075729..11e9513 100644 --- a/usr.bin/cut/cut.c +++ b/usr.bin/cut/cut.c @@ -80,7 +80,7 @@ main(argc, argv) /* Since we don't support multi-byte characters, the -c and -b options are equivalent, and the -n option is meaningless. */ - while ((ch = getopt(argc, argv, "b:c:d:f:sn")) != EOF) + while ((ch = getopt(argc, argv, "b:c:d:f:sn")) != -1) switch(ch) { case 'b': case 'c': @@ -147,7 +147,7 @@ get_list(list) * overlapping lists. We also handle "-3-5" although there's no * real reason too. */ - for (; (p = strtok(list, ", \t")); list = NULL) { + for (; (p = strsep(&list, ", \t"));) { setautostart = start = stop = 0; if (*p == '-') { ++p; @@ -231,7 +231,7 @@ f_cut(fp, fname) output = 0; for (isdelim = 0, p = lbuf;; ++p) { if (!(ch = *p)) - errx(1, "%s: line too long", fname); + errx(1, "%s: line too long.", fname); /* this should work if newline is delimiter */ if (ch == sep) isdelim = 1; |