diff options
Diffstat (limited to 'include/carefulputc.h')
-rw-r--r-- | include/carefulputc.h | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/include/carefulputc.h b/include/carefulputc.h index 3a0ec5b66..681e66660 100644 --- a/include/carefulputc.h +++ b/include/carefulputc.h @@ -26,7 +26,7 @@ static inline int fputc_careful(int c, FILE *fp, const char fail) return (ret < 0) ? EOF : 0; } -static inline void fputs_quoted(const char *data, FILE *out) +static inline void fputs_quoted_case(const char *data, FILE *out, int dir) { const char *p; @@ -41,11 +41,17 @@ static inline void fputs_quoted(const char *data, FILE *out) fprintf(out, "\\x%02x", (unsigned char) *p); } else - fputc(*p, out); + fputc(dir == 1 ? toupper(*p) : + dir == -1 ? tolower(*p) : + *p, out); } fputc('"', out); } +#define fputs_quoted(_d, _o) fputs_quoted_case(_d, _o, 0) +#define fputs_quoted_upper(_d, _o) fputs_quoted_case(_d, _o, 1) +#define fputs_quoted_lower(_d, _o) fputs_quoted_case(_d, _o, -1) + static inline void fputs_nonblank(const char *data, FILE *out) { const char *p; |