summaryrefslogtreecommitdiff
path: root/ext/syck/syck.c
diff options
context:
space:
mode:
authorwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-13 06:34:18 +0000
committerwhy <why@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-05-13 06:34:18 +0000
commitbd810795c589a81e8939b53ad921f823e7133ee9 (patch)
tree5c96a98d2d411fd2f8324791db1977423fc1e14c /ext/syck/syck.c
parentcea30a129ac3e25d1f45947b346788aeff8ee4d6 (diff)
* lib/yaml/rubytypes.rb: object and struct loading
* lib/yaml.rb: YAML::detect_implicit will discover typing for a Ruby string * ext/syck/: Fixed portable comments, misuse of NULL and methods without return VALUEs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/syck.c')
-rw-r--r--ext/syck/syck.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/ext/syck/syck.c b/ext/syck/syck.c
index 8e163516927..180d40ba185 100644
--- a/ext/syck/syck.c
+++ b/ext/syck/syck.c
@@ -1,11 +1,11 @@
-//
-// syck.c
-//
-// $Author$
-// $Date$
-//
-// Copyright (C) 2003 why the lucky stiff
-//
+/*
+ * syck.c
+ *
+ * $Author$
+ * $Date$
+ *
+ * Copyright (C) 2003 why the lucky stiff
+ */
#include <stdio.h>
#include <string.h>
@@ -15,9 +15,9 @@
#define SYCK_YAML_MINOR 0
#define SYCK_BUFFERSIZE 262144
-//
-// Custom assert
-//
+/*
+ * Custom assert
+ */
void
syck_assert( char *file_name, unsigned line_num )
{
@@ -36,9 +36,9 @@ syck_strndup( char *buf, long len )
S_MEMCPY( new, buf, char, len );
}
-//
-// Default IO functions
-//
+/*
+ * Default IO functions
+ */
long
syck_io_file_read( char *buf, SyckIoFile *file, long max_size, long skip )
{
@@ -109,7 +109,7 @@ syck_parser_reset_levels( SyckParser *p )
{
p->lvl_idx = 1;
p->levels[0].spaces = -1;
- p->levels[0].domain = ""; // YAML_DOMAIN + "/";
+ p->levels[0].domain = syck_strndup( "", 1 ); // YAML_DOMAIN + "/";
p->levels[0].status = syck_lvl_header;
}
@@ -135,9 +135,9 @@ syck_parser_reset_cursor( SyckParser *p )
p->force_token = 0;
}
-//
-// Allocate the parser
-//
+/*
+ * Allocate the parser
+ */
SyckParser *
syck_new_parser()
{
@@ -303,10 +303,7 @@ syck_parser_pop_level( SyckParser *p )
if ( p->lvl_idx <= 1 ) return;
p->lvl_idx -= 1;
- if ( p->levels[p->lvl_idx - 1].domain != p->levels[p->lvl_idx].domain )
- {
- free( p->levels[p->lvl_idx].domain );
- }
+ free( p->levels[p->lvl_idx].domain );
}
void
@@ -321,7 +318,7 @@ syck_parser_add_level( SyckParser *p, int len, enum syck_level_status status )
ASSERT( len > p->levels[p->lvl_idx-1].spaces );
p->levels[p->lvl_idx].spaces = len;
- p->levels[p->lvl_idx].domain = p->levels[p->lvl_idx-1].domain;
+ p->levels[p->lvl_idx].domain = syck_strndup( p->levels[p->lvl_idx-1].domain, strlen( p->levels[p->lvl_idx-1].domain ) );
p->levels[p->lvl_idx].status = status;
p->lvl_idx += 1;
}
@@ -443,7 +440,7 @@ syck_parse( SyckParser *p )
ASSERT( p != NULL );
- p->root = NULL;
+ p->root = 0;
syck_parser_reset_levels( p );
yyparse( p );
return p->root;