From 439e03c6f9296ade78985a8d0b5c892846b6b06a Mon Sep 17 00:00:00 2001 From: Mark Pulford Date: Sun, 1 May 2011 16:44:01 +0930 Subject: Add MIT license and update lua_cjson.c caveats --- LICENSE | 20 ++++++++++++++++++++ lua_cjson.c | 52 ++++++++++++++++++++++++++++++++++------------------ strbuf.c | 24 ++++++++++++++++++++++++ strbuf.h | 24 ++++++++++++++++++++++++ 4 files changed, 102 insertions(+), 18 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..8b16d47 --- /dev/null +++ b/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2010-2011 Mark Pulford + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE 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 @@ -/* Lua JSON routines +/* CJSON - JSON support for Lua + * + * Copyright (c) 2010-2011 Mark Pulford + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* Caveats: - * - Assumes strings are valid UTF-8 and mostly treats them as opaque - * binary data. Will not throw an exception on bad data. - * - Will decode \uXXXX escapes, but leaves high codepoints as UTF-8 - * when encoding. - * - JSON "null" values are represented as lightuserdata. Compare with - * json.null. - * - Parsing comments is not supported. According to json.org, this isn't - * part of the spec. - * - Parser accepts number formats beyond the JSON spec. + * - JSON "null" values are represented as lightuserdata since Lua + * tables cannot contain "nil". Compare with cjson.null. + * - Only standard JSON escapes and \u0000 are used when encoding + * JSON. Most unprintable characters are not escaped. + * - Invalid UTF-8 characters are not detected and will be passed + * untouched. + * - Cannot parse NaN/Inf numbers when strict_numbers has been disabled. + * - Javascript comments are not part of the JSON spec, and are not + * supported. * - * Note: lua_json_decode() probably spends significant time rehashing - * tables since it is difficult to know their size ahead of time. - * Earlier JSON libaries didn't have this problem but the intermediate - * storage (and their implementations) were much slower anyway.. - */ - -/* FIXME: - * - Option to encode non-printable characters? Only \" \\ are required + * Note: Decoding is slower than encoding. Lua probably spends + * significant time rehashing tables when parsing JSON since it is + * difficult to know object/array sizes ahead of time. */ #include diff --git a/strbuf.c b/strbuf.c index 208a7be..b6227fc 100644 --- a/strbuf.c +++ b/strbuf.c @@ -1,3 +1,27 @@ +/* strbuf - string buffer routines + * + * Copyright (c) 2010-2011 Mark Pulford + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + #include #include #include diff --git a/strbuf.h b/strbuf.h index d6e2d90..9b662ef 100644 --- a/strbuf.h +++ b/strbuf.h @@ -1,3 +1,27 @@ +/* strbuf - String buffer routines + * + * Copyright (c) 2010-2011 Mark Pulford + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + #include #include -- cgit v1.2.3-55-g6feb