diff options
author | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-07 15:34:39 +0000 |
---|---|---|
committer | why <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-08-07 15:34:39 +0000 |
commit | e3619768b1273cd532c87ca5948b85475a147f54 (patch) | |
tree | 7d9acbd3febff8df77ed6b5f07909d6f6063deed /ext/syck/rubyext.c | |
parent | 5190564b682d8bfe6f71f7bbd07d897a354b3712 (diff) |
* lib/implicit.c: added sexagecimal float#base60.
* ext/syck/rubyext.c (yaml_org_handler): ditto.
* lib/token.c: indentation absolutely ignored when processing flow
collections. plain scalars are trimmed if indentation follows in
an ambiguous flow collection.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/rubyext.c')
-rw-r--r-- | ext/syck/rubyext.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c index cdf184c432..c54deea618 100644 --- a/ext/syck/rubyext.c +++ b/ext/syck/rubyext.c @@ -482,6 +482,31 @@ yaml_org_handler( n, ref ) syck_str_blow_away_commas( n ); obj = rb_cstr2inum( n->data.str->ptr, 10 ); } + else if ( strcmp( type_id, "float#base60" ) == 0 ) + { + char *ptr, *end; + long sixty = 1; + double total = 0.0; + syck_str_blow_away_commas( n ); + ptr = n->data.str->ptr; + end = n->data.str->ptr + n->data.str->len; + while ( end > ptr ) + { + double bnum = 0; + char *colon = end - 1; + while ( colon >= ptr && *colon != ':' ) + { + colon--; + } + if ( *colon == ':' ) *colon = '\0'; + + bnum = strtod( colon + 1, NULL ); + total += bnum * sixty; + sixty *= 60; + end = colon; + } + obj = rb_float_new( total ); + } else if ( strcmp( type_id, "float#nan" ) == 0 ) { obj = rb_float_new( S_nan() ); |