summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2017-08-22 15:04:19 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2017-08-22 15:04:19 +0000
commit325ad0a702ccdec35dc8c419b15fe95572421158 (patch)
treed3b4492f9f1ddefad46b0ecbf9738cdee24133e3 /usr.bin
parent7bfdcbee5d3a40ddbb5da28d492484142299fbb6 (diff)
Use a boolean variable to remember the quotation level instead of
doing string pointer arithmetic. Fixes a clang warning. OK otto@ tom@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/telnet/utilities.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/usr.bin/telnet/utilities.c b/usr.bin/telnet/utilities.c
index b3acee87613..28534234f94 100644
--- a/usr.bin/telnet/utilities.c
+++ b/usr.bin/telnet/utilities.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: utilities.c,v 1.21 2014/09/09 03:41:08 guenther Exp $ */
+/* $OpenBSD: utilities.c,v 1.22 2017/08/22 15:04:18 bluhm Exp $ */
/* $NetBSD: utilities.c,v 1.5 1996/02/28 21:04:21 thorpej Exp $ */
/*
@@ -575,46 +575,44 @@ printsub(char direction, /* '<' or '>' */
fprintf(NetTrace, "INFO ");
env_common:
{
- int noquote = 2;
+ int quote = 0;
for (i = 2; i < length; i++ ) {
switch (pointer[i]) {
case NEW_ENV_VALUE:
- fprintf(NetTrace, "\" VALUE " + noquote);
- noquote = 2;
+ fprintf(NetTrace, "%sVALUE ", quote ? "\" " : "");
+ quote = 0;
break;
case NEW_ENV_VAR:
- fprintf(NetTrace, "\" VAR " + noquote);
- noquote = 2;
+ fprintf(NetTrace, "%sVAR ", quote ? "\" " : "");
+ quote = 0;
break;
case ENV_ESC:
- fprintf(NetTrace, "\" ESC " + noquote);
- noquote = 2;
+ fprintf(NetTrace, "%sESC ", quote ? "\" " : "");
+ quote = 0;
break;
case ENV_USERVAR:
- fprintf(NetTrace, "\" USERVAR " + noquote);
- noquote = 2;
+ fprintf(NetTrace, "%sUSERVAR ", quote ? "\" " : "");
+ quote = 0;
break;
default:
if (isprint((unsigned char)pointer[i]) &&
pointer[i] != '"') {
- if (noquote) {
- putc('"', NetTrace);
- noquote = 0;
- }
- putc(pointer[i], NetTrace);
+ fprintf(NetTrace, "%s%c",
+ quote ? "" : "\"", pointer[i]);
+ quote = 1;
} else {
- fprintf(NetTrace, "\" %03o " + noquote,
- pointer[i]);
- noquote = 2;
+ fprintf(NetTrace, "%s%03o ",
+ quote ? "\" " : "", pointer[i]);
+ quote = 0;
}
break;
}
}
- if (!noquote)
+ if (quote)
putc('"', NetTrace);
break;
}