gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot/lua-plot.cpp
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年09月08日 11:08:11 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年09月08日 11:08:11 +0200
commit5649c4f2cd5f7c2f6a4342cbbce03bb01eb10f7b (patch)
tree0ce886c5cbed278cf914c9b3825a93323a12675b /agg-plot/lua-plot.cpp
parent4f616877375d742ac07c2935fa7e9ba854ac5701 (diff)
downloadgsl-shell-5649c4f2cd5f7c2f6a4342cbbce03bb01eb10f7b.tar.gz
Add '.svg' extension in save_svg method if not already given
Diffstat (limited to 'agg-plot/lua-plot.cpp')
-rw-r--r--agg-plot/lua-plot.cpp 8
1 files changed, 8 insertions, 0 deletions
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);
generated by cgit v1.2.3 (git 2.25.1) at 2025年09月14日 02:24:38 +0000

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