diff options
author | Andreas Gruenbacher <agruen@suse.de> | 2009-06-22 21:23:52 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@suse.de> | 2009-06-22 21:23:52 +0200 |
commit | 2c66ff0decc062a99c038797013f1230cab73114 (patch) | |
tree | f89023225e4abd7e83eeb1b40837fc3b21fe7d91 | |
parent | a45ee50050719aa6a863a89a04b9af8c50202ec6 (diff) | |
parent | 6fab4d7598d0be4908e54d469171a1715e57cda2 (diff) | |
download | attr-2c66ff0decc062a99c038797013f1230cab73114.tar.gz |
Merge branch 'misc'
-rw-r--r-- | include/misc.h | 2 | ||||
-rw-r--r-- | libmisc/quote.c | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/include/misc.h b/include/misc.h index 58c2640..0c5fdcc 100644 --- a/include/misc.h +++ b/include/misc.h @@ -17,7 +17,7 @@ extern int high_water_alloc(void **buf, size_t *bufsize, size_t newsize); -extern const char *quote(const char *str); +extern const char *quote(const char *str, const char *quote_chars); extern char *unquote(char *str); extern char *next_line(FILE *file); diff --git a/libmisc/quote.c b/libmisc/quote.c index 4fb7035..f98c887 100644 --- a/libmisc/quote.c +++ b/libmisc/quote.c @@ -22,7 +22,7 @@ #include <ctype.h> #include "misc.h" -const char *quote(const char *str) +const char *quote(const char *str, const char *quote_chars) { static char *quoted_str; static size_t quoted_str_len; @@ -34,7 +34,7 @@ const char *quote(const char *str) return str; for (nonpr = 0, s = (unsigned char *)str; *s != '\0'; s++) - if (!isprint(*s) || isspace(*s) || *s == '\\' || *s == '=') + if (*s == '\\' || strchr(quote_chars, *s)) nonpr++; if (nonpr == 0) return str; @@ -43,7 +43,7 @@ const char *quote(const char *str) (s - (unsigned char *)str) + nonpr * 3 + 1)) return NULL; for (s = (unsigned char *)str, q = quoted_str; *s != '\0'; s++) { - if (!isprint(*s) || isspace(*s) || *s == '\\' || *s == '=') { + if (*s == '\\' || strchr(quote_chars, *s)) { *q++ = '\\'; *q++ = '0' + ((*s >> 6) ); *q++ = '0' + ((*s >> 3) & 7); |