summaryrefslogtreecommitdiff
path: root/ext/syck/syck.c
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-11 22:52:14 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-11 22:52:14 +0000
commita1e257ec48911d3ca1aaeda0127061c244f36147 (patch)
treeb77a31d1f26f6f313ee33af850fc539a6e149f39 /ext/syck/syck.c
parent30399f6c758c85ac9794d4298ee2b51426a144bc (diff)
* ext/syck/emitter.c: new emitter code.
* ext/syck/rubyext.c: Emitter class. * lib/yaml.rb: Load Syck emitter, if available. * lib/yaml/stream.rb: ditto. * lib/yaml/baseemitter.rb: underlying class for all emitters. * lib/yaml/rubytypes.rb: use BaseEmitter abstraction. * lib/yaml/emitter.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/syck.c')
-rw-r--r--ext/syck/syck.c37
1 files changed, 13 insertions, 24 deletions
diff --git a/ext/syck/syck.c b/ext/syck/syck.c
index a7955b448b9..4b7be32a180 100644
--- a/ext/syck/syck.c
+++ b/ext/syck/syck.c
@@ -11,10 +11,6 @@
#include "syck.h"
-#define SYCK_YAML_MAJOR 1
-#define SYCK_YAML_MINOR 0
-#define SYCK_BUFFERSIZE 262144
-
void syck_parser_pop_level( SyckParser * );
/*
@@ -30,6 +26,9 @@ syck_assert( char *file_name, unsigned line_num )
abort();
}
+/*
+ * Allocates and copies a string
+ */
char *
syck_strndup( char *buf, long len )
{
@@ -40,7 +39,7 @@ syck_strndup( char *buf, long len )
}
/*
- * Default IO functions
+ * Default FILE IO function
*/
long
syck_io_file_read( char *buf, SyckIoFile *file, long max_size, long skip )
@@ -52,18 +51,15 @@ syck_io_file_read( char *buf, SyckIoFile *file, long max_size, long skip )
max_size -= skip;
len = fread( buf + skip, max_size, sizeof( char ), file->ptr );
-#if REDEBUG
- printf( "LEN: %d\n", len );
-#endif
len += skip;
buf[len] = '\0';
-#if REDEBUG
- printf( "POS: %d\n", len );
- printf( "BUFFER: %s\n", buf );
-#endif
+
return len;
}
+/*
+ * Default string IO function
+ */
long
syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
{
@@ -95,15 +91,9 @@ syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip )
len = str->ptr - beg;
S_MEMCPY( buf + skip, beg, char, len );
}
-#if REDEBUG
- printf( "LEN: %d\n", len );
-#endif
len += skip;
buf[len] = '\0';
-#if REDEBUG
- printf( "POS: %d\n", len );
- printf( "BUFFER: %s\n", buf );
-#endif
+
return len;
}
@@ -150,6 +140,9 @@ syck_parser_reset_cursor( SyckParser *p )
p->force_token = 0;
}
+/*
+ * Value to return on a parse error
+ */
void
syck_parser_set_root_on_error( SyckParser *p, SYMID roer )
{
@@ -212,7 +205,7 @@ syck_st_free( SyckParser *p )
{
/*
* Free the adhoc symbol table
- */
+ */
if ( p->syms != NULL )
{
st_free_table( p->syms );
@@ -410,10 +403,6 @@ syck_move_tokens( SyckParser *p )
if ( skip < 1 )
return 0;
-#if REDEBUG
- printf( "DIFF: %d\n", skip );
-#endif
-
if ( ( count = p->token - p->buffer ) )
{
S_MEMMOVE( p->buffer, p->token, char, skip );