diff --git a/src/exec.c b/src/exec.c index c9e4261c..bfccfada 100644 --- a/src/exec.c +++ b/src/exec.c @@ -243,18 +243,17 @@ void scan_execi_arg(struct text_object *obj, const char *arg) void scan_execgraph_arg(struct text_object *obj, const char *arg) { struct execi_data *ed; - char *buf; ed = malloc(sizeof(struct execi_data)); memset(ed, 0, sizeof(struct execi_data)); - buf = scan_graph(obj, arg, 100); - if (!buf) { + ed->cmd = scan_execgraph(obj, arg); + obj->data.opaque = ed; + + if(! ed->cmd) { NORM_ERR("missing command argument to execgraph object"); return; } - ed->cmd = buf; - obj->data.opaque = ed; } #endif /* X11 */ @@ -388,7 +387,7 @@ void print_execgraph(struct text_object *obj, char *p, int p_max_size) read_exec(ed->cmd, p, p_max_size, 1); barnum = get_barnum(p); - if (barnum > 0) { + if (barnum >= 0) { new_graph(obj, p, p_max_size, round_to_int(barnum)); } } diff --git a/src/specials.c b/src/specials.c index fc7e9f43..89b1586d 100644 --- a/src/specials.c +++ b/src/specials.c @@ -35,6 +35,7 @@ #include "logging.h" #include "specials.h" #include +#include /* maximum number of special things, e.g. fonts, offsets, aligns, etc. */ int max_specials = MAX_SPECIALS_DEFAULT; @@ -215,20 +216,6 @@ char *scan_graph(struct text_object *obj, const char *args, int defscale) sscanf(args, "%1023s %d,%d", buf, &g->height, &g->width); } - /* escape quotes at end in case of execgraph */ - if (*buf == '"') { - char *_ptr; - size_t _size; - if (_ptr = strrchr(args, '"')) { - _size = _ptr - args - 1; - } - _size = _size < 1024 ? _size : 1023; - strncpy(buf, args + 1, _size); - buf[_size] = 0; - } - -#undef g - return strndup(buf, text_buffer_size); } @@ -238,6 +225,45 @@ char *scan_graph(struct text_object *obj, const char *args, int defscale) return strndup(buf, text_buffer_size); } } + +// scan_graph is a mess and it does not work for execgraph, so i'll just rewrite it for this case +char *scan_execgraph(struct text_object *obj, const char *arg) +{ + struct graph *g; + + g = malloc(sizeof(struct graph)); + memset(g, 0, sizeof(struct graph)); + obj->special_data = g; + + /* zero width means all space that is available */ + g->width = default_graph_width; + g->height = default_graph_height; + g->first_colour = 0; + g->last_colour = 0; + g->scale = 100; + g->tempgrad = FALSE; + g->showaslog = FALSE; + + while(arg && *arg) { + while(isspace(*arg)) ++arg; + + if(strncmp(arg, TEMPGRAD, strlen(TEMPGRAD)) == 0 && !isalnum(arg[strlen(TEMPGRAD)])) { + g->tempgrad = TRUE; + arg += strlen(TEMPGRAD); + continue; + } + + if(strncmp(arg, LOGGRAPH, strlen(LOGGRAPH)) == 0 && !isalnum(arg[strlen(LOGGRAPH)])) { + g->showaslog = TRUE; + arg += strlen(LOGGRAPH); + continue; + } + + return strdup(arg); + } + + return NULL; +} #endif /* X11 */ /* diff --git a/src/specials.h b/src/specials.h index f529ee35..985638aa 100644 --- a/src/specials.h +++ b/src/specials.h @@ -99,6 +99,7 @@ const char *scan_gauge(struct text_object *, const char *); #ifdef X11 char *scan_font(const char *); char *scan_graph(struct text_object *, const char *, int); +char *scan_execgraph(struct text_object *obj, const char *arg); void scan_tab(struct text_object *, const char *); void scan_stippled_hr(struct text_object *, const char*);