summaryrefslogtreecommitdiff
path: root/libmisc
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@suse.de>2009-06-22 20:03:16 +0200
committerAndreas Gruenbacher <agruen@suse.de>2009-06-22 20:46:54 +0200
commit6fab4d7598d0be4908e54d469171a1715e57cda2 (patch)
treef6999db84d02e423005821383368783e5bad2cfc /libmisc
parentcb44d79564db216af18d9beb632700e40634f166 (diff)
downloadacl-6fab4d7598d0be4908e54d469171a1715e57cda2.tar.gz
Add a parameter to quote() to specify which characters to quote
Diffstat (limited to 'libmisc')
-rw-r--r--libmisc/quote.c6
1 files changed, 3 insertions, 3 deletions
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);