mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 11:05:18 +00:00
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.
This commit is contained in:
parent
c9f1c318aa
commit
92ae6fab8a
@ -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;
|
||||
|
@ -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 name> [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 name> [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: <height>,<width> <function name> [function parameters]")
|
||||
|
@ -26,10 +26,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
#include "text_object.h"
|
||||
#include "logging.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user