summaryrefslogtreecommitdiff
path: root/usr.bin/uniq
diff options
context:
space:
mode:
authorTim J. Robbins <tjr@FreeBSD.org>2002-07-05 09:28:13 +0000
committerTim J. Robbins <tjr@FreeBSD.org>2002-07-05 09:28:13 +0000
commit7dd4ac68f14a2c747109a62e82495c1eda6c45c4 (patch)
tree57ff142a33e9fbf09059bded7592ee7b820b3bff /usr.bin/uniq
parent81d858170e52f46ca9605f14d639312e8255a35a (diff)
downloadsrc-test2-7dd4ac68f14a2c747109a62e82495c1eda6c45c4.tar.gz
src-test2-7dd4ac68f14a2c747109a62e82495c1eda6c45c4.zip
Use err instead of errx when malloc fails. "malloc" is not a helpful
error message.
Notes
Notes: svn path=/head/; revision=99433
Diffstat (limited to 'usr.bin/uniq')
-rw-r--r--usr.bin/uniq/uniq.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
index c8bb5d4622e2..e7d964584bbc 100644
--- a/usr.bin/uniq/uniq.c
+++ b/usr.bin/uniq/uniq.c
@@ -136,10 +136,12 @@ main (argc, argv)
prevline = malloc(MAXLINELEN);
thisline = malloc(MAXLINELEN);
if (prevline == NULL || thisline == NULL)
- errx(1, "malloc");
+ err(1, "malloc");
if (getline(prevline, MAXLINELEN, ifp) == NULL)
exit(0);
+ if (!cflag && uflag && dflag)
+ show(ofp, prevline);
while (getline(thisline, MAXLINELEN, ifp)) {
/* If requested get the chosen fields + character offsets. */
@@ -158,15 +160,19 @@ main (argc, argv)
comp = strcoll(t1, t2);
if (comp) {
- show(ofp, prevline);
+ if (cflag || !dflag || !uflag)
+ show(ofp, prevline);
t1 = prevline;
prevline = thisline;
+ if (!cflag && uflag && dflag)
+ show(ofp, prevline);
thisline = t1;
repeats = 0;
} else
++repeats;
}
- show(ofp, prevline);
+ if (cflag || !dflag || !uflag)
+ show(ofp, prevline);
exit(0);
}
@@ -253,7 +259,7 @@ obsolete(argv)
*/
len = strlen(ap);
if ((start = p = malloc(len + 3)) == NULL)
- errx(1, "malloc");
+ err(1, "malloc");
*p++ = '-';
*p++ = ap[0] == '+' ? 's' : 'f';
(void)strcpy(p, ap + 1);