Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
bagua99 committed Jul 11, 2019
1 parent 6e9c4ad commit 8e28fc7
Show file tree
Hide file tree
Showing 612 changed files with 160,434 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

*.svn-base
.svn/
5 changes: 5 additions & 0 deletions 3rd/cjson/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.gitattributes export-ignore
.gitignore export-ignore
build-packages.sh export-ignore
TODO export-ignore
devel export-ignore
7 changes: 7 additions & 0 deletions 3rd/cjson/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.html
*.o
*.so
notes
packages
tags
tests/utf8.dat
83 changes: 83 additions & 0 deletions 3rd/cjson/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# If Lua is installed in a non-standard location, please set the LUA_DIR
# environment variable to point to prefix for the install. Eg:
# Unix: export LUA_DIR=/home/user/pkg
# Windows: set LUA_DIR=c:\lua51

project(lua-cjson C)
cmake_minimum_required(VERSION 2.6)

option(USE_INTERNAL_FPCONV "Use internal strtod() / g_fmt() code for performance")
option(MULTIPLE_THREADS "Support multi-threaded apps with internal fpconv - recommended" ON)

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()

find_package(Lua51 REQUIRED)
include_directories(${LUA_INCLUDE_DIR})

if(NOT USE_INTERNAL_FPCONV)
# Use libc number conversion routines (strtod(), sprintf())
set(FPCONV_SOURCES fpconv.c)
else()
# Use internal number conversion routines
add_definitions(-DUSE_INTERNAL_FPCONV)
set(FPCONV_SOURCES g_fmt.c dtoa.c)

include(TestBigEndian)
TEST_BIG_ENDIAN(IEEE_BIG_ENDIAN)
if(IEEE_BIG_ENDIAN)
add_definitions(-DIEEE_BIG_ENDIAN)
endif()

if(MULTIPLE_THREADS)
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
if(NOT CMAKE_USE_PTHREADS_INIT)
message(FATAL_ERROR
"Pthreads not found - required by MULTIPLE_THREADS option")
endif()
add_definitions(-DMULTIPLE_THREADS)
endif()
endif()

# Handle platforms missing isinf() macro (Eg, some Solaris systems).
include(CheckSymbolExists)
CHECK_SYMBOL_EXISTS(isinf math.h HAVE_ISINF)
if(NOT HAVE_ISINF)
add_definitions(-DUSE_INTERNAL_ISINF)
endif()

set(_MODULE_LINK "${CMAKE_THREAD_LIBS_INIT}")
get_filename_component(_lua_lib_dir ${LUA_LIBRARY} PATH)

if(APPLE)
set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS
"${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
endif()

if(WIN32)
# Win32 modules need to be linked to the Lua library.
set(_MODULE_LINK ${LUA_LIBRARY} ${_MODULE_LINK})
set(_lua_module_dir "${_lua_lib_dir}")
# Windows sprintf()/strtod() handle NaN/inf differently. Not supported.
add_definitions(-DDISABLE_INVALID_NUMBERS)
else()
set(_lua_module_dir "${_lua_lib_dir}/lua/5.1")
endif()

if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-Dinline=__inline)
add_definitions(-Dsnprintf=_snprintf)
add_definitions(-Dstrncasecmp=_strnicmp)
endif()

add_library(cjson MODULE lua_cjson.c strbuf.c ${FPCONV_SOURCES})
set_target_properties(cjson PROPERTIES PREFIX "")
target_link_libraries(cjson ${_MODULE_LINK})
install(TARGETS cjson DESTINATION "${_lua_module_dir}")

# vi:ai et sw=4 ts=4:
20 changes: 20 additions & 0 deletions 3rd/cjson/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2010-2012 Mark Pulford <mark@kyne.com.au>

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.
120 changes: 120 additions & 0 deletions 3rd/cjson/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
##### Available defines for CJSON_CFLAGS #####
##
## USE_INTERNAL_ISINF: Workaround for Solaris platforms missing isinf().
## DISABLE_INVALID_NUMBERS: Permanently disable invalid JSON numbers:
## NaN, Infinity, hex.
##
## Optional built-in number conversion uses the following defines:
## USE_INTERNAL_FPCONV: Use builtin strtod/dtoa for numeric conversions.
## IEEE_BIG_ENDIAN: Required on big endian architectures.
## MULTIPLE_THREADS: Must be set when Lua CJSON may be used in a
## multi-threaded application. Requries _pthreads_.

##### Build defaults #####
LUA_VERSION = 5.3
TARGET = cjson.so
PREFIX = /usr/local
#CFLAGS = -g -Wall -pedantic -fno-inline
CFLAGS = -O3 -Wall -pedantic -DNDEBUG
CJSON_CFLAGS = -fpic
CJSON_LDFLAGS = -shared
LUA_INCLUDE_DIR = $(PREFIX)/include
LUA_CMODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION)
LUA_MODULE_DIR = $(PREFIX)/share/lua/$(LUA_VERSION)
LUA_BIN_DIR = $(PREFIX)/bin

##### Platform overrides #####
##
## Tweak one of the platform sections below to suit your situation.
##
## See http://lua-users.org/wiki/BuildingModules for further platform
## specific details.

## Linux

## FreeBSD
#LUA_INCLUDE_DIR = $(PREFIX)/include/lua51

## MacOSX (Macports)
#PREFIX = /opt/local
#CJSON_LDFLAGS = -bundle -undefined dynamic_lookup

## Solaris
#PREFIX = /home/user/opt
#CC = gcc
#CJSON_CFLAGS = -fpic -DUSE_INTERNAL_ISINF

## Windows (MinGW)
#TARGET = cjson.dll
#PREFIX = /home/user/opt
#CJSON_CFLAGS = -DDISABLE_INVALID_NUMBERS
#CJSON_LDFLAGS = -shared -L$(PREFIX)/lib -llua51
#LUA_BIN_SUFFIX = .lua

##### Number conversion configuration #####

## Use Libc support for number conversion (default)
FPCONV_OBJS = fpconv.o

## Use built in number conversion
#FPCONV_OBJS = g_fmt.o dtoa.o
#CJSON_CFLAGS += -DUSE_INTERNAL_FPCONV

## Compile built in number conversion for big endian architectures
#CJSON_CFLAGS += -DIEEE_BIG_ENDIAN

## Compile built in number conversion to support multi-threaded
## applications (recommended)
#CJSON_CFLAGS += -pthread -DMULTIPLE_THREADS
#CJSON_LDFLAGS += -pthread

##### End customisable sections #####

TEST_FILES = README bench.lua genutf8.pl test.lua octets-escaped.dat \
example1.json example2.json example3.json example4.json \
example5.json numbers.json rfc-example1.json \
rfc-example2.json types.json
DATAPERM = 644
EXECPERM = 755

ASCIIDOC = asciidoc

BUILD_CFLAGS = -I$(LUA_INCLUDE_DIR) $(CJSON_CFLAGS)
OBJS = lua_cjson.o strbuf.o $(FPCONV_OBJS)

.PHONY: all clean install install-extra doc

.SUFFIXES: .html .adoc

.c.o:
$(CC) -c $(CFLAGS) $(CPPFLAGS) $(BUILD_CFLAGS) -o $@ $<

.adoc.html:
$(ASCIIDOC) -n -a toc $<

all: $(TARGET)

doc: manual.html performance.html

$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) $(CJSON_LDFLAGS) -o $@ $(OBJS)

install: $(TARGET)
mkdir -p $(DESTDIR)/$(LUA_CMODULE_DIR)
cp $(TARGET) $(DESTDIR)/$(LUA_CMODULE_DIR)
chmod $(EXECPERM) $(DESTDIR)/$(LUA_CMODULE_DIR)/$(TARGET)

install-extra:
mkdir -p $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/tests \
$(DESTDIR)/$(LUA_BIN_DIR)
cp lua/cjson/util.lua $(DESTDIR)/$(LUA_MODULE_DIR)/cjson
chmod $(DATAPERM) $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/util.lua
cp lua/lua2json.lua $(DESTDIR)/$(LUA_BIN_DIR)/lua2json$(LUA_BIN_SUFFIX)
chmod $(EXECPERM) $(DESTDIR)/$(LUA_BIN_DIR)/lua2json$(LUA_BIN_SUFFIX)
cp lua/json2lua.lua $(DESTDIR)/$(LUA_BIN_DIR)/json2lua$(LUA_BIN_SUFFIX)
chmod $(EXECPERM) $(DESTDIR)/$(LUA_BIN_DIR)/json2lua$(LUA_BIN_SUFFIX)
cd tests; cp $(TEST_FILES) $(DESTDIR)/$(LUA_MODULE_DIR)/cjson/tests
cd tests; chmod $(DATAPERM) $(TEST_FILES); chmod $(EXECPERM) *.lua *.pl

clean:
rm -f *.o $(TARGET)
44 changes: 44 additions & 0 deletions 3rd/cjson/NEWS
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Version 2.1.0 (Mar 1 2012)
* Added cjson.safe module interface which returns nil after an error
* Improved Makefile compatibility with Solaris make

Version 2.0.0 (Jan 22 2012)
* Improved platform compatibility for strtod/sprintf locale workaround
* Added option to build with David Gay's dtoa.c for improved performance
* Added support for Lua 5.2
* Added option to encode infinity/NaN as JSON null
* Fixed encode bug with a raised default limit and deeply nested tables
* Updated Makefile for compatibility with non-GNU make implementations
* Added CMake build support
* Added HTML manual
* Increased default nesting limit to 1000
* Added support for re-entrant use of encode and decode
* Added support for installing lua2json and json2lua utilities
* Added encode_invalid_numbers() and decode_invalid_numbers()
* Added decode_max_depth()
* Removed registration of global cjson module table
* Removed refuse_invalid_numbers()

Version 1.0.4 (Nov 30 2011)
* Fixed numeric conversion under locales with a comma decimal separator

Version 1.0.3 (Sep 15 2011)
* Fixed detection of objects with numeric string keys
* Provided work around for missing isinf() on Solaris

Version 1.0.2 (May 30 2011)
* Portability improvements for Windows
- No longer links with -lm
- Use "socket" instead of "posix" for sub-second timing
* Removed UTF-8 test dependency on Perl Text::Iconv
* Added simple CLI commands for testing Lua <-> JSON conversions
* Added cjson.encode_number_precision()

Version 1.0.1 (May 10 2011)
* Added build support for OSX
* Removed unnecessary whitespace from JSON output
* Added cjson.encode_keep_buffer()
* Fixed memory leak on Lua stack overflow exception

Version 1.0 (May 9 2011)
* Initial release
27 changes: 27 additions & 0 deletions 3rd/cjson/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
= Lua CJSON =
Mark Pulford <mark@kyne.com.au>

The Lua CJSON module provides JSON support for Lua.

*Features*::
- Fast, standards compliant encoding/parsing routines
- Full support for JSON with UTF-8, including decoding surrogate pairs
- Optional run-time support for common exceptions to the JSON
specification (infinity, NaN,..)
- No dependencies on other libraries

*Caveats*::
- UTF-16 and UTF-32 are not supported

Lua CJSON is covered by the MIT license. Review the file +LICENSE+ for
details.

Please read +manual.adoc+ for installation instructions and the API
manual.

The current stable version of this software is available from the
http://www.kyne.com.au/%7Emark/software/lua-cjson.php[Lua CJSON website].

Feel free to email me if you have any patches, suggestions, or comments.

// vi:ft=asciidoc tw=72:
9 changes: 9 additions & 0 deletions 3rd/cjson/THANKS
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The following people have helped with bug reports, testing and/or
suggestions:

- Louis-Philippe Perron (@loopole)
- Ondřej Jirman
- Steve Donovan <steve.j.donovan@gmail.com>
- Zhang "agentzh" Yichun <agentzh@gmail.com>

Thanks!
2 changes: 2 additions & 0 deletions 3rd/cjson/TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Improve Windows build support.
- Provide option to force/record whether a table is an object or array.
36 changes: 36 additions & 0 deletions 3rd/cjson/build-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh

# build-packages.sh [ REF ]

# Build packages. Use current checked out version, or a specific tag/commit.

# Files requiring a version bump
VERSION_FILES="lua-cjson-2.1devel-1.rockspec lua-cjson.spec lua_cjson.c manual.adoc runtests.sh tests/test.lua"

[ "$1" ] && BRANCH="$1" || BRANCH="`git describe --match '[1-3].[0-9]*'`"
VERSION="`git describe --match '[1-3].[0-9]*' $BRANCH`"
VERSION="${VERSION//-/.}"

PREFIX="lua-cjson-$VERSION"

set -x
set -e

DESTDIR="`pwd`/packages"
mkdir -p "$DESTDIR"
BUILDROOT="`mktemp -d`"
trap "rm -rf '$BUILDROOT'" 0

git archive --prefix="$PREFIX/" "$BRANCH" | tar xf - -C "$BUILDROOT"
cd "$BUILDROOT"

cd "$PREFIX"
rename 2.1devel "$VERSION" $VERSION_FILES
perl -pi -e "s/\\b2.1devel\\b/$VERSION/g" ${VERSION_FILES/2.1devel/$VERSION};
cd ..

make -C "$PREFIX" doc
tar cf - "$PREFIX" | gzip -9 > "$DESTDIR/$PREFIX.tar.gz"
zip -9rq "$DESTDIR/$PREFIX.zip" "$PREFIX"

# vi:ai et sw=4 ts=4:
Loading

0 comments on commit 8e28fc7

Please sign in to comment.