[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Is terminating null required for Lua strings?
- From: "Juris Kalnins" <juris@...>
- Date: Mon, 16 Feb 2009 14:50:32 +0200
Thank you for the pointers.
API users are free to assume that strings will always have a
terminating null: "lua_tolstring returns a fully aligned pointer to a
string inside the Lua state. This string always has a zero ('\0')
after its last character (as in C), but may contain other zeros in its
This is a non-problem, since there are no API users.
Some parts of the standard string library (specifically parts of the
pattern matching code) will also break without a terminating null.
I grepped for strlen and printf and looks like there indeed is some
non-trivial code that expects lua_tolstring to return proper C strings,
like in the str_format function. Will try to figure it out.