summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--quote.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/quote.c b/quote.c
index 76eb144265..7218a7080d 100644
--- a/quote.c
+++ b/quote.c
@@ -126,8 +126,10 @@ static int quote_c_style_counted(const char *name, int namelen,
if (!no_dq)
EMIT('"');
- for (sp = name; (ch = *sp++) && (sp - name) <= namelen; ) {
-
+ for (sp = name; sp < name + namelen; sp++) {
+ ch = *sp;
+ if (!ch)
+ break;
if ((ch < ' ') || (ch == '"') || (ch == '\\') ||
(ch == 0177)) {
needquote = 1;