Commit a96936c0 authored by Jason Pleau's avatar Jason Pleau

Update upstream source from tag 'upstream/0.5.1'

Update to upstream version '0.5.1'
with Debian dir c6aad40917e76cb4d8064e0c89a94f1e74701c83
parents 70f641ff d4c3a1ef
language: c
language: python
sudo: false
env:
- LUASUFFIX=5.1 LUAVER=5.1
- LUASUFFIX=5.2 LUAVER=5.2
- LUASUFFIX=jit LUAVER=5.1
- LUA="lua 5.1" COMPAT=default CFLAGS=""
- LUA="lua 5.2" COMPAT=default CFLAGS=""
- LUA="lua 5.2" COMPAT=none CFLAGS=""
- LUA="lua 5.3" COMPAT=default CFLAGS=""
- LUA="lua 5.3" COMPAT=none CFLAGS=""
- LUA="lua 5.3" COMPAT=default CFLAGS="-DLUA_NOCVTN2S -DLUA_NOCVTS2N"
- LUA="lua 5.3" COMPAT=default CFLAGS="-DLUA_32BITS"
- LUA="lua 5.3" COMPAT=default CFLAGS="-DLUA_FLOAT_TYPE=3"
- LUA="lua 5.3" COMPAT=default SRC53="LUAVER=5.3" CFLAGS=""
- LUA="lua 5.3" COMPAT=none SRC53="LUAVER=5.3" CFLAGS=""
- LUA="lua 5.3" COMPAT=default SRC53="LUAVER=5.3" CFLAGS="-DLUA_NOCVTN2S -DLUA_NOCVTS2N"
- LUA="lua 5.3" COMPAT=default SRC53="LUAVER=5.3" CFLAGS="-DLUA_32BITS"
- LUA="lua 5.3" COMPAT=default SRC53="LUAVER=5.3" CFLAGS="-DLUA_FLOAT_TYPE=3"
- LUA="luajit 2.0" COMPAT=none CFLAGS=""
- LUA="luajit 2.0" COMPAT=all CFLAGS=""
- LUA="luajit 2.1" COMPAT=none CFLAGS=""
- LUA="luajit 2.1" COMPAT=all CFLAGS=""
before_install:
- pip install hererocks
- hererocks HERE --$LUA --compat $COMPAT --cflags="$CFLAGS" --no-readline --luarocks latest --verbose
- hererocks HERE --show
- source HERE/bin/activate
# Tool setup.
install:
- sudo apt-get update -qq
- sudo apt-get install -qq lua5.1 liblua5.1-0-dev
- sudo apt-get install -qq lua5.2 liblua5.2-dev
- sudo apt-get install -qq luajit
- sudo ln -s /usr/bin/luajit-2.0.0-beta9 /usr/bin/luajit
- sudo rm /usr/bin/lua
- sudo ln -s /usr/bin/lua$LUASUFFIX /usr/bin/lua
- lua -v
- git clone git://github.com/keplerproject/luarocks.git
- cd luarocks
- ./configure --lua-version=$LUAVER --lua-suffix=$LUASUFFIX
- make
- sudo make install
- cd ..
- sudo luarocks install lua-testmore
- sudo luarocks install lua-coat
- sudo luarocks install lbc
- sudo luarocks install luacov-coveralls
- sudo luarocks install luacheck
- luarocks install luacov-coveralls
- luarocks install luacheck
- luarocks install lua-testmore
- luarocks install lua-coat
- luarocks install lbc
- luarocks install lmathx # required by Lua-5.3-strict
# Build and test.
script:
- make luacheck
- make LUA=lua$LUASUFFIX test
- make LUA=lua$LUASUFFIX coveralls
- make test $SRC53
after_success:
- make coveralls $SRC53
branches:
only:
......
Revision history for lua-MessagePack
0.5.1 Sat Jan 20 19:30:00 2018
fix extra bytes detection (see PR #26)
allows ipairs(mp.packers) (see PR #27)
0.5.0 Fri Mar 10 17:07:20 2017
export unpack_cursor instead of unpackers (see issue #23)
......
......@@ -5,7 +5,7 @@ lua-MessagePack is licensed under the terms of the MIT/X11 license reproduced be
===============================================================================
Copyright (C) 2012-2017 Francois Perrad.
Copyright (C) 2012-2018 Francois Perrad.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
......@@ -4,7 +4,7 @@ VERSION := $(shell cd src && $(LUA) -e "m = require [[MessagePack]]; print(m._VE
TARBALL := lua-messagepack-$(VERSION).tar.gz
REV := 1
LUAVER := 5.1
LUAVER := 5.2
PREFIX := /usr/local
DPREFIX := $(DESTDIR)$(PREFIX)
LIBDIR := $(DPREFIX)/share/lua/$(LUAVER)
......@@ -101,7 +101,7 @@ coverage:
coveralls:
rm -f src/luacov.stats.out src/luacov.report.out
cd $(SRC) && prove --exec="$(LUA) -lluacov" ../test/*.t
cd $(SRC) && luacov-coveralls -e ^/usr -e %.t$
cd $(SRC) && luacov-coveralls -e /HERE/ -e %.t$
README.html: README.md
Markdown.pl README.md > README.html
......
......@@ -25,7 +25,7 @@ and the sources are hosted at <http://github.com/fperrad/lua-MessagePack/>.
Copyright and License
---------------------
Copyright (c) 2012-2017 Francois Perrad
Copyright (c) 2012-2018 Francois Perrad
This library is licensed under the terms of the MIT/X11 license, like Lua itself.
......@@ -60,7 +60,7 @@ make test
## Copyright and License
Copyright &copy; 2012-2017 Fran&ccedil;ois Perrad
Copyright &copy; 2012-2018 Fran&ccedil;ois Perrad
[![OpenHUB](http://www.openhub.net/accounts/4780/widgets/account_rank.gif)](http://www.openhub.net/accounts/4780?ref=Rank)
[![LinkedIn](http://www.linkedin.com/img/webpromo/btn_liprofile_blue_80x15.gif)](http://www.linkedin.com/in/fperrad)
......
......@@ -55,9 +55,9 @@ The default is `'string_compat'` in order to be compatible with old implementati
- When a __MessagePack__ 64 bits `integer` is converted to a __Lua__ `number`
it is possible that the resulting number will not represent the original number but just an approximation.
- A __Lua__ `table` is converted into a __MessagePack__ `array`
only if _all_ the keys are composed of positive integers greater than 1,
only if _all_ the keys are composed of strictly positive integers,
without hole or with holes (see `set_array`).
Otherwise it is converted into __MessagePack__ `map\.
Otherwise it is converted into __MessagePack__ `map`.
- An empty `table` is always converted into a __MessagePack__ `array`.
- With `set_array'always_as_map'`,
all __Lua__ `table` are converted into a __MessagePack__ `map`.
......
......@@ -6,4 +6,4 @@ pages:
- Home: index.md
- API: messagepack.md
theme: mkdocs
copyright: Copyright &copy; 2012-2017 Fran&ccedil;ois Perrad
copyright: Copyright &copy; 2012-2018 Fran&ccedil;ois Perrad
......@@ -38,6 +38,6 @@ Links
Copyright and License
---------------------
Copyright (c) 2012-2017 Francois Perrad [![rank](https://www.openhub.net/accounts/4780/widgets/account_rank.gif)](https://www.openhub.net/accounts/4780)
Copyright (c) 2012-2018 Francois Perrad [![rank](https://www.openhub.net/accounts/4780/widgets/account_rank.gif)](https://www.openhub.net/accounts/4780)
This library is licensed under the terms of the MIT/X11 license, like Lua itself.
package = 'lua-MessagePack'
version = '0.5.1-1'
source = {
url = 'http://github.com/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.1.tar.gz',
md5 = 'd7f524b174b8baa822442b11421ff3ac',
dir = 'lua-MessagePack-0.5.1',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.1',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
package = 'lua-MessagePack-lua53'
version = '0.5.1-1'
source = {
url = 'http://github.com/fperrad/lua-MessagePack/raw/releases/lua-messagepack-0.5.1.tar.gz',
md5 = 'd7f524b174b8baa822442b11421ff3ac',
dir = 'lua-MessagePack-0.5.1',
}
description = {
summary = "a pure Lua implementation of the MessagePack serialization format",
detailed = [[
MessagePack is an efficient binary serialization format.
It lets you exchange data among multiple languages like JSON but it's faster and smaller.
]],
homepage = 'http://fperrad.github.io/lua-MessagePack/',
maintainer = 'Francois Perrad',
license = 'MIT/X11'
}
dependencies = {
'lua >= 5.3',
}
build = {
type = 'builtin',
modules = {
['MessagePack'] = 'src5.3/MessagePack.lua',
},
copy_directories = { 'docs', 'test' },
}
......@@ -60,7 +60,10 @@ local function checktype (caller, narg, arg, tname)
end
local packers = setmetatable({}, {
__index = function (t, k) error("pack '" .. k .. "' is unimplemented") end
__index = function (t, k)
if k == 1 then return end -- allows ipairs
error("pack '" .. k .. "' is unimplemented")
end
})
m.packers = packers
......@@ -796,7 +799,7 @@ unpackers = setmetatable({
elseif k > 0xDF then
return function (c, val) return val - 0x100 end
else
return function () error("unpack '" .. format('0x%X', k) .. "' is unimplemented") end
return function () error("unpack '" .. format('%#x', k) .. "' is unimplemented") end
end
end
})
......@@ -838,7 +841,7 @@ function m.unpack (s)
checktype('unpack', 1, s, 'string')
local cursor = cursor_string(s)
local data = unpack_cursor(cursor)
if cursor.i < cursor.j then
if cursor.i <= cursor.j then
error "extra bytes"
end
return data
......@@ -887,9 +890,9 @@ else
end
set_array'without_hole'
m._VERSION = '0.5.0'
m._VERSION = '0.5.1'
m._DESCRIPTION = "lua-MessagePack : a pure Lua implementation"
m._COPYRIGHT = "Copyright (c) 2012-2017 Francois Perrad"
m._COPYRIGHT = "Copyright (c) 2012-2018 Francois Perrad"
return m
--
-- This library is licensed under the terms of the MIT/X11 license,
......
......@@ -43,7 +43,10 @@ local function checktype (caller, narg, arg, tname)
end
local packers = setmetatable({}, {
__index = function (t, k) error("pack '" .. k .. "' is unimplemented") end
__index = function (t, k)
if k == 1 then return end -- allows ipairs
error("pack '" .. k .. "' is unimplemented")
end
})
m.packers = packers
......@@ -64,9 +67,9 @@ packers['string_compat'] = function (buffer, str)
if n <= 0x1F then
buffer[#buffer+1] = char(0xA0 + n) -- fixstr
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>BI2', 0xDA, n) -- str16
buffer[#buffer+1] = pack('>B I2', 0xDA, n) -- str16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>BI4', 0xDB, n) -- str32
buffer[#buffer+1] = pack('>B I4', 0xDB, n) -- str32
else
error"overflow in pack 'string_compat'"
end
......@@ -80,9 +83,9 @@ packers['_string'] = function (buffer, str)
elseif n <= 0xFF then
buffer[#buffer+1] = char(0xD9, n) -- str8
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>BI2', 0xDA, n) -- str16
buffer[#buffer+1] = pack('>B I2', 0xDA, n) -- str16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>BI4', 0xDB, n) -- str32
buffer[#buffer+1] = pack('>B I4', 0xDB, n) -- str32
else
error"overflow in pack 'string'"
end
......@@ -94,9 +97,9 @@ packers['binary'] = function (buffer, str)
if n <= 0xFF then
buffer[#buffer+1] = char(0xC4, n) -- bin8
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>BI2', 0xC5, n) -- bin16
buffer[#buffer+1] = pack('>B I2', 0xC5, n) -- bin16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>BI4', 0xC6, n) -- bin32
buffer[#buffer+1] = pack('>B I4', 0xC6, n) -- bin32
else
error"overflow in pack 'binary'"
end
......@@ -120,9 +123,9 @@ packers['map'] = function (buffer, tbl, n)
if n <= 0x0F then
buffer[#buffer+1] = char(0x80 + n) -- fixmap
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>BI2', 0xDE, n) -- map16
buffer[#buffer+1] = pack('>B I2', 0xDE, n) -- map16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>BI4', 0xDF, n) -- map32
buffer[#buffer+1] = pack('>B I4', 0xDF, n) -- map32
else
error"overflow in pack 'map'"
end
......@@ -136,9 +139,9 @@ packers['array'] = function (buffer, tbl, n)
if n <= 0x0F then
buffer[#buffer+1] = char(0x90 + n) -- fixarray
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>BI2', 0xDC, n) -- array16
buffer[#buffer+1] = pack('>B I2', 0xDC, n) -- array16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>BI4', 0xDD, n) -- array32
buffer[#buffer+1] = pack('>B I4', 0xDD, n) -- array32
else
error"overflow in pack 'array'"
end
......@@ -215,23 +218,23 @@ packers['unsigned'] = function (buffer, n)
elseif n <= 0xFF then
buffer[#buffer+1] = char(0xCC, n) -- uint8
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>BI2', 0xCD, n) -- uint16
buffer[#buffer+1] = pack('>B I2', 0xCD, n) -- uint16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>BI4', 0xCE, n) -- uint32
buffer[#buffer+1] = pack('>B I4', 0xCE, n) -- uint32
else
buffer[#buffer+1] = pack('>BI8', 0xCF, n) -- uint64
buffer[#buffer+1] = pack('>B I8', 0xCF, n) -- uint64
end
else
if n >= -0x20 then
buffer[#buffer+1] = char(0x100 + n) -- fixnum_neg
elseif n >= -0x80 then
buffer[#buffer+1] = pack('>Bi1', 0xD0, n) -- int8
buffer[#buffer+1] = pack('>B i1', 0xD0, n) -- int8
elseif n >= -0x8000 then
buffer[#buffer+1] = pack('>Bi2', 0xD1, n) -- int16
buffer[#buffer+1] = pack('>B i2', 0xD1, n) -- int16
elseif n >= -0x80000000 then
buffer[#buffer+1] = pack('>Bi4', 0xD2, n) -- int32
buffer[#buffer+1] = pack('>B i4', 0xD2, n) -- int32
else
buffer[#buffer+1] = pack('>Bi8', 0xD3, n) -- int64
buffer[#buffer+1] = pack('>B i8', 0xD3, n) -- int64
end
end
end
......@@ -241,23 +244,23 @@ packers['signed'] = function (buffer, n)
if n <= 0x7F then
buffer[#buffer+1] = char(n) -- fixnum_pos
elseif n <= 0x7FFF then
buffer[#buffer+1] = pack('>Bi2', 0xD1, n) -- int16
buffer[#buffer+1] = pack('>B i2', 0xD1, n) -- int16
elseif n <= 0x7FFFFFFF then
buffer[#buffer+1] = pack('>Bi4', 0xD2, n) -- int32
buffer[#buffer+1] = pack('>B i4', 0xD2, n) -- int32
else
buffer[#buffer+1] = pack('>Bi8', 0xD3, n) -- int64
buffer[#buffer+1] = pack('>B i8', 0xD3, n) -- int64
end
else
if n >= -0x20 then
buffer[#buffer+1] = char(0xE0 + 0x20 + n) -- fixnum_neg
elseif n >= -0x80 then
buffer[#buffer+1] = pack('>Bi1', 0xD0, n) -- int8
buffer[#buffer+1] = pack('>B i1', 0xD0, n) -- int8
elseif n >= -0x8000 then
buffer[#buffer+1] = pack('>Bi2', 0xD1, n) -- int16
buffer[#buffer+1] = pack('>B i2', 0xD1, n) -- int16
elseif n >= -0x80000000 then
buffer[#buffer+1] = pack('>Bi4', 0xD2, n) -- int32
buffer[#buffer+1] = pack('>B i4', 0xD2, n) -- int32
else
buffer[#buffer+1] = pack('>Bi8', 0xD3, n) -- int64
buffer[#buffer+1] = pack('>B i8', 0xD3, n) -- int64
end
end
end
......@@ -274,11 +277,11 @@ end
m.set_integer = set_integer
packers['float'] = function (buffer, n)
buffer[#buffer+1] = pack('>Bf', 0xCA, n)
buffer[#buffer+1] = pack('>B f', 0xCA, n)
end
packers['double'] = function (buffer, n)
buffer[#buffer+1] = pack('>Bd', 0xCB, n)
buffer[#buffer+1] = pack('>B d', 0xCB, n)
end
local set_number = function (number)
......@@ -309,7 +312,7 @@ for k = 0, 4 do
local fixext = 0xD4 + k
packers['fixext' .. tostring(n)] = function (buffer, tag, data)
assert(#data == n, "bad length for fixext" .. tostring(n))
buffer[#buffer+1] = pack('>Bi1', fixext, tag)
buffer[#buffer+1] = pack('>B i1', fixext, tag)
buffer[#buffer+1] = data
end
end
......@@ -317,11 +320,11 @@ end
packers['ext'] = function (buffer, tag, data)
local n = #data
if n <= 0xFF then
buffer[#buffer+1] = pack('>BBi1', 0xC7, n, tag) -- ext8
buffer[#buffer+1] = pack('>B B i1', 0xC7, n, tag) -- ext8
elseif n <= 0xFFFF then
buffer[#buffer+1] = pack('>BI2i1', 0xC8, n, tag) -- ext16
buffer[#buffer+1] = pack('>B I2 i1', 0xC8, n, tag) -- ext16
elseif n <= 0xFFFFFFFF.0 then
buffer[#buffer+1] = pack('>BI4i1', 0xC9, n, tag) -- ext32
buffer[#buffer+1] = pack('>B I4 i1', 0xC9, n, tag) -- ext32
else
error"overflow in pack 'ext'"
end
......@@ -547,7 +550,7 @@ unpackers = setmetatable({
elseif k > 0xDF then
return function (c, val) return val - 0x100 end
else
return function () error("unpack '" .. format('0x%X', k) .. "' is unimplemented") end
return function () error("unpack '" .. format('%#x', k) .. "' is unimplemented") end
end
end
})
......@@ -589,7 +592,7 @@ function m.unpack (s)
checktype('unpack', 1, s, 'string')
local cursor = cursor_string(s)
local data = unpack_cursor(cursor)
if cursor.i < cursor.j then
if cursor.i <= cursor.j then
error "extra bytes"
end
return data
......@@ -635,9 +638,9 @@ else
end
set_array'without_hole'
m._VERSION = '0.5.0'
m._VERSION = '0.5.1'
m._DESCRIPTION = "lua-MessagePack : a pure Lua 5.3 implementation"
m._COPYRIGHT = "Copyright (c) 2012-2017 Francois Perrad"
m._COPYRIGHT = "Copyright (c) 2012-2018 Francois Perrad"
return m
--
-- This library is licensed under the terms of the MIT/X11 license,
......
......@@ -2,7 +2,7 @@
require 'Test.More'
plan(22)
plan(24)
local mp = require 'MessagePack'
......@@ -42,7 +42,7 @@ error_like( function ()
error_like( function ()
mp.unpack(string.char(0xC1))
end,
"unpack '0xC1' is unimplemented" )
"unpack '0xc1' is unimplemented" )
is( mp.unpack(mp.pack("text")), "text" )
......@@ -56,6 +56,11 @@ error_like( function ()
end,
"extra bytes" )
error_like( function ()
mp.unpack(mp.pack("text") .. "1")
end,
"extra bytes" )
error_like( function ()
mp.unpack( {} )
end,
......@@ -109,6 +114,10 @@ error_like( function ()
lives_ok( function ()
mp.packers['fixext4']({}, 1, '1234')
end,
"fixext4" )
end,
"fixext4" )
lives_ok( function ()
for _ in ipairs(mp.packers) do end
end,
"cannot iterate packers" )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment