apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Karl Fogel <kfo...@newton.ch.collab.net>
Subject Re: started applying Marcus' patch
Date Tue, 09 Jul 2002 19:48:42 GMT
Sorry, folks, I accidentally CC'd a Subversion message to the APR list
a moment ago.  Here is the message I *meant* to CC to dev@apr:

Marcus Comstedt <marcus@mc.pp.se> writes:
> ... avoid the call to iconv_open if both charsets are the same.
> (That's not just an optimization, at least on Solaris iconv_open can
> actually fail if you request a converter from UTF-8 to UTF-8...)
> [...]
>
> Log message:
> 
> * i18n/unix/xlate.c
>   (make_identity_table): New function to create a sbcs_table that
> performs unity conversion.  See apr_xlate_open.
>   (apr_xlate_open): When topage and frompage are the same,
> make_identity_table is used to create a shortcut instead of calling 
> iconv_open.  The reason being that iconv_open can fail in this case.
> 
> Shouldn't we CC some APR list at this point?

Yes.  How about now :-)?

Marcus's log message above is for the following patch.  Anyone have
comments/thoughts?

Index: i18n/unix/xlate.c
===================================================================
RCS file: /home/cvspublic/apr/i18n/unix/xlate.c,v
retrieving revision 1.26
diff -u -r1.26 xlate.c
--- i18n/unix/xlate.c	8 Jun 2002 18:53:13 -0000	1.26
+++ i18n/unix/xlate.c	28 Jun 2002 14:52:34 -0000
@@ -219,6 +219,14 @@
 }
 #endif /* HAVE_ICONV */
 
+static void make_identity_table(apr_xlate_t *convset)
+{
+  int i;
+  convset->sbcs_table = apr_palloc(convset->pool, 256);
+  for (i=0; i<256; i++)
+      convset->sbcs_table[i] = i;
+}
+
 apr_status_t apr_xlate_open(apr_xlate_t **convset, const char *topage,
                             const char *frompage, apr_pool_t *pool)
 {
@@ -251,6 +259,12 @@
     set found to non-zero if found in the cache
 #endif
 
+    if (!found && !strcmp(topage, frompage)) {
+        /* to and from are the same */
+        found = 1;
+	make_identity_table(new);
+    }
+
 #ifdef HAVE_ICONV
     if (!found) {
         new->ich = iconv_open(topage, frompage);
@@ -259,7 +273,8 @@
         }
         found = 1;
         check_sbcs(new);
-    }
+    } else
+        new->ich = (iconv_t)-1;
 #endif /* HAVE_ICONV */
 
     if (found) {



Mime
View raw message