apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr-util/xlate xlate.c
Date Fri, 10 Jan 2003 15:17:43 GMT
wrowe       2003/01/10 07:17:43

  Modified:    xlate    xlate.c
  Log:
    Some problematic code since Mr. Stoddard recognized we weren't setting
    or testing the correct #defines.
  
  Revision  Changes    Path
  1.15      +46 -8     apr-util/xlate/xlate.c
  
  Index: xlate.c
  ===================================================================
  RCS file: /home/cvs/apr-util/xlate/xlate.c,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- xlate.c	8 Jan 2003 17:47:26 -0000	1.14
  +++ xlate.c	10 Jan 2003 15:17:43 -0000	1.15
  @@ -96,8 +96,10 @@
       char *frompage;
       char *topage;
       char *sbcs_table;
  -#if APU_HAVE_APR_ICONV || APU_HAVE_ICONV
  +#if APU_HAVE_ICONV
       iconv_t ich;
  +#else APU_HAVE_APR_ICONV
  +    apr_iconv_t ich;
   #endif
   };
   
  @@ -121,7 +123,7 @@
   
   #if APU_HAVE_APR_ICONV
       if (old->ich != (apr_iconv_t)-1) {
  -        return apr_iconv_close(old->ich);
  +        return apr_iconv_close(old->ich, old->pool);
       }
   
   #elif APU_HAVE_ICONV
  @@ -171,7 +173,43 @@
           /* TODO: add the table to the cache */
       }
   }
  -#endif /* APU_HAVE_ICONV */
  +#elif defined(APU_HAVE_APR_ICONV)
  +static void check_sbcs(apr_xlate_t *convset)
  +{
  +    char inbuf[256], outbuf[256];
  +    char *inbufptr = inbuf;
  +    char *outbufptr = outbuf;
  +    apr_size_t inbytes_left, outbytes_left;
  +    int i;
  +    apr_size_t translated;
  +    apr_status_t rv;
  +
  +    for (i = 0; i < sizeof(inbuf); i++) {
  +        inbuf[i] = i;
  +    }
  +
  +    inbytes_left = outbytes_left = sizeof(inbuf);
  +    rv = apr_iconv(convset->ich, (ICONV_INBUF_TYPE)&inbufptr,
  +                   &inbytes_left, &outbufptr, &outbytes_left,
  +                   &translated);
  +
  +    if ((rv == APR_SUCCESS)
  +        && (translated != (apr_size_t)-1)
  +        && inbytes_left == 0
  +        && outbytes_left == 0) {
  +        /* hurray... this is simple translation; save the table,
  +         * close the iconv descriptor
  +         */
  +
  +        convset->sbcs_table = apr_palloc(convset->pool, sizeof(outbuf));
  +        memcpy(convset->sbcs_table, outbuf, sizeof(outbuf));
  +        apr_iconv_close(convset->ich, convset->pool);
  +        convset->ich = (apr_iconv_t)-1;
  +
  +        /* TODO: add the table to the cache */
  +    }
  +}
  +#endif /* APU_HAVE_APR_ICONV */
   
   static void make_identity_table(apr_xlate_t *convset)
   {
  @@ -187,7 +225,7 @@
                                            const char *frompage,
                                            apr_pool_t *pool)
   {
  -    apr_status_t status;
  +    apr_status_t rv;
       apr_xlate_t *new;
       int found = 0;
   
  @@ -251,14 +289,14 @@
           *convset = new;
           apr_pool_cleanup_register(pool, (void *)new, apr_xlate_cleanup,
                               apr_pool_cleanup_null);
  -        status = APR_SUCCESS;
  +        rv = APR_SUCCESS;
       }
       else {
  -        status = APR_EINVAL; /* iconv() would return EINVAL if it
  +        rv = APR_EINVAL; /* iconv() would return EINVAL if it
                                   couldn't handle the pair */
       }
   
  -    return status;
  +    return rv;
   }
   
   APU_DECLARE(apr_status_t) apr_xlate_sb_get(apr_xlate_t *convset, int *onoff)
  @@ -276,7 +314,7 @@
       apr_status_t status = APR_SUCCESS;
   
   #if APU_HAVE_APR_ICONV
  -    if (convset->ich != (iconv_t)-1) {
  +    if (convset->ich != (apr_iconv_t)-1) {
           const char *inbufptr = inbuf;
           apr_size_t translated;
           char *outbufptr = outbuf;
  
  
  

Mime
View raw message