[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Findings on '%q' formatting and documentation
- From: Asko Kauppi <askok@...>
- Date: Mon, 26 Feb 2007 00:14:37 +0200
In doing serialization code using Lua/C API, I found two things
concerning the '%q' formatting used in string.format():
* There is no Lua/C API way to convert a string into its safe, '%q'
formatted representation.
- string.format code (in lstrlib.c) has 'static' scope for the
functions involved
- lua_pushfstring() could support '%q' but it's conceptually in wrong
level (no luaL functions in core)
I would suggest adding serialization/deserialization right into the
Lua/C API itself, this would cover the '%q' case as well (serialize a
string and you get its '%q' conversion).
* The second finding concerns documentation:
http://www.lua.org/manual/5.1/manual.html#pdf-string.format
states: "This function does not accept string values containing
embedded zeros."
should be: "This function does not accept format strings and %s
parameters containing embedded zeros."
Having embedded zeros in '%q' parameters is okay (they convert to \000).
-asko