Code

make sure the image size only gets printed from rrd_tool when --imageinfo is NOT...
[rrdtool-all.git] / program / src / rrd_graph.c
index 97f6d68bb7241f6ae7c819e84447f3ffb8785fa8..a762b25bfa4bac99b3c2404fa48fcaff70e94710 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * RRDtool 1.2.11  Copyright by Tobi Oetiker, 1997-2005
+ * RRDtool 1.2.12  Copyright by Tobi Oetiker, 1997-2005
  ****************************************************************************
  * rrd__graph.c  produce graphs from data in rrdfiles
  ****************************************************************************/
@@ -1527,11 +1527,10 @@ calc_horizontal_grid(image_desc_t   *im)
     double   range;
     double   scaledrange;
     int      pixel,i;
-    int      gridind;
+    int      gridind=0;
     int      decimals, fractionals;
 
     im->ygrid_scale.labfact=2;
-    gridind=-1;
     range =  im->maxval - im->minval;
     scaledrange = range / im->magfact;
 
@@ -1582,17 +1581,16 @@ calc_horizontal_grid(image_desc_t   *im)
        else {
            for(i=0;ylab[i].grid > 0;i++){
                pixel = im->ysize / (scaledrange / ylab[i].grid);
-               if (pixel > 7) {
-                   gridind = i;
-                   break;
-               }
+               gridind = i;
+               if (pixel > 7)
+                    break;
            }
            
            for(i=0; i<4;i++) {
               if (pixel * ylab[gridind].lfac[i] >=  2.5 * im->text_prop[TEXT_PROP_AXIS].size) {
-                 im->ygrid_scale.labfact =  ylab[gridind].lfac[i];
+                 im->ygrid_scale.labfact =  ylab[gridind].lfac[i];
                  break;
-              }                          
+               }
            } 
            
            im->ygrid_scale.gridstep = ylab[gridind].grid * im->magfact;
@@ -2740,6 +2738,7 @@ gdes_alloc(image_desc_t *im){
 
 
     im->gdes[im->gdes_c-1].step=im->step;
+    im->gdes[im->gdes_c-1].step_orig=im->step;
     im->gdes[im->gdes_c-1].stack=0;
     im->gdes[im->gdes_c-1].debug=0;
     im->gdes[im->gdes_c-1].start=im->start; 
@@ -2765,7 +2764,7 @@ gdes_alloc(image_desc_t *im){
 /* copies input untill the first unescaped colon is found
    or until input ends. backslashes have to be escaped as well */
 int
-scan_for_col(char *input, int len, char *output)
+scan_for_col(const char *const input, int len, char *const output)
 {
     int inp,outp=0;
     for (inp=0; 
@@ -2881,7 +2880,6 @@ rrd_graph_init(image_desc_t *im)
     im->xsize = 400;
     im->ysize = 100;
     im->step = 0;
-    im->step_orig = 0;
     im->ylegend[0] = '\0';
     im->title[0] = '\0';
     im->minval = DNAN;
@@ -3386,12 +3384,17 @@ int bad_format(char *fmt) {
              /* '%s', '%S' and '%%' are allowed */
              if (*ptr == 's' || *ptr == 'S' || *ptr == '%') ptr++;
 
+             /* %c is allowed (but use only with vdef!) */
+            else if (*ptr == 'c') {
+               ptr++;
+               n=1;
+            }
+
              /* or else '% 6.2lf' and such are allowed */
              else {
-   
                  /* optional padding character */
                  if (*ptr == ' ' || *ptr == '+' || *ptr == '-') ptr++;
-  
+
                  /* This should take care of 'm.n' with all three optional */
                  while (*ptr >= '0' && *ptr <= '9') ptr++;
                  if (*ptr == '.') ptr++;
@@ -3412,7 +3415,7 @@ int bad_format(char *fmt) {
 int
 vdef_parse(gdes,str)
 struct graph_desc_t *gdes;
-char *str;
+const char *const str;
 {
     /* A VDEF currently is either "func" or "param,func"
      * so the parsing is rather simple.  Change if needed.