From a4aa765cb680691e8aef1c88eadf48a073d8df2f Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 4 Jul 2003 12:51:42 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/syck/rubyext.c | 158 +++++++++++++++++++++++++-------------------- ext/syck/syck.c | 22 +++---- ext/syck/syck.h | 46 ++++++------- ext/syck/token.c | 32 ++++----- 4 files changed, 137 insertions(+), 121 deletions(-) diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c index dfd6f2d28e..724dd7a912 100644 --- a/ext/syck/rubyext.c +++ b/ext/syck/rubyext.c @@ -14,22 +14,24 @@ typedef struct RVALUE { union { - //struct { - // unsigned long flags; /* always 0 for freed obj */ - // struct RVALUE *next; - //} free; +#if 0 + struct { + unsigned long flags; /* always 0 for freed obj */ + struct RVALUE *next; + } free; +#endif struct RBasic basic; struct RObject object; struct RClass klass; - //struct RFloat flonum; - //struct RString string; + /*struct RFloat flonum;*/ + /*struct RString string;*/ struct RArray array; - //struct RRegexp regexp; + /*struct RRegexp regexp;*/ struct RHash hash; - //struct RData data; + /*struct RData data;*/ struct RStruct rstruct; - //struct RBignum bignum; - //struct RFile file; + /*struct RBignum bignum;*/ + /*struct RFile file;*/ } as; } RVALUE; @@ -57,7 +59,7 @@ void rb_syck_err_handler _((SyckParser *, char *)); SyckNode * rb_syck_bad_anchor_handler _((SyckParser *, char *)); struct parser_xtra { - VALUE data; // Borrowed this idea from marshal.c to fix [ruby-core:8067] problem + VALUE data; /* Borrowed this idea from marshal.c to fix [ruby-core:8067] problem */ VALUE proc; }; @@ -75,9 +77,9 @@ rb_syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip ) if ( max_size > 0 ) { - // - // call io#read. - // + /* + * call io#read. + */ VALUE src = (VALUE)str->ptr; VALUE n = LONG2NUM(max_size); VALUE str = rb_funcall2(src, s_read, 1, &n); @@ -101,16 +103,20 @@ syck_parser_assign_io(parser, port) VALUE port; { if (rb_respond_to(port, rb_intern("to_str"))) { - //arg.taint = OBJ_TAINTED(port); /* original taintedness */ - //StringValue(port); /* possible conversion */ +#if 0 + arg.taint = OBJ_TAINTED(port); /* original taintedness */ + StringValue(port); /* possible conversion */ +#endif syck_parser_str( parser, RSTRING(port)->ptr, RSTRING(port)->len, NULL ); } else if (rb_respond_to(port, s_read)) { if (rb_respond_to(port, s_binmode)) { rb_funcall2(port, s_binmode, 0, 0); } - //arg.taint = Qfalse; - syck_parser_str( parser, (char *)port, 0, rb_syck_io_str_read ); +#if 0 + arg.taint = Qfalse; +#endif + syck_parser_str( parser, (char *)port, 0, rb_syck_io_str_read ); } else { rb_raise(rb_eTypeError, "instance of IO needed"); @@ -144,36 +150,36 @@ rb_syck_mktime(str) char *ptr = str; VALUE year, mon, day, hour, min, sec, usec; - // Year + /* Year*/ ptr[4] = '\0'; year = INT2FIX(strtol(ptr, NULL, 10)); - // Month + /* Month*/ ptr += 4; while ( !isdigit( *ptr ) ) ptr++; mon = INT2FIX(strtol(ptr, NULL, 10)); - // Day + /* Day*/ ptr += 2; while ( !isdigit( *ptr ) ) ptr++; day = INT2FIX(strtol(ptr, NULL, 10)); - // Hour + /* Hour*/ ptr += 2; while ( !isdigit( *ptr ) ) ptr++; hour = INT2FIX(strtol(ptr, NULL, 10)); - // Minute + /* Minute */ ptr += 2; while ( !isdigit( *ptr ) ) ptr++; min = INT2FIX(strtol(ptr, NULL, 10)); - // Second + /* Second */ ptr += 2; while ( !isdigit( *ptr ) ) ptr++; sec = INT2FIX(strtol(ptr, NULL, 10)); - // Millisecond + /* Millisecond */ ptr += 2; if ( *ptr == '.' ) { @@ -184,10 +190,10 @@ rb_syck_mktime(str) usec = INT2FIX( 0 ); } - // Make UTC time + /* Make UTC time*/ time = rb_funcall(rb_cTime, s_utc, 7, year, mon, day, hour, min, sec, usec); - // Time Zone + /* Time Zone*/ while ( *ptr != 'Z' && *ptr != '+' && *ptr != '-' && *ptr != '\0' ) ptr++; if ( *ptr == '-' || *ptr == '+' ) { @@ -209,7 +215,7 @@ rb_syck_mktime(str) } } - // Make TZ time + /* Make TZ time*/ utc_time = NUM2DBL(rb_funcall(time, s_to_f, 0)); utc_time -= tz_offset; time = rb_funcall(rb_cTime, s_at, 1, rb_float_new(utc_time)); @@ -374,16 +380,16 @@ rb_syck_load_handler(p, n) char *ptr = n->data.str->ptr; VALUE year, mon, day; - // Year + /* Year*/ ptr[4] = '\0'; year = INT2FIX(strtol(ptr, NULL, 10)); - // Month + /* Month*/ ptr += 4; while ( !isdigit( *ptr ) ) ptr++; mon = INT2FIX(strtol(ptr, NULL, 10)); - // Day + /* Day*/ ptr += 2; while ( !isdigit( *ptr ) ) ptr++; day = INT2FIX(strtol(ptr, NULL, 10)); @@ -422,9 +428,9 @@ rb_syck_load_handler(p, n) VALUE v = syck_map_read( n, map_value, i ); int merge_key = 0; - // - // Handle merge keys - // + /* + * Handle merge keys + */ if ( rb_obj_is_kind_of( k, cMergeKey ) ) { if ( rb_obj_is_kind_of( v, rb_cHash ) ) @@ -458,9 +464,9 @@ rb_syck_load_handler(p, n) break; } - // - // ID already set, let's alter the symbol table to accept the new object - // + /* + * ID already set, let's alter the symbol table to accept the new object + */ if (n->id > 0) { MEMCPY((void *)n->id, (void *)obj, RVALUE, 1); @@ -631,7 +637,9 @@ syck_parser_load(argc, argv, self) parser->bonus = (void *)&bonus; - //v = rb_ensure(rb_run_syck_parse, (VALUE)&parser, rb_syck_ensure, (VALUE)&parser); +#if 0 + v = rb_ensure(rb_run_syck_parse, (VALUE)&parser, rb_syck_ensure, (VALUE)&parser); +#endif return syck_parse( parser ); } @@ -827,12 +835,15 @@ syck_loader_transfer( self, type, val ) { char *taguri = NULL; - // rb_funcall(rb_mKernel, rb_intern("p"), 2, rb_str_new2( "-- TYPE --" ), type); +#if 0 + rb_p(rb_str_new2( "-- TYPE --" )); + rb_p(type); +#endif if (NIL_P(type) || !RSTRING(type)->ptr || RSTRING(type)->len == 0) { - // - // Empty transfer, detect type - // + /* + * Empty transfer, detect type + */ if ( TYPE(val) == T_STRING ) { taguri = syck_match_implicit( RSTRING(val)->ptr, RSTRING(val)->len ); @@ -851,7 +862,9 @@ syck_loader_transfer( self, type, val ) VALUE str_taguri = rb_str_new2("taguri"); VALUE str_xprivate = rb_str_new2("x-private"); VALUE parts = rb_str_split( type_uri, ":" ); - // rb_funcall(rb_mKernel, rb_intern("p"), 1, parts); +#if 0 + rb_p(parts); +#endif scheme = rb_ary_shift( parts ); @@ -884,7 +897,10 @@ syck_loader_transfer( self, type, val ) name = rb_ary_shift( col ); type_proc = rb_ary_shift( col ); } - // rb_funcall(rb_mKernel, rb_intern("p"), 2, name, type_proc); +#if 0 + rb_p(name); + rb_p(type_proc); +#endif } if ( rb_respond_to( type_proc, s_call ) ) @@ -1009,9 +1025,9 @@ Init_syck() VALUE rb_syck = rb_define_module_under( rb_yaml, "Syck" ); rb_define_const( rb_syck, "VERSION", rb_str_new2( SYCK_VERSION ) ); - // - // Global symbols - // + /* + * Global symbols + */ s_new = rb_intern("new"); s_utc = rb_intern("utc"); s_at = rb_intern("at"); @@ -1030,15 +1046,15 @@ Init_syck() sym_scalar = ID2SYM(rb_intern("scalar")); sym_seq = ID2SYM(rb_intern("seq")); - // - // Load Date module - // + /* + * Load Date module + */ rb_require( "date" ); cDate = rb_funcall( rb_cObject, rb_intern("const_get"), 1, rb_str_new2("Date") ); - // - // Define YAML::Syck::Loader class - // + /* + * Define YAML::Syck::Loader class + */ cLoader = rb_define_class_under( rb_syck, "Loader", rb_cObject ); rb_define_attr( cLoader, "families", 1, 1 ); rb_define_attr( cLoader, "private_types", 1, 1 ); @@ -1053,9 +1069,9 @@ Init_syck() oDefaultLoader = rb_funcall( cLoader, rb_intern( "new" ), 0 ); rb_define_const( rb_syck, "DefaultLoader", oDefaultLoader ); - // - // Define YAML::Syck::Parser class - // + /* + * Define YAML::Syck::Parser class + */ cParser = rb_define_class_under( rb_syck, "Parser", rb_cObject ); rb_define_attr( cParser, "options", 1, 1 ); rb_define_singleton_method( cParser, "new", syck_parser_new, -1 ); @@ -1063,9 +1079,9 @@ Init_syck() rb_define_method(cParser, "load", syck_parser_load, -1); rb_define_method(cParser, "load_documents", syck_parser_load_documents, -1); - // - // Define YAML::Syck::Node class - // + /* + * Define YAML::Syck::Node class + */ cNode = rb_define_class_under( rb_syck, "Node", rb_cObject ); rb_define_attr( cNode, "kind", 1, 1 ); rb_define_attr( cNode, "type_id", 1, 1 ); @@ -1074,33 +1090,33 @@ Init_syck() rb_define_method( cNode, "initialize", syck_node_initialize, 2); rb_define_method( cNode, "transform", syck_node_transform, 0); - // - // Define YAML::Syck::PrivateType class - // + /* + * Define YAML::Syck::PrivateType class + */ cPrivateType = rb_define_class_under( rb_syck, "PrivateType", rb_cObject ); rb_define_attr( cPrivateType, "type_id", 1, 1 ); rb_define_attr( cPrivateType, "value", 1, 1 ); rb_define_method( cPrivateType, "initialize", syck_privatetype_initialize, 2); - // - // Define YAML::Syck::DomainType class - // + /* + * Define YAML::Syck::DomainType class + */ cDomainType = rb_define_class_under( rb_syck, "DomainType", rb_cObject ); rb_define_attr( cDomainType, "domain", 1, 1 ); rb_define_attr( cDomainType, "type_id", 1, 1 ); rb_define_attr( cDomainType, "value", 1, 1 ); rb_define_method( cDomainType, "initialize", syck_domaintype_initialize, 3); - // - // Define YAML::Syck::BadAlias class - // + /* + * Define YAML::Syck::BadAlias class + */ cBadAlias = rb_define_class_under( rb_syck, "BadAlias", rb_cObject ); rb_define_attr( cBadAlias, "name", 1, 1 ); rb_define_method( cBadAlias, "initialize", syck_badalias_initialize, 1); - // - // Define YAML::Syck::MergeKey class - // + /* + * Define YAML::Syck::MergeKey class + */ cMergeKey = rb_define_class_under( rb_syck, "MergeKey", rb_cObject ); } diff --git a/ext/syck/syck.c b/ext/syck/syck.c index d227a36305..a7955b448b 100644 --- a/ext/syck/syck.c +++ b/ext/syck/syck.c @@ -85,7 +85,7 @@ syck_io_str_read( char *buf, SyckIoStr *str, long max_size, long skip ) } else { - // Use exact string length + /* Use exact string length */ while ( str->ptr < str->end ) { if (*(str->ptr++) == '\n') break; } @@ -210,18 +210,18 @@ syck_st_free_nodes( char *key, SyckNode *n, char *arg ) void syck_st_free( SyckParser *p ) { - // - // Free the adhoc symbol table - // + /* + * Free the adhoc symbol table + */ if ( p->syms != NULL ) { st_free_table( p->syms ); p->syms = NULL; } - // - // Free the anchor tables - // + /* + * Free the anchor tables + */ if ( p->anchors != NULL ) { st_foreach( p->anchors, syck_st_free_nodes, 0 ); @@ -243,9 +243,9 @@ syck_free_parser( SyckParser *p ) char *key; SyckNode *node; - // - // Free tables, levels - // + /* + * Free tables, levels + */ syck_st_free( p ); syck_parser_reset_levels( p ); S_FREE( p->levels[0].domain ); @@ -349,7 +349,7 @@ syck_parser_pop_level( SyckParser *p ) { ASSERT( p != NULL ); - // The root level should never be popped + /* The root level should never be popped */ if ( p->lvl_idx <= 1 ) return; p->lvl_idx -= 1; diff --git a/ext/syck/syck.h b/ext/syck/syck.h index ef9c05471c..20ad18a843 100644 --- a/ext/syck/syck.h +++ b/ext/syck/syck.h @@ -84,35 +84,35 @@ enum map_part { }; struct _syck_node { - // Symbol table ID + /* Symbol table ID */ SYMID id; - // Underlying kind + /* Underlying kind */ enum syck_kind_tag kind; - // Fully qualified tag-uri for type + /* Fully qualified tag-uri for type */ char *type_id; - // Anchor name + /* Anchor name */ char *anchor; union { - // Storage for map data + /* Storage for map data */ struct SyckMap { SYMID *keys; SYMID *values; long capa; long idx; } *pairs; - // Storage for sequence data + /* Storage for sequence data */ struct SyckSeq { SYMID *items; long capa; long idx; } *list; - // Storage for string data + /* Storage for string data */ struct SyckStr { char *ptr; long len; } *str; } data; - // Shortcut node + /* Shortcut node */ void *shortcut; }; @@ -143,29 +143,29 @@ enum syck_level_status { }; struct _syck_parser { - // Root node + /* Root node */ SYMID root, root_on_error; - // Implicit typing flag + /* Implicit typing flag */ int implicit_typing, taguri_expansion; - // Scripting language function to handle nodes + /* Scripting language function to handle nodes */ SyckNodeHandler handler; - // Error handler + /* Error handler */ SyckErrorHandler error_handler; - // InvalidAnchor handler + /* InvalidAnchor handler */ SyckBadAnchorHandler bad_anchor_handler; - // IO type + /* IO type */ enum syck_io_type io_type; - // Custom buffer size + /* Custom buffer size */ size_t bufsize; - // Buffer pointers + /* Buffer pointers */ char *buffer, *linectptr, *lineptr, *toktmp, *token, *cursor, *marker, *limit; - // Line counter + /* Line counter */ int linect; - // Last token from yylex() + /* Last token from yylex() */ int last_token; - // Force a token upon next call to yylex() + /* Force a token upon next call to yylex() */ int force_token; - // EOF flag + /* EOF flag */ int eof; union { struct _syck_file { @@ -177,11 +177,11 @@ struct _syck_parser { SyckIoStrRead read; } *str; } io; - // Symbol table for anchors + /* Symbol table for anchors */ st_table *anchors, *bad_anchors; - // Optional symbol table for SYMIDs + /* Optional symbol table for SYMIDs */ st_table *syms; - // Levels of indentation + /* Levels of indentation */ struct _syck_level { int spaces; char *domain; diff --git a/ext/syck/token.c b/ext/syck/token.c index 2051ca2a5c..03ab196510 100644 --- a/ext/syck/token.c +++ b/ext/syck/token.c @@ -448,12 +448,12 @@ yy33: yyaccept = 0; goto yy86; yy34: #line 319 - { // Isolate spaces + { /* Isolate spaces */ int indt_len; GOBBLE_UP_INDENT( indt_len, YYTOKEN ); lvl = CURRENT_LEVEL(); - // Check for open indent + /* Check for open indent */ ENSURE_IEND(lvl, indt_len); ENSURE_IOPEN(lvl, indt_len, 0); if ( indt_len == -1 ) @@ -878,11 +878,11 @@ yy74: { ENSURE_IOPEN(lvl, 0, 1); yylval->name = syck_strndup( YYTOKEN + 1, YYCURSOR - YYTOKEN - 1 ); - // - // Remove previous anchors of the same name. Since the parser will likely - // construct deeper nodes first, we want those nodes to be placed in the - // queue for matching at a higher level of indentation. - // + /* + * Remove previous anchors of the same name. Since the parser will likely + * construct deeper nodes first, we want those nodes to be placed in the + * queue for matching at a higher level of indentation. + */ syck_hdlr_remove_anchor(parser, yylval->name); return ANCHOR; } @@ -1551,7 +1551,7 @@ yy137: } else if ( indt_len < lvl->spaces ) { - // Error! + /* Error! */ } while ( YYTOKTMP < YYCURSOR ) @@ -1685,7 +1685,7 @@ yy153: } else if ( indt_len < lvl->spaces ) { - // Error! + /* Error! */ } if ( keep_nl == 1 ) @@ -1909,9 +1909,9 @@ yy180: lvl = CURRENT_LEVEL(); - // - // URL Prefixing - // + /* + * URL Prefixing + */ if ( *(YYTOKEN + 1) == '^' ) { yylval->name = S_ALLOC_N( char, ( YYCURSOR - YYTOKEN ) + strlen( lvl->domain ) ); @@ -2054,10 +2054,10 @@ yy191: RETURN_BLOCK(); } - // - // Fold only in the event of two lines being on the leftmost - // indentation. - // + /* + * Fold only in the event of two lines being on the leftmost + * indentation. + */ if ( blockType == BLOCK_FOLD && lastIndent == 0 && ( indt_len - lvl->spaces ) == 0 ) { fold_nl = 1;