1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Tue Dec 25 12:32:32 2007 Martin Duerst <duerst@it.aoyama.ac.jp>

* transcode.c: Moving a static counter from inside register_transcoder()
	  and register_functional_transcoder() to outside the functions, renaming
	  from n to next_transcoder_position. Fixes 3) in [ruby-dev:32715].



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
duerst 2007-12-25 03:33:23 +00:00
parent 520d763d77
commit e7ac333ba8
2 changed files with 25 additions and 19 deletions

View file

@ -1,3 +1,9 @@
Tue Dec 25 12:32:32 2007 Martin Duerst <duerst@it.aoyama.ac.jp>
* transcode.c: Moving a static counter from inside register_transcoder()
and register_functional_transcoder() to outside the functions, renaming
from n to next_transcoder_position. Fixes 3) in [ruby-dev:32715].
Tue Dec 25 12:22:17 2007 NARUSE, Yui <naruse@ruby-lang.org>
* sample/from.rb: follow Ruby 1.9 libraries.

View file

@ -72,6 +72,8 @@ extern void to_iso_2022_jp_transcoder_postprocessor(char**, char**, char*, char*
/* in the future, add some mechanism for dynamically adding stuff here */
#define MAX_TRANSCODERS 35 /* todo: fix: this number has to be adjusted by hand */
static transcoder transcoder_table[MAX_TRANSCODERS];
/* variable to work across register_transcoder and register_functional_transcoder */
static int next_transcoder_position = 0;
/* not sure why it's not possible to do relocatable initializations */
/* maybe the code here can be removed (changed to simple initialization) */
@ -80,18 +82,17 @@ static void
register_transcoder(const char *from_e, const char *to_e,
const BYTE_LOOKUP *tree_start, int max_output, int from_utf8)
{
static int n = 0;
if (n >= MAX_TRANSCODERS) {
if (next_transcoder_position >= MAX_TRANSCODERS) {
/* we are initializing, is it okay to use rb_raise here? */
rb_raise(rb_eRuntimeError /*change exception*/, "not enough transcoder slots");
}
transcoder_table[n].from_encoding = from_e;
transcoder_table[n].to_encoding = to_e;
transcoder_table[n].conv_tree_start = tree_start;
transcoder_table[n].max_output = max_output;
transcoder_table[n].from_utf8 = from_utf8;
transcoder_table[next_transcoder_position].from_encoding = from_e;
transcoder_table[next_transcoder_position].to_encoding = to_e;
transcoder_table[next_transcoder_position].conv_tree_start = tree_start;
transcoder_table[next_transcoder_position].max_output = max_output;
transcoder_table[next_transcoder_position].from_utf8 = from_utf8;
n++;
next_transcoder_position++;
}
static void
@ -100,21 +101,20 @@ register_functional_transcoder(const char *from_e, const char *to_e,
void (*preprocessor)(char**, char**, char*, char*, transcoder*, transcoding*),
void (*postprocessor)(char**, char**, char*, char*, transcoder*, transcoding*))
{
static int n = 0;
if (n >= MAX_TRANSCODERS) {
if (next_transcoder_position >= MAX_TRANSCODERS) {
/* we are initializing, is it okay to use rb_raise here? */
rb_raise(rb_eRuntimeError /*change exception*/, "not enough transcoder slots");
}
transcoder_table[n].from_encoding = from_e;
transcoder_table[n].to_encoding = to_e;
transcoder_table[n].conv_tree_start = tree_start;
transcoder_table[n].max_output = max_output;
transcoder_table[n].from_utf8 = from_utf8;
transcoder_table[n].conv_tree_start = tree_start;
transcoder_table[n].preprocessor = preprocessor;
transcoder_table[n].postprocessor = postprocessor;
transcoder_table[next_transcoder_position].from_encoding = from_e;
transcoder_table[next_transcoder_position].to_encoding = to_e;
transcoder_table[next_transcoder_position].conv_tree_start = tree_start;
transcoder_table[next_transcoder_position].max_output = max_output;
transcoder_table[next_transcoder_position].from_utf8 = from_utf8;
transcoder_table[next_transcoder_position].conv_tree_start = tree_start;
transcoder_table[next_transcoder_position].preprocessor = preprocessor;
transcoder_table[next_transcoder_position].postprocessor = postprocessor;
n++;
next_transcoder_position++;
}
static void