From: oetiker Date: Sun, 9 Nov 2008 00:00:33 +0000 (+0000) Subject: use basename to determine filename for imginfo as suggested by sebastian X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=928cb97feaaaa2d75f7083b3ff55b02d1e216b4f;p=rrdtool-all.git use basename to determine filename for imginfo as suggested by sebastian git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.3@1662 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_graph.c b/program/src/rrd_graph.c index 46bf7364..41f99f6c 100644 --- a/program/src/rrd_graph.c +++ b/program/src/rrd_graph.c @@ -3647,14 +3647,11 @@ rrd_info_t *rrd_graph_v( if (im.imginfo) { rrd_infoval_t info; + char *path; char *filename; - filename = im.graphfile + strlen(im.graphfile); - while (filename > im.graphfile) { - if (*(filename - 1) == '/' || *(filename - 1) == '\\') - break; - filename--; - } + path = strdup(im.graphfile); + filename = basename(path); info.u_str = sprintf_alloc(im.imginfo, filename, @@ -3662,6 +3659,7 @@ rrd_info_t *rrd_graph_v( im.ximg), (long) (im.zoom * im.yimg)); grinfo_push(&im, sprintf_alloc("image_info"), RD_I_STR, info); free(info.u_str); + free(path); } if (im.rendered_image) { rrd_infoval_t img;