diff options
author | Robert Manea <gotmor@gmail.com> | 2009-09-16 12:03:43 +0200 |
---|---|---|
committer | Robert Manea <gotmor@gmail.com> | 2009-09-16 12:03:43 +0200 |
commit | 976b45ef520dfa5d3bbfa1df6be28a1b679df578 (patch) | |
tree | 2f3ac107ff476794a7fb576b461d3beb5350fd9c /uzbl-core.c | |
parent | 5e8224c60e887253669cd72ae0df5c343825c221 (diff) |
Stage 1: refactor expand system
Diffstat (limited to 'uzbl-core.c')
-rw-r--r-- | uzbl-core.c | 65 |
1 files changed, 37 insertions, 28 deletions
diff --git a/uzbl-core.c b/uzbl-core.c index 3eabfe7..451c6ac 100644 --- a/uzbl-core.c +++ b/uzbl-core.c @@ -1057,7 +1057,6 @@ void event(WebKitWebView *page, GArray *argv, GString *result) { (void) page; (void) result; GString *event_name; - gchar *event_details = NULL; gchar **split = g_strsplit(argv_idx(argv, 0), " ", 2); if(split[0]) @@ -1065,25 +1064,21 @@ event(WebKitWebView *page, GArray *argv, GString *result) { else return; - if(split[1]) - event_details = expand(split[1], 0); - - send_event(0, event_details?event_details:"", event_name->str); + send_event(0, split[1]?split[1]:"", event_name->str); g_string_free(event_name, TRUE); - if(event_details) - g_free(event_details); g_strfreev(split); } void print(WebKitWebView *page, GArray *argv, GString *result) { (void) page; (void) result; - gchar* buf; + //gchar* buf; - buf = expand(argv_idx(argv, 0), 0); - g_string_assign(result, buf); - g_free(buf); + //buf = expand(argv_idx(argv, 0), 0); + //g_string_assign(result, buf); + g_string_assign(result, argv_idx(argv, 0)); + //g_free(buf); } void @@ -2061,31 +2056,45 @@ set_var_value(const gchar *name, gchar *val) { return TRUE; } -enum {M_CMD, M_HTML}; 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; - if((ctl_line[0] == '#') /* Comments */ - || (ctl_line[0] == ' ') - || (ctl_line[0] == '\n')) - ; /* ignore these lines */ - else { /* parse a command */ - gchar *ctlstrip; - gchar **tokens = NULL; - len = strlen(ctl_line); - - if (ctl_line[len - 1] == '\n') /* strip trailing newline */ - ctlstrip = g_strndup(ctl_line, len - 1); - else ctlstrip = g_strdup(ctl_line); + work_string = g_strdup(ctl_line); - tokens = g_strsplit(ctlstrip, " ", 2); - parse_command(tokens[0], tokens[1], result); - g_free(ctlstrip); - g_strfreev(tokens); + /* 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), "") + ) { + /* ignore comments */ + if((exp_line[0] == '#')) + ; + + /* parse a command */ + else { + gchar **tokens = NULL; + + tokens = g_strsplit(exp_line, " ", 2); + parse_command(tokens[0], tokens[1], result); + g_strfreev(tokens); + } + g_free(exp_line); } + + g_free(ctlstrip); } + /*@null@*/ gchar* build_stream_name(int type, const gchar* dir) { State *s = &uzbl.state; |