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:
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.39.1) at 2025年09月20日 11:21:21 +0000

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