Changeset 47 for trunk/ext/php

Show
Ignore:
Timestamp:
03/30/2003 20:35:54 (6 years ago)
Author:
whythluckystiff
Message:

Floats in PHP, Python.
Literal parsing, chomping, keeping, explicit indent. It's all there.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/ext/php/phpext.c

    r42 r47  
    1818#include "ext/standard/info.h" 
    1919#include "php_syck.h" 
     20 
     21static double zero()    { return 0.0; } 
     22static double one() { return 1.0; } 
     23static double inf() { return one() / zero(); } 
     24static double nan() { return zero() / zero(); } 
    2025 
    2126/* {{{ syck_functions[] 
     
    176181            else if ( strcmp( n->type_id, "float" ) == 0 ) 
    177182            { 
    178                                 //double floatVal = strtol( n->data.str->ptr ); 
    179                                 ZVAL_DOUBLE( o, 3.45 ); 
     183                double f; 
     184                syck_str_blow_away_commas( n ); 
     185                f = strtod( n->data.str->ptr, NULL ); 
     186                                ZVAL_DOUBLE( o, f ); 
     187            } 
     188            else if ( strcmp( n->type_id, "float#nan" ) == 0 ) 
     189            { 
     190                ZVAL_DOUBLE( o, nan() ); 
     191            } 
     192            else if ( strcmp( n->type_id, "float#inf" ) == 0 ) 
     193            { 
     194                ZVAL_DOUBLE( o, inf() ); 
     195            } 
     196            else if ( strcmp( n->type_id, "float#neginf" ) == 0 ) 
     197            { 
     198                ZVAL_DOUBLE( o, -inf() ); 
    180199            } 
    181200            else