Project import
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5740697 --- /dev/null +++ b/Makefile
@@ -0,0 +1,119 @@ +# +# Copyright (c) 2010-2012 Nest Labs, Inc. +# All rights reserved. +# +# This document is the property of Nest. It is considered +# confidential and proprietary information. +# +# This document may not be reproduced or transmitted in any form, +# in whole or in part, without the express written permission of +# Nest. +# +# Description: +# This file is the make file for mjson, a small, C-based +# JavaScript Object Notation (JSON) parser. +# + +BuildConfigSpecialized := No +BuildProductSpecialized := No + +include pre.mak + +PackageName := mjson + +PackageExtension := tar.gz +PackageSeparator := - + +PackagePatchArgs := -p1 + +PackageArchive := $(PackageName).$(PackageExtension) +PackageSourceDir := json$(PackageSeparator)$(PackageVersion) + +PackageBuildMakefile = $(call GenerateBuildPaths,Makefile) + +CleanPaths += $(PackageLicenseFile) + +all: $(PackageDefaultGoal) + +# Generate the package license contents. + +$(PackageSourceDir)/COPYING: source + +$(PackageLicenseFile): $(PackageSourceDir)/COPYING + $(copy-result) + +# Extract the source from the archive and apply patches, if any. + +$(PackageSourceDir): $(PackageArchive) $(PackagePatchPaths) + $(expand-and-patch-package) + +# Prepare the sources. + +.PHONY: source +source: | $(PackageSourceDir) + +# Patch the sources, if necessary. + +.PHONY: patch +patch: source + +# Generate the package build makefile. + +$(PackageBuildMakefile): | $(PackageSourceDir) $(BuildDirectory) + $(Verbose)cd $(BuildDirectory) && \ + $(CURDIR)/$(PackageSourceDir)/configure \ + CC="$(CC)" CXX="$(CXX)" AR=$(AR) NM=$(NM) RANLIB=$(RANLIB) STRIP=$(STRIP) \ + INSTALL="$(INSTALL) $(INSTALLFLAGS)" \ + --build=$(HostTuple) \ + --host=$(TargetTuple) \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --disable-static + +# Configure the source for building. + +.PHONY: configure +configure: source $(PackageBuildMakefile) + +# Build the source. +# +# We have to unset MAKEFLAGS since they confuse the package build otherwise. + +.PHONY: build +build: configure + $(Verbose)unset MAKEFLAGS && \ + $(MAKE) $(JOBSFLAG) -C $(BuildDirectory) all + +# Stage the build to a temporary installation area. +# +# We have to unset MAKEFLAGS since they confuse the package build otherwise. +# +# We explictly remove 'libfoo.la' because some packages that depend on +# these libraries use libtool. If libtool finds a 'libfoo.la' file for +# a library, it uses the value of 'libdir=<dir>' it finds. In our +# case, since '--prefix=/usr' this value is '/usr/lib'. It then +# resolves '-lfoo'. In a cross-compilation environment, this is likely +# to be neither the right architecture nor the right version to link +# against. In short, we lose. +# +# We could also handle this by removing DESTDIR and setting the prefix +# to $(ResultDirectory); however, that results in libtool hard-coding +# $(ResultDirectory) as the RPATH in the linked executables which is +# NOT what we want either. We lose again. +# +# By removing the '*.la' file, we win by ensuring neither a misdirected +# link nor an RPATH. + +.PHONY: stage +stage: build | $(ResultDirectory) + $(Verbose)unset MAKEFLAGS && \ + $(MAKE) $(JOBSFLAG) -C $(BuildDirectory) DESTDIR=$(ResultDirectory) install + $(Verbose)$(RM) $(RMFLAGS) $(call GenerateResultPaths,,usr/lib/libmjson.la) + +clean: + $(Verbose)$(RM) $(RMFLAGS) -r $(PackageSourceDir) + $(Verbose)$(RM) $(RMFLAGS) -r $(BuildDirectory) + $(Verbose)$(RM) $(RMFLAGS) -r $(ResultDirectory) + +include post.mak
diff --git a/mjson.patches/mjson-50.description b/mjson.patches/mjson-50.description new file mode 100644 index 0000000..b0be3a7 --- /dev/null +++ b/mjson.patches/mjson-50.description
@@ -0,0 +1 @@ +This patch const-qualifies the input argument to json_{un,}escape.
diff --git a/mjson.patches/mjson-50.patch b/mjson.patches/mjson-50.patch new file mode 100644 index 0000000..101b625 --- /dev/null +++ b/mjson.patches/mjson-50.patch
@@ -0,0 +1,42 @@ +diff -aruN a/src/json.c b/src/json.c +--- a/src/json.c 2010-09-28 06:50:05.000000000 -0700 ++++ b/src/json.c 2012-04-05 15:40:51.396325939 -0700 +@@ -1134,7 +1134,7 @@ + + + char * +-json_escape (char *text) ++json_escape (const char *text) + { + rcstring *output; + size_t i, length; +@@ -1200,7 +1200,7 @@ + + + char * +-json_unescape (char *text) ++json_unescape (const char *text) + { + char *result = malloc (strlen (text) + 1); + size_t r; /* read cursor */ +diff -aruN a/src/json.h b/src/json.h +--- a/src/json.h 2009-12-19 06:16:26.000000000 -0800 ++++ b/src/json.h 2012-04-05 15:41:07.076245294 -0700 +@@ -277,7 +277,7 @@ + @param text an UTF8 char text string + @return an UTF-8 c-string holding the same text string but with escaped characters + **/ +- char *json_escape (char *text); ++ char *json_escape (const char *text); + + /** + * Outputs a new UTF-8 c-string which has all escaped characters replaced by +@@ -286,7 +286,7 @@ + * @param test a UTF-8 c-string + * @return a newly allocated UTF-8 c-string; free with free() + */ +- char *json_unescape (char *text); ++ char *json_unescape (const char *text); + + + /**
diff --git a/mjson.patches/mjson-51.description b/mjson.patches/mjson-51.description new file mode 100644 index 0000000..76035a9 --- /dev/null +++ b/mjson.patches/mjson-51.description
@@ -0,0 +1 @@ +Making sure const char* is used for pointers that don't need to modify the buffer
diff --git a/mjson.patches/mjson-51.patch b/mjson.patches/mjson-51.patch new file mode 100644 index 0000000..642df20 --- /dev/null +++ b/mjson.patches/mjson-51.patch
@@ -0,0 +1,60 @@ +diff -ruN a/src/json.c b/src/json.c +--- a/src/json.c 2012-08-14 18:08:21.403880832 -0700 ++++ b/src/json.c 2012-08-14 18:12:32.010823782 -0700 +@@ -1370,7 +1370,7 @@ + + + int +-lexer (char *buffer, char **p, unsigned int *state, rcstring ** text, size_t *line) ++lexer (const char *buffer, const char **p, unsigned int *state, rcstring ** text, size_t *line) + { + assert (buffer != NULL); + assert (p != NULL); +@@ -2133,7 +2133,7 @@ + + + enum json_error +-json_parse_fragment (struct json_parsing_info *info, char *buffer) ++json_parse_fragment (struct json_parsing_info *info, const char *buffer) + { + json_t *temp = NULL; + +@@ -2770,7 +2770,7 @@ + + + enum json_error +-json_parse_document (json_t ** root, char *text) ++json_parse_document (json_t ** root, const char *text) + { + enum json_error error; + struct json_parsing_info *jpi; +diff -ruN a/src/json.h b/src/json.h +--- a/src/json.h 2012-08-14 18:08:21.403880832 -0700 ++++ b/src/json.h 2012-08-14 18:10:51.622902467 -0700 +@@ -108,7 +108,7 @@ + unsigned int state; /*!< the state where the parsing was left on the last parser run */ + unsigned int lex_state; + rcstring *lex_text; +- char *p; ++ const char *p; + int string_length_limit_reached; /*!< flag informing if the string limit length defined by JSON_MAX_STRING_LENGTH was reached */ + size_t line; // current document line + json_t *cursor; /*!< pointers to nodes belonging to the document tree which aid the document parsing */ +@@ -303,7 +303,7 @@ + @param buffer a null-terminated c-string containing a JSON document fragment + @return a code describing how the operation ended up + **/ +- enum json_error json_parse_fragment (struct json_parsing_info *info, char *buffer); ++ enum json_error json_parse_fragment (struct json_parsing_info *info, const char *buffer); + + + /** +@@ -312,7 +312,7 @@ + @param text a c-string containing a complete JSON text document + @return a pointer to the new document tree or NULL if some error occurred + **/ +- enum json_error json_parse_document (json_t ** root, char *text); ++ enum json_error json_parse_document (json_t ** root, const char *text); + + + /**
diff --git a/mjson.patches/mjson-52.description b/mjson.patches/mjson-52.description new file mode 100644 index 0000000..637107b --- /dev/null +++ b/mjson.patches/mjson-52.description
@@ -0,0 +1,2 @@ +Updates mjson-1.3 to allow parsing of JSON blobs that have an array instead of +an object at the top level.
diff --git a/mjson.patches/mjson-52.patch b/mjson.patches/mjson-52.patch new file mode 100644 index 0000000..ddafc0e --- /dev/null +++ b/mjson.patches/mjson-52.patch
@@ -0,0 +1,14 @@ +diff -aruN json-1.3/src/json.c json-1.3.N/src/json.c +--- json-1.3/src/json.c 2015-06-11 19:17:20.000000000 -0700 ++++ json-1.3.N/src/json.c 2015-06-11 19:16:07.000000000 -0700 +@@ -2153,6 +2153,10 @@ + info->state = 1; /* begin object */ + break; + ++ case LEX_BEGIN_ARRAY: ++ info->state = 7; /* begin array */ ++ break; ++ + case LEX_INVALID_CHARACTER: + return JSON_MALFORMED_DOCUMENT; + break;
diff --git a/mjson.tar.gz b/mjson.tar.gz new file mode 100644 index 0000000..1aafa55 --- /dev/null +++ b/mjson.tar.gz Binary files differ
diff --git a/mjson.url b/mjson.url new file mode 100644 index 0000000..f65ae9b --- /dev/null +++ b/mjson.url
@@ -0,0 +1 @@ +http://download.sourceforge.net/mjson/mjson-1.3.tar.gz
diff --git a/mjson.version b/mjson.version new file mode 100644 index 0000000..7e32cd5 --- /dev/null +++ b/mjson.version
@@ -0,0 +1 @@ +1.3