summaryrefslogtreecommitdiff
path: root/usr.bin/uniq
diff options
context:
space:
mode:
authoritojun <itojun@NetBSD.org>2003-07-14 09:29:21 +0000
committeritojun <itojun@NetBSD.org>2003-07-14 09:29:21 +0000
commiteea9ee07204a986e92dceb1c7d142975c65c19b7 (patch)
treef353d966e85bdfb51cee5c08b6f9071632afd7e9 /usr.bin/uniq
parent2777b2aa10e83eb271256727a1870650b37c6d6f (diff)
asprintf is easier and safer
Diffstat (limited to 'usr.bin/uniq')
-rw-r--r--usr.bin/uniq/uniq.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c
index 7ee72421601..25222cd4e39 100644
--- a/usr.bin/uniq/uniq.c
+++ b/usr.bin/uniq/uniq.c
@@ -1,4 +1,4 @@
-/* $NetBSD: uniq.c,v 1.9 1998/12/19 23:23:49 christos Exp $ */
+/* $NetBSD: uniq.c,v 1.10 2003/07/14 09:29:21 itojun Exp $ */
/*
* Copyright (c) 1989, 1993
@@ -46,7 +46,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\
#if 0
static char sccsid[] = "@(#)uniq.c 8.3 (Berkeley) 5/4/95";
#endif
-__RCSID("$NetBSD: uniq.c,v 1.9 1998/12/19 23:23:49 christos Exp $");
+__RCSID("$NetBSD: uniq.c,v 1.10 2003/07/14 09:29:21 itojun Exp $");
#endif /* not lint */
#include <err.h>
@@ -220,7 +220,6 @@ void
obsolete(argv)
char *argv[];
{
- int len;
char *ap, *p, *start;
while ((ap = *++argv) != NULL) {
@@ -236,12 +235,10 @@ obsolete(argv)
* Digit signifies an old-style option. Malloc space for dash,
* new option and argument.
*/
- len = strlen(ap);
- if ((start = p = malloc(len + 3)) == NULL)
+ asprintf(&p, "-%c%s", ap[0] == '+' ? 's' : 'f', ap + 1);
+ if (!p)
err(1, "malloc");
- *p++ = '-';
- *p++ = ap[0] == '+' ? 's' : 'f';
- (void)strcpy(p, ap + 1);
+ start = p;
*argv = start;
}
}