[PHP-CVS] cvs: php-src(PHP_5_3) /ext/json JSON_parser.c

2009-05-19 Thread Kalle Sommer Nielsen
kalle   Tue May 19 16:06:01 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/json   JSON_parser.c 
  Log:
  Cast to unsigned char to prevent compiler warning
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12.2.10r2=1.1.2.12.2.11diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12.2.10 
php-src/ext/json/JSON_parser.c:1.1.2.12.2.11
--- php-src/ext/json/JSON_parser.c:1.1.2.12.2.10Thu May 14 22:02:08 2009
+++ php-src/ext/json/JSON_parser.c  Tue May 19 16:06:00 2009
@@ -360,7 +360,7 @@
 | (utf16  0x3ff)) + 0x1;
 buf-len -= 3;
 
-smart_str_appendc(buf, 0xf0 | (utf32  18));
+smart_str_appendc(buf, (unsigned char) (0xf0 | (utf32  18)));
 smart_str_appendc(buf, 0x80 | ((utf32  12)  0x3f));
 smart_str_appendc(buf, 0x80 | ((utf32  6)  0x3f));
 smart_str_appendc(buf, 0x80 | (utf32  0x3f));



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



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

2009-05-14 Thread Scott MacVicar
scottmacThu May 14 22:02:08 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/json   JSON_parser.c JSON_parser.h json.c 
  Log:
  MFH Allow a custom recursion depth to be specified for json_decode()
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12.2.9r2=1.1.2.12.2.10diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12.2.9 
php-src/ext/json/JSON_parser.c:1.1.2.12.2.10
--- php-src/ext/json/JSON_parser.c:1.1.2.12.2.9 Thu Mar 19 19:26:00 2009
+++ php-src/ext/json/JSON_parser.c  Thu May 14 22:02:08 2009
@@ -247,6 +247,11 @@
 jp-top = -1;
jp-error_code = PHP_JSON_ERROR_NONE;
 jp-stack = (int*)ecalloc(depth, sizeof(int));
+if (depth  JSON_PARSER_DEFAULT_DEPTH) {
+jp-the_zstack = (zval **)safe_emalloc(depth, sizeof(zval), 0);
+} else {
+jp-the_zstack = jp-the_static_zstack[0];
+}
 push(jp, MODE_DONE);
 return jp;
 }
@@ -258,6 +263,9 @@
 free_JSON_parser(JSON_parser jp)
 {
 efree((void*)jp-stack);
+if (jp-the_zstack != jp-the_static_zstack[0]) {
+efree(jp-the_zstack);
+}
 efree((void*)jp);
 return false;
 }
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.h?r1=1.1.2.1.2.2r2=1.1.2.1.2.3diff_format=u
Index: php-src/ext/json/JSON_parser.h
diff -u php-src/ext/json/JSON_parser.h:1.1.2.1.2.2 
php-src/ext/json/JSON_parser.h:1.1.2.1.2.3
--- php-src/ext/json/JSON_parser.h:1.1.2.1.2.2  Fri Dec 19 02:00:57 2008
+++ php-src/ext/json/JSON_parser.h  Thu May 14 22:02:08 2009
@@ -6,7 +6,7 @@
 #include php.h
 #include ext/standard/php_smart_str.h
 
-#define JSON_PARSER_MAX_DEPTH 512
+#define JSON_PARSER_DEFAULT_DEPTH 512
 
 typedef struct JSON_parser_struct {
 int state;
@@ -14,8 +14,8 @@
 int top;
int error_code;
 int* stack;
-zval *the_zstack[JSON_PARSER_MAX_DEPTH];
-
+zval **the_zstack;
+zval *the_static_zstack[JSON_PARSER_DEFAULT_DEPTH];
 } * JSON_parser;
 
 enum error_codes {
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.19.2.19r2=1.9.2.19.2.20diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.19.2.19 
php-src/ext/json/json.c:1.9.2.19.2.20
--- php-src/ext/json/json.c:1.9.2.19.2.19   Tue Mar 17 23:26:02 2009
+++ php-src/ext/json/json.c Thu May 14 22:02:08 2009
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: json.c,v 1.9.2.19.2.19 2009/03/17 23:26:02 scottmac Exp $ */
+/* $Id: json.c,v 1.9.2.19.2.20 2009/05/14 22:02:08 scottmac Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include config.h
@@ -494,7 +494,7 @@
char *str;
int str_len, utf16_len;
zend_bool assoc = 0; /* return JS objects as PHP objects by default */
-   long depth = JSON_PARSER_MAX_DEPTH;
+   long depth = JSON_PARSER_DEFAULT_DEPTH;
zval *z;
unsigned short *utf16;
JSON_parser jp;
@@ -517,9 +517,9 @@
RETURN_NULL();
}
 
-   /* can be removed once we remove the max depth limit */
-   if (depth = 0 || depth  JSON_PARSER_MAX_DEPTH) {
-   depth = JSON_PARSER_MAX_DEPTH;
+   if (depth = 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Depth must greater 
than zero.);
+   RETURN_NULL();
}
 
ALLOC_INIT_ZVAL(z);



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



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/json JSON_parser.c

2009-03-19 Thread Matt Wilmas
mattwil Thu Mar 19 19:26:00 2009 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/json   JSON_parser.c 
  Log:
  MFH: Avoid 2 conversions when decoding numbers
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12.2.8r2=1.1.2.12.2.9diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12.2.8 
php-src/ext/json/JSON_parser.c:1.1.2.12.2.9
--- php-src/ext/json/JSON_parser.c:1.1.2.12.2.8 Tue Mar 17 14:57:39 2009
+++ php-src/ext/json/JSON_parser.c  Thu Mar 19 19:26:00 2009
@@ -289,16 +289,27 @@
 
 if (type == IS_LONG)
 {
-   long l = strtol(buf-c, NULL, 10);
-   double d = zend_strtod(buf-c, NULL);
-   if (d  LONG_MAX || d  LONG_MIN) {
-   ZVAL_DOUBLE(*z, d);
-   } else {
-   ZVAL_LONG(*z, l);
+   if (buf-c[0] == '-') {
+   buf-len--;
}
+
+   if (buf-len = MAX_LENGTH_OF_LONG - 1) {
+   if (buf-len == MAX_LENGTH_OF_LONG - 1) {
+   int cmp = strcmp(buf-c + (buf-c[0] == '-'), 
long_min_digits);
+
+   if (!(cmp  0 || (cmp == 0  buf-c[0] == 
'-'))) {
+   goto use_double;
+   }
+   } else {
+   goto use_double;
+   }
+   }
+
+   ZVAL_LONG(*z, strtol(buf-c, NULL, 10));
 }
 else if (type == IS_DOUBLE)
 {
+use_double:
 ZVAL_DOUBLE(*z, zend_strtod(buf-c, NULL));
 }
 else if (type == IS_STRING)



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



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/json JSON_parser.c /ext/json/tests bug47644.phpt

2009-03-16 Thread Scott MacVicar
scottmacTue Mar 17 02:00:13 2009 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/json/tests bug47644.phpt 

  Modified files:  
/php-src/ext/json   JSON_parser.c 
  Log:
  MFH Fix bug #47644 - Valid integers are truncated with json_decode()
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12.2.6r2=1.1.2.12.2.7diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12.2.6 
php-src/ext/json/JSON_parser.c:1.1.2.12.2.7
--- php-src/ext/json/JSON_parser.c:1.1.2.12.2.6 Fri Dec 19 02:00:57 2008
+++ php-src/ext/json/JSON_parser.c  Tue Mar 17 02:00:13 2009
@@ -289,11 +289,11 @@
 
 if (type == IS_LONG)
 {
-   double d = zend_strtod(buf-c, NULL);
-   if (d  LONG_MAX || d  LONG_MIN) {
-   ZVAL_DOUBLE(*z, d);
+   long l = strtol(buf-c, NULL, 10);
+   if (l  LONG_MAX || l  LONG_MIN) {
+   ZVAL_DOUBLE(*z, zend_strtod(buf-c, NULL));
} else {
-   ZVAL_LONG(*z, (long)d);
+   ZVAL_LONG(*z, l);
}
 }
 else if (type == IS_DOUBLE)

http://cvs.php.net/viewvc.cgi/php-src/ext/json/tests/bug47644.phpt?view=markuprev=1.1
Index: php-src/ext/json/tests/bug47644.phpt
+++ php-src/ext/json/tests/bug47644.phpt
--TEST--
Bug #47644 (valid large integers are truncated)
--SKIPIF--
?php
  if (!extension_loaded('json')) die('skip: json extension not available');
  if (PHP_INT_SIZE != 8) die(skip this test is for 64bit platform only);
?
--FILE--
?php

for ($i = 1; $i  10006; $i++) {
var_dump(json_decode([$i]));
}


echo Done\n;
?
--EXPECT--  
array(1) {
  [0]=
  int(1)
}
array(1) {
  [0]=
  int(10001)
}
array(1) {
  [0]=
  int(10002)
}
array(1) {
  [0]=
  int(10003)
}
array(1) {
  [0]=
  int(10004)
}
array(1) {
  [0]=
  int(10005)
}
Done



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



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/json JSON_parser.c JSON_parser.h json.c php_json.h /ext/json/tests 007.phpt

2008-12-18 Thread Scott MacVicar
scottmacFri Dec 19 02:00:57 2008 UTC

  Added files: (Branch: PHP_5_3)
/php-src/ext/json/tests 007.phpt 

  Modified files:  
/php-src/ext/json   JSON_parser.c JSON_parser.h json.c php_json.h 
  Log:
  MFH Add json_last_error() for getting a bit of information about what failed 
during a decode, also fixes a segfault when we have [1}
  [DOC]
  
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12.2.5r2=1.1.2.12.2.6diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12.2.5 
php-src/ext/json/JSON_parser.c:1.1.2.12.2.6
--- php-src/ext/json/JSON_parser.c:1.1.2.12.2.5 Wed Dec 17 15:46:21 2008
+++ php-src/ext/json/JSON_parser.c  Fri Dec 19 02:00:57 2008
@@ -194,13 +194,6 @@
 MODE_OBJECT,
 };
 
-enum error_codes {
-ERROR_DEPTH, 
-ERROR_MISMATCH,  
-ERROR_CTRL_CHAR,   
-ERROR_SYNTAX,
-};
-
 
 /*
 Push a mode onto the stack. Return false if there is overflow.
@@ -210,7 +203,7 @@
 {
 jp-top += 1;
 if (jp-top = jp-depth) {
-   jp-error = ERROR_DEPTH;
+   jp-error_code = PHP_JSON_ERROR_DEPTH;
 return false;
 }
 jp-stack[jp-top] = mode;
@@ -226,7 +219,7 @@
 pop(JSON_parser jp, int mode)
 {
 if (jp-top  0 || jp-stack[jp-top] != mode) {
-   jp-error = ERROR_MISMATCH;
+   jp-error_code = PHP_JSON_ERROR_STATE_MISMATCH;
 return false;
 }
 jp-top -= 1;
@@ -252,6 +245,7 @@
 jp-state = GO;
 jp-depth = depth;
 jp-top = -1;
+   jp-error_code = PHP_JSON_ERROR_NONE;
 jp-stack = (int*)ecalloc(depth, sizeof(int));
 push(jp, MODE_DONE);
 return jp;
@@ -428,7 +422,7 @@
} else {
next_class = ascii_class[next_char];
if (next_class = __) {
-   jp-error = ERROR_CTRL_CHAR;
+   jp-error_code = PHP_JSON_ERROR_CTRL_CHAR;
FREE_BUFFERS();
return false;
}
@@ -511,9 +505,7 @@
 break;
 /* } */
 case -8:
-if (type != -1 
-(jp-stack[jp-top] == MODE_OBJECT ||
- jp-stack[jp-top] == MODE_ARRAY))
+if (type != -1  jp-stack[jp-top] == MODE_OBJECT)
 {
 zval *mval;
 smart_str_0(buf);
@@ -541,9 +533,7 @@
 /* ] */
 case -7:
 {
-if (type != -1 
-(jp-stack[jp-top] == MODE_OBJECT ||
- jp-stack[jp-top] == MODE_ARRAY))
+if (type != -1  jp-stack[jp-top] == MODE_ARRAY)
 {
 zval *mval;
 smart_str_0(buf);
@@ -702,7 +692,7 @@
 */
 default:
 {
-   jp-error = ERROR_SYNTAX;
+   jp-error_code = PHP_JSON_ERROR_SYNTAX;
 FREE_BUFFERS();
 return false;
 }
@@ -711,8 +701,12 @@
 }
 
 FREE_BUFFERS();
+   if (jp-state == OK  pop(jp, MODE_DONE)) {
+   return true;
+   }
 
-return jp-state == OK  pop(jp, MODE_DONE);
+   jp-error_code = PHP_JSON_ERROR_SYNTAX;
+   return false;
 }
 
 
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.h?r1=1.1.2.1.2.1r2=1.1.2.1.2.2diff_format=u
Index: php-src/ext/json/JSON_parser.h
diff -u php-src/ext/json/JSON_parser.h:1.1.2.1.2.1 
php-src/ext/json/JSON_parser.h:1.1.2.1.2.2
--- php-src/ext/json/JSON_parser.h:1.1.2.1.2.1  Wed Dec 17 14:40:06 2008
+++ php-src/ext/json/JSON_parser.h  Fri Dec 19 02:00:57 2008
@@ -12,12 +12,20 @@
 int state;
 int depth;
 int top;
-   int error;
+   int error_code;
 int* stack;
 zval *the_zstack[JSON_PARSER_MAX_DEPTH];
 
 } * JSON_parser;
 
+enum error_codes {
+   PHP_JSON_ERROR_NONE = 0,
+PHP_JSON_ERROR_DEPTH, 
+PHP_JSON_ERROR_STATE_MISMATCH,  
+PHP_JSON_ERROR_CTRL_CHAR,   
+PHP_JSON_ERROR_SYNTAX,
+};
+
 extern JSON_parser new_JSON_parser(int depth);
 extern int parse_JSON(JSON_parser jp, zval *z, unsigned short utf16_json[], 
int length, int assoc TSRMLS_DC);
 extern int free_JSON_parser(JSON_parser jp);
http://cvs.php.net/viewvc.cgi/php-src/ext/json/json.c?r1=1.9.2.19.2.14r2=1.9.2.19.2.15diff_format=u
Index: php-src/ext/json/json.c
diff -u php-src/ext/json/json.c:1.9.2.19.2.14 
php-src/ext/json/json.c:1.9.2.19.2.15
--- php-src/ext/json/json.c:1.9.2.19.2.14   Wed Dec 17 14:40:06 2008
+++ php-src/ext/json/json.c Fri Dec 19 02:00:57 2008
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: json.c,v 1.9.2.19.2.14 2008/12/17 14:40:06 scottmac Exp $ */
+/* $Id: json.c,v 1.9.2.19.2.15 2008/12/19 02:00:57 scottmac Exp $ */
 
 #ifdef 

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/json JSON_parser.c

2008-12-17 Thread Scott MacVicar
scottmacWed Dec 17 15:46:21 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/json   JSON_parser.c 
  Log:
  MFH Fix Windows build
  
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12.2.4r2=1.1.2.12.2.5diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12.2.4 
php-src/ext/json/JSON_parser.c:1.1.2.12.2.5
--- php-src/ext/json/JSON_parser.c:1.1.2.12.2.4 Wed Dec 17 14:40:06 2008
+++ php-src/ext/json/JSON_parser.c  Wed Dec 17 15:46:21 2008
@@ -29,6 +29,9 @@
 #include stdio.h
 #include JSON_parser.h
 
+/* Windows defines IN for documentation */
+#undef IN
+
 #define true  1
 #define false 0
 #define __   -1 /* the universal error code */



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



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

2008-12-17 Thread Scott MacVicar
scottmacWed Dec 17 14:40:06 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/json   JSON_parser.c JSON_parser.h json.c 
  Log:
  Update the JSON parser with that on json.org, biggest change here is code 
readability. Less magic numbers in the state table.
  Add missing reflection information to json_encode()
  Fixes bug #45791 with 0e0 not being supported as a value
  Error values are stored when encountered during parsing
  
  
  http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12.2.3r2=1.1.2.12.2.4diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12.2.3 
php-src/ext/json/JSON_parser.c:1.1.2.12.2.4
--- php-src/ext/json/JSON_parser.c:1.1.2.12.2.3 Tue Dec  2 14:50:22 2008
+++ php-src/ext/json/JSON_parser.c  Wed Dec 17 14:40:06 2008
@@ -26,216 +26,191 @@
 SOFTWARE.
 */
 
-
-#include JSON_parser.h
 #include stdio.h
+#include JSON_parser.h
 
 #define true  1
 #define false 0
+#define __   -1 /* the universal error code */
 
 /*
-Characters are mapped into these 32 symbol classes. This allows for
-significant reductions in the size of the state transition table.
+Characters are mapped into these 31 character classes. This allows for
+a significant reduction in the size of the state transition table.
 */
 
-/* error */
-#define S_ERR -1
-
-/* space */
-#define S_SPA 0
-
-/* other whitespace */
-#define S_WSP 1
-
-/* {  */
-#define S_LBE 2
-
-/* } */
-#define S_RBE 3
-
-/* [ */
-#define S_LBT 4
-
-/* ] */
-#define S_RBT 5
-
-/* : */
-#define S_COL 6
-
-/* , */
-#define S_COM 7
-
-/*  */
-#define S_QUO 8
-
-/* \ */
-#define S_BAC 9
-
-/* / */
-#define S_SLA 10
-
-/* + */
-#define S_PLU 11
-
-/* - */
-#define S_MIN 12
-
-/* . */
-#define S_DOT 13
-
-/* 0 */
-#define S_ZER 14
-
-/* 123456789 */
-#define S_DIG 15
-
-/* a */
-#define S__A_ 16
-
-/* b */
-#define S__B_ 17
-
-/* c */
-#define S__C_ 18
-
-/* d */
-#define S__D_ 19
-
-/* e */
-#define S__E_ 20
-
-/* f */
-#define S__F_ 21
-
-/* l */
-#define S__L_ 22
-
-/* n */
-#define S__N_ 23
-
-/* r */
-#define S__R_ 24
-
-/* s */
-#define S__S_ 25
-
-/* t */
-#define S__T_ 26
-
-/* u */
-#define S__U_ 27
-
-/* ABCDF */
-#define S_A_F 28
-
-/* E */
-#define S_E   29
+enum classes {
+C_SPACE,  /* space */
+C_WHITE,  /* other whitespace */
+C_LCURB,  /* {  */
+C_RCURB,  /* } */
+C_LSQRB,  /* [ */
+C_RSQRB,  /* ] */
+C_COLON,  /* : */
+C_COMMA,  /* , */
+C_QUOTE,  /*  */
+C_BACKS,  /* \ */
+C_SLASH,  /* / */
+C_PLUS,   /* + */
+C_MINUS,  /* - */
+C_POINT,  /* . */
+C_ZERO ,  /* 0 */
+C_DIGIT,  /* 123456789 */
+C_LOW_A,  /* a */
+C_LOW_B,  /* b */
+C_LOW_C,  /* c */
+C_LOW_D,  /* d */
+C_LOW_E,  /* e */
+C_LOW_F,  /* f */
+C_LOW_L,  /* l */
+C_LOW_N,  /* n */
+C_LOW_R,  /* r */
+C_LOW_S,  /* s */
+C_LOW_T,  /* t */
+C_LOW_U,  /* u */
+C_ABCDF,  /* ABCDF */
+C_E,  /* E */
+C_ETC,/* everything else */
+NR_CLASSES
+};
 
-/* everything else */
-#define S_ETC 30
+static const int ascii_class[128] = {
+/*
+This array maps the 128 ASCII characters into character classes.
+The remaining Unicode characters should be mapped to C_ETC.
+Non-whitespace control characters are errors.
+*/
+__,  __,  __,  __,  __,  __,  __,  __,
+__,  C_WHITE, C_WHITE, __,  __,  C_WHITE, __,  __,
+__,  __,  __,  __,  __,  __,  __,  __,
+__,  __,  __,  __,  __,  __,  __,  __,
+
+C_SPACE, C_ETC,   C_QUOTE, C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,
+C_ETC,   C_ETC,   C_ETC,   C_PLUS,  C_COMMA, C_MINUS, C_POINT, C_SLASH,
+C_ZERO,  C_DIGIT, C_DIGIT, C_DIGIT, C_DIGIT, C_DIGIT, C_DIGIT, C_DIGIT,
+C_DIGIT, C_DIGIT, C_COLON, C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,
+
+C_ETC,   C_ABCDF, C_ABCDF, C_ABCDF, C_ABCDF, C_E, C_ABCDF, C_ETC,
+C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,
+C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_ETC,
+C_ETC,   C_ETC,   C_ETC,   C_LSQRB, C_BACKS, C_RSQRB, C_ETC,   C_ETC,
+
+C_ETC,   C_LOW_A, C_LOW_B, C_LOW_C, C_LOW_D, C_LOW_E, C_LOW_F, C_ETC,
+C_ETC,   C_ETC,   C_ETC,   C_ETC,   C_LOW_L, C_ETC,   C_LOW_N, C_ETC,
+C_ETC,   C_ETC,   C_LOW_R, C_LOW_S, C_LOW_T, C_LOW_U, C_ETC,   C_ETC,
+C_ETC,   C_ETC,   C_ETC,   C_LCURB, C_ETC,   C_RCURB, C_ETC,   C_ETC
+};
 
 
 /*
-This table maps the 128 ASCII characters into the 32 character classes.
-The remaining Unicode characters should be mapped to S_ETC.
+The state codes.
 */
-static const int ascii_class[128] = {
-S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
-S_ERR, S_WSP, S_WSP, S_ERR, S_ERR, S_WSP, S_ERR, S_ERR,
-S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR,
-S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, S_ERR, 

[PHP-CVS] cvs: php-src(PHP_5_3) /ext/json JSON_parser.c

2008-12-02 Thread Matt Wilmas
mattwil Tue Dec  2 14:50:22 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/json   JSON_parser.c 
  Log:
  MFH: Changed logic for LONG_MIN
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12.2.2r2=1.1.2.12.2.3diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12.2.2 
php-src/ext/json/JSON_parser.c:1.1.2.12.2.3
--- php-src/ext/json/JSON_parser.c:1.1.2.12.2.2 Wed Jul 30 13:52:59 2008
+++ php-src/ext/json/JSON_parser.c  Tue Dec  2 14:50:22 2008
@@ -285,7 +285,7 @@
 if (type == IS_LONG)
 {
double d = zend_strtod(buf-c, NULL);
-   if (d  LONG_MAX || d  -LONG_MAX) {
+   if (d  LONG_MAX || d  LONG_MIN) {
ZVAL_DOUBLE(*z, d);
} else {
ZVAL_LONG(*z, (long)d);



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



[PHP-CVS] cvs: php-src(PHP_5_3) /ext/json JSON_parser.c

2008-07-30 Thread Rasmus Lerdorf
rasmus  Wed Jul 30 13:52:59 2008 UTC

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/json   JSON_parser.c 
  Log:
  We can afford a larger stack here and other json parsers out there
  go deeper than 128.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/json/JSON_parser.c?r1=1.1.2.12.2.1r2=1.1.2.12.2.2diff_format=u
Index: php-src/ext/json/JSON_parser.c
diff -u php-src/ext/json/JSON_parser.c:1.1.2.12.2.1 
php-src/ext/json/JSON_parser.c:1.1.2.12.2.2
--- php-src/ext/json/JSON_parser.c:1.1.2.12.2.1 Sun Oct  7 05:22:04 2007
+++ php-src/ext/json/JSON_parser.c  Wed Jul 30 13:52:59 2008
@@ -201,7 +201,7 @@
 /*29*/ {29,29,-1,-1,-1,-1,-1,-1, 
3,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1}
 };
 
-#define JSON_PARSER_MAX_DEPTH 128
+#define JSON_PARSER_MAX_DEPTH 512
 
 
 /*



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