X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_graph_helper.c;h=cefb76b389e175f804b65f384f5486240b571ce7;hb=64a61838d25173dfed09eb1040c5eaad8e5e8933;hp=b464007d8a09f9ef5104f4248391fd21fa4ae26f;hpb=31f6e9071af7d014dac71d42d61594016832868c;p=rrdtool.git diff --git a/src/rrd_graph_helper.c b/src/rrd_graph_helper.c index b464007..cefb76b 100644 --- a/src/rrd_graph_helper.c +++ b/src/rrd_graph_helper.c @@ -1,5 +1,5 @@ /**************************************************************************** - * RRDtool 1.2.2 Copyright by Tobi Oetiker, 1997-2005 + * RRDtool 1.2.8 Copyright by Tobi Oetiker, 1997-2005 **************************************************************************** * rrd_graph_helper.c commandline parser functions * this code initially written by Alex van den Bogaerdt @@ -119,7 +119,7 @@ rrd_parse_color(char *string, graph_desc_t *gdp) { */ i=0; - while (string[i] && isxdigit(string[i])) i++; + while (string[i] && isxdigit((unsigned int)string[i])) i++; if (string[i] != '\0') return 1; /* garbage follows hexdigits */ switch (i) { case 3: @@ -295,9 +295,29 @@ rrd_parse_PVHLAST(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc int i,j,k; int colorfound=0; char tmpstr[MAX_VNAME_LEN + 10]; /* vname#RRGGBBAA\0 */ + static int spacecnt = 0; + + if (spacecnt == 0) { + float one_space = gfx_get_text_width(im->canvas, 0, + im->text_prop[TEXT_PROP_LEGEND].font, + im->text_prop[TEXT_PROP_LEGEND].size, + im->tabwidth," ", 0) / 4.0; + float target_space = gfx_get_text_width(im->canvas, 0, + im->text_prop[TEXT_PROP_LEGEND].font, + im->text_prop[TEXT_PROP_LEGEND].size, + im->tabwidth,"oo", 0); + spacecnt = target_space / one_space; + dprintf("- spacecnt: %i onespace: %f targspace: %f\n",spacecnt,one_space,target_space); + } + dprintf("- parsing '%s'\n",&line[*eaten]); + /* have simpler code in the drawing section */ + if ( gdp->gf == GF_STACK ){ + gdp->stack=1; + } + i=scan_for_col(&line[*eaten],MAX_VNAME_LEN+9,tmpstr); if (line[*eaten+i]!='\0' && line[*eaten+i]!=':') { rrd_set_error("Cannot parse line '%s'",line); @@ -388,23 +408,21 @@ rrd_parse_PVHLAST(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc ** LINE:val::STACK means no legend, and do STACK */ if (colorfound) { - char c1,c2; int err=0; char *linecp = strdup(line); dprintf("- looking for optional legend\n"); - - /* The legend needs to be prefixed with "m ". This then gets - ** replaced by the color box. */ - + dprintf("- examining '%s'\n",&line[*eaten]); - - (*eaten)--; - linecp[*eaten]=' '; - (*eaten)--; - linecp[*eaten]='m'; + if (linecp[*eaten] != '\0' && linecp[*eaten] != ':') { + int spi; + /* If the legend is not empty, it has to be prefixed with spacecnt ' ' characters. This then gets + * replaced by the color box later on. */ + for (spi=0;spi 1;spi++){ + linecp[--(*eaten)]=' '; + } + } if (rrd_parse_legend(linecp, eaten, gdp)) err=1; - free(linecp); if (err) return 1; @@ -456,10 +474,6 @@ rrd_parse_PVHLAST(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc (*eaten)++; dprintf("- parsing '%s'\n",&line[*eaten]); - /* have simpler code in the drawing section */ - if ( gdp->gf == GF_STACK ){ - gdp->stack=1; - } return 0; }