Skip to content

Commit

Permalink
* ext/syck/token.c: directives choked on a period.
Browse files Browse the repository at this point in the history
* ext/syck/gram.y: anchors work above a collection. [ruby-core:1071]

* ext/syck/handler.c, ext/syck/syck.c: ensure a fresh strtable between
  parser iterations.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
why committed Jun 5, 2003
1 parent 45c7ea5 commit 017d4ff
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 193 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
@@ -1,3 +1,12 @@
Thu Jun 5 04:48:57 2003 why the lucky stiff <ruby-cvs@whytheluckystiff.net>

* ext/syck/token.c: directives choked on a period.

* ext/syck/gram.y: anchors work above a collection. [ruby-core:1071]

* ext/syck/handler.c, ext/syck/syck.c: ensure a fresh strtable between
parser iterations.

Tue Jun 3 22:20:49 2003 Yukihiro Matsumoto <matz@ruby-lang.org>

* eval.c (rb_call_super): should search superclass method based on
Expand Down
261 changes: 151 additions & 110 deletions ext/syck/gram.c

Large diffs are not rendered by default.

11 changes: 9 additions & 2 deletions ext/syck/handler.c
Expand Up @@ -31,6 +31,10 @@ SyckNode *
syck_hdlr_add_anchor( SyckParser *p, char *a, SyckNode *n )
{
n->anchor = a;
if ( p->anchors == NULL )
{
p->anchors = st_init_strtable();
}
st_insert( p->anchors, (st_data_t)a, (st_data_t)n );
return n;
}
Expand All @@ -40,9 +44,12 @@ syck_hdlr_add_alias( SyckParser *p, char *a )
{
SyckNode *n;

if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&n ) )
if ( p->anchors != NULL )
{
return n;
if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&n ) )
{
return n;
}
}

//
Expand Down
1 change: 0 additions & 1 deletion ext/syck/node.c
Expand Up @@ -192,7 +192,6 @@ syck_map_update( SyckNode *map1, SyckNode *map2 )
S_REALLOC_N( m1->keys, SYMID, m1->capa );
S_REALLOC_N( m1->values, SYMID, m1->capa );
}
new_idx = 0;
for ( new_idx = 0; new_idx < m2->idx; m1->idx++, new_idx++ )
{
m1->keys[m1->idx] = m2->keys[new_idx];
Expand Down
10 changes: 9 additions & 1 deletion ext/syck/rubyext.c
Expand Up @@ -438,6 +438,14 @@ rb_syck_ensure(parser)
return 0;
}

static void
syck_mark_parser(parser)
SyckParser *parser;
{
rb_gc_mark(parser->root);
rb_gc_mark(parser->root_on_error);
}

/*
* YAML::Syck::Parser.new
*/
Expand All @@ -451,7 +459,7 @@ syck_parser_new(argc, argv, class)
SyckParser *parser = syck_new_parser();

rb_scan_args(argc, argv, "01", &options);
pobj = Data_Wrap_Struct( class, 0, syck_free_parser, parser );
pobj = Data_Wrap_Struct( class, syck_mark_parser, syck_free_parser, parser );

syck_parser_set_root_on_error( parser, Qnil );

Expand Down
27 changes: 19 additions & 8 deletions ext/syck/syck.c
Expand Up @@ -169,7 +169,7 @@ syck_new_parser()
p->io_type = syck_io_str;
p->io.str = NULL;
p->syms = NULL;
p->anchors = st_init_strtable();
p->anchors = NULL;
p->implicit_typing = 1;
p->taguri_expansion = 0;
p->bufsize = SYCK_BUFFERSIZE;
Expand Down Expand Up @@ -207,28 +207,38 @@ syck_st_free_nodes( char *key, SyckNode *n, char *arg )
}

void
syck_free_parser( SyckParser *p )
syck_st_free( SyckParser *p )
{
char *key;
SyckNode *node;

//
// Free the adhoc symbol table
//
if ( p->syms != NULL )
{
st_free_table( p->syms );
p->syms = NULL;
}

//
// Free the anchor table
//
st_foreach( p->anchors, syck_st_free_nodes, 0 );
st_free_table( p->anchors );
if ( p->anchors != NULL )
{
st_foreach( p->anchors, syck_st_free_nodes, 0 );
st_free_table( p->anchors );
p->anchors = NULL;
}
}

void
syck_free_parser( SyckParser *p )
{
char *key;
SyckNode *node;

//
// Free all else
// Free tables, levels
//
syck_st_free( p );
syck_parser_reset_levels( p );
S_FREE( p->levels[0].domain );
S_FREE( p->levels );
Expand Down Expand Up @@ -467,6 +477,7 @@ syck_parse( SyckParser *p )

ASSERT( p != NULL );

syck_st_free( p );
syck_parser_reset_levels( p );
yyparse( p );
return p->root;
Expand Down

0 comments on commit 017d4ff

Please sign in to comment.