fix warning

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@24572 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2009-02-04 22:03:07 +00:00
parent 67612f57da
commit c529394cb5

View File

@@ -248,6 +248,18 @@ optionstatus(void)
} }
static void __attribute__((format (printf, 3, 4)))
qprintf(int quote, FILE *f, const char *fmt, ...)
{
va_list va;
if (quote)
fprintf(f, "\" ");
va_start(va, fmt);
vfprintf(f, fmt, va);
va_end(va);
}
void void
printsub(int direction, unsigned char *pointer, size_t length) printsub(int direction, unsigned char *pointer, size_t length)
{ {
@@ -728,57 +740,44 @@ printsub(int direction, unsigned char *pointer, size_t length)
fprintf(NetTrace, "INFO "); fprintf(NetTrace, "INFO ");
env_common: env_common:
{ {
int noquote = 2; int quote = 0;
for (i = 2; i < length; i++ ) { for (i = 2; i < length; i++ ) {
switch (pointer[i]) { switch (pointer[i]) {
case NEW_ENV_VALUE: case NEW_ENV_VAR:
#ifdef OLD_ENVIRON qprintf(quote, NetTrace, "VAR ");
/* case NEW_ENV_OVAR: */ quote = 0;
if (pointer[0] == TELOPT_OLD_ENVIRON) {
fprintf(NetTrace, "\" VAR " + noquote);
} else
#endif /* OLD_ENVIRON */
fprintf(NetTrace, "\" VALUE " + noquote);
noquote = 2;
break; break;
case NEW_ENV_VAR: case NEW_ENV_VALUE:
#ifdef OLD_ENVIRON qprintf(quote, NetTrace, "VALUE");
/* case OLD_ENV_VALUE: */ quote = 0;
if (pointer[0] == TELOPT_OLD_ENVIRON) {
fprintf(NetTrace, "\" VALUE " + noquote);
} else
#endif /* OLD_ENVIRON */
fprintf(NetTrace, "\" VAR " + noquote);
noquote = 2;
break; break;
case ENV_ESC: case ENV_ESC:
fprintf(NetTrace, "\" ESC " + noquote); qprintf(quote, NetTrace, "ESC ");
noquote = 2; quote = 0;
break; break;
case ENV_USERVAR: case ENV_USERVAR:
fprintf(NetTrace, "\" USERVAR " + noquote); qprintf(quote, NetTrace, "USERVAR ");
noquote = 2; quote = 0;
break; break;
default: default:
if (isprint(pointer[i]) && pointer[i] != '"') { if (isprint(pointer[i]) && pointer[i] != '"') {
if (noquote) { if (!quote) {
putc('"', NetTrace); putc('"', NetTrace);
noquote = 0; quote = 1;
} }
putc(pointer[i], NetTrace); putc(pointer[i], NetTrace);
} else { } else {
fprintf(NetTrace, "\" %03o " + noquote, qprintf(quote, NetTrace, "%03o ", pointer[i]);
pointer[i]); quote = 0;
noquote = 2;
} }
break; break;
} }
} }
if (!noquote) if (quote)
putc('"', NetTrace); putc('"', NetTrace);
break; break;
} }