Browse files

Revert "replace string_to_argv() with g_strsplit()"

This reverts commit 023473a.

Conflicts:
	dunst.c
  • Loading branch information...
1 parent 1a9c20a commit db27662e780f9c00babc64641262b0d5e012e2c0 @knopwob committed Mar 25, 2013
Showing with 22 additions and 1 deletion.
  1. +2 −1 settings.c
  2. +18 −0 utils.c
  3. +2 −0 utils.h
View
3 settings.c
@@ -12,6 +12,7 @@
#include "option_parser.h"
#include "settings.h"
#include "config.h"
+#include "utils.h"
settings_t settings;
@@ -174,7 +175,7 @@ void load_settings(char *cmdline_config_path)
settings.dmenu =
option_get_string("global", "dmenu", "-dmenu", dmenu,
"path to dmenu");
- settings.dmenu_cmd = g_strsplit(dmenu, " ", 0);
+ settings.dmenu_cmd = string_to_argv(settings.dmenu);
settings.browser =
option_get_string("global", "browser", "-browser", browser,
View
18 utils.c
@@ -68,6 +68,24 @@ char *string_append(char *a, const char *b, const char *sep)
}
+char **string_to_argv(const char *s)
+{
+ char *str = strdup(s);
+ char **argv = NULL;
+ char *p = strtok (str, " ");
+ int n_spaces = 0;
+
+ while (p) {
+ argv = realloc (argv, sizeof (char*) * ++n_spaces);
+ argv[n_spaces-1] = p;
+ p = strtok (NULL, " ");
+ }
+ argv = realloc (argv, sizeof (char*) * (n_spaces+1));
+ argv[n_spaces] = NULL;
+
+ return argv;
+}
+
int digit_count(int i)
{
i = ABS(i);
View
2 utils.h
@@ -15,6 +15,8 @@ char *string_replace(const char *needle, const char *replacement,
char *string_append(char *a, const char *b, const char *sep);
+char **string_to_argv(const char *s);
+
/* exit with an error message */
void die(char *msg, int exit_value);

0 comments on commit db27662

Please sign in to comment.