Return-Path: Delivered-To: apmail-apr-cvs-archive@apr.apache.org Received: (qmail 51336 invoked by uid 500); 15 Jul 2002 19:21:03 -0000 Mailing-List: contact cvs-help@apr.apache.org; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Reply-To: dev@apr.apache.org Delivered-To: mailing list cvs@apr.apache.org Received: (qmail 51312 invoked from network); 15 Jul 2002 19:21:02 -0000 Date: 15 Jul 2002 19:21:01 -0000 Message-ID: <20020715192101.94521.qmail@icarus.apache.org> From: kfogel@apache.org To: apr-cvs@apache.org Subject: cvs commit: apr/i18n/unix xlate.c X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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 Reviewed by: Karl Fogel 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) {