From ee3ff561b384bdbf549378b99b4bdbd122683a59 Mon Sep 17 00:00:00 2001 From: oetiker Date: Sun, 9 Nov 2008 00:00:33 +0000 Subject: [PATCH] use basename to determine filename for imginfo as suggested by sebastian git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@1662 a5681a0c-68f1-0310-ab6d-d61299d08faa --- src/rrd_graph.c | 10 ++++------ src/rrd_graph.h | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/rrd_graph.c b/src/rrd_graph.c index 4e05d04..65c3807 100644 --- a/src/rrd_graph.c +++ b/src/rrd_graph.c @@ -3180,6 +3180,7 @@ rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize, FILE *s *ymax=im.maxval; if (im.imginfo) { char *filename; + char *path; if (!(*prdata)) { /* maybe prdata is not allocated yet ... lets do it now */ if ((*prdata = calloc(2,sizeof(char *)))==NULL) { @@ -3192,13 +3193,10 @@ rrd_graph(int argc, char **argv, char ***prdata, int *xsize, int *ysize, FILE *s rrd_set_error("malloc imginfo"); return -1; } - filename=im.graphfile+strlen(im.graphfile); - while(filename > im.graphfile) { - if (*(filename-1)=='/' || *(filename-1)=='\\' ) break; - filename--; - } - + path = strdup(im.graphfile); + filename = basename(path); sprintf((*prdata)[0],im.imginfo,filename,(long)(im.canvas->zoom*im.ximg),(long)(im.canvas->zoom*im.yimg)); + free(path); } im_free(&im); return 0; diff --git a/src/rrd_graph.h b/src/rrd_graph.h index 56308bb..04f1d7c 100644 --- a/src/rrd_graph.h +++ b/src/rrd_graph.h @@ -4,6 +4,7 @@ #include "rrd_tool.h" #include "rrd_rpncalc.h" #include "rrd_gfx.h" +#include #define MAX_VNAME_LEN 255 #define DEF_NAM_FMT "%255[-_A-Za-z0-9]" -- 2.30.2