lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>That helped a lot

I didn't do much testing; I tried to keep it simple and go for correctness
instead of speed. If you find any bugs, please let me know.

>I'll seek for a MIT-licensed vsprintf.c on Google... If I 
>can't find one, I'll write one by my own. :-) 

Note that you do not need a full-blown sprintf. The only place in the core
that uses sprintf is this:

lvm.c:#define lua_number2str(s,n)     sprintf((s), LUA_NUMBER_FMT, (n))

So, you only need it to convert numbers to strings. If your port does not
use floating-point numbers, this is really easy...

The functions that the core uses but are not in my implementation are:
sprintf, strtod, setjmp, longjmp, exit.

strtod is only needed to convert strings to numbers. The same remark about
sprintf applies here: strtod is used at only one place:

lobject.c:#define lua_str2number(s,p)     strtod((s), (p))

setjmp and longjmp depend on the compiler.

exit depends on the hosting environment.

Good luck.
--lhf