summaryrefslogtreecommitdiff
path: root/ext/syck/handler.c
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-10 19:55:18 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-10 19:55:18 +0000
commit4b25d0d2cb5e47907c3586ba86646b25bd25ceaf (patch)
treedb80e493d079350f0123f8fa9783684a5d66b685 /ext/syck/handler.c
parentb2bb895aab7422fd95ce883be5b19d2f82981da5 (diff)
* ext/syck/gram.c ext/syck/handler.c ext/syck/implicit.c
ext/syck/node.c ext/syck/rubyext.c ext/syck/syck.c ext/syck/syck.h ext/syck/token.c: updated to Syck 0.27 * lib/yaml/loader.rb: new YAML::Loader class * lib/yaml.rb: loading of type families leverages YAML::DefaultLoader git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/handler.c')
-rw-r--r--ext/syck/handler.c81
1 files changed, 23 insertions, 58 deletions
diff --git a/ext/syck/handler.c b/ext/syck/handler.c
index 50ba3e42324..c54ee0408e9 100644
--- a/ext/syck/handler.c
+++ b/ext/syck/handler.c
@@ -30,7 +30,7 @@ SyckNode *
syck_hdlr_add_anchor( SyckParser *p, char *a, SyckNode *n )
{
n->anchor = a;
- st_insert( p->anchors, (st_data_t)a, (st_data_t)n );
+ st_insert( p->anchors, a, n );
return n;
}
@@ -39,7 +39,7 @@ syck_hdlr_add_alias( SyckParser *p, char *a )
{
SyckNode *n;
- if ( st_lookup( p->anchors, (st_data_t)a, (st_data_t *)&n ) )
+ if ( st_lookup( p->anchors, a, &n ) )
{
return n;
}
@@ -54,76 +54,41 @@ syck_add_transfer( char *uri, SyckNode *n, int taguri )
char *slash = uri;
char *domain = NULL;
- if ( taguri == 0 )
+ if ( n->type_id != NULL )
{
- n->type_id = uri;
- return;
+ S_FREE( n->type_id );
}
- if ( uri[0] == '!' )
+ if ( taguri == 0 )
{
- syck_xprivate( n, uri + 1, strlen( uri ) - 1 );
- S_FREE( uri );
+ n->type_id = uri;
return;
}
- while ( *(++slash) != '\0' )
- {
- if ( *slash == '/' )
- break;
-
- if ( *slash == ',' )
- comma = slash;
- }
-
- if ( *slash == '\0' )
- {
- syck_taguri( n, "yaml.org,2002", uri, strlen( uri ) );
- }
- else if ( comma == NULL )
- {
- domain = S_ALLOC_N( char, ( slash - uri ) + 15 );
- domain[0] = '\0';
- strncat( domain, uri, slash - uri );
- strcat( domain, ".yaml.org,2002" );
- syck_taguri( n, domain, slash + 1, strlen( uri ) - ( slash - uri + 1 ) );
- S_FREE( domain );
- }
- else
- {
- domain = S_ALLOC_N( char, slash - uri );
- domain[0] = '\0';
- strncat( domain, uri, slash - uri );
- syck_taguri( n, domain, slash + 1, strlen( uri ) - ( slash - uri + 1 ) );
- S_FREE( domain );
- }
+ n->type_id = syck_type_id_to_uri( uri );
S_FREE( uri );
}
-void
-syck_xprivate( SyckNode *n, char *type_id, int type_len )
+char *
+syck_xprivate( char *type_id, int type_len )
{
- if ( n->type_id != NULL )
- S_FREE( n->type_id );
-
- n->type_id = S_ALLOC_N( char, type_len + 14 );
- n->type_id[0] = '\0';
- strcat( n->type_id, "x-private:" );
- strncat( n->type_id, type_id, type_len );
+ char *uri = S_ALLOC_N( char, type_len + 14 );
+ uri[0] = '\0';
+ strcat( uri, "x-private:" );
+ strncat( uri, type_id, type_len );
+ return uri;
}
-void
-syck_taguri( SyckNode *n, char *domain, char *type_id, int type_len )
+char *
+syck_taguri( char *domain, char *type_id, int type_len )
{
- if ( n->type_id != NULL )
- S_FREE( n->type_id );
-
- n->type_id = S_ALLOC_N( char, strlen( domain ) + type_len + 14 );
- n->type_id[0] = '\0';
- strcat( n->type_id, "taguri:" );
- strcat( n->type_id, domain );
- strcat( n->type_id, ":" );
- strncat( n->type_id, type_id, type_len );
+ char *uri = S_ALLOC_N( char, strlen( domain ) + type_len + 14 );
+ uri[0] = '\0';
+ strcat( uri, "taguri:" );
+ strcat( uri, domain );
+ strcat( uri, ":" );
+ strncat( uri, type_id, type_len );
+ return uri;
}
int