summaryrefslogtreecommitdiff
path: root/cups/array.c
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2012-10-01 03:01:10 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2012-10-01 03:01:10 +0000
commit5a9febac19255ab8aea598449ea63bda730b2fe0 (patch)
tree1ca7eead0982e5b8893cadd8b2215d1ea96171f7 /cups/array.c
parent37e7e6e0b27c7db3be8e160e87a63fec66e0fcca (diff)
downloadcups-5a9febac19255ab8aea598449ea63bda730b2fe0.tar.gz
Merge changes from CUPS 1.7svn-r10629.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@3933 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cups/array.c')
-rw-r--r--cups/array.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/cups/array.c b/cups/array.c
index 2fb7701c0..a84f3e2a2 100644
--- a/cups/array.c
+++ b/cups/array.c
@@ -138,8 +138,7 @@ cupsArrayAdd(cups_array_t *a, /* I - Array */
/*
- * '_cupsArrayAddStrings()' - Add zero or more comma-delimited strings to an
- * array.
+ * '_cupsArrayAddStrings()' - Add zero or more delimited strings to an array.
*
* Note: The array MUST be created using the @link _cupsArrayNewStrings@
* function. Duplicate strings are NOT added. If the string pointer "s" is NULL
@@ -148,7 +147,8 @@ cupsArrayAdd(cups_array_t *a, /* I - Array */
int /* O - 1 on success, 0 on failure */
_cupsArrayAddStrings(cups_array_t *a, /* I - Array */
- const char *s) /* I - Comma-delimited strings or NULL */
+ const char *s, /* I - Delimited strings or NULL */
+ char delim)/* I - Delimiter character */
{
char *buffer, /* Copy of string */
*start, /* Start of string */
@@ -159,10 +159,21 @@ _cupsArrayAddStrings(cups_array_t *a, /* I - Array */
if (!a || !s || !*s)
return (0);
- if (!strchr(s, ','))
+ if (delim == ' ')
{
/*
- * String doesn't contain a comma, so add it as a single value...
+ * Skip leading whitespace...
+ */
+
+ while (*s && isspace(*s & 255))
+ s ++;
+ }
+
+ if (!strchr(s, delim) ||
+ (delim == ' ' && !strchr(s, '\t') && !strchr(s, '\n')))
+ {
+ /*
+ * String doesn't contain a delimiter, so add it as a single value...
*/
if (!cupsArrayFind(a, (void *)s))
@@ -179,7 +190,14 @@ _cupsArrayAddStrings(cups_array_t *a, /* I - Array */
* it...
*/
- if ((end = strchr(start, ',')) != NULL)
+ if (delim == ' ')
+ {
+ while (*end && !isspace(*end & 255))
+ end ++;
+ while (*end && isspace(*end & 255))
+ *end++ = '\0';
+ }
+ else if ((end = strchr(start, delim)) != NULL)
*end++ = '\0';
else
end = start + strlen(start);
@@ -782,7 +800,8 @@ cupsArrayNew3(cups_array_func_t f, /* I - Comparison function or @code NULL@ fo
*/
cups_array_t * /* O - Array */
-_cupsArrayNewStrings(const char *s) /* I - Comma-delimited strings or NULL */
+_cupsArrayNewStrings(const char *s, /* I - Delimited strings or NULL */
+ char delim) /* I - Delimiter character */
{
cups_array_t *a; /* Array */
@@ -790,7 +809,7 @@ _cupsArrayNewStrings(const char *s) /* I - Comma-delimited strings or NULL */
if ((a = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0,
(cups_acopy_func_t)_cupsStrAlloc,
(cups_afree_func_t)_cupsStrFree)) != NULL)
- _cupsArrayAddStrings(a, s);
+ _cupsArrayAddStrings(a, s, delim);
return (a);
}