* ext/syck/bytecode.c: turn off default implicit typing.

* ext/syck/implicit.c: detect base60 integers.

* ext/syck/rubyext.c: handle base60, as well as hex and octal
  with commas.  implicit typing of ruby symbols.

* test/yaml/test_yaml.rb: add test.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
why 2004-01-12 22:55:09 +00:00
Родитель 84c0dcfca2
Коммит 52e0ab245a
5 изменённых файлов: 1253 добавлений и 1153 удалений

Просмотреть файл

@ -1,3 +1,14 @@
Tue Jan 13 07:52:40 2004 why the lucky stiff <why@ruby-lang.org>
* ext/syck/bytecode.c: turn off default implicit typing.
* ext/syck/implicit.c: detect base60 integers.
* ext/syck/rubyext.c: handle base60, as well as hex and octal
with commas. implicit typing of ruby symbols.
* test/yaml/test_yaml.rb: add test.
Tue Jan 13 04:29:52 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_driver.rb (RiDriver::report_method_stuff):

Просмотреть файл

@ -1,4 +1,4 @@
/* Generated by re2c 0.5 on Sun Nov 23 14:51:02 2003 */
/* Generated by re2c 0.5 on Mon Jan 12 11:40:10 2004 */
#line 1 "bytecode.re"
/*
* bytecode.re
@ -510,7 +510,7 @@ yy44: yych = *++YYCURSOR;
Directive:
{
YYTOKTMP = YYCURSOR;
YYTOKEN = YYCURSOR;
{
YYCTYPE yych;
@ -611,7 +611,7 @@ yy48: yyaccept = 0;
}
yy49:
#line 400
{ YYCURSOR = YYTOKTMP;
{ YYCURSOR = YYTOKEN;
return YAML_DOCSEP;
}
yy50: yych = *++YYCURSOR;
@ -876,7 +876,7 @@ yy58: yych = *++YYCURSOR;
Comment:
{
YYTOKTMP = YYCURSOR;
YYTOKEN = YYCURSOR;
{
YYCTYPE yych;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -412,7 +412,7 @@ yaml_org_handler( n, ref )
{
case syck_str_kind:
transferred = 1;
if ( type_id == NULL || strcmp( type_id, "str" ) == 0 )
if ( type_id == NULL )
{
obj = rb_str_new( n->data.str->ptr, n->data.str->len );
}
@ -438,12 +438,39 @@ yaml_org_handler( n, ref )
}
else if ( strcmp( type_id, "int#hex" ) == 0 )
{
syck_str_blow_away_commas( n );
obj = rb_cstr2inum( n->data.str->ptr, 16 );
}
else if ( strcmp( type_id, "int#oct" ) == 0 )
{
syck_str_blow_away_commas( n );
obj = rb_cstr2inum( n->data.str->ptr, 8 );
}
else if ( strcmp( type_id, "int#base60" ) == 0 )
{
char *ptr, *end;
long sixty = 1;
long total = 0;
syck_str_blow_away_commas( n );
ptr = n->data.str->ptr;
end = n->data.str->ptr + n->data.str->len;
while ( end > ptr )
{
long bnum = 0;
char *colon = end - 1;
while ( colon >= ptr && *colon != ':' )
{
colon--;
}
if ( *colon == ':' ) *colon = '\0';
bnum = strtol( colon + 1, NULL, 10 );
total += bnum * sixty;
sixty *= 60;
end = colon;
}
obj = INT2FIX(total);
}
else if ( strncmp( type_id, "int", 3 ) == 0 )
{
syck_str_blow_away_commas( n );
@ -495,14 +522,6 @@ yaml_org_handler( n, ref )
while ( !ISDIGIT( *ptr ) ) ptr++;
day = INT2FIX(strtol(ptr, NULL, 10));
if ( !cDate ) {
/*
* Load Date module
*/
rb_require( "date" );
cDate = rb_const_get( rb_cObject, rb_intern("Date") );
}
obj = rb_funcall( cDate, s_new, 3, year, mon, day );
}
else if ( strncmp( type_id, "timestamp", 9 ) == 0 )
@ -517,6 +536,17 @@ yaml_org_handler( n, ref )
{
obj = rb_funcall( cDefaultKey, s_new, 0 );
}
else if ( strncmp( n->data.str->ptr, ":", 1 ) == 0 )
{
char *tmp;
tmp = syck_strndup( n->data.str->ptr + 1, n->data.str->len - 1 );
obj = ID2SYM( rb_intern( tmp ) );
free( tmp );
}
else if ( strcmp( type_id, "str" ) == 0 )
{
obj = rb_str_new( n->data.str->ptr, n->data.str->len );
}
else
{
transferred = 0;

Просмотреть файл

@ -442,6 +442,14 @@ octal: 014
hexadecimal: 0xC
EOY
)
assert_parse_only(
{ 'canonical' => 685230, 'decimal' => 685230, 'octal' => '02472256'.oct, 'hexadecimal' => '0x0A74AE'.hex, 'sexagesimal' => 685230 }, <<EOY
canonical: 685230
decimal: +685,230
octal: 02472256
hexadecimal: 0x0A,74,AE
sexagesimal: 190:20:30
EOY
end
def test_spec_type_float