aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Pulford <mark@kyne.com.au>2011-05-01 16:44:01 +0930
committerMark Pulford <mark@kyne.com.au>2011-05-01 16:44:01 +0930
commit439e03c6f9296ade78985a8d0b5c892846b6b06a (patch)
tree466e92e4b2f48ee7ac9b82a6141375e4c1e8408b
parent2567d6cf12ad25ae6f1bf7230d83c572e72ad49f (diff)
downloadlua-cjson-439e03c6f9296ade78985a8d0b5c892846b6b06a.tar.gz
lua-cjson-439e03c6f9296ade78985a8d0b5c892846b6b06a.tar.bz2
lua-cjson-439e03c6f9296ade78985a8d0b5c892846b6b06a.zip
Add MIT license and update lua_cjson.c caveats
-rw-r--r--LICENSE20
-rw-r--r--lua_cjson.c52
-rw-r--r--strbuf.c24
-rw-r--r--strbuf.h24
4 files changed, 102 insertions, 18 deletions
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..8b16d47
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
1Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au>
2
3Permission is hereby granted, free of charge, to any person obtaining
4a copy of this software and associated documentation files (the
5"Software"), to deal in the Software without restriction, including
6without limitation the rights to use, copy, modify, merge, publish,
7distribute, sublicense, and/or sell copies of the Software, and to
8permit persons to whom the Software is furnished to do so, subject to
9the following conditions:
10
11The above copyright notice and this permission notice shall be
12included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/lua_cjson.c b/lua_cjson.c
index de67766..379ea23 100644
--- a/lua_cjson.c
+++ b/lua_cjson.c
@@ -1,25 +1,41 @@
1/* Lua JSON routines 1/* CJSON - JSON support for Lua
2 *
3 * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2 */ 23 */
3 24
4/* Caveats: 25/* Caveats:
5 * - Assumes strings are valid UTF-8 and mostly treats them as opaque 26 * - JSON "null" values are represented as lightuserdata since Lua
6 * binary data. Will not throw an exception on bad data. 27 * tables cannot contain "nil". Compare with cjson.null.
7 * - Will decode \uXXXX escapes, but leaves high codepoints as UTF-8 28 * - Only standard JSON escapes and \u0000 are used when encoding
8 * when encoding. 29 * JSON. Most unprintable characters are not escaped.
9 * - JSON "null" values are represented as lightuserdata. Compare with 30 * - Invalid UTF-8 characters are not detected and will be passed
10 * json.null. 31 * untouched.
11 * - Parsing comments is not supported. According to json.org, this isn't 32 * - Cannot parse NaN/Inf numbers when strict_numbers has been disabled.
12 * part of the spec. 33 * - Javascript comments are not part of the JSON spec, and are not
13 * - Parser accepts number formats beyond the JSON spec. 34 * supported.
14 * 35 *
15 * Note: lua_json_decode() probably spends significant time rehashing 36 * Note: Decoding is slower than encoding. Lua probably spends
16 * tables since it is difficult to know their size ahead of time. 37 * significant time rehashing tables when parsing JSON since it is
17 * Earlier JSON libaries didn't have this problem but the intermediate 38 * difficult to know object/array sizes ahead of time.
18 * storage (and their implementations) were much slower anyway..
19 */
20
21/* FIXME:
22 * - Option to encode non-printable characters? Only \" \\ are required
23 */ 39 */
24 40
25#include <assert.h> 41#include <assert.h>
diff --git a/strbuf.c b/strbuf.c
index 208a7be..b6227fc 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,3 +1,27 @@
1/* strbuf - string buffer routines
2 *
3 * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
1#include <stdio.h> 25#include <stdio.h>
2#include <stdlib.h> 26#include <stdlib.h>
3#include <stdarg.h> 27#include <stdarg.h>
diff --git a/strbuf.h b/strbuf.h
index d6e2d90..9b662ef 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -1,3 +1,27 @@
1/* strbuf - String buffer routines
2 *
3 * Copyright (c) 2010-2011 Mark Pulford <mark@kyne.com.au>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
1#include <stdlib.h> 25#include <stdlib.h>
2#include <stdarg.h> 26#include <stdarg.h>
3 27