mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/yaml.rb: removed fallback to pure Ruby parser.
* lib/yaml/baseemitter.rb (node_text): rewriting folded scalars. * ext/syck/syck.h: reports style of scalars now, be they plain, block single-, or double-quoted. * ext/syck/syck.c: ditto. * ext/syck/gram.c: ditto. * ext/syck/node.c: ditto. * ext/syck/token.c: ditto. * ext/syck/rubyext.c (yaml_org_handler): symbols loaded only if scalar style is plain. * test/yaml/test_yaml.rb (test_perl_regexp): updated test to match new regexp serialization. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6315 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
094290e68f
commit
c474911e5b
11 changed files with 362 additions and 340 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
Sat May 15 12:04:58 2004 why the lucky stiff <why@ruby-lang.org>
|
||||
|
||||
* lib/yaml.rb: removed fallback to pure Ruby parser.
|
||||
|
||||
* lib/yaml/baseemitter.rb (node_text): rewriting folded scalars.
|
||||
|
||||
* ext/syck/syck.h: reports style of scalars now, be they plain, block
|
||||
single-, or double-quoted.
|
||||
|
||||
* ext/syck/syck.c: ditto.
|
||||
|
||||
* ext/syck/gram.c: ditto.
|
||||
|
||||
* ext/syck/node.c: ditto.
|
||||
|
||||
* ext/syck/token.c: ditto.
|
||||
|
||||
* ext/syck/rubyext.c (yaml_org_handler): symbols loaded only
|
||||
if scalar style is plain.
|
||||
|
||||
* test/yaml/test_yaml.rb (test_perl_regexp): updated test to
|
||||
match new regexp serialization.
|
||||
|
||||
Sat May 15 01:41:34 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (eval): forgot to restore $SAFE value before evaluating
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
#define YYLEX_PARAM parser
|
||||
|
||||
#define NULL_NODE(parser, node) \
|
||||
SyckNode *node = syck_new_str( "" ); \
|
||||
SyckNode *node = syck_new_str( "", scalar_plain ); \
|
||||
if ( ((SyckParser *)parser)->taguri_expansion == 1 ) \
|
||||
{ \
|
||||
node->type_id = syck_taguri( YAML_DOMAIN, "null", 4 ); \
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
|
||||
|
||||
#ifndef YYSTYPE
|
||||
#line 23 "gram.y"
|
||||
#line 33 "gram.y"
|
||||
typedef union {
|
||||
SYMID nodeId;
|
||||
SyckNode *nodeData;
|
||||
|
|
|
@ -83,6 +83,7 @@ syck_alloc_str()
|
|||
s = S_ALLOC( struct SyckStr );
|
||||
s->len = 0;
|
||||
s->ptr = NULL;
|
||||
s->style = scalar_none;
|
||||
|
||||
n = syck_alloc_node( syck_str_kind );
|
||||
n->data.str = s;
|
||||
|
@ -91,19 +92,20 @@ syck_alloc_str()
|
|||
}
|
||||
|
||||
SyckNode *
|
||||
syck_new_str( char *str )
|
||||
syck_new_str( char *str, enum scalar_style style )
|
||||
{
|
||||
return syck_new_str2( str, strlen( str ) );
|
||||
return syck_new_str2( str, strlen( str ), style );
|
||||
}
|
||||
|
||||
SyckNode *
|
||||
syck_new_str2( char *str, long len )
|
||||
syck_new_str2( char *str, long len, enum scalar_style style )
|
||||
{
|
||||
SyckNode *n;
|
||||
|
||||
n = syck_alloc_str();
|
||||
n->data.str->ptr = S_ALLOC_N( char, len + 1 );
|
||||
n->data.str->len = len;
|
||||
n->data.str->style = style;
|
||||
memcpy( n->data.str->ptr, str, len );
|
||||
n->data.str->ptr[len] = '\0';
|
||||
|
||||
|
|
|
@ -15,33 +15,25 @@
|
|||
|
||||
typedef struct RVALUE {
|
||||
union {
|
||||
#if 0
|
||||
struct {
|
||||
unsigned long flags; /* always 0 for freed obj */
|
||||
struct RVALUE *next;
|
||||
} free;
|
||||
#endif
|
||||
struct RBasic basic;
|
||||
struct RObject object;
|
||||
struct RClass klass;
|
||||
struct RFloat flonum;
|
||||
struct RString string;
|
||||
/*struct RFloat flonum;*/
|
||||
/*struct RString string;*/
|
||||
struct RArray array;
|
||||
struct RRegexp regexp;
|
||||
/*struct RRegexp regexp;*/
|
||||
struct RHash hash;
|
||||
struct RData data;
|
||||
/*struct RData data;*/
|
||||
struct RStruct rstruct;
|
||||
struct RBignum bignum;
|
||||
struct RFile file;
|
||||
#if 0
|
||||
struct RNode node;
|
||||
struct RMatch match;
|
||||
struct RVarmap varmap;
|
||||
struct SCOPE scope;
|
||||
#endif
|
||||
/*struct RBignum bignum;*/
|
||||
/*struct RFile file;*/
|
||||
} as;
|
||||
#ifdef GC_DEBUG
|
||||
char *file;
|
||||
int line;
|
||||
#endif
|
||||
} RVALUE;
|
||||
|
||||
typedef struct {
|
||||
|
@ -558,7 +550,9 @@ yaml_org_handler( n, ref )
|
|||
{
|
||||
obj = rb_funcall( cDefaultKey, s_new, 0 );
|
||||
}
|
||||
else if ( n->data.str->len > 1 && strncmp( n->data.str->ptr, ":", 1 ) == 0 )
|
||||
else if ( n->data.str->style == scalar_plain &&
|
||||
n->data.str->len > 1 &&
|
||||
strncmp( n->data.str->ptr, ":", 1 ) == 0 )
|
||||
{
|
||||
obj = rb_funcall( oDefaultLoader, s_transfer, 2,
|
||||
rb_str_new2( "ruby/sym" ),
|
||||
|
|
|
@ -84,6 +84,14 @@ enum map_part {
|
|||
map_value
|
||||
};
|
||||
|
||||
enum scalar_style {
|
||||
scalar_none,
|
||||
scalar_plain,
|
||||
scalar_1quote,
|
||||
scalar_2quote,
|
||||
scalar_block
|
||||
};
|
||||
|
||||
/*
|
||||
* Node metadata struct
|
||||
*/
|
||||
|
@ -112,6 +120,7 @@ struct _syck_node {
|
|||
} *list;
|
||||
/* Storage for string data */
|
||||
struct SyckStr {
|
||||
enum scalar_style style;
|
||||
char *ptr;
|
||||
long len;
|
||||
} *str;
|
||||
|
@ -367,8 +376,8 @@ SyckNode *syck_alloc_seq();
|
|||
SyckNode *syck_alloc_str();
|
||||
void syck_free_node( SyckNode * );
|
||||
void syck_free_members( SyckNode * );
|
||||
SyckNode *syck_new_str( char * );
|
||||
SyckNode *syck_new_str2( char *, long );
|
||||
SyckNode *syck_new_str( char *, enum scalar_style );
|
||||
SyckNode *syck_new_str2( char *, long, enum scalar_style );
|
||||
void syck_str_blow_away_commas( SyckNode * );
|
||||
char *syck_str_read( SyckNode * );
|
||||
SyckNode *syck_new_map( SYMID, SYMID );
|
||||
|
|
132
ext/syck/token.c
132
ext/syck/token.c
|
@ -1,4 +1,4 @@
|
|||
/* Generated by re2c 0.5 on Tue Nov 25 12:10:28 2003 */
|
||||
/* Generated by re2c 0.5 on Thu May 13 01:45:26 2004 */
|
||||
#line 1 "token.re"
|
||||
/*
|
||||
* token.re
|
||||
|
@ -122,6 +122,7 @@
|
|||
YYCURSOR = YYTOKEN; \
|
||||
n->data.str->ptr = qstr; \
|
||||
n->data.str->len = qidx; \
|
||||
n->data.str->style = scalar_plain; \
|
||||
sycklval->nodeData = n; \
|
||||
if ( parser->implicit_typing == 1 ) \
|
||||
{ \
|
||||
|
@ -140,6 +141,7 @@
|
|||
n->type_id = syck_strndup( "str", 3 ); \
|
||||
n->data.str->ptr = qstr; \
|
||||
n->data.str->len = qidx; \
|
||||
n->data.str->style = scalar_block; \
|
||||
if ( qidx > 0 ) \
|
||||
{ \
|
||||
if ( nlDoWhat != NL_KEEP ) \
|
||||
|
@ -257,7 +259,7 @@ sycklex_yaml_utf8( YYSTYPE *sycklval, SyckParser *parser )
|
|||
return t;
|
||||
}
|
||||
|
||||
#line 276
|
||||
#line 278
|
||||
|
||||
|
||||
if ( YYLINEPTR != YYCURSOR )
|
||||
|
@ -294,7 +296,7 @@ yy2: yyaccept = 0;
|
|||
default: goto yy3;
|
||||
}
|
||||
yy3:
|
||||
#line 335
|
||||
#line 337
|
||||
{ YYPOS(0);
|
||||
goto Document;
|
||||
}
|
||||
|
@ -306,13 +308,13 @@ yy4: yyaccept = 0;
|
|||
}
|
||||
yy5: yych = *++YYCURSOR;
|
||||
yy6:
|
||||
#line 317
|
||||
#line 319
|
||||
{ eat_comments( parser );
|
||||
goto Header;
|
||||
}
|
||||
yy7: yych = *++YYCURSOR;
|
||||
yy8:
|
||||
#line 321
|
||||
#line 323
|
||||
{ SyckLevel *lvl = CURRENT_LEVEL();
|
||||
ENSURE_YAML_IEND(lvl, -1);
|
||||
YYPOS(0);
|
||||
|
@ -322,7 +324,7 @@ yy9: yyaccept = 1;
|
|||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
goto yy18;
|
||||
yy10:
|
||||
#line 327
|
||||
#line 329
|
||||
{ GOBBLE_UP_YAML_INDENT( doc_level, YYTOKEN );
|
||||
goto Header;
|
||||
}
|
||||
|
@ -334,7 +336,7 @@ yy11: yych = *++YYCURSOR;
|
|||
yy12: yych = *++YYCURSOR;
|
||||
goto yy16;
|
||||
yy13:
|
||||
#line 331
|
||||
#line 333
|
||||
{ doc_level = YYCURSOR - YYLINEPTR;
|
||||
goto Header;
|
||||
}
|
||||
|
@ -382,7 +384,7 @@ yy22: yych = *++YYCURSOR;
|
|||
}
|
||||
yy23: yych = *++YYCURSOR;
|
||||
yy24:
|
||||
#line 303
|
||||
#line 305
|
||||
{ SyckLevel *lvl = CURRENT_LEVEL();
|
||||
if ( lvl->status == syck_lvl_header )
|
||||
{
|
||||
|
@ -422,7 +424,7 @@ yy29: yych = *++YYCURSOR;
|
|||
}
|
||||
yy30: yych = *++YYCURSOR;
|
||||
yy31:
|
||||
#line 289
|
||||
#line 291
|
||||
{ SyckLevel *lvl = CURRENT_LEVEL();
|
||||
if ( lvl->status == syck_lvl_header )
|
||||
{
|
||||
|
@ -449,7 +451,7 @@ yy34: yych = *++YYCURSOR;
|
|||
default: goto yy20;
|
||||
}
|
||||
}
|
||||
#line 339
|
||||
#line 341
|
||||
|
||||
|
||||
Document:
|
||||
|
@ -492,7 +494,7 @@ yy37: yyaccept = 0;
|
|||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
goto yy90;
|
||||
yy38:
|
||||
#line 353
|
||||
#line 355
|
||||
{ /* Isolate spaces */
|
||||
int indt_len;
|
||||
GOBBLE_UP_YAML_INDENT( indt_len, YYTOKEN );
|
||||
|
@ -520,13 +522,13 @@ yy39: yych = *++YYCURSOR;
|
|||
default: goto yy40;
|
||||
}
|
||||
yy40:
|
||||
#line 445
|
||||
#line 447
|
||||
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
|
||||
goto Plain;
|
||||
}
|
||||
yy41: yych = *++YYCURSOR;
|
||||
yy42:
|
||||
#line 375
|
||||
#line 377
|
||||
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
|
||||
lvl = CURRENT_LEVEL();
|
||||
ADD_LEVEL(lvl->spaces + 1, syck_lvl_inline);
|
||||
|
@ -534,7 +536,7 @@ yy42:
|
|||
}
|
||||
yy43: yych = *++YYCURSOR;
|
||||
yy44:
|
||||
#line 381
|
||||
#line 383
|
||||
{ POP_LEVEL();
|
||||
return YYTOKEN[0];
|
||||
}
|
||||
|
@ -684,16 +686,16 @@ yy48: yych = *++YYCURSOR;
|
|||
}
|
||||
yy49: yych = *++YYCURSOR;
|
||||
yy50:
|
||||
#line 419
|
||||
#line 421
|
||||
{ goto TransferMethod; }
|
||||
yy51: yych = *++YYCURSOR;
|
||||
yy52:
|
||||
#line 421
|
||||
#line 423
|
||||
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
|
||||
goto SingleQuote; }
|
||||
yy53: yych = *++YYCURSOR;
|
||||
yy54:
|
||||
#line 424
|
||||
#line 426
|
||||
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
|
||||
goto DoubleQuote; }
|
||||
yy55: yyaccept = 1;
|
||||
|
@ -716,18 +718,18 @@ yy55: yyaccept = 1;
|
|||
}
|
||||
yy56: yych = *++YYCURSOR;
|
||||
yy57:
|
||||
#line 434
|
||||
#line 436
|
||||
{ eat_comments( parser );
|
||||
goto Document;
|
||||
}
|
||||
yy58: yych = *++YYCURSOR;
|
||||
goto yy64;
|
||||
yy59:
|
||||
#line 438
|
||||
#line 440
|
||||
{ goto Document; }
|
||||
yy60: yych = *++YYCURSOR;
|
||||
yy61:
|
||||
#line 440
|
||||
#line 442
|
||||
{ ENSURE_YAML_IEND(lvl, -1);
|
||||
YYPOS(0);
|
||||
return 0;
|
||||
|
@ -767,7 +769,7 @@ yy67: YYCURSOR = YYMARKER;
|
|||
}
|
||||
yy68: yych = *++YYCURSOR;
|
||||
yy69:
|
||||
#line 427
|
||||
#line 429
|
||||
{ if ( is_newline( YYCURSOR - 1 ) )
|
||||
{
|
||||
YYCURSOR--;
|
||||
|
@ -853,7 +855,7 @@ yy74: switch(yych){
|
|||
default: goto yy75;
|
||||
}
|
||||
yy75:
|
||||
#line 414
|
||||
#line 416
|
||||
{ ENSURE_YAML_IOPEN(lvl, doc_level, 1);
|
||||
sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
|
||||
return YAML_ALIAS;
|
||||
|
@ -925,7 +927,7 @@ yy77: switch(yych){
|
|||
default: goto yy78;
|
||||
}
|
||||
yy78:
|
||||
#line 403
|
||||
#line 405
|
||||
{ sycklval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 );
|
||||
|
||||
/*
|
||||
|
@ -938,7 +940,7 @@ yy78:
|
|||
}
|
||||
yy79: yych = *++YYCURSOR;
|
||||
yy80:
|
||||
#line 389
|
||||
#line 391
|
||||
{ ENSURE_YAML_IOPEN(lvl, YYTOKEN - YYLINEPTR, 1);
|
||||
FORCE_NEXT_TOKEN(YAML_IOPEN);
|
||||
if ( is_newline( YYCURSOR ) || is_newline( YYCURSOR - 1 ) )
|
||||
|
@ -966,7 +968,7 @@ yy83: yych = *++YYCURSOR;
|
|||
}
|
||||
yy84: yych = *++YYCURSOR;
|
||||
yy85:
|
||||
#line 385
|
||||
#line 387
|
||||
{ YYPOS(1);
|
||||
return YYTOKEN[0];
|
||||
}
|
||||
|
@ -999,7 +1001,7 @@ yy91: ++YYCURSOR;
|
|||
default: goto yy67;
|
||||
}
|
||||
}
|
||||
#line 449
|
||||
#line 451
|
||||
|
||||
}
|
||||
|
||||
|
@ -1106,14 +1108,14 @@ yy95: yyaccept = 0;
|
|||
default: goto yy96;
|
||||
}
|
||||
yy96:
|
||||
#line 462
|
||||
#line 464
|
||||
{ YYCURSOR = YYTOKTMP;
|
||||
return YAML_DOCSEP;
|
||||
}
|
||||
yy97: yych = *++YYCURSOR;
|
||||
goto yy101;
|
||||
yy98:
|
||||
#line 460
|
||||
#line 462
|
||||
{ goto Directive; }
|
||||
yy99: yych = *++YYCURSOR;
|
||||
goto yy96;
|
||||
|
@ -1365,10 +1367,10 @@ yy106: switch(yych){
|
|||
default: goto yy107;
|
||||
}
|
||||
yy107:
|
||||
#line 458
|
||||
#line 460
|
||||
{ goto Directive; }
|
||||
}
|
||||
#line 465
|
||||
#line 467
|
||||
|
||||
|
||||
}
|
||||
|
@ -1412,7 +1414,7 @@ yy110: yyaccept = 0;
|
|||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
goto yy136;
|
||||
yy111:
|
||||
#line 488
|
||||
#line 490
|
||||
{ int indt_len, nl_count = 0;
|
||||
SyckLevel *lvl;
|
||||
char *tok = YYTOKEN;
|
||||
|
@ -1450,7 +1452,7 @@ yy112: yych = *++YYCURSOR;
|
|||
default: goto yy113;
|
||||
}
|
||||
yy113:
|
||||
#line 542
|
||||
#line 544
|
||||
{ QUOTECATS(qstr, qcapa, qidx, YYTOKEN, YYCURSOR - YYTOKEN);
|
||||
goto Plain2;
|
||||
}
|
||||
|
@ -1464,7 +1466,7 @@ yy114: yyaccept = 1;
|
|||
}
|
||||
yy115: yych = *++YYCURSOR;
|
||||
yy116:
|
||||
#line 522
|
||||
#line 524
|
||||
{ if ( plvl->status != syck_lvl_inline )
|
||||
{
|
||||
if ( *(YYCURSOR - 1) == ' ' || is_newline( YYCURSOR - 1 ) )
|
||||
|
@ -1490,17 +1492,17 @@ yy118: yych = *++YYCURSOR;
|
|||
default: goto yy119;
|
||||
}
|
||||
yy119:
|
||||
#line 540
|
||||
#line 542
|
||||
{ goto Plain3; }
|
||||
yy120: yych = *++YYCURSOR;
|
||||
yy121:
|
||||
#line 538
|
||||
#line 540
|
||||
{ RETURN_IMPLICIT(); }
|
||||
yy122: yych = *++YYCURSOR;
|
||||
goto yy113;
|
||||
yy123: yych = *++YYCURSOR;
|
||||
yy124:
|
||||
#line 534
|
||||
#line 536
|
||||
{ eat_comments( parser );
|
||||
RETURN_IMPLICIT();
|
||||
}
|
||||
|
@ -1525,7 +1527,7 @@ yy129: YYCURSOR = YYMARKER;
|
|||
}
|
||||
yy130: yych = *++YYCURSOR;
|
||||
yy131:
|
||||
#line 520
|
||||
#line 522
|
||||
{ RETURN_IMPLICIT(); }
|
||||
yy132: ++YYCURSOR;
|
||||
if(YYLIMIT == YYCURSOR) YYFILL(1);
|
||||
|
@ -1556,7 +1558,7 @@ yy137: ++YYCURSOR;
|
|||
default: goto yy129;
|
||||
}
|
||||
}
|
||||
#line 546
|
||||
#line 548
|
||||
|
||||
}
|
||||
|
||||
|
@ -1588,7 +1590,7 @@ yy140: yyaccept = 0;
|
|||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
goto yy151;
|
||||
yy141:
|
||||
#line 560
|
||||
#line 562
|
||||
{ int indt_len;
|
||||
int nl_count = 0;
|
||||
SyckLevel *lvl;
|
||||
|
@ -1630,7 +1632,7 @@ yy142: yych = *++YYCURSOR;
|
|||
default: goto yy143;
|
||||
}
|
||||
yy143:
|
||||
#line 615
|
||||
#line 618
|
||||
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
|
||||
goto SingleQuote2;
|
||||
}
|
||||
|
@ -1640,7 +1642,7 @@ yy144: yych = *++YYCURSOR;
|
|||
default: goto yy145;
|
||||
}
|
||||
yy145:
|
||||
#line 600
|
||||
#line 602
|
||||
{ SyckLevel *lvl;
|
||||
SyckNode *n = syck_alloc_str();
|
||||
lvl = CURRENT_LEVEL();
|
||||
|
@ -1652,6 +1654,7 @@ yy145:
|
|||
n->type_id = syck_strndup( "str", 3 );
|
||||
n->data.str->ptr = qstr;
|
||||
n->data.str->len = qidx;
|
||||
n->data.str->style = scalar_1quote;
|
||||
sycklval->nodeData = n;
|
||||
return YAML_PLAIN;
|
||||
}
|
||||
|
@ -1661,7 +1664,7 @@ yy147: yych = *++YYCURSOR;
|
|||
goto yy143;
|
||||
yy148: yych = *++YYCURSOR;
|
||||
yy149:
|
||||
#line 596
|
||||
#line 598
|
||||
{ QUOTECAT(qstr, qcapa, qidx, '\'');
|
||||
goto SingleQuote2;
|
||||
}
|
||||
|
@ -1686,7 +1689,7 @@ yy153: YYCURSOR = YYMARKER;
|
|||
case 0: goto yy141;
|
||||
}
|
||||
}
|
||||
#line 619
|
||||
#line 622
|
||||
|
||||
|
||||
}
|
||||
|
@ -1723,7 +1726,7 @@ yy156: yyaccept = 0;
|
|||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
goto yy178;
|
||||
yy157:
|
||||
#line 637
|
||||
#line 640
|
||||
{ int indt_len;
|
||||
int nl_count = 0;
|
||||
SyckLevel *lvl;
|
||||
|
@ -1769,7 +1772,7 @@ yy158: yych = *++YYCURSOR;
|
|||
default: goto yy159;
|
||||
}
|
||||
yy159:
|
||||
#line 711
|
||||
#line 715
|
||||
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
|
||||
goto DoubleQuote2;
|
||||
}
|
||||
|
@ -1787,7 +1790,7 @@ yy160: yyaccept = 1;
|
|||
}
|
||||
yy161: yych = *++YYCURSOR;
|
||||
yy162:
|
||||
#line 696
|
||||
#line 699
|
||||
{ SyckLevel *lvl;
|
||||
SyckNode *n = syck_alloc_str();
|
||||
lvl = CURRENT_LEVEL();
|
||||
|
@ -1799,6 +1802,7 @@ yy162:
|
|||
n->type_id = syck_strndup( "str", 3 );
|
||||
n->data.str->ptr = qstr;
|
||||
n->data.str->len = qidx;
|
||||
n->data.str->style = scalar_2quote;
|
||||
sycklval->nodeData = n;
|
||||
return YAML_PLAIN;
|
||||
}
|
||||
|
@ -1822,7 +1826,7 @@ yy167: YYCURSOR = YYMARKER;
|
|||
}
|
||||
yy168: yych = *++YYCURSOR;
|
||||
yy169:
|
||||
#line 691
|
||||
#line 694
|
||||
{ keep_nl = 0;
|
||||
YYCURSOR--;
|
||||
goto DoubleQuote2;
|
||||
|
@ -1858,7 +1862,7 @@ yy171: yych = *++YYCURSOR;
|
|||
}
|
||||
yy172: yych = *++YYCURSOR;
|
||||
yy173:
|
||||
#line 677
|
||||
#line 680
|
||||
{ char ch = *( YYCURSOR - 1 );
|
||||
QUOTECAT(qstr, qcapa, qidx, escape_seq( ch ));
|
||||
goto DoubleQuote2;
|
||||
|
@ -1889,7 +1893,7 @@ yy174: yych = *++YYCURSOR;
|
|||
}
|
||||
yy175: yych = *++YYCURSOR;
|
||||
yy176:
|
||||
#line 682
|
||||
#line 685
|
||||
{ long ch;
|
||||
char *chr_text = syck_strndup( YYTOKEN, 4 );
|
||||
chr_text[0] = '0';
|
||||
|
@ -1915,7 +1919,7 @@ yy179: ++YYCURSOR;
|
|||
default: goto yy167;
|
||||
}
|
||||
}
|
||||
#line 715
|
||||
#line 719
|
||||
|
||||
}
|
||||
|
||||
|
@ -1950,7 +1954,7 @@ yy182: YYCURSOR = YYMARKER;
|
|||
}
|
||||
yy183: yych = *++YYCURSOR;
|
||||
yy184:
|
||||
#line 729
|
||||
#line 733
|
||||
{ SyckLevel *lvl;
|
||||
YYCURSOR = YYTOKTMP;
|
||||
if ( YYCURSOR == YYTOKEN + 1 )
|
||||
|
@ -2008,7 +2012,7 @@ yy186: yych = *++YYCURSOR;
|
|||
default: goto yy187;
|
||||
}
|
||||
yy187:
|
||||
#line 796
|
||||
#line 800
|
||||
{ QUOTECAT(qstr, qcapa, qidx, *(YYCURSOR - 1));
|
||||
goto TransferMethod2;
|
||||
}
|
||||
|
@ -2049,7 +2053,7 @@ yy190: yych = *++YYCURSOR;
|
|||
}
|
||||
yy191: yych = *++YYCURSOR;
|
||||
yy192:
|
||||
#line 782
|
||||
#line 786
|
||||
{ char ch = *( YYCURSOR - 1 );
|
||||
QUOTECAT(qstr, qcapa, qidx, escape_seq( ch ));
|
||||
goto TransferMethod2;
|
||||
|
@ -2080,7 +2084,7 @@ yy193: yych = *++YYCURSOR;
|
|||
}
|
||||
yy194: yych = *++YYCURSOR;
|
||||
yy195:
|
||||
#line 787
|
||||
#line 791
|
||||
{ long ch;
|
||||
char *chr_text = syck_strndup( YYTOKTMP, 4 );
|
||||
chr_text[0] = '0';
|
||||
|
@ -2099,7 +2103,7 @@ yy198: switch(yych){
|
|||
default: goto yy184;
|
||||
}
|
||||
}
|
||||
#line 801
|
||||
#line 805
|
||||
|
||||
}
|
||||
|
||||
|
@ -2165,7 +2169,7 @@ yy201: yyaccept = 0;
|
|||
yych = *(YYMARKER = ++YYCURSOR);
|
||||
goto yy220;
|
||||
yy202:
|
||||
#line 848
|
||||
#line 852
|
||||
{ char *pacer;
|
||||
char *tok = YYTOKEN;
|
||||
int indt_len = 0, nl_count = 0, fold_nl = 0, nl_begin = 0;
|
||||
|
@ -2237,13 +2241,13 @@ yy203: yych = *++YYCURSOR;
|
|||
default: goto yy204;
|
||||
}
|
||||
yy204:
|
||||
#line 953
|
||||
#line 957
|
||||
{ QUOTECAT(qstr, qcapa, qidx, *YYTOKEN);
|
||||
goto ScalarBlock2;
|
||||
}
|
||||
yy205: yych = *++YYCURSOR;
|
||||
yy206:
|
||||
#line 915
|
||||
#line 919
|
||||
{ lvl = CURRENT_LEVEL();
|
||||
if ( lvl->status != syck_lvl_block )
|
||||
{
|
||||
|
@ -2258,7 +2262,7 @@ yy206:
|
|||
}
|
||||
yy207: yych = *++YYCURSOR;
|
||||
yy208:
|
||||
#line 929
|
||||
#line 933
|
||||
{ YYCURSOR--;
|
||||
POP_LEVEL();
|
||||
RETURN_YAML_BLOCK();
|
||||
|
@ -2290,7 +2294,7 @@ yy213: yych = *++YYCURSOR;
|
|||
}
|
||||
yy214: yych = *++YYCURSOR;
|
||||
yy215:
|
||||
#line 934
|
||||
#line 938
|
||||
{ if ( YYTOKEN == YYLINEPTR )
|
||||
{
|
||||
if ( blockType == BLOCK_FOLD )
|
||||
|
@ -2338,7 +2342,7 @@ yy221: ++YYCURSOR;
|
|||
default: goto yy212;
|
||||
}
|
||||
}
|
||||
#line 958
|
||||
#line 962
|
||||
|
||||
}
|
||||
|
||||
|
@ -2369,7 +2373,7 @@ yy222:
|
|||
}
|
||||
yy224: yych = *++YYCURSOR;
|
||||
yy225:
|
||||
#line 974
|
||||
#line 978
|
||||
{ YYCURSOR = YYTOKEN;
|
||||
return;
|
||||
}
|
||||
|
@ -2382,7 +2386,7 @@ yy227: yych = *++YYCURSOR;
|
|||
default: goto yy228;
|
||||
}
|
||||
yy228:
|
||||
#line 978
|
||||
#line 982
|
||||
{ goto Comment;
|
||||
}
|
||||
yy229: yych = *++YYCURSOR;
|
||||
|
@ -2408,7 +2412,7 @@ yy233: YYCURSOR = YYMARKER;
|
|||
case 0: goto yy225;
|
||||
}
|
||||
}
|
||||
#line 981
|
||||
#line 985
|
||||
|
||||
|
||||
}
|
||||
|
|
21
lib/yaml.rb
21
lib/yaml.rb
|
@ -5,21 +5,12 @@
|
|||
#
|
||||
# Loads the parser/loader and emitter/writer.
|
||||
#
|
||||
|
||||
module YAML
|
||||
|
||||
begin
|
||||
require 'yaml/syck'
|
||||
@@parser = YAML::Syck::Parser
|
||||
@@loader = YAML::Syck::DefaultLoader
|
||||
@@emitter = YAML::Syck::Emitter
|
||||
rescue LoadError
|
||||
require 'yaml/parser'
|
||||
@@parser = YAML::Parser
|
||||
@@loader = YAML::DefaultLoader
|
||||
require 'yaml/emitter'
|
||||
@@emitter = YAML::Emitter
|
||||
end
|
||||
require 'yaml/loader'
|
||||
require 'yaml/stream'
|
||||
|
||||
|
@ -148,7 +139,7 @@ module YAML
|
|||
end
|
||||
|
||||
#
|
||||
# Method to extract colon-separated type and class, returning
|
||||
# Method to extract colon-seperated type and class, returning
|
||||
# the type and the constant of the class
|
||||
#
|
||||
def YAML.read_type_class( type, obj_class )
|
||||
|
@ -160,20 +151,12 @@ module YAML
|
|||
#
|
||||
# Allocate blank object
|
||||
#
|
||||
def YAML.object_maker( obj_class, val, is_attr = false )
|
||||
def YAML.object_maker( obj_class, val )
|
||||
if Hash === val
|
||||
# name = obj_class.name
|
||||
# ostr = sprintf( "%c%co:%c%s\000", ::Marshal::MAJOR_VERSION, ::Marshal::MINOR_VERSION,
|
||||
# name.length + 5, name )
|
||||
# if is_attr
|
||||
# ostr[ -1, 1 ] = ::Marshal.dump( val ).sub( /^[^{]+\{/, '' )
|
||||
# end
|
||||
o = obj_class.allocate
|
||||
unless is_attr
|
||||
val.each_pair { |k,v|
|
||||
o.instance_variable_set("@#{k}", v)
|
||||
}
|
||||
end
|
||||
o
|
||||
else
|
||||
raise YAML::Error, "Invalid object explicitly tagged !ruby/Object: " + val.inspect
|
||||
|
|
|
@ -45,6 +45,9 @@ module YAML
|
|||
else
|
||||
'>'
|
||||
end
|
||||
if valx =~ /\A[ \t#]/
|
||||
block += options(:Indent).to_s
|
||||
end
|
||||
block +=
|
||||
if valx =~ /\n\Z\n/
|
||||
"+"
|
||||
|
@ -53,9 +56,6 @@ module YAML
|
|||
else
|
||||
"-"
|
||||
end
|
||||
if valx =~ /\A[ \t#]/
|
||||
block += options(:Indent).to_s
|
||||
end
|
||||
end
|
||||
if valx =~ /#{YAML::ESCAPE_CHAR}/
|
||||
valx = YAML::escape( valx )
|
||||
|
@ -95,16 +95,23 @@ module YAML
|
|||
#
|
||||
def indent_text( text, indt = nil )
|
||||
return "" if text.to_s.empty?
|
||||
spacing = " " * ( level * ( indt || options(:Indent) ) )
|
||||
indt ||= 0
|
||||
spacing = indent( indt )
|
||||
return "\n" + text.gsub( /^([^\n])/, "#{spacing}\\1" )
|
||||
end
|
||||
|
||||
#
|
||||
# Write a current indent
|
||||
#
|
||||
def indent
|
||||
def indent( mod = nil )
|
||||
#p [ self.id, @level, :INDENT ]
|
||||
return " " * ( level * options(:Indent) )
|
||||
if level.zero?
|
||||
mod ||= 0
|
||||
else
|
||||
mod ||= options(:Indent)
|
||||
mod += ( level - 1 ) * options(:Indent)
|
||||
end
|
||||
return " " * mod
|
||||
end
|
||||
|
||||
#
|
||||
|
|
|
@ -290,7 +290,7 @@ class String
|
|||
( self.count( "^ -~", "^\r\n" ) / self.size > 0.3 || self.count( "\x00" ) > 0 )
|
||||
end
|
||||
def to_yaml_type
|
||||
"!ruby/string#{ if self.class != ::String; ":#{ self.class }"; end }"
|
||||
"!ruby/string#{ ":#{ self.class }" if self.class != ::String }"
|
||||
end
|
||||
def to_yaml_fold
|
||||
nil
|
||||
|
@ -315,8 +315,8 @@ class String
|
|||
}
|
||||
elsif self.is_binary_data?
|
||||
out.binary_base64( self )
|
||||
elsif self =~ /^ |#{YAML::ESCAPE_CHAR}| $/
|
||||
complex = false
|
||||
# elsif self =~ /^ |#{YAML::ESCAPE_CHAR}| $/
|
||||
# complex = false
|
||||
else
|
||||
out.node_text( self, to_yaml_fold )
|
||||
end
|
||||
|
@ -326,7 +326,7 @@ class String
|
|||
self
|
||||
elsif empty?
|
||||
"''"
|
||||
elsif self =~ /^[^#{YAML::WORD_CHAR}]| \#|#{YAML::ESCAPE_CHAR}|[#{YAML::SPACE_INDICATORS}]( |$)| $|\n|\'/
|
||||
elsif self =~ /^[^#{YAML::WORD_CHAR}\/]| \#|#{YAML::ESCAPE_CHAR}|[#{YAML::SPACE_INDICATORS}]( |$)| $|\n|\'/
|
||||
"\"#{YAML.escape( self )}\""
|
||||
elsif YAML.detect_implicit( self ) != 'str'
|
||||
"\"#{YAML.escape( self )}\""
|
||||
|
|
|
@ -1045,8 +1045,8 @@ EOY
|
|||
assert_parse_only(
|
||||
[ /bozo$/i ], <<EOY
|
||||
- !perl/regexp:
|
||||
REGEXP: bozo$
|
||||
MODIFIERS: i
|
||||
regexp: bozo$
|
||||
mods: i
|
||||
EOY
|
||||
)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue