summaryrefslogtreecommitdiff
path: root/src/libstrongswan/utils/enumerator.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstrongswan/utils/enumerator.c')
-rw-r--r--src/libstrongswan/utils/enumerator.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/src/libstrongswan/utils/enumerator.c b/src/libstrongswan/utils/enumerator.c
index 4ebc2e097..e7653a9b2 100644
--- a/src/libstrongswan/utils/enumerator.c
+++ b/src/libstrongswan/utils/enumerator.c
@@ -1,4 +1,5 @@
/*
+ * Copyright (C) 2008 Tobias Brunner
* Copyright (C) 2007 Martin Willi
* Hochschule fuer Technik Rapperswil
*
@@ -12,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
- * $Id: enumerator.c 4142 2008-07-02 08:09:07Z martin $
+ * $Id: enumerator.c 4744 2008-12-03 10:03:59Z tobias $
*/
#include "enumerator.h"
@@ -215,27 +216,48 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
}
}
- /* find separators */
- sep = this->sep;
- while (*sep)
+ switch (*this->pos)
{
- tmp = strchr(this->pos, *sep);
- if (tmp && (pos == NULL || tmp < pos))
+ case '"':
+ case '\'':
{
- pos = tmp;
+ /* read quoted token */
+ tmp = strchr(this->pos + 1, *this->pos);
+ if (tmp)
+ {
+ *token = this->pos + 1;
+ *tmp = '\0';
+ this->pos = tmp + 1;
+ return TRUE;
+ }
+ /* unterminated string, FALL-THROUGH */
+ }
+ default:
+ {
+ /* find nearest separator */
+ sep = this->sep;
+ while (*sep)
+ {
+ tmp = strchr(this->pos, *sep);
+ if (tmp && (pos == NULL || tmp < pos))
+ {
+ pos = tmp;
+ }
+ sep++;
+ }
+ *token = this->pos;
+ if (pos)
+ {
+ *pos = '\0';
+ this->pos = pos + 1;
+ }
+ else
+ {
+ last = TRUE;
+ pos = this->pos = strchr(this->pos, '\0');
+ }
+ break;
}
- sep++;
- }
- *token = this->pos;
- if (pos)
- {
- *pos = '\0';
- this->pos = pos + 1;
- }
- else
- {
- last = TRUE;
- pos = this->pos = strchr(this->pos, '\0');
}
/* trim trailing characters/separators */
@@ -268,7 +290,7 @@ static bool enumerate_token_enum(token_enum_t *this, char **token)
}
}
- if (!last || pos > *token)
+ if (!last || pos >= *token)
{
return TRUE;
}