[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json json.c php_json.h

2009-06-22 Thread Stanislav Malyshev
stasMon Jun 22 18:41:13 2009 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   json.c php_json.h 
  Log:
  fix shared build on Windows
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.29&r2=1.9.2.30&diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.29 php-src/ext/json/json.c:1.9.2.30
--- php-src/ext/json/json.c:1.9.2.29Mon Jun  1 14:03:24 2009
+++ php-src/ext/json/json.c Mon Jun 22 18:41:13 2009
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: json.c,v 1.9.2.29 2009/06/01 14:03:24 tony2001 Exp $ */
+/* $Id: json.c,v 1.9.2.30 2009/06/22 18:41:13 stas Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -341,7 +341,7 @@
 }
 /* }}} */
 
-PHPAPI void php_json_encode(smart_str *buf, zval *val TSRMLS_DC) /* {{{ */
+PHP_JSON_API void php_json_encode(smart_str *buf, zval *val TSRMLS_DC) /* {{{ 
*/
 {
 switch (Z_TYPE_P(val)) {
 case IS_NULL:
@@ -393,7 +393,7 @@
 }
 /* }}} */
 
-PHPAPI void php_json_decode(zval *return_value, char *buf, int buf_len, 
zend_bool assoc TSRMLS_DC) /* {{{ */
+PHP_JSON_API void php_json_decode(zval *return_value, char *buf, int buf_len, 
zend_bool assoc TSRMLS_DC) /* {{{ */
 {
unsigned short *utf16;
int utf16_len;
http://cvs.php.net/viewvc.cgi/php-src/ext/json/php_json.h?r1=1.8.2.7&r2=1.8.2.8&diff_format=u
Index: php-src/ext/json/php_json.h
diff -u php-src/ext/json/php_json.h:1.8.2.7 php-src/ext/json/php_json.h:1.8.2.8
--- php-src/ext/json/php_json.h:1.8.2.7 Mon Jun  1 14:03:24 2009
+++ php-src/ext/json/php_json.h Mon Jun 22 18:41:13 2009
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: php_json.h,v 1.8.2.7 2009/06/01 14:03:24 tony2001 Exp $ */
+/* $Id: php_json.h,v 1.8.2.8 2009/06/22 18:41:13 stas Exp $ */
 
 #ifndef PHP_JSON_H
 #define PHP_JSON_H
@@ -44,8 +44,8 @@
 #define JSON_G(v) (json_globals.v)
 #endif
 
-PHPAPI void php_json_encode(smart_str *buf, zval *val TSRMLS_DC);
-PHPAPI void php_json_decode(zval *return_value, char *buf, int buf_len, 
zend_bool assoc TSRMLS_DC);
+PHP_JSON_API void php_json_encode(smart_str *buf, zval *val TSRMLS_DC);
+PHP_JSON_API void php_json_decode(zval *return_value, char *buf, int buf_len, 
zend_bool assoc TSRMLS_DC);
 
 #endif  /* PHP_JSON_H */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json json.c php_json.h

2009-06-01 Thread Antony Dovgal
tony2001Mon Jun  1 14:03:24 2009 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   json.c php_json.h 
  Log:
  fix ZTS build
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.28&r2=1.9.2.29&diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.28 php-src/ext/json/json.c:1.9.2.29
--- php-src/ext/json/json.c:1.9.2.28Sun May 31 13:51:23 2009
+++ php-src/ext/json/json.c Mon Jun  1 14:03:24 2009
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: json.c,v 1.9.2.28 2009/05/31 13:51:23 jani Exp $ */
+/* $Id: json.c,v 1.9.2.29 2009/06/01 14:03:24 tony2001 Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -393,7 +393,7 @@
 }
 /* }}} */
 
-PHPAPI void php_json_decode(zval *return_value, char *buf, int buf_len, 
zend_bool assoc) /* {{{ */
+PHPAPI void php_json_decode(zval *return_value, char *buf, int buf_len, 
zend_bool assoc TSRMLS_DC) /* {{{ */
 {
unsigned short *utf16;
int utf16_len;
@@ -487,7 +487,7 @@
 RETURN_NULL();
 }
 
-   php_json_decode(return_value, parameter, parameter_len, assoc);
+   php_json_decode(return_value, parameter, parameter_len, assoc 
TSRMLS_CC);
 }
 /* }}} */
 
http://cvs.php.net/viewvc.cgi/php-src/ext/json/php_json.h?r1=1.8.2.6&r2=1.8.2.7&diff_format=u
Index: php-src/ext/json/php_json.h
diff -u php-src/ext/json/php_json.h:1.8.2.6 php-src/ext/json/php_json.h:1.8.2.7
--- php-src/ext/json/php_json.h:1.8.2.6 Sun May 31 18:55:36 2009
+++ php-src/ext/json/php_json.h Mon Jun  1 14:03:24 2009
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: php_json.h,v 1.8.2.6 2009/05/31 18:55:36 andrei Exp $ */
+/* $Id: php_json.h,v 1.8.2.7 2009/06/01 14:03:24 tony2001 Exp $ */
 
 #ifndef PHP_JSON_H
 #define PHP_JSON_H
@@ -45,7 +45,7 @@
 #endif
 
 PHPAPI void php_json_encode(smart_str *buf, zval *val TSRMLS_DC);
-PHPAPI void php_json_decode(zval *return_value, char *buf, int buf_len, 
zend_bool assoc);
+PHPAPI void php_json_decode(zval *return_value, char *buf, int buf_len, 
zend_bool assoc TSRMLS_DC);
 
 #endif  /* PHP_JSON_H */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/json json.c php_json.h

2009-05-30 Thread Andrei Zmievski
andrei  Sun May 31 01:43:45 2009 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/json   json.c php_json.h 
  Log:
  Expose encode/decode API.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.26&r2=1.9.2.27&diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.26 php-src/ext/json/json.c:1.9.2.27
--- php-src/ext/json/json.c:1.9.2.26Thu Feb 12 00:36:23 2009
+++ php-src/ext/json/json.c Sun May 31 01:43:45 2009
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: json.c,v 1.9.2.26 2009/02/12 00:36:23 scottmac Exp $ */
+/* $Id: json.c,v 1.9.2.27 2009/05/31 01:43:45 andrei Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -83,7 +83,6 @@
 }
 /* }}} */
 
-static void json_encode_r(smart_str *buf, zval *val TSRMLS_DC);
 static void json_escape_string(smart_str *buf, char *s, int len TSRMLS_DC);
 
 static int json_determine_array_type(zval **val TSRMLS_DC)  /* {{{ */
@@ -176,7 +175,7 @@
 need_comma = 1;
 }
  
-json_encode_r(buf, *data TSRMLS_CC);
+php_json_encode(buf, *data TSRMLS_CC);
 } else if (r == 1) {
 if (i == HASH_KEY_IS_STRING) {
 if (key[0] == '\0' && Z_TYPE_PP(val) == IS_OBJECT) {
@@ -196,7 +195,7 @@
 json_escape_string(buf, key, key_len - 1 TSRMLS_CC);
 smart_str_appendc(buf, ':');
 
-json_encode_r(buf, *data TSRMLS_CC);
+php_json_encode(buf, *data TSRMLS_CC);
 } else {
 if (need_comma) {
 smart_str_appendc(buf, ',');
@@ -209,7 +208,7 @@
 smart_str_appendc(buf, '"');
 smart_str_appendc(buf, ':');
 
-json_encode_r(buf, *data TSRMLS_CC);
+php_json_encode(buf, *data TSRMLS_CC);
 }
 }
 
@@ -342,7 +341,7 @@
 }
 /* }}} */
 
-static void json_encode_r(smart_str *buf, zval *val TSRMLS_DC) /* {{{ */
+PHPAPI void php_json_encode(smart_str *buf, zval *val TSRMLS_DC) /* {{{ */
 {
 switch (Z_TYPE_P(val)) {
 case IS_NULL:
@@ -372,7 +371,7 @@
smart_str_appendl(buf, d, len);
efree(d);
 } else {
-zend_error(E_WARNING, "[json] (json_encode_r) double %.9g 
does not conform to the JSON spec, encoded as 0.", dbl);
+zend_error(E_WARNING, "[json] (php_json_encode) double 
%.9g does not conform to the JSON spec, encoded as 0.", dbl);
 smart_str_appendc(buf, '0');
 }
 }
@@ -385,7 +384,7 @@
 json_encode_array(buf, &val TSRMLS_CC);
 break;
 default:
-zend_error(E_WARNING, "[json] (json_encode_r) type is unsupported, 
encoded as null.");
+zend_error(E_WARNING, "[json] (php_json_encode) type is 
unsupported, encoded as null.");
 smart_str_appendl(buf, "null", 4);
 break;
 }
@@ -394,6 +393,64 @@
 }
 /* }}} */
 
+PHPAPI void php_json_decode(zval *return_value, char *buf, int buf_len, 
zend_bool assoc) /* {{{ */
+{
+   unsigned short *utf16;
+   int utf16_len;
+   zval *z;
+
+   utf16 = (unsigned short *) safe_emalloc((buf_len+1), sizeof(unsigned 
short), 1);
+
+   utf16_len = utf8_to_utf16(utf16, buf, buf_len);
+   if (utf16_len <= 0)
+   {
+   if (utf16)
+   {
+   efree(utf16);
+   }
+
+   RETURN_NULL();
+   }
+
+   ALLOC_INIT_ZVAL(z);
+   if (JSON_parser(z, utf16, utf16_len, assoc TSRMLS_CC))
+   {
+   *return_value = *z;
+
+   FREE_ZVAL(z);
+   efree(utf16);
+   }
+   else
+   {
+   double d;
+   int type;
+   long p;
+
+   zval_dtor(z);
+   FREE_ZVAL(z);
+   efree(utf16);
+
+   if (buf_len == 4) {
+   if (!strcasecmp(buf, "null")) {
+   RETURN_NULL();
+   } else if (!strcasecmp(buf, "true")) {
+   RETURN_BOOL(1);
+   }
+   } else if (buf_len == 5 && !strcasecmp(buf, "false")) {
+   RETURN_BOOL(0);
+   }
+   if ((type = is_numeric_string(buf, buf_len, &p, &d, 0)) != 0) {
+   if (type == IS_LONG) {
+   RETURN_LONG(p);
+   } else if (type == IS_DOUBLE) {
+   RETURN_DOUBLE(d);
+   }
+   }
+   RETURN_NULL();
+   }
+}
+/* }}} */
+
 /* {{{ proto string json_encod