[前][次][番号順一覧][スレッド一覧]

ruby-changes:3159

From: ko1@a...
Date: 25 Dec 2007 12:33:53 +0900
Subject: [ruby-changes:3159] duerst - Ruby:r14651 (trunk): Tue Dec 25 12:32:32 2007 Martin Duerst <duerst@i...>

duerst	2007-12-25 12:33:23 +0900 (Tue, 25 Dec 2007)

  New Revision: 14651

  Modified files:
    trunk/ChangeLog
    trunk/transcode.c

  Log:
    Tue Dec 25 12:32:32 2007  Martin Duerst  <duerst@i...>
    
    * 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].
    


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14651&r2=14650
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/transcode.c?r1=14651&r2=14650

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 14650)
+++ ChangeLog	(revision 14651)
@@ -1,3 +1,9 @@
+Tue Dec 25 12:32:32 2007  Martin Duerst  <duerst@i...>
+
+	* 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@r...>
 
 	* sample/from.rb: follow Ruby 1.9 libraries.
Index: transcode.c
===================================================================
--- transcode.c	(revision 14650)
+++ transcode.c	(revision 14651)
@@ -72,6 +72,8 @@
 /* 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 @@
 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 @@
     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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml

[前][次][番号順一覧][スレッド一覧]