aboutsummaryrefslogtreecommitdiffstats
path: root/ext/syck/handler.c
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-29 23:33:10 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-29 23:33:10 +0000
commit5d47fda3f8b7148087a866cfd3033ab185e492fd (patch)
tree26a0794e612989e8f2f8a02e69a1d651702c8d12 /ext/syck/handler.c
parent4ca5e66ee793f0c8b7f96d4f82d813c8f98a26be (diff)
downloadruby-5d47fda3f8b7148087a866cfd3033ab185e492fd.tar.gz
* ext/syck/handler.c, ext/syck/syck.h: removed syck_fold_format().
* ext/syck/gram.c: flexibility for aliases and anchors. * ext/syck/token.c: folding now handled in the tokenizer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/handler.c')
-rw-r--r--ext/syck/handler.c101
1 files changed, 4 insertions, 97 deletions
diff --git a/ext/syck/handler.c b/ext/syck/handler.c
index 0a03596a56..f2e387a925 100644
--- a/ext/syck/handler.c
+++ b/ext/syck/handler.c
@@ -13,6 +13,7 @@ SYMID
syck_hdlr_add_node( SyckParser *p, SyckNode *n )
{
SYMID id;
+
if ( ! n->id )
{
n->id = (p->handler)( p, n );
@@ -44,6 +45,9 @@ syck_hdlr_add_alias( SyckParser *p, char *a )
return n;
}
+ //
+ // FIXME: Return an InvalidAnchor object
+ //
return syck_new_str( "..." );
}
@@ -97,100 +101,3 @@ syck_try_implicit( SyckNode *n )
return 1;
}
-void
-syck_fold_format( struct SyckStr *n, int blockType, int indt_len, int nlDisp )
-{
- char *spc;
- char *eol = NULL;
- char *first_nl = NULL;
- char *fc = n->ptr;
- int keep_nl = 0;
- int nl_count = 0;
-
- //
- // Scan the sucker for newlines and strip indent
- //
- while ( fc < n->ptr + n->len )
- {
- if ( *fc == '\n' )
- {
- spc = fc;
- while ( *(++spc) == ' ' )
- {
- if ( blockType != BLOCK_PLAIN && spc - fc > indt_len )
- break;
- }
-
- if ( blockType != BLOCK_LIT && *spc != ' ' )
- {
- if ( eol != NULL ) fc = eol;
- if ( first_nl == NULL && keep_nl == 1 )
- {
- first_nl = fc;
- *first_nl = ' ';
- }
- if ( nl_count == 1 )
- {
- *first_nl = '\n';
- keep_nl = 0;
- }
- }
-
- fc += keep_nl;
- if ( fc != spc && ( n->len - ( spc - n->ptr ) ) > 0 )
- {
- S_MEMMOVE( fc, spc, char, n->len - ( spc - n->ptr ) );
- }
-
- n->len -= spc - fc;
- keep_nl = 1;
- eol = NULL;
- nl_count++;
- }
- else
- {
- //
- // eol tracks the last space on a line
- //
- if ( *fc == ' ' )
- {
- if ( eol == NULL ) eol = fc;
- }
- else
- {
- eol = NULL;
- }
- first_nl = NULL;
- nl_count = 0;
- fc++;
- }
- }
-
- n->ptr[n->len] = '\n';
-
- //
- // Chomp or keep?
- //
- if ( nlDisp != NL_KEEP )
- {
- fc = n->ptr + n->len - 1;
- while ( *fc == '\n' )
- fc--;
-
- if ( nlDisp != NL_CHOMP )
- fc += 1;
-
- n->len = fc - n->ptr + 1;
- }
- else
- {
- //
- // Force last line break which I gave back
- // to the tokenizer.
- //
- n->len++;
- n->ptr[n->len] = '\n';
- }
- n->ptr[ n->len ] = '\0';
-}
-