Skip to content

Commit

Permalink
tool_setopt: rework code to avoid warning
Browse files Browse the repository at this point in the history
  • Loading branch information
vszakats committed Jan 27, 2024
1 parent afe70e2 commit 8003adc
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/tool_setopt.c
Expand Up @@ -240,22 +240,15 @@ static char *c_escape(const char *str, curl_off_t len)
if(p && *p)
result = curlx_dyn_addn(&escaped, to + 2 * (p - from), 2);
else {
const char *format = "\\x%02x";

if(len > 1 && ISXDIGIT(s[1])) {
/* Octal escape to avoid >2 digit hex. */
format = "\\%03o";
result = curlx_dyn_addf(&escaped, "\\%03o",
(unsigned int) *(unsigned char *) s);
}
else {
result = curlx_dyn_addf(&escaped, "\\x%02x",
(unsigned int) *(unsigned char *) s);
}

#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wformat-nonliteral"
#endif
result = curlx_dyn_addf(&escaped, format,
(unsigned int) *(unsigned char *) s);
#ifdef __clang__
#pragma clang diagnostic pop
#endif
}
}
}
Expand Down

0 comments on commit 8003adc

Please sign in to comment.