From 85c18a49cb25272f96853a004311ad977b2e66e3 Mon Sep 17 00:00:00 2001 From: leitner Date: Sun, 2 Jun 2002 00:40:43 +0000 Subject: [PATCH] Lots of good clean-ups from Jukka Zitting! --- fmt.h | 1 + fmt/fmt_long.3 | 4 ++-- fmt/fmt_strn.c | 12 ++++++------ fmt/fmt_ulong0.c | 2 +- ip6.h | 2 ++ socket/socket_send6.3 | 4 ++-- str/str_diffn.3 | 2 +- str/str_start.c | 2 +- uint/uint16_pack.3 | 4 ++-- uint/uint16_pack_big.3 | 5 ++--- uint/uint16_unpack.3 | 2 +- uint/uint16_unpack_big.3 | 2 +- uint/uint32_pack.3 | 4 ++-- uint/uint32_pack_big.3 | 5 ++--- uint/uint32_unpack.3 | 2 +- uint/uint32_unpack_big.3 | 2 +- uint16.h | 2 -- 17 files changed, 28 insertions(+), 29 deletions(-) diff --git a/fmt.h b/fmt.h index 45a6e4d..fc63663 100644 --- a/fmt.h +++ b/fmt.h @@ -1,6 +1,7 @@ #ifndef FMT_H #define FMT_H +#define FMT_LONG 41 /* enough space to hold -2^127 in decimal, plus \0 */ #define FMT_ULONG 40 /* enough space to hold 2^128 - 1 in decimal, plus \0 */ #define FMT_8LONG 44 /* enough space to hold 2^128 - 1 in octal, plus \0 */ #define FMT_XLONG 33 /* enough space to hold 2^128 - 1 in hexadecimal, plus \0 */ diff --git a/fmt/fmt_long.3 b/fmt/fmt_long.3 index e918383..72f1929 100644 --- a/fmt/fmt_long.3 +++ b/fmt/fmt_long.3 @@ -14,7 +14,7 @@ fmt_long does not append \\0. If \fIdest\fR equals FMT_LEN (i.e. is zero), fmt_long returns the number of bytes it would have written. -For convenience, fmt.h defines the integer FMT_ULONG to be big enough to -contain every possible fmt_ulong output plus \\0. +For convenience, fmt.h defines the integer FMT_LONG to be big enough to +contain every possible fmt_long output plus \\0. .SH "SEE ALSO" scan_long(3) diff --git a/fmt/fmt_strn.c b/fmt/fmt_strn.c index c0fd0c7..8728a38 100644 --- a/fmt/fmt_strn.c +++ b/fmt/fmt_strn.c @@ -3,12 +3,12 @@ unsigned int fmt_strn(char *out,const char *in,unsigned int limit) { register char* s=out; register const char* t=in; - register const char* u=out+limit; + register const char* u=in+limit; for (;;) { - if (!*t) break; *s=*t; if (s==u) break; ++s; ++t; - if (!*t) break; *s=*t; if (s==u) break; ++s; ++t; - if (!*t) break; *s=*t; if (s==u) break; ++s; ++t; - if (!*t) break; *s=*t; if (s==u) break; ++s; ++t; + if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t; + if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t; + if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t; + if (!*t) break; if (s) { *s=*t; ++s; } if (t==u) break; ++t; } - return s-out; + return t-in; } diff --git a/fmt/fmt_ulong0.c b/fmt/fmt_ulong0.c index 5366b33..efa2157 100644 --- a/fmt/fmt_ulong0.c +++ b/fmt/fmt_ulong0.c @@ -8,7 +8,7 @@ unsigned int fmt_ulong0(char *dest,unsigned long i,unsigned int pad) { /* now see if we need to pad */ if (dest) { while (len - typedef unsigned short uint16; #if defined(__i386__) && !defined(NO_UINT16_MACROS)