Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/lib/libc/net Pullup 1.11 [is]:
details: https://anonhg.NetBSD.org/src/rev/d56e502416e9
branches: netbsd-1-5
changeset: 489955:d56e502416e9
user: tv <tv%NetBSD.org@localhost>
date: Fri Oct 20 17:19:51 2000 +0000
description:
Pullup 1.11 [is]:
avoid use of variable string fmt.
diffstat:
lib/libc/net/ns_addr.c | 27 +++++++++++++++------------
1 files changed, 15 insertions(+), 12 deletions(-)
diffs (67 lines):
diff -r 8cff9dad55d6 -r d56e502416e9 lib/libc/net/ns_addr.c
--- a/lib/libc/net/ns_addr.c Fri Oct 20 17:18:46 2000 +0000
+++ b/lib/libc/net/ns_addr.c Fri Oct 20 17:19:51 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ns_addr.c,v 1.10 1999/09/20 04:39:15 lukem Exp $ */
+/* $NetBSD: ns_addr.c,v 1.10.8.1 2000/10/20 17:19:51 tv Exp $ */
/*
* Copyright (c) 1986, 1993
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)ns_addr.c 8.1 (Berkeley) 6/7/93";
#else
-__RCSID("$NetBSD: ns_addr.c,v 1.10 1999/09/20 04:39:15 lukem Exp $");
+__RCSID("$NetBSD: ns_addr.c,v 1.10.8.1 2000/10/20 17:19:51 tv Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@@ -114,7 +114,6 @@
register char *bp = buf;
int i, ibase, base16 = 0, base10 = 0, clen = 0;
int hb[6], *hp;
- char *fmt;
_DIAGASSERT(buf != NULL);
_DIAGASSERT(out != NULL);
@@ -185,13 +184,11 @@
*--bp = 0; /* Ends Loop */
}
if (base16) {
- fmt = "%3x";
ibase = 4096;
} else if (base10 == 0 && *buf == '0') {
- fmt = "%3o";
ibase = 512;
} else {
- fmt = "%3d";
+ base10 = 1;
ibase = 1000;
}
@@ -202,13 +199,19 @@
bp = clen + buf - 3;
hp = hb + i - 1;
- while (hp > hb) {
- (void)sscanf(bp, fmt, hp);
- bp[0] = 0;
- hp--;
- bp -= 3;
+ while (hp >= hb) {
+ if (base16)
+ (void)sscanf(bp, "%3x", hp);
+ else if (base10)
+ (void)sscanf(bp, "%3d", hp);
+ else
+ (void)sscanf(bp, "%3o", hp);
+ if (hp > hb) {
+ bp[0] = 0;
+ hp--;
+ bp -= 3;
+ }
}
- (void)sscanf(buf, fmt, hp);
cvtbase((long)ibase, 256, hb, i, out, len);
}
Home |
Main Index |
Thread Index |
Old Index