Diff for /embedaddon/php/ext/json/JSON_parser.c between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 23:47:57 version 1.1.1.2, 2012/05/29 12:34:40
Line 291  static int dehexchar(char c) Line 291  static int dehexchar(char c)
 }  }
   
   
static void json_create_zval(zval **z, smart_str *buf, int type)static void json_create_zval(zval **z, smart_str *buf, int type, int options)
 {  {
     ALLOC_INIT_ZVAL(*z);      ALLOC_INIT_ZVAL(*z);
   
     if (type == IS_LONG)      if (type == IS_LONG)
     {      {
                   zend_bool bigint = 0;
   
                 if (buf->c[0] == '-') {                  if (buf->c[0] == '-') {
                         buf->len--;                          buf->len--;
                 }                  }
Line 306  static void json_create_zval(zval **z, smart_str *buf, Line 308  static void json_create_zval(zval **z, smart_str *buf,
                                 int cmp = strcmp(buf->c + (buf->c[0] == '-'), long_min_digits);                                  int cmp = strcmp(buf->c + (buf->c[0] == '-'), long_min_digits);
   
                                 if (!(cmp < 0 || (cmp == 0 && buf->c[0] == '-'))) {                                  if (!(cmp < 0 || (cmp == 0 && buf->c[0] == '-'))) {
                                        goto use_double;                                        bigint = 1;
                                 }                                  }
                         } else {                          } else {
                                   bigint = 1;
                           }
                   }
   
                   if (bigint) {
                           /* value too large to represent as a long */
                           if (options & PHP_JSON_BIGINT_AS_STRING) {
                                   if (buf->c[0] == '-') {
                                           /* Restore last char consumed above */
                                           buf->len++;
                                   }
                                   goto use_string;
                           } else {
                                 goto use_double;                                  goto use_double;
                         }                          }
                 }                  }
Line 322  use_double: Line 337  use_double:
     }      }
     else if (type == IS_STRING)      else if (type == IS_STRING)
     {      {
   use_string:
         ZVAL_STRINGL(*z, buf->c, buf->len, 1);          ZVAL_STRINGL(*z, buf->c, buf->len, 1);
     }      }
     else if (type == IS_BOOL)      else if (type == IS_BOOL)
Line 420  static void attach_zval(JSON_parser jp, int up, int cu Line 436  static void attach_zval(JSON_parser jp, int up, int cu
     machine with a stack.      machine with a stack.
 */  */
 int  int
parse_JSON(JSON_parser jp, zval *z, unsigned short utf16_json[], int length, int assoc TSRMLS_DC)parse_JSON_ex(JSON_parser jp, zval *z, unsigned short utf16_json[], int length, int options TSRMLS_DC)
 {  {
     int next_char;  /* the next character */      int next_char;  /* the next character */
     int next_class;  /* the next character class */      int next_class;  /* the next character class */
     int next_state;  /* the next state */      int next_state;  /* the next state */
     int the_index;      int the_index;
       int assoc = options & PHP_JSON_OBJECT_AS_ARRAY;
   
     smart_str buf = {0};      smart_str buf = {0};
     smart_str key = {0};      smart_str key = {0};
Line 530  parse_JSON(JSON_parser jp, zval *z, unsigned short utf Line 547  parse_JSON(JSON_parser jp, zval *z, unsigned short utf
                     zval *mval;                      zval *mval;
                     smart_str_0(&buf);                      smart_str_0(&buf);
   
                    json_create_zval(&mval, &buf, type);                    json_create_zval(&mval, &buf, type, options);
   
                     if (!assoc) {                      if (!assoc) {
                         add_property_zval_ex(jp->the_zstack[jp->top], (key.len ? key.c : "_empty_"), (key.len ? (key.len + 1) : sizeof("_empty_")), mval TSRMLS_CC);                          add_property_zval_ex(jp->the_zstack[jp->top], (key.len ? key.c : "_empty_"), (key.len ? (key.len + 1) : sizeof("_empty_")), mval TSRMLS_CC);
Line 558  parse_JSON(JSON_parser jp, zval *z, unsigned short utf Line 575  parse_JSON(JSON_parser jp, zval *z, unsigned short utf
                     zval *mval;                      zval *mval;
                     smart_str_0(&buf);                      smart_str_0(&buf);
   
                    json_create_zval(&mval, &buf, type);                    json_create_zval(&mval, &buf, type, options);
                     add_next_index_zval(jp->the_zstack[jp->top], mval);                      add_next_index_zval(jp->the_zstack[jp->top], mval);
                     buf.len = 0;                      buf.len = 0;
                     JSON_RESET_TYPE();                      JSON_RESET_TYPE();
Line 670  parse_JSON(JSON_parser jp, zval *z, unsigned short utf Line 687  parse_JSON(JSON_parser jp, zval *z, unsigned short utf
                      jp->stack[jp->top] == MODE_ARRAY))                       jp->stack[jp->top] == MODE_ARRAY))
                 {                  {
                     smart_str_0(&buf);                      smart_str_0(&buf);
                    json_create_zval(&mval, &buf, type);                    json_create_zval(&mval, &buf, type, options);
                 }                  }
   
                 switch (jp->stack[jp->top]) {                  switch (jp->stack[jp->top]) {

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>