From 2ee1227ddc3010ae3f0a26c3d269bfe32e1de0d4 Mon Sep 17 00:00:00 2001 From: oetiker Date: Mon, 13 Jun 2005 05:43:44 +0000 Subject: [PATCH] allow for VNAMES starting with a number and add documentation -- Alex git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2@636 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/doc/rrdgraph_data.pod | 2 +- program/src/rrd_graph_helper.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/program/doc/rrdgraph_data.pod b/program/doc/rrdgraph_data.pod index dba53f37..c3891d46 100644 --- a/program/doc/rrdgraph_data.pod +++ b/program/doc/rrdgraph_data.pod @@ -20,7 +20,7 @@ instructions use a language called B which is described in its own manual page. Variable names (I) must be made up strings of the following characters -C, starting with a letter and a maximum length of 255 characters. +C and a maximum length of 255 characters. =head1 DEF diff --git a/program/src/rrd_graph_helper.c b/program/src/rrd_graph_helper.c index 2e807419..6babc574 100644 --- a/program/src/rrd_graph_helper.c +++ b/program/src/rrd_graph_helper.c @@ -330,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; -- 2.30.2