* transcode.c (transcode_loop): constified.

* transcode.c (str_transcode): rb_str_set_len() sets a delimiter.

* transcode_data.h (rb_transcoder): constified preprocessor and
  postprocessor input.

* enc/trans/japanese.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-07-14 09:47:33 +00:00
Родитель ae87557916
Коммит 94ed51b281
4 изменённых файлов: 27 добавлений и 57 удалений

Просмотреть файл

@ -1,45 +1,13 @@
Mon Jul 14 17:37:01 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
Mon Jul 14 18:47:30 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* test/ruby/test_time.rb (TestTime#test_time_interval): add timeout
to avoid stopping tests.
* transcode.c (transcode_loop): constified.
Mon Jul 14 15:18:30 2008 NARUSE, Yui <naruse@ruby-lang.org>
* transcode.c (str_transcode): rb_str_set_len() sets a delimiter.
* transcode.c (get_replacement_character): temporary function,
get characters for replacement mode.
* transcode_data.h (rb_transcoder): constified preprocessor and
postprocessor input.
* transcode.c (transcode_loop): add undef key and replace value.
* transcode.c (str_transcode): ditto.
* transcode.c (Init_transcode): define sym_undef and sym_replace.
Mon Jul 14 15:16:40 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
* test/ruby/test_variable.rb (TestVariable#test_global_variable_0):
add test of $0.
Mon Jul 14 13:36:15 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* ext/socket/extconf.rb: initialize winsock on win32 to avoid error
dialog of OS.
Mon Jul 14 06:02:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* lib/optparse.rb (OptionParser#environment): requires shellwords.
[ruby-dev:35466]
Sun Jul 13 21:23:08 2008 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (EVENTSINK_Invoke): using hash
to set value to the reference argument of event.
* test/win32ole/test_win32ole_event.rb: ditto.
Sun Jul 13 06:57:09 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/pty/pty.c (raise_from_wait, pty_syswait, get_device_once):
constified.
* enc/trans/japanese.c: ditto.
Sun Jul 13 05:37:50 2008 NAKAMURA Usaku <usa@ruby-lang.org>

Просмотреть файл

@ -23702,10 +23702,10 @@ enum ISO_2022_ESCSEQ {
#define ISO_2022_GZ_JIS_X_0213_2004_1 ISO_2022_ENCODING(ISO_2022_GZDM4,'Q')
static int
get_iso_2022_mode(unsigned char **in_pos)
get_iso_2022_mode(const unsigned char **in_pos)
{
int new_mode;
unsigned char *in_p = *in_pos;
const unsigned char *in_p = *in_pos;
switch (*in_p++)
{
case '(':
@ -23750,12 +23750,13 @@ get_iso_2022_mode(unsigned char **in_pos)
}
static void
from_iso_2022_jp_transcoder_preprocessor(unsigned char **in_pos, unsigned char **out_pos,
unsigned char *in_stop, unsigned char *out_stop,
from_iso_2022_jp_transcoder_preprocessor(const unsigned char **in_pos, unsigned char **out_pos,
const unsigned char *in_stop, unsigned char *out_stop,
rb_transcoding *my_transcoding)
{
const rb_transcoder *my_transcoder = my_transcoding->transcoder;
unsigned char *in_p = *in_pos, *out_p = *out_pos;
const unsigned char *in_p = *in_pos;
unsigned char *out_p = *out_pos;
int cur_mode = ISO_2022_GZ_ASCII;
unsigned char c1;
unsigned char *out_s = out_stop - my_transcoder->max_output + 1;
@ -23830,12 +23831,13 @@ select_iso_2022_mode(unsigned char **out_pos, int new_mode)
}
static void
to_iso_2022_jp_transcoder_postprocessor(unsigned char **in_pos, unsigned char **out_pos,
unsigned char *in_stop, unsigned char *out_stop,
to_iso_2022_jp_transcoder_postprocessor(const unsigned char **in_pos, unsigned char **out_pos,
const unsigned char *in_stop, unsigned char *out_stop,
rb_transcoding *my_transcoding)
{
const rb_transcoder *my_transcoder = my_transcoding->transcoder;
unsigned char *in_p = *in_pos, *out_p = *out_pos;
const unsigned char *in_p = *in_pos;
unsigned char *out_p = *out_pos;
int cur_mode = ISO_2022_GZ_ASCII, new_mode = 0;
unsigned char next_byte;
unsigned char *out_s = out_stop - my_transcoder->max_output + 1;

Просмотреть файл

@ -157,22 +157,24 @@ get_replacement_character(rb_encoding *enc)
* Transcoding engine logic
*/
static void
transcode_loop(unsigned char **in_pos, unsigned char **out_pos,
unsigned char *in_stop, unsigned char *out_stop,
transcode_loop(const unsigned char **in_pos, unsigned char **out_pos,
const unsigned char *in_stop, unsigned char *out_stop,
const rb_transcoder *my_transcoder,
rb_transcoding *my_transcoding,
const int opt)
{
unsigned char *in_p = *in_pos, *out_p = *out_pos;
const unsigned char *in_p = *in_pos;
unsigned char *out_p = *out_pos;
const BYTE_LOOKUP *conv_tree_start = my_transcoder->conv_tree_start;
const BYTE_LOOKUP *next_table;
unsigned char *char_start;
const unsigned char *char_start;
unsigned int next_offset;
VALUE next_info;
unsigned char next_byte;
int from_utf8 = my_transcoder->from_utf8;
unsigned char *out_s = out_stop - my_transcoder->max_output + 1;
rb_encoding *to_encoding = rb_enc_find(my_transcoder->to_encoding);
while (in_p < in_stop) {
char_start = in_p;
next_table = conv_tree_start;
@ -302,7 +304,8 @@ str_transcode(int argc, VALUE *argv, VALUE *self)
VALUE dest;
VALUE str = *self;
long blen, slen;
unsigned char *buf, *bp, *sp, *fromp;
unsigned char *buf, *bp, *sp;
const unsigned char *fromp;
rb_encoding *from_enc, *to_enc;
const char *from_e, *to_e;
int from_encidx, to_encidx;
@ -401,9 +404,7 @@ str_transcode(int argc, VALUE *argv, VALUE *self)
if (fromp != sp+slen) {
rb_raise(rb_eArgError, "not fully converted, %"PRIdPTRDIFF" bytes left", sp+slen-fromp);
}
buf = (unsigned char *)RSTRING_PTR(dest);
*bp = '\0';
rb_str_set_len(dest, bp - buf);
rb_str_set_len(dest, (char *)bp - RSTRING_PTR(dest));
str = dest;
}
fromp = sp = (unsigned char *)RSTRING_PTR(str);
@ -434,7 +435,6 @@ str_transcode(int argc, VALUE *argv, VALUE *self)
rb_raise(rb_eArgError, "not fully converted, %"PRIdPTRDIFF" bytes left", sp+slen-fromp);
}
buf = (unsigned char *)RSTRING_PTR(dest);
*bp = '\0';
rb_str_set_len(dest, bp - buf);
}

Просмотреть файл

@ -72,8 +72,8 @@ typedef struct rb_transcoder {
const BYTE_LOOKUP *conv_tree_start;
int max_output;
int from_utf8;
void (*preprocessor)(unsigned char**, unsigned char**, unsigned char*, unsigned char*, struct rb_transcoding *);
void (*postprocessor)(unsigned char**, unsigned char**, unsigned char*, unsigned char*, struct rb_transcoding *);
void (*preprocessor)(const unsigned char**, unsigned char**, const unsigned char*, unsigned char*, struct rb_transcoding *);
void (*postprocessor)(const unsigned char**, unsigned char**, const unsigned char*, unsigned char*, struct rb_transcoding *);
VALUE (*func_ii)(VALUE); /* info -> info */
VALUE (*func_si)(const unsigned char *); /* start -> info */
int (*func_io)(VALUE, const unsigned char*); /* info -> output */