diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/about.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/src/about.c b/src/about.c index e21fa9e..26ea0a7 100644 --- a/src/about.c +++ b/src/about.c @@ -19,6 +19,8 @@ * along with Marquee. If not, see <http://www.gnu.org/licenses/>. */ +#define _POSIX_C_SOURCE 200809L + #include <string.h> #include <webkit2/webkit2.h> @@ -31,28 +33,18 @@ GHashTable * parse_query_string(gchar *str) { GHashTable *hash_table; + gboolean first; + gchar *saveptr; gchar *key; gchar *val; hash_table = g_hash_table_new(g_str_hash, g_str_equal); - while (*str) { - key = str; - for (; *str && *str != '='; ++str); - if (!*str) { - g_hash_table_insert(hash_table, key, NULL); - break; - } - *str = '\0'; - val = ++str; - for (; *str && *str != '&'; ++str); - if (!*str) { - g_hash_table_insert(hash_table, key, val); - break; - } - *str = '\0'; + first = TRUE; + while ((key = strtok_r(first ? str : NULL, "=", &saveptr))) { + first = FALSE; + val = strtok_r(NULL, "&", &saveptr); g_hash_table_insert(hash_table, key, val); - ++str; } return hash_table; |