From 92ae6fab8af92c5c7da5edd791bb5dc97b428bfa Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Sun, 29 Nov 2009 20:18:37 +0100 Subject: [PATCH] replace substitute_newlines() object typecheck with object field This is the more generic way, although I doubt this is really error preventing. To me, it's not totally clear as to when substitute_newlines() is forbidden and when not. Maybe someone (the author?) can shed light on the internal algorithm of this feature. --- src/conky.c | 7 +------ src/core.c | 4 ++++ src/text_object.c | 3 +++ src/text_object.h | 3 +++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/conky.c b/src/conky.c index e239cc0e..bdcbc2b5 100644 --- a/src/conky.c +++ b/src/conky.c @@ -805,13 +805,8 @@ obj_loop_tail: #ifdef HAVE_ICONV iconv_convert(&a, buff_in, p, p_max_size); #endif /* HAVE_ICONV */ - if (obj->type != OBJ_text && obj->type != OBJ_execp && obj->type != OBJ_execpi -#ifdef HAVE_LUA - && obj->type != OBJ_lua && obj->type != OBJ_lua_parse -#endif /* HAVE_LUA */ - ) { + if (!obj->verbatim_output) substitute_newlines(p, a - 2); - } p += a; p_max_size -= a; (*p) = 0; diff --git a/src/core.c b/src/core.c index 3b9b959f..f1660396 100644 --- a/src/core.c +++ b/src/core.c @@ -563,6 +563,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long obj->callbacks.free = &free_exec; END OBJ(execp, 0) scan_exec_arg(obj, arg); + obj->verbatim_output = 1; obj->callbacks.print = &print_execp; obj->callbacks.free = &free_exec; END OBJ(execbar, 0) @@ -599,6 +600,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long obj->callbacks.free = &free_execi; END OBJ_ARG(execpi, 0, "execpi needs arguments") scan_execi_arg(obj, arg); + obj->verbatim_output = 1; obj->callbacks.print = &print_execpi; obj->callbacks.free = &free_execi; END OBJ_ARG(texeci, 0, "texeci needs arguments") @@ -1389,10 +1391,12 @@ struct text_object *construct_text_object(const char *s, const char *arg, long #ifdef HAVE_LUA END OBJ_ARG(lua, 0, "lua needs arguments: [function parameters]") obj->data.s = strndup(arg, text_buffer_size); + obj->verbatim_output = 1; obj->callbacks.print = &print_lua; obj->callbacks.free = &gen_free_opaque; END OBJ_ARG(lua_parse, 0, "lua_parse needs arguments: [function parameters]") obj->data.s = strndup(arg, text_buffer_size); + obj->verbatim_output = 1; obj->callbacks.print = &print_lua_parse; obj->callbacks.free = &gen_free_opaque; END OBJ_ARG(lua_bar, 0, "lua_bar needs arguments: , [function parameters]") diff --git a/src/text_object.c b/src/text_object.c index 33de70a9..0b866075 100644 --- a/src/text_object.c +++ b/src/text_object.c @@ -26,10 +26,12 @@ * along with this program. If not, see . * */ +#define _GNU_SOURCE #include "text_object.h" #include "logging.h" #include #include +#include void gen_free_opaque(struct text_object *obj) { @@ -196,6 +198,7 @@ void obj_be_plain_text(struct text_object *obj, const char *text) { obj->type = OBJ_text; obj->data.s = strdup(text); + obj->verbatim_output = 1; memset(&obj->callbacks, 0, sizeof(obj->callbacks)); obj->callbacks.print = &gen_print_obj_data_s; diff --git a/src/text_object.h b/src/text_object.h index 6d894013..638976a4 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -516,6 +516,9 @@ struct text_object { long l; /* some long integer */ } data; + /* if non-zero, no substitute_newlines() is applied to object's output */ + char verbatim_output; + void *special_data; int type; long line;