From 456142241c7d9c40c90f28990f678232f4b38ddd Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Wed, 10 Feb 2010 15:02:00 +0100 Subject: [PATCH] Combine print_execi and print_execpi as much as possible --- src/core.cc | 3 ++- src/exec.cc | 25 +++++-------------------- src/text_object.h | 1 + 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/src/core.cc b/src/core.cc index 92d49298..36b1edc3 100644 --- a/src/core.cc +++ b/src/core.cc @@ -623,7 +623,8 @@ struct text_object *construct_text_object(const char *s, const char *arg, long END OBJ_ARG(execpi, 0, "execpi needs arguments") scan_execi_arg(obj, arg); obj->verbatim_output = 1; - obj->callbacks.print = &print_execpi; + obj->parse = true; + obj->callbacks.print = &print_execi; obj->callbacks.free = &free_execi; END OBJ_ARG(texeci, 0, "texeci needs arguments") scan_execi_arg(obj, arg); diff --git a/src/exec.cc b/src/exec.cc index bfbd23b5..fdd0693c 100644 --- a/src/exec.cc +++ b/src/exec.cc @@ -323,26 +323,11 @@ void print_execi(struct text_object *obj, char *p, int p_max_size) read_exec(ed->cmd, ed->buffer, text_buffer_size); ed->last_update = current_update_time; } - snprintf(p, p_max_size, "%s", ed->buffer); -} - -void print_execpi(struct text_object *obj, char *p, int p_max_size) -{ - struct execi_data *ed = (struct execi_data *)obj->data.opaque; - struct text_object subroot; - - if (!ed) - return; - - if (time_to_update(ed)) { - if (!ed->buffer) - ed->buffer = (char*)malloc(text_buffer_size); - - read_exec(ed->cmd, ed->buffer, text_buffer_size); - ed->last_update = current_update_time; - } - parse_conky_vars(&subroot, ed->buffer, p, p_max_size); - free_text_objects(&subroot); + if(obj->parse == true) { + struct text_object subroot; + parse_conky_vars(&subroot, ed->buffer, p, p_max_size); + free_text_objects(&subroot); + } else snprintf(p, p_max_size, "%s", ed->buffer); } char* threaded_exec_caller(struct text_object *obj) { diff --git a/src/text_object.h b/src/text_object.h index dc7f3718..e45020a7 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -95,6 +95,7 @@ struct text_object { void *special_data; long line; struct obj_cb callbacks; + bool parse; //if this true then data.s should still be parsed }; /* text object list helpers */