ruby-changes:7846
From: akr <ko1@a...>
Date: Tue, 16 Sep 2008 00:42:54 +0900 (JST)
Subject: [ruby-changes:7846] Ruby:r19366 (trunk): * transcode_data.h (STR1_LENGTH): defined.
akr 2008-09-16 00:42:30 +0900 (Tue, 16 Sep 2008) New Revision: 19366 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19366 Log: * transcode_data.h (STR1_LENGTH): defined. (makeSTR1LEN): defined. * tool/transcode-tblgen.rb: use makeSTR1LEN. generate STR1 for 4 to 259 bytes. * transcode.c (rb_transcoding): new field: output_index. (transcode_restartable0): use STR1_LENGTH. Modified files: trunk/ChangeLog trunk/tool/transcode-tblgen.rb trunk/transcode.c trunk/transcode_data.h Index: ChangeLog =================================================================== --- ChangeLog (revision 19365) +++ ChangeLog (revision 19366) @@ -1,3 +1,14 @@ +Tue Sep 16 00:40:56 2008 Tanaka Akira <akr@f...> + + * transcode_data.h (STR1_LENGTH): defined. + (makeSTR1LEN): defined. + + * tool/transcode-tblgen.rb: use makeSTR1LEN. generate STR1 for 4 to + 259 bytes. + + * transcode.c (rb_transcoding): new field: output_index. + (transcode_restartable0): use STR1_LENGTH. + Mon Sep 15 23:52:45 2008 Koichi Sasada <ko1@a...> * gc.c, include/ruby/ruby.h: rename rb_register_mark_object() Index: transcode_data.h =================================================================== --- transcode_data.h (revision 19365) +++ transcode_data.h (revision 19366) @@ -34,10 +34,12 @@ #define FUNsi (PType 0x0D) /* function from start to info */ #define FUNio (PType 0x0E) /* function from info to output */ #define FUNso (PType 0x0F) /* function from start to output */ -#define STR1 (PType 0x11) /* string up to 255 bytes: 1byte length + content */ +#define STR1 (PType 0x11) /* string 4 <= len <= 259 bytes: 1byte length + content */ +#define STR1_LENGTH(byte_addr) (*(byte_addr) + 4) #define STR1_BYTEINDEX(w) ((w) >> 6) #define makeSTR1(bi) (((bi) << 6) | STR1) +#define makeSTR1LEN(len) ((len)-4) #define o1(b1) (PType((((unsigned char)(b1))<<8)|ONEbt)) #define o2(b1,b2) (PType((((unsigned char)(b1))<<8)|(((unsigned char)(b2))<<16)|TWObt)) Index: tool/transcode-tblgen.rb =================================================================== --- tool/transcode-tblgen.rb (revision 19365) +++ tool/transcode-tblgen.rb (revision 19366) @@ -307,7 +307,7 @@ n = str_name(bytes) @bytes_code.insert_at_last(1 + len, "\#define #{n} makeSTR1(#{size})\n" + - " #{len}," + bytes.gsub(/../, ' 0x\&,') + "\n\n") + " makeSTR1LEN(#{len})," + bytes.gsub(/../, ' 0x\&,') + "\n\n") n end end @@ -336,7 +336,7 @@ "o3(0x#$1,0x#$2,0x#$3)" when /\A(f[0-7])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])\z/i "o4(0x#$1,0x#$2,0x#$3,0x#$4)" - when /\A([0-9a-f][0-9a-f]){0,255}\z/i + when /\A([0-9a-f][0-9a-f]){4,259}\z/i gen_str(info.upcase) when /\A\/\*BYTE_LOOKUP\*\// # pointer to BYTE_LOOKUP structure $'.to_s Index: transcode.c =================================================================== --- transcode.c (revision 19365) +++ transcode.c (revision 19366) @@ -52,6 +52,7 @@ unsigned int next_table; VALUE next_info; unsigned char next_byte; + unsigned int output_index; int recognized_len; /* already interpreted */ int readagain_len; /* not yet interpreted */ @@ -584,10 +585,10 @@ SUSPEND_OBUF(19); *out_p++ = getBT3(next_info); continue; case STR1: - next_byte = 0; /* index */ - while (next_byte < BYTE_ADDR(STR1_BYTEINDEX(next_info))[0]) { - SUSPEND_OBUF(28); *out_p++ = BYTE_ADDR(STR1_BYTEINDEX(next_info))[1+next_byte]; - next_byte++; + tc->output_index = 0; + while (tc->output_index < STR1_LENGTH(BYTE_ADDR(STR1_BYTEINDEX(next_info)))) { + SUSPEND_OBUF(28); *out_p++ = BYTE_ADDR(STR1_BYTEINDEX(next_info))[1+tc->output_index]; + tc->output_index++; } continue; case FUNii: -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/