kfogel 2002/07/15 12:21:01
Modified: i18n/unix xlate.c
Log:
(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.
Submitted by: Marcus Comstedt <[EMAIL PROTECTED]>
Reviewed by: Karl Fogel <[EMAIL PROTECTED]>
Revision Changes Path
1.28 +16 -1 apr/i18n/unix/xlate.c
Index: xlate.c
===================================================================
RCS file: /home/cvs/apr/i18n/unix/xlate.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- xlate.c 10 Jul 2002 06:01:12 -0000 1.27
+++ xlate.c 15 Jul 2002 19:21:01 -0000 1.28
@@ -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) == 0)) {
+ /* 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) {