-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: return module Previously loading this module would set `pack` and `unpack` into the global `string` library. Since these methods now exist (since Lua 5.3), other Lua modules will use these functions if they exist, assuming that they are the implemenations in Lua 5.3. More generally, modern best practice is to return the module when loading instead of setting anything globally. Obviously this is a breaking change. * bump version to 2.0.0 * Remove Makefile Use `luarocks build` or `luarocks make` instead. The "builtin" process is much better at providing the appropriate CFLAGS. * Fix test Still not a real test, since it doesn't show failure, but at least now it runs to completion. * Update README.md Since it no longer pollutes the `string` table, it's just a normal module. Also use a bit of formatting. Co-authored-by: Javier Guerra <[email protected]>
- Loading branch information
1 parent
a6be401
commit 495bf30
Showing
5 changed files
with
35 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,35 @@ | ||
This library is extended from `lpack` library on Luarocks to support Hexdecimal data too. | ||
|
||
This is a simple Lua library for packing and unpacking binary data. | ||
The library adds two functions to the string library: pack and unpack. | ||
The library provides two functions: `pack` and `unpack`. | ||
|
||
pack is called as follows: pack(F,x1,x2,...), where F is a string describing | ||
how the values x1, x2, ... are to be interpreted and formatted. Each letter | ||
in the format string F consumes one of the given values. Only values of type | ||
number or string are accepted. pack returns a (binary) string containing the | ||
values packed as described in F. The letter codes understood by pack are listed | ||
`pack` is called as follows: `pack(F,x1,x2,...)`, where `F` is a string describing | ||
how the values `x1`, `x2`, ... are to be interpreted and formatted. Each letter | ||
in the format string `F` consumes one of the given values. Only values of type | ||
number or string are accepted. `pack` returns a (binary) string containing the | ||
values packed as described in `F`. The letter codes understood by pack are listed | ||
in lpack.c (they are inspired by Perl's codes but are not the same). Numbers | ||
following letter codes in F indicate repetitions. | ||
following letter codes in `F` indicate repetitions. | ||
|
||
unpack is called as follows: unpack(s,F,[init]), where s is a (binary) string | ||
containing data packed as if by pack, F is a format string describing what is | ||
to be read from s, and the optional init marks where in s to begin reading the | ||
values. unpack returns one value per letter in F until F or s is exhausted | ||
(the letters codes are the same as for pack, except that numbers following `A' | ||
`unpack` is called as follows: `unpack(s,F,[init])`, where `s` is a (binary) string | ||
containing data packed as if by `pack`, `F` is a format string describing what is | ||
to be read from `s`, and the optional `init` marks where in `s` to begin reading the | ||
values. `unpack` returns one value per letter in `F` until `F` or `s` is exhausted | ||
(the letters codes are the same as for `pack`, except that numbers following ``A'` | ||
are interpreted as the number of characters to read into the string, not as | ||
repetitions). | ||
|
||
The first value returned by unpack is the next unread position in s, which can | ||
be used as the init position in a subsequent call to unpack. This allows you to | ||
unpack values in a loop or in several steps. If the position returned by unpack | ||
is beyond the end of s, then s has been exhausted; any calls to unpack starting | ||
beyond the end of s will always return nil values. | ||
The first value returned by `unpack` is the next unread position in `s`, which can | ||
be used as the init position in a subsequent call to `unpack`. This allows you to | ||
unpack values in a loop or in several steps. If the position returned by `unpack` | ||
is beyond the end of `s`, then `s` has been exhausted; any calls to `unpack` starting | ||
beyond the end of `s` will always return `nil` values. | ||
|
||
------------------------------------------------------------------------------- | ||
|
||
``` | ||
pack library: | ||
pack(f,...) unpack(s,f,[init]) | ||
``` | ||
|
||
------------------------------------------------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters