summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2012-11-24 12:47:18 +0100
committerRemi Collet <fedora@famillecollet.com>2012-11-24 12:47:18 +0100
commit63b903db5b265adc5982b368f0b206678325e935 (patch)
tree6c00a6216910cc0a662fcc93cc0a4ecb7f085061
json-c: import from rawhide
-rw-r--r--json-c-add-json_tokener_parse_verbose-and-return-NULL-on-pa.patch120
-rw-r--r--json-c.spec91
2 files changed, 211 insertions, 0 deletions
diff --git a/json-c-add-json_tokener_parse_verbose-and-return-NULL-on-pa.patch b/json-c-add-json_tokener_parse_verbose-and-return-NULL-on-pa.patch
new file mode 100644
index 0000000..5558e9d
--- /dev/null
+++ b/json-c-add-json_tokener_parse_verbose-and-return-NULL-on-pa.patch
@@ -0,0 +1,120 @@
+From a503ee8217a9912f3c58acae33cf3d1d840dab6c Mon Sep 17 00:00:00 2001
+From: Jehiah Czebotar <jehiah@gmail.com>
+Date: Wed, 8 Dec 2010 03:52:07 +0000
+Subject: [patch json-c] add json_tokener_parse_verbose, and return NULL on
+ parser errors
+
+git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@62 327403b1-1117-474d-bef2-5cb71233fd97
+---
+ bits.h | 3 ++-
+ json_tokener.c | 18 +++++++++++++++++-
+ json_tokener.h | 3 ++-
+ test1.c | 15 +++++++++++++--
+ 4 files changed, 34 insertions(+), 5 deletions(-)
+
+diff --git a/bits.h b/bits.h
+index f308da3..c8cbbc8 100644
+--- a/bits.h
++++ b/bits.h
+@@ -22,6 +22,7 @@
+
+ #define hexdigit(x) (((x) <= '9') ? (x) - '0' : ((x) & 7) + 9)
+ #define error_ptr(error) ((void*)error)
+-#define is_error(ptr) ((unsigned long)ptr > (unsigned long)-4000L)
++#define error_description(error) (json_tokener_errors[error])
++#define is_error(ptr) (ptr == NULL)
+
+ #endif
+diff --git a/json_tokener.c b/json_tokener.c
+index da414e7..df106b1 100644
+--- a/json_tokener.c
++++ b/json_tokener.c
+@@ -115,11 +115,27 @@ struct json_object* json_tokener_parse(const char *str)
+ tok = json_tokener_new();
+ obj = json_tokener_parse_ex(tok, str, -1);
+ if(tok->err != json_tokener_success)
+- obj = (struct json_object*)error_ptr(-tok->err);
++ obj = NULL;
+ json_tokener_free(tok);
+ return obj;
+ }
+
++struct json_object* json_tokener_parse_verbose(const char *str, enum json_tokener_error *error)
++{
++ struct json_tokener* tok;
++ struct json_object* obj;
++
++ tok = json_tokener_new();
++ obj = json_tokener_parse_ex(tok, str, -1);
++ *error = tok->err;
++ if(tok->err != json_tokener_success) {
++ obj = NULL;
++ }
++
++ json_tokener_free(tok);
++ return obj;
++}
++
+
+ #if !HAVE_STRNDUP
+ /* CAW: compliant version of strndup() */
+diff --git a/json_tokener.h b/json_tokener.h
+index 7d40b40..162a152 100644
+--- a/json_tokener.h
++++ b/json_tokener.h
+@@ -76,7 +76,7 @@ struct json_tokener
+ char *str;
+ struct printbuf *pb;
+ int depth, is_double, st_pos, char_offset;
+- ptrdiff_t err;
++ enum json_tokener_error err;
+ unsigned int ucs_char;
+ char quote_char;
+ struct json_tokener_srec stack[JSON_TOKENER_MAX_DEPTH];
+@@ -88,6 +88,7 @@ extern struct json_tokener* json_tokener_new(void);
+ extern void json_tokener_free(struct json_tokener *tok);
+ extern void json_tokener_reset(struct json_tokener *tok);
+ extern struct json_object* json_tokener_parse(const char *str);
++extern struct json_object* json_tokener_parse_verbose(const char *str, enum json_tokener_error *error);
+ extern struct json_object* json_tokener_parse_ex(struct json_tokener *tok,
+ const char *str, int len);
+
+diff --git a/test1.c b/test1.c
+index a3cc6d9..ac1b882 100644
+--- a/test1.c
++++ b/test1.c
+@@ -2,6 +2,7 @@
+ #include <stdlib.h>
+ #include <stddef.h>
+ #include <string.h>
++#include <assert.h>
+
+ #include "json.h"
+
+@@ -135,11 +136,21 @@ int main(int argc, char **argv)
+ printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj));
+ json_object_put(new_obj);
+
++ enum json_tokener_error error = json_tokener_success;
++ new_obj = json_tokener_parse_verbose("{ foo }", &error);
++ assert (error == json_tokener_error_parse_object_key_name);
++ assert (new_obj == NULL);
++
+ new_obj = json_tokener_parse("{ foo }");
+- if(is_error(new_obj)) printf("got error as expected\n");
++ assert (new_obj == NULL);
++
++ // if(is_error(new_obj)) printf("got error as expected\n");
+
+ new_obj = json_tokener_parse("foo");
+- if(is_error(new_obj)) printf("got error as expected\n");
++ assert (new_obj == NULL);
++ new_obj = json_tokener_parse_verbose("foo", &error);
++ assert (new_obj == NULL);
++ assert (error == json_tokener_error_parse_boolean);
+
+ new_obj = json_tokener_parse("{ \"foo");
+ if(is_error(new_obj)) printf("got error as expected\n");
+--
+1.7.6.4
+
diff --git a/json-c.spec b/json-c.spec
new file mode 100644
index 0000000..d0fff7a
--- /dev/null
+++ b/json-c.spec
@@ -0,0 +1,91 @@
+Name: json-c
+Version: 0.9
+Release: 5%{?dist}
+Summary: A JSON implementation in C
+Group: Development/Libraries
+License: MIT
+URL: http://oss.metaparadigm.com/json-c/
+Source0: http://oss.metaparadigm.com/json-c/json-c-%{version}.tar.gz
+BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
+
+# Upstream has applied this in git master branch
+Patch0: json-c-add-json_tokener_parse_verbose-and-return-NULL-on-pa.patch
+
+%description
+JSON-C implements a reference counting object model that allows you to easily
+construct JSON objects in C, output them as JSON formatted strings and parse
+JSON formatted strings back into the C representation of JSON objects.
+
+%package devel
+Summary: Development headers and library for json-c
+Group: Development/Libraries
+Requires: %{name} = %{version}-%{release}
+Requires: pkgconfig
+
+%description devel
+This package contains the development headers and library for json-c.
+
+
+%package doc
+Summary: Reference manual for json-c
+Group: Documentation
+BuildArch: noarch
+
+%description doc
+This package contains the reference manual for json-c.
+
+%prep
+%setup -q
+%patch0 -p1
+for doc in ChangeLog; do
+ iconv -f iso-8859-1 -t utf8 $doc > $doc.new &&
+ touch -r $doc $doc.new &&
+ mv $doc.new $doc
+done
+
+%build
+%configure --enable-shared --disable-static
+make %{?_smp_mflags}
+
+%install
+rm -rf %{buildroot}
+make install DESTDIR=%{buildroot}
+# Get rid of la files
+rm -rf %{buildroot}%{_libdir}/*.la
+
+%clean
+rm -rf %{buildroot}
+
+%post -p /sbin/ldconfig
+%postun -p /sbin/ldconfig
+
+%files
+%defattr(-,root,root,-)
+%doc AUTHORS ChangeLog COPYING NEWS README README.html
+%{_libdir}/libjson.so.*
+
+%files devel
+%defattr(-,root,root,-)
+%{_includedir}/json/
+%{_libdir}/libjson.so
+%{_libdir}/pkgconfig/json.pc
+
+%files doc
+%defattr(-,root,root,-)
+%doc doc/html/*
+
+%changelog
+* Thu Jul 19 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9-5
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_18_Mass_Rebuild
+
+* Mon Jan 23 2012 Jiri Pirko <jpirko@redhat.com> - 0.9-4
+- add json_tokener_parse_verbose, and return NULL on parser errors
+
+* Fri Jan 13 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9-3
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild
+
+* Wed Feb 09 2011 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.9-2
+- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild
+
+* Tue Apr 06 2010 Jussi Lehtola <jussilehtola@fedoraproject.org> - 0.9-1
+- First release.