index 23a44d45ce28d53b9a751d22950c04f01d230e3e..6babc574c60521930c44e307d1a0a6a68620846f 100644 (file)
/****************************************************************************
- * RRDtool 1.2.2 Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.9 Copyright by Tobi Oetiker, 1997-2005
****************************************************************************
* rrd_graph_helper.c commandline parser functions
* this code initially written by Alex van den Bogaerdt
*/
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);
@@ -310,16 +330,28 @@ rrd_parse_PVHLAST(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc
tmpstr[j]='\0';
}
+ /* Number or vname ?
+ * It is a number only if "k" equals either "j" or "i",
+ * depending on which is appropriate
+ */
dprintf("- examining value '%s'\n",tmpstr);
k=0;
if (gdp->gf == GF_VRULE) {
sscanf(tmpstr,"%li%n",&gdp->xrule,&k);
- if (k) dprintf("- found time: %li\n",gdp->xrule);
+ if (((j!=0)&&(k==j))||((j==0)&&(k==i))) {
+ dprintf("- found time: %li\n",gdp->xrule);
+ } else {
+ gdp->xrule=0; /* reset the value to "none" */
+ }
} else {
sscanf(tmpstr,"%lf%n",&gdp->yrule,&k);
- if (k) dprintf("- found number: %f\n",gdp->yrule);
+ if (((j!=0)&&(k==j))||((j==0)&&(k==i))) {
+ dprintf("- found number: %f\n",gdp->yrule);
+ } else {
+ gdp->yrule=DNAN; /* reset the value to "none" */
+ }
}
- if (!k) {
+ if (((j!=0)&&(k!=j))||((j==0)&&(k!=i))) {
if ((gdp->vidx=find_var(im,tmpstr))<0) {
rrd_set_error("Not a valid vname: %s in line %s",tmpstr,line);
return 1;
@@ -394,16 +426,15 @@ rrd_parse_PVHLAST(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc
dprintf("- examining '%s'\n",&line[*eaten]);
if (linecp[*eaten] != '\0' && linecp[*eaten] != ':') {
- /* If the legend is not empty, it has to be prefixed with "m ". This then gets
+ 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. */
- (*eaten)--;
- linecp[*eaten]=' ';
- (*eaten)--;
- linecp[*eaten]='m';
+ for (spi=0;spi<spacecnt && (*eaten) > 1;spi++){
+ linecp[--(*eaten)]=' ';
+ }
}
if (rrd_parse_legend(linecp, eaten, gdp)) err=1;
-
free(linecp);
if (err) return 1;
@@ -455,10 +486,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;
}