summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--ext/syck/emitter.c54
-rw-r--r--ext/syck/implicit.c7
-rw-r--r--ext/syck/rubyext.c11
-rw-r--r--ext/syck/syck.c12
-rw-r--r--ext/syck/syck.h30
-rw-r--r--ext/syck/token.c2
-rw-r--r--ext/syck/yaml2byte.c13
8 files changed, 76 insertions, 57 deletions
diff --git a/ChangeLog b/ChangeLog
index 66d52073dc2..7b749686c33 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Jul 23 03:02:08 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/syck: suppress warnings.
+
Wed Jul 23 00:34:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/openssl: suppress warnings.
diff --git a/ext/syck/emitter.c b/ext/syck/emitter.c
index 56a5592cb3c..c9106c5bc60 100644
--- a/ext/syck/emitter.c
+++ b/ext/syck/emitter.c
@@ -538,7 +538,7 @@ void syck_emit_indent( SyckEmitter *e )
* Basic printable test for LATIN-1 characters.
*/
int
-syck_scan_scalar( int req_width, char *cursor, long len )
+syck_scan_scalar( int req_width, const char *cursor, long len )
{
long i = 0, start = 0;
int flags = SCAN_NONE;
@@ -638,13 +638,14 @@ syck_scan_scalar( int req_width, char *cursor, long len )
* All scalars should be emitted through this function, which determines an appropriate style,
* tag and indent.
*/
-void syck_emit_scalar( SyckEmitter *e, char *tag, enum scalar_style force_style, int force_indent, int force_width,
- char keep_nl, char *str, long len )
+void syck_emit_scalar( SyckEmitter *e, const char *tag, enum scalar_style force_style, int force_indent, int force_width,
+ char keep_nl, const char *str, long len )
{
enum scalar_style favor_style = scalar_literal;
SyckLevel *parent = syck_emitter_parent_level( e );
SyckLevel *lvl = syck_emitter_current_level( e );
int scan = 0;
+ const char *match_implicit;
char *implicit;
if ( str == NULL ) str = "";
@@ -658,10 +659,10 @@ void syck_emit_scalar( SyckEmitter *e, char *tag, enum scalar_style force_style,
}
scan = syck_scan_scalar( force_width, str, len );
- implicit = syck_match_implicit( str, len );
+ match_implicit = syck_match_implicit( str, len );
/* quote strings which default to implicits */
- implicit = syck_taguri( YAML_DOMAIN, implicit, strlen( implicit ) );
+ implicit = syck_taguri( YAML_DOMAIN, match_implicit, strlen( match_implicit ) );
if ( syck_tagcmp( tag, implicit ) != 0 && syck_tagcmp( tag, "tag:yaml.org,2002:str" ) == 0 ) {
force_style = scalar_2quote;
} else {
@@ -772,7 +773,7 @@ void syck_emit_scalar( SyckEmitter *e, char *tag, enum scalar_style force_style,
}
void
-syck_emitter_escape( SyckEmitter *e, char *src, long len )
+syck_emitter_escape( SyckEmitter *e, const char *src, long len )
{
int i;
for( i = 0; i < len; i++ )
@@ -801,12 +802,13 @@ syck_emitter_escape( SyckEmitter *e, char *src, long len )
/*
* Outputs a single-quoted block.
*/
-void syck_emit_1quoted( SyckEmitter *e, int width, char *str, long len )
+void
+syck_emit_1quoted( SyckEmitter *e, int width, const char *str, long len )
{
char do_indent = 0;
- char *mark = str;
- char *start = str;
- char *end = str;
+ const char *mark = str;
+ const char *start = str;
+ const char *end = str;
syck_emitter_write( e, "'", 1 );
while ( mark < str + len ) {
if ( do_indent ) {
@@ -848,12 +850,13 @@ void syck_emit_1quoted( SyckEmitter *e, int width, char *str, long len )
/*
* Outputs a double-quoted block.
*/
-void syck_emit_2quoted( SyckEmitter *e, int width, char *str, long len )
+void
+syck_emit_2quoted( SyckEmitter *e, int width, const char *str, long len )
{
char do_indent = 0;
- char *mark = str;
- char *start = str;
- char *end = str;
+ const char *mark = str;
+ const char *start = str;
+ const char *end = str;
syck_emitter_write( e, "\"", 1 );
while ( mark < str + len ) {
if ( do_indent > 0 ) {
@@ -908,11 +911,12 @@ void syck_emit_2quoted( SyckEmitter *e, int width, char *str, long len )
/*
* Outputs a literal block.
*/
-void syck_emit_literal( SyckEmitter *e, char keep_nl, char *str, long len )
+void
+syck_emit_literal( SyckEmitter *e, char keep_nl, const char *str, long len )
{
- char *mark = str;
- char *start = str;
- char *end = str;
+ const char *mark = str;
+ const char *start = str;
+ const char *end = str;
syck_emitter_write( e, "|", 1 );
if ( keep_nl == NL_CHOMP ) {
syck_emitter_write( e, "-", 1 );
@@ -943,11 +947,12 @@ void syck_emit_literal( SyckEmitter *e, char keep_nl, char *str, long len )
/*
* Outputs a folded block.
*/
-void syck_emit_folded( SyckEmitter *e, int width, char keep_nl, char *str, long len )
+void
+syck_emit_folded( SyckEmitter *e, int width, char keep_nl, const char *str, long len )
{
- char *mark = str;
- char *start = str;
- char *end = str;
+ const char *mark = str;
+ const char *start = str;
+ const char *end = str;
syck_emitter_write( e, ">", 1 );
if ( keep_nl == NL_CHOMP ) {
syck_emitter_write( e, "-", 1 );
@@ -992,7 +997,7 @@ void syck_emit_folded( SyckEmitter *e, int width, char keep_nl, char *str, long
/*
* Begins emission of a sequence.
*/
-void syck_emit_seq( SyckEmitter *e, char *tag, enum seq_style style )
+void syck_emit_seq( SyckEmitter *e, const char *tag, enum seq_style style )
{
SyckLevel *parent = syck_emitter_parent_level( e );
SyckLevel *lvl = syck_emitter_current_level( e );
@@ -1013,7 +1018,8 @@ void syck_emit_seq( SyckEmitter *e, char *tag, enum seq_style style )
/*
* Begins emission of a mapping.
*/
-void syck_emit_map( SyckEmitter *e, char *tag, enum map_style style )
+void
+syck_emit_map( SyckEmitter *e, const char *tag, enum map_style style )
{
SyckLevel *parent = syck_emitter_parent_level( e );
SyckLevel *lvl = syck_emitter_current_level( e );
diff --git a/ext/syck/implicit.c b/ext/syck/implicit.c
index 92a31d8006d..58abfc97691 100644
--- a/ext/syck/implicit.c
+++ b/ext/syck/implicit.c
@@ -20,7 +20,7 @@
void
try_tag_implicit( SyckNode *n, int taguri )
{
- char *tid = "";
+ const char *tid = "";
switch ( n->kind )
{
case syck_str_kind:
@@ -44,9 +44,10 @@ try_tag_implicit( SyckNode *n, int taguri )
}
}
-char *syck_match_implicit( char *str, size_t len )
+const char *
+syck_match_implicit( const char *str, size_t len )
{
- char *cursor, *limit, *marker;
+ const char *cursor, *limit, *marker;
cursor = str;
limit = str + len;
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index 7c2508f853c..96994d564b4 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -71,7 +71,7 @@ static VALUE syck_node_transform( VALUE );
* handler prototypes
*/
SYMID rb_syck_load_handler _((SyckParser *, SyckNode *));
-void rb_syck_err_handler _((SyckParser *, char *));
+void rb_syck_err_handler _((SyckParser *, const char *));
SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *));
void rb_syck_output_handler _((SyckEmitter *, char *, long));
void rb_syck_emitter_handler _((SyckEmitter *, st_data_t));
@@ -103,7 +103,8 @@ rb_syck_compile(VALUE self, VALUE port)
int taint;
char *ret;
VALUE bc;
- bytestring_t *sav;
+ bytestring_t *sav;
+ void *data;
SyckParser *parser = syck_new_parser();
taint = syck_parser_assign_io(parser, &port);
@@ -112,7 +113,7 @@ rb_syck_compile(VALUE self, VALUE port)
syck_parser_implicit_typing( parser, 0 );
syck_parser_taguri_expansion( parser, 0 );
oid = syck_parse( parser );
- syck_lookup_sym( parser, oid, &sav );
+ if (syck_lookup_sym( parser, oid, &data )) sav = data;
ret = S_ALLOCA_N( char, strlen( sav->buffer ) + 3 );
ret[0] = '\0';
@@ -634,7 +635,7 @@ rb_syck_load_handler(SyckParser *p, SyckNode *n)
* friendly errors.
*/
void
-rb_syck_err_handler(SyckParser *p, char *msg)
+rb_syck_err_handler(SyckParser *p, const char *msg)
{
char *endl = p->cursor;
@@ -1189,7 +1190,7 @@ syck_resolver_tagurize(VALUE self, VALUE val)
VALUE
syck_defaultresolver_detect_implicit(VALUE self, VALUE val)
{
- char *type_id;
+ const char *type_id;
VALUE tmp = rb_check_string_type(val);
if ( !NIL_P(tmp) )
diff --git a/ext/syck/syck.c b/ext/syck/syck.c
index 9c9266dda96..9ac62688fa4 100644
--- a/ext/syck/syck.c
+++ b/ext/syck/syck.c
@@ -177,7 +177,7 @@ syck_new_parser(void)
}
int
-syck_add_sym( SyckParser *p, char *data )
+syck_add_sym( SyckParser *p, void *data )
{
SYMID id = 0;
if ( p->syms == NULL )
@@ -190,10 +190,14 @@ syck_add_sym( SyckParser *p, char *data )
}
int
-syck_lookup_sym( SyckParser *p, SYMID id, void *data )
+syck_lookup_sym( SyckParser *p, SYMID id, void **datap )
{
+ st_data_t data = (st_data_t)*datap;
+ int ret;
if ( p->syms == NULL ) return 0;
- return st_lookup( p->syms, id, data );
+ ret = st_lookup( p->syms, id, &data );
+ *datap = (void *)data;
+ return ret;
}
int
@@ -493,7 +497,7 @@ syck_parse( SyckParser *p )
}
void
-syck_default_error_handler( SyckParser *p, char *msg )
+syck_default_error_handler( SyckParser *p, const char *msg )
{
printf( "Error at [Line %d, Col %d]: %s\n",
p->linect,
diff --git a/ext/syck/syck.h b/ext/syck/syck.h
index 5372699016b..afcf1daae83 100644
--- a/ext/syck/syck.h
+++ b/ext/syck/syck.h
@@ -155,7 +155,7 @@ typedef struct _syck_str SyckIoStr;
typedef struct _syck_level SyckLevel;
typedef SYMID (*SyckNodeHandler)(SyckParser *, SyckNode *);
-typedef void (*SyckErrorHandler)(SyckParser *, char *);
+typedef void (*SyckErrorHandler)(SyckParser *, const char *);
typedef SyckNode * (*SyckBadAnchorHandler)(SyckParser *, char *);
typedef long (*SyckIoFileRead)(char *, SyckIoFile *, long, long);
typedef long (*SyckIoStrRead)(char *, SyckIoStr *, long, long);
@@ -348,12 +348,12 @@ void syck_add_transfer( char *, SyckNode *, int );
char *syck_xprivate( char *, int );
char *syck_taguri( const char *, const char *, int );
int syck_tagcmp( const char *, const char * );
-int syck_add_sym( SyckParser *, char * );
-int syck_lookup_sym( SyckParser *, SYMID, void * );
+int syck_add_sym( SyckParser *, void * );
+int syck_lookup_sym( SyckParser *, SYMID, void ** );
int syck_try_implicit( SyckNode * );
char *syck_type_id_to_uri( char * );
void try_tag_implicit( SyckNode *, int );
-char *syck_match_implicit( char *, size_t );
+const char *syck_match_implicit( const char *, size_t );
/*
* API prototypes
@@ -371,17 +371,17 @@ void syck_emitter_handler( SyckEmitter *, SyckEmitterHandler );
void syck_free_emitter( SyckEmitter * );
void syck_emitter_clear( SyckEmitter * );
void syck_emitter_write( SyckEmitter *, const char *, long );
-void syck_emitter_escape( SyckEmitter *, char *, long );
+void syck_emitter_escape( SyckEmitter *, const char *, long );
void syck_emitter_flush( SyckEmitter *, long );
void syck_emit( SyckEmitter *, st_data_t );
-void syck_emit_scalar( SyckEmitter *, char *, enum scalar_style, int, int, char, char *, long );
-void syck_emit_1quoted( SyckEmitter *, int, char *, long );
-void syck_emit_2quoted( SyckEmitter *, int, char *, long );
-void syck_emit_folded( SyckEmitter *, int, char, char *, long );
-void syck_emit_literal( SyckEmitter *, char, char *, long );
-void syck_emit_seq( SyckEmitter *, char *, enum seq_style );
+void syck_emit_scalar( SyckEmitter *, const char *, enum scalar_style, int, int, char, const char *, long );
+void syck_emit_1quoted( SyckEmitter *, int, const char *, long );
+void syck_emit_2quoted( SyckEmitter *, int, const char *, long );
+void syck_emit_folded( SyckEmitter *, int, char, const char *, long );
+void syck_emit_literal( SyckEmitter *, char, const char *, long );
+void syck_emit_seq( SyckEmitter *, const char *, enum seq_style );
void syck_emit_item( SyckEmitter *, st_data_t );
-void syck_emit_map( SyckEmitter *, char *, enum map_style );
+void syck_emit_map( SyckEmitter *, const char *, enum map_style );
void syck_emit_end( SyckEmitter * );
void syck_emit_tag( SyckEmitter *, const char *, const char * );
void syck_emit_indent( SyckEmitter * );
@@ -395,7 +395,7 @@ void syck_free_parser( SyckParser * );
void syck_parser_set_root_on_error( SyckParser *, SYMID );
void syck_parser_implicit_typing( SyckParser *, int );
void syck_parser_taguri_expansion( SyckParser *, int );
-int syck_scan_scalar( int, char *, long );
+int syck_scan_scalar( int, const char *, long );
void syck_parser_handler( SyckParser *, SyckNodeHandler );
void syck_parser_error_handler( SyckParser *, SyckErrorHandler );
void syck_parser_bad_anchor_handler( SyckParser *, SyckBadAnchorHandler );
@@ -410,7 +410,7 @@ void free_any_io( SyckParser * );
long syck_parser_read( SyckParser * );
long syck_parser_readlen( SyckParser *, long );
SYMID syck_parse( SyckParser * );
-void syck_default_error_handler( SyckParser *, char * );
+void syck_default_error_handler( SyckParser *, const char * );
SYMID syck_yaml2byte_handler( SyckParser *, SyckNode * );
char *syck_yaml2byte( char * );
@@ -445,7 +445,7 @@ long syck_seq_count( SyckNode * );
/*
* Lexer prototypes
*/
-void syckerror( char * );
+void syckerror( const char * );
int syckparse( void * );
union YYSTYPE;
int sycklex( union YYSTYPE *, SyckParser * );
diff --git a/ext/syck/token.c b/ext/syck/token.c
index 15bbab69593..045f81774fc 100644
--- a/ext/syck/token.c
+++ b/ext/syck/token.c
@@ -2713,7 +2713,7 @@ syckwrap()
}
void
-syckerror( char *msg )
+syckerror( const char *msg )
{
if ( syck_parser_ptr->error_handler == NULL )
syck_parser_ptr->error_handler = syck_default_error_handler;
diff --git a/ext/syck/yaml2byte.c b/ext/syck/yaml2byte.c
index 7492fd6c84c..1b1ce26c494 100644
--- a/ext/syck/yaml2byte.c
+++ b/ext/syck/yaml2byte.c
@@ -128,6 +128,7 @@ syck_yaml2byte_handler(p, n)
char *finish;
bytestring_t *val = NULL;
bytestring_t *sav = NULL;
+ void *data;
/*TRACE0("syck_yaml2byte_handler()");*/
val = bytestring_alloc();
if(n->anchor) bytestring_append(val,YAMLBYTE_ANCHOR, n->anchor, NULL);
@@ -188,7 +189,7 @@ syck_yaml2byte_handler(p, n)
for ( i = 0; i < n->data.list->idx; i++ )
{
oid = syck_seq_read( n, i );
- syck_lookup_sym( p, oid, &sav );
+ if (syck_lookup_sym( p, oid, &data )) sav = data;
bytestring_extend(val, sav);
}
bytestring_append(val,YAMLBYTE_END_BRANCH,NULL,NULL);
@@ -198,10 +199,10 @@ syck_yaml2byte_handler(p, n)
for ( i = 0; i < n->data.pairs->idx; i++ )
{
oid = syck_map_read( n, map_key, i );
- syck_lookup_sym( p, oid, &sav );
+ if (syck_lookup_sym( p, oid, &data )) sav = data;
bytestring_extend(val, sav);
oid = syck_map_read( n, map_value, i );
- syck_lookup_sym( p, oid, &sav );
+ if (syck_lookup_sym( p, oid, &data )) sav = data;
bytestring_extend(val, sav);
}
bytestring_append(val,YAMLBYTE_END_BRANCH,NULL,NULL);
@@ -217,7 +218,8 @@ syck_yaml2byte(char *yamlstr)
{
SYMID oid;
char *ret;
- bytestring_t *sav;
+ bytestring_t *sav;
+ void *data;
SyckParser *parser = syck_new_parser();
syck_parser_str_auto( parser, yamlstr, NULL );
@@ -227,7 +229,8 @@ syck_yaml2byte(char *yamlstr)
syck_parser_taguri_expansion( parser, 1 );
oid = syck_parse( parser );
- if ( syck_lookup_sym( parser, oid, &sav ) == 1 ) {
+ if ( syck_lookup_sym( parser, oid, &data ) ) {
+ sav = data;
ret = S_ALLOC_N( char, strlen( sav->buffer ) + 3 );
ret[0] = '\0';
strcat( ret, "D\n" );