summaryrefslogtreecommitdiffstats
path: root/ext/syck/rubyext.c
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-07 15:40:47 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-08-07 15:40:47 +0000
commit8048c754976fd19ff7bda993c9aaa425a6b6844c (patch)
treef4b14ebe865c5bc6cfe8d3742099f50753071735 /ext/syck/rubyext.c
parent3d234c14fb5e9653cf4917f0086137513f0dfe18 (diff)
downloadruby-8048c754976fd19ff7bda993c9aaa425a6b6844c.tar.gz
ruby-8048c754976fd19ff7bda993c9aaa425a6b6844c.tar.xz
ruby-8048c754976fd19ff7bda993c9aaa425a6b6844c.zip
* 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: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@6742 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/rubyext.c')
-rw-r--r--ext/syck/rubyext.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index cdf184c43..c54deea61 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() );