the rrd_graph_check_vname function is not used anywhere in the code ...
[rrdtool.git] / src / rrd_graph.c
index cd5bdfc..cb95dd8 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * RRDtool 1.2.15  Copyright by Tobi Oetiker, 1997-2006
+ * RRDtool 1.2.19  Copyright by Tobi Oetiker, 1997-2007
  ****************************************************************************
  * rrd__graph.c  produce graphs from data in rrdfiles
  ****************************************************************************/
@@ -7,10 +7,12 @@
 
 #include <sys/stat.h>
 
+#ifdef WIN32
+#include "strftime.h"
+#endif
 #include "rrd_tool.h"
 
-#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
-#include "strftime.h"
+#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)
 #include <io.h>
 #include <fcntl.h>
 #endif
@@ -1062,8 +1064,9 @@ data_proc( image_desc_t *im ){
                        ** relevant for min and max
                        */
                        if (finite(paintval) && im->gdes[ii].gf != GF_TICK ) {
-                           if (isnan(minval) || paintval <  minval)
-                               minval = paintval;
+                           if ((isnan(minval) || paintval <  minval ) &&
+                             ! (im->logarithmic && paintval <= 0.0)) 
+                                       minval = paintval;
                            if (isnan(maxval) || paintval >  maxval)
                                maxval = paintval;
                        }
@@ -1443,7 +1446,27 @@ leg_place(image_desc_t *im)
        } else {
            prt_fctn = '\0';
        }
+       /* only valid control codes */
+        if (prt_fctn != 'l' && 
+           prt_fctn != 'n' && /* a synonym for l */
+           prt_fctn != 'r' &&
+           prt_fctn != 'j' &&
+           prt_fctn != 'c' &&
+           prt_fctn != 's' &&
+            prt_fctn != 't' &&
+            prt_fctn != '\0' &&
+            prt_fctn != 'g' ) {
+              free(legspace);
+              rrd_set_error("Unknown control code at the end of '%s\\%c'",im->gdes[i].legend,prt_fctn);
+                      return -1;
+
+       }
+
         /* remove exess space */
+        if ( prt_fctn == 'n' ){
+            prt_fctn='l';
+        }
+
         while (prt_fctn=='g' && 
               leg_cc > 0 && 
               im->gdes[i].legend[leg_cc-1]==' '){
@@ -2401,7 +2424,7 @@ graph_size_location(image_desc_t *im, int elements
        if (im->draw_x_grid) {
            Yxlabel=im->text_prop[TEXT_PROP_AXIS].size *2.5;
        }
-       if (im->draw_y_grid) {
+       if (im->draw_y_grid || im->forceleftspace ) {
            Xylabel=gfx_get_text_width(im->canvas, 0,
                        im->text_prop[TEXT_PROP_AXIS].font,
                        im->text_prop[TEXT_PROP_AXIS].size,
@@ -3092,6 +3115,7 @@ rrd_graph_init(image_desc_t *im)
     im->maxval = DNAN;    
     im->unitsexponent= 9999;
     im->unitslength= 6; 
+    im->forceleftspace = 0;
     im->symbol = ' ';
     im->viewfactor = 1.0;
     im->extra_flags= 0;
@@ -3261,6 +3285,7 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im)
            break;
        case 'L':
            im->unitslength = atoi(optarg);
+            im->forceleftspace = 1;
            break;
        case 'T':
            im->tabwidth = atof(optarg);
@@ -3547,15 +3572,6 @@ rrd_graph_options(int argc, char *argv[],image_desc_t *im)
 }
 
 int
-rrd_graph_check_vname(image_desc_t *im, char *varname, char *err)
-{
-    if ((im->gdes[im->gdes_c-1].vidx=find_var(im,varname))==-1) {
-       rrd_set_error("Unknown variable '%s' in %s",varname,err);
-       return -1;
-    }
-    return 0;
-}
-int
 rrd_graph_color(image_desc_t *im, char *var, char *err, int optional)
 {
     char *color;