From 5649c4f2cd5f7c2f6a4342cbbce03bb01eb10f7b Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Sat, 8 Sep 2012 11:08:11 +0200 Subject: Add '.svg' extension in save_svg method if not already given --- agg-plot/lua-plot.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'agg-plot/lua-plot.cpp') diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp index 6b1d9254..674d2738 100644 --- a/agg-plot/lua-plot.cpp +++ b/agg-plot/lua-plot.cpp @@ -590,6 +590,14 @@ plot_save_svg (lua_State *L) if (!filename) return gs_type_error(L, 2, "string"); + unsigned fnlen = strlen(filename); + if (fnlen <= 4 || strcmp(filename + (fnlen - 4), ".svg") != 0) + { + const char* basename = (fnlen> 0 ? filename : "unnamed"); + lua_pushfstring(L, "%s.svg", basename); + filename = lua_tostring(L, -1); + } + FILE* f = fopen(filename, "w"); if (!f) return luaL_error(L, "cannot open filename: %s", filename); -- cgit v1.2.3

AltStyle によって変換されたページ (->オリジナル) /