aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/uzbl-core.c
diff options
context:
space:
mode:
authorGravatar Brendan Taylor <whateley@gmail.com>2011-01-13 12:11:09 -0700
committerGravatar Brendan Taylor <whateley@gmail.com>2011-01-13 17:52:42 -0700
commit1bb84ff92e4ed2e7594a8311ec95428a4a0600cc (patch)
tree1950b2fc1b5efc44ac03cd1b9d21a8f325503402 /src/uzbl-core.c
parent3c1697ff57a8fb4b01969da16d66ed37f0652d9b (diff)
simplify parse_cmd_line
Diffstat (limited to 'src/uzbl-core.c')
-rw-r--r--src/uzbl-core.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/uzbl-core.c b/src/uzbl-core.c
index 147a9ae..8f9ff88 100644
--- a/src/uzbl-core.c
+++ b/src/uzbl-core.c
@@ -1467,23 +1467,14 @@ set_var_value(const gchar *name, gchar *val) {
void
parse_cmd_line(const char *ctl_line, GString *result) {
- size_t len=0;
- gchar *ctlstrip = NULL;
gchar *exp_line = NULL;
- gchar *work_string = NULL;
+ gchar *work_string = g_strdup(ctl_line);
- work_string = g_strdup(ctl_line);
+ /* strip trailing newline, and any other whitespace in front */
+ g_strstrip(work_string);
- /* strip trailing newline */
- len = strlen(ctl_line);
- if (work_string[len - 1] == '\n')
- ctlstrip = g_strndup(work_string, len - 1);
- else
- ctlstrip = g_strdup(work_string);
- g_free(work_string);
-
- if( strcmp(g_strchug(ctlstrip), "") &&
- strcmp(exp_line = expand(ctlstrip, 0), "")
+ if( strcmp(work_string, "") &&
+ strcmp(exp_line = expand(work_string, 0), "")
) {
/* ignore comments */
if((exp_line[0] == '#'))
@@ -1500,7 +1491,7 @@ parse_cmd_line(const char *ctl_line, GString *result) {
g_free(exp_line);
}
- g_free(ctlstrip);
+ g_free(work_string);
}
/*@null@*/ gchar*