2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 14:25:41 +00:00

Account for tabs when pointing out errors.

This commit is contained in:
Ted Lemon
1999-03-29 18:51:19 +00:00
parent f345b36d53
commit a17d7685dc

View File

@@ -29,7 +29,7 @@
#ifndef lint #ifndef lint
static char copyright[] = static char copyright[] =
"$Id: errwarn.c,v 1.17 1999/03/16 05:50:34 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n"; "$Id: errwarn.c,v 1.18 1999/03/29 18:51:19 mellon Exp $ Copyright (c) 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */ #endif /* not lint */
#include "dhcpd.h" #include "dhcpd.h"
@@ -203,6 +203,8 @@ int parse_warn (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
{ {
va_list list; va_list list;
static char spaces [] = " "; static char spaces [] = " ";
char lexbuf [256];
int i, lix;
do_percentm (mbuf, fmt); do_percentm (mbuf, fmt);
#ifndef NO_SNPRINTF #ifndef NO_SNPRINTF
@@ -217,12 +219,23 @@ int parse_warn (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
vsnprintf (mbuf, sizeof mbuf, fbuf, list); vsnprintf (mbuf, sizeof mbuf, fbuf, list);
va_end (list); va_end (list);
lix = 0;
for (i = 0; token_line [i] && i < (lexchar - 1); i++) {
if (lix < (sizeof lexbuf) - 1)
lexbuf [lix++] = ' ';
if (token_line [i] == '\t') {
for (lix;
lix < (sizeof lexbuf) - 1 && (lix & 7); lix++)
lexbuf [lix] = ' ';
}
}
lexbuf [lix] = 0;
#ifndef DEBUG #ifndef DEBUG
syslog (log_priority | LOG_ERR, mbuf); syslog (log_priority | LOG_ERR, mbuf);
syslog (log_priority | LOG_ERR, token_line); syslog (log_priority | LOG_ERR, token_line);
if (lexline < 81) if (lexchar < 81)
syslog (log_priority | LOG_ERR, syslog (log_priority | LOG_ERR, "%s^", lexbuf);
"%s^", &spaces [sizeof spaces - lexchar]);
#endif #endif
if (log_perror) { if (log_perror) {
@@ -230,7 +243,8 @@ int parse_warn (ANSI_DECL (char *) fmt, VA_DOTDOTDOT)
write (2, "\n", 1); write (2, "\n", 1);
write (2, token_line, strlen (token_line)); write (2, token_line, strlen (token_line));
write (2, "\n", 1); write (2, "\n", 1);
write (2, spaces, lexchar - 1); if (lexchar < 81)
write (2, lexbuf, lix);
write (2, "^\n", 2); write (2, "^\n", 2);
} }