|
From: Tatsuro M. <tma...@ya...> - 2009-12-03 10:00:39
|
Hello
I have tried to build lua/tikz terminals on DJGPP on cvs source.
The gcc-4.4.1 on DJGPP seems not to have snprintf.
In file included from term.h:454,
from term.c:1366:
../term/lua.trm: In function 'LUA_GP_int_error':
../term/lua.trm:213: warning: incompatible implicit declaration of built-in function 'snprintf'
../term/lua.trm: In function 'LUA_call_report':
../term/lua.trm:506: warning: incompatible implicit declaration of built-in function 'snprintf'
gcc -o gnuplot alloc.o axis.o binary.o bitmap.o breaders.o color.o command.o contour.o datafile.o
dynarray.o eval.o fit.o gadgets.o getcolor.o graph3d.o graphics.o help.o hidden3d.o history.o
internal.o interpol.o matrix.o misc.o mouse.o pa
rse.o plot.o plot2d.o plot3d.o pm3d.o readline.o save.o scanner.o set.o show.o specfun.o standard.o
stdfn.o tables.o tabulate.o term.o time.o unset.o util.o util3d.o variable.o version.o
-Ld:/usr/Tatsu/DJGPPH~1/lua/LUA-51~1.4-I/lib -Lc:/djgpp/contrib/grx246/lib/dj2 -lgrx20 -llua -lm -lpc
term.o:term.c:(.text+0x2ddc5): undefined reference to `_snprintf'
term.o:term.c:(.text+0x4a91d): undefined reference to `_snprintf'
term.o:term.c:(.text+0x4aa1a): undefined reference to `_snprintf'
term.o:term.c:(.text+0x4ab39): undefined reference to `_snprintf'
term.o:term.c:(.text+0x4ad3c): undefined reference to `_snprintf'
term.o:term.c:(.text+0x4af2d): more undefined references to `_snprintf' followcollect2: ld returned 1
exit status
make.exe: *** [gnuplot.exe] Error 1
make.exe: Leaving directory `d:/usr/Tatsu/djgpphome/gnuplotcvs/gnuplot/src'
According to the web snprintf semms to be useful.
snprintf() doesn't cause a buffer overflow.
(http://www.devx.com/tips/Tip/13827)
However unfortunately, it might not to be used in DJGPP.
So I have tried to use sprintf instead of snprintf.
Is this allowable?
The following is the patch that I have used.
***********************************************************************
--- LUATRM~1.ORI 2009-12-02 14:34:34 +0000
+++ lua.trm 2009-12-03 18:11:50 +0000
@@ -210,8 +210,12 @@
break;
}
+#ifdef DJGPP
+ sprintf(last_error_msg, MAX_LINE_LEN, "%s Lua context closed.", msg);
+#else
snprintf(last_error_msg, MAX_LINE_LEN, "%s Lua context closed.", msg);
-
+#endif
+
/* close Lua context on fatal errors */
LUA_close();
@@ -503,7 +507,11 @@
if (status) {
const char *msg = lua_tostring(L, -1);
if (msg == NULL) msg = "(error with no message)";
+#ifdef DJGPP
+ sprintf(last_error_msg, MAX_LINE_LEN, "%s. Lua context closed.", msg);
+#else
snprintf(last_error_msg, MAX_LINE_LEN, "%s. Lua context closed.", msg);
+#endif
LUA_close();
int_error(NO_CARET, last_error_msg);
}
************************************
With this patch the following preliminary test is successful.
gnuplot> set term tikz
Terminal type set to 'tikz'
Options are 'color dashed'
gnuplot> set out 'test.lua'
gnuplot> plot sin(x)
gnuplot> set out
Regards
Tatsuro
--------------------------------------
Learn more about HIV/AIDS - Red Ribbon Campaign 2009
http://pr.mail.yahoo.co.jp/redribbon/
|