lua-users home
lua-l archive

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


Hi Luis,

sorry to be such a nuisance... but I think the newly posted code
(thanks!) has another small error (discovered late last night so I
didn't want to post w/o further checking).

Look at these lines in unpickle():
>   if t == TNIL then
>     return nil, 2
__________________^
>   elseif t == TBOOLEAN then
>     return unpack("B", o, p) == 1, 3
_____________________________________^

I think they should read:
>   if t == TNIL then
>     return nil, p
>   elseif t == TBOOLEAN then
>     return unpack("B", o, p) == 1, p+1 -- as "B" consumes 1 byte

(i.e. this shouldn't return a numerical 2 (or 3) but p (or p+1)).

I am not sure that the TNIL case can ever be executed... as tables can't
contain nil values, by definition. It's of course possible to call
"pickle(nil)", so perhaps it should remain in there.

-- 
cheers  thomasl

web : http://thomaslauer.com/start