ksprintn() may be called with base=2, so redefine MAXNBUF accordingly.
Other brucification tweaks. Obtained from: bde@freebsd.org
This commit is contained in:
parent
b2b9dd4d0a
commit
289c2a94b6
@ -36,7 +36,7 @@
|
|||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
|
* @(#)subr_prf.c 8.3 (Berkeley) 1/21/94
|
||||||
* $Id: subr_prf.c,v 1.52 1999/06/01 18:20:29 jlemon Exp $
|
* $Id: subr_prf.c,v 1.53 1999/06/06 02:41:55 archie Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
@ -60,21 +60,21 @@
|
|||||||
#define TOTTY 0x02
|
#define TOTTY 0x02
|
||||||
#define TOLOG 0x04
|
#define TOLOG 0x04
|
||||||
|
|
||||||
/* Max number conversion buffer length: a long in base 8, plus NUL byte */
|
/* Max number conversion buffer length: a long in base 2, plus NUL byte. */
|
||||||
#define MAXNBUF (sizeof(long) * NBBY / 3 + 2)
|
#define MAXNBUF (sizeof(long) * NBBY + 1)
|
||||||
|
|
||||||
struct tty *constty; /* pointer to console "window" tty */
|
|
||||||
|
|
||||||
struct putchar_arg {
|
struct putchar_arg {
|
||||||
int flags;
|
int flags;
|
||||||
struct tty *tty;
|
struct tty *tty;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct snprintf_arg {
|
struct snprintf_arg {
|
||||||
char *str;
|
char *str;
|
||||||
size_t remain;
|
size_t remain;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct tty *constty; /* pointer to console "window" tty */
|
||||||
|
|
||||||
static void (*v_putc)(int) = cnputc; /* routine to putc on virtual console */
|
static void (*v_putc)(int) = cnputc; /* routine to putc on virtual console */
|
||||||
static void logpri __P((int level));
|
static void logpri __P((int level));
|
||||||
static void msglogchar(int c, void *dummyarg);
|
static void msglogchar(int c, void *dummyarg);
|
||||||
@ -217,8 +217,8 @@ static void
|
|||||||
logpri(level)
|
logpri(level)
|
||||||
int level;
|
int level;
|
||||||
{
|
{
|
||||||
register char *p;
|
|
||||||
char nbuf[MAXNBUF];
|
char nbuf[MAXNBUF];
|
||||||
|
register char *p;
|
||||||
|
|
||||||
msglogchar('<', NULL);
|
msglogchar('<', NULL);
|
||||||
for (p = ksprintn(nbuf, (u_long)level, 10, NULL); *p;)
|
for (p = ksprintn(nbuf, (u_long)level, 10, NULL); *p;)
|
||||||
@ -386,25 +386,26 @@ snprintf_func(int ch, void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Put a number (base <= 16) in a buffer in reverse order; return an
|
* Put a NUL-terminated ASCII number (base <= 16) in a buffer in reverse
|
||||||
* optional length and a pointer to the NULL terminated (preceded?)
|
* order; return an optional length and a pointer to the last character
|
||||||
* buffer. The buffer pointed to by "buf" must have length >= MAXNBUF.
|
* written in the buffer (i.e., the first character of the string).
|
||||||
|
* The buffer pointed to by `nbuf' must have length >= MAXNBUF.
|
||||||
*/
|
*/
|
||||||
static char *
|
static char *
|
||||||
ksprintn(buf, ul, base, lenp)
|
ksprintn(nbuf, ul, base, lenp)
|
||||||
char *buf;
|
char *nbuf;
|
||||||
register u_long ul;
|
register u_long ul;
|
||||||
register int base, *lenp;
|
register int base, *lenp;
|
||||||
{ /* A long in base 8, plus NULL. */
|
{
|
||||||
register char *p;
|
register char *p;
|
||||||
|
|
||||||
p = buf;
|
p = nbuf;
|
||||||
*p = '\0';
|
*p = '\0';
|
||||||
do {
|
do {
|
||||||
*++p = hex2ascii(ul % base);
|
*++p = hex2ascii(ul % base);
|
||||||
} while (ul /= base);
|
} while (ul /= base);
|
||||||
if (lenp)
|
if (lenp)
|
||||||
*lenp = p - buf;
|
*lenp = p - nbuf;
|
||||||
return (p);
|
return (p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user