lua-users home
lua-l archive

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


Hi

In the Lua Reference manual is written that format() can only be used 
with strings that don't contain '\0'.
For this reason, I use format("%s") to cut the characters following the 
first '\0' from a string.
It works fine until I use a string of length greater than or equal to 
100 characters.
For example:

strlen(format("%s", "1" .. strrep("\000", 98)))  -->  1
strlen(format("%s", "1" .. strrep("\000", 99)))  -->  100

strlen(format("%s", "\000" .. strrep("1", 98)))  -->  0
strlen(format("%s", "\000" .. strrep("1", 99)))  -->  100

format() executes "addnchar(L, s, l)" with string of length >= 100, and 
addnchar() includes also the embeded '\0'.
Is it the right way to change this statement with "addnchar(L, s, strlen
(s))" ?

Bye
Mauro