From 1c0072e77e9b06e4e8b5661fadec0b11a5bbcb7b Mon Sep 17 00:00:00 2001 From: Keith Bostic Date: Mon, 19 Dec 1988 20:07:15 -0800 Subject: [PATCH] increase buffer size; rewrite argument collection loop SCCS-vsn: usr.bin/logger/logger.c 6.10 --- usr/src/usr.bin/logger/logger.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/usr/src/usr.bin/logger/logger.c b/usr/src/usr.bin/logger/logger.c index 31cfa2239e..a21635d5f5 100644 --- a/usr/src/usr.bin/logger/logger.c +++ b/usr/src/usr.bin/logger/logger.c @@ -22,7 +22,7 @@ char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)logger.c 6.9 (Berkeley) %G%"; +static char sccsid[] = "@(#)logger.c 6.10 (Berkeley) %G%"; #endif /* not lint */ #include @@ -44,7 +44,7 @@ main(argc, argv) extern int optind; int pri = LOG_NOTICE; int ch, logflags = 0; - char *tag, buf[200], *getlogin(); + char *tag, buf[1024], *getlogin(); tag = NULL; while ((ch = getopt(argc, argv, "f:ip:t:")) != EOF) @@ -81,30 +81,23 @@ main(argc, argv) register char *p, *endp; int len; - for (p = buf, endp = buf + sizeof(buf) - 1;;) { + for (p = buf, endp = buf + sizeof(buf) - 2; *argv;) { len = strlen(*argv); - if (p + len < endp && p > buf) { - *--p = '\0'; + if (p + len > endp && p > buf) { syslog(pri, "%s", buf); p = buf; } - if (len > sizeof(buf) - 1) { + if (len > sizeof(buf) - 1) syslog(pri, "%s", *argv++); - if (!--argc) - break; - } else { + else { + if (p != buf) + *p++ = ' '; bcopy(*argv++, p, len); - p += len; - if (!--argc) - break; - *p++ = ' '; - *--p = '\0'; + *(p += len) = '\0'; } } - if (p != buf) { - *p = '\0'; + if (p != buf) syslog(pri, "%s", buf); - } exit(0); } -- 2.20.1