From 86608179d72b93ca3a38b27b62f280ec63adef20 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@1662 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_graph.c | 10 ++++------ program/src/rrd_graph.h | 1 + 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index 4e05d04d..65c38073 100644 --- a/program/src/rrd_graph.c +++ b/program/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/program/src/rrd_graph.h b/program/src/rrd_graph.h index 56308bb8..04f1d7cd 100644 --- a/program/src/rrd_graph.h +++ b/program/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