summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 03:33:23 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-25 03:33:23 +0000
commite7ac333ba841e774911eac23ffb680ab3de7a993 (patch)
treed944976b4bac00ee876a86ad55a1189914f7d94a
parent520d763d777721fd82bac7cea574e3f136efe91f (diff)
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
-rw-r--r--ChangeLog6
-rw-r--r--transcode.c40
2 files changed, 26 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b6f52d123..d1120f20e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/transcode.c b/transcode.c
index 281ecba697..c915cc299d 100644
--- a/transcode.c
+++ b/transcode.c
@@ -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;
-
- n++;
+ 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;
+
+ next_transcoder_position++;
}
static void