apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gst...@apache.org
Subject cvs commit: apr-util/xlate xlate.c
Date Thu, 18 Jul 2002 00:12:14 GMT
gstein      2002/07/17 17:12:14

  Modified:    xlate    xlate.c
  Log:
  Fix some error handling for platforms with a broken iconv(). In
  certain cases, iconv will return -1 to indicate an error, but it won't
  set the errno variable. Return EINVAL in these cases.
  
  Revision  Changes    Path
  1.4       +19 -4     apr-util/xlate/xlate.c
  
  Index: xlate.c
  ===================================================================
  RCS file: /home/cvs/apr-util/xlate/xlate.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- xlate.c	17 Jul 2002 05:24:04 -0000	1.3
  +++ xlate.c	18 Jul 2002 00:12:13 -0000	1.4
  @@ -177,7 +177,9 @@
   
       if (old->ich != (iconv_t)-1) {
           if (iconv_close(old->ich)) {
  -            return errno;
  +            int rv = errno;
  +            /* Sometimes, iconv is not good about setting errno. */
  +            return rv ? rv : EINVAL;
           }
       }
   #endif
  @@ -270,7 +272,9 @@
       if (!found) {
           new->ich = iconv_open(topage, frompage);
           if (new->ich == (iconv_t)-1) {
  -            return errno;
  +            int rv = errno;
  +            /* Sometimes, iconv is not good about setting errno. */
  +            return rv ? rv : EINVAL;
           }
           found = 1;
           check_sbcs(new);
  @@ -327,19 +331,30 @@
            * c) the error condition where the input is invalid
            */
           if (translated == (apr_size_t)-1) {
  -            switch (errno) {
  +            int rv = errno;
  +            switch (rv) {
  +
               case E2BIG:  /* out of space on output */
                   status = 0; /* change table lookup code below if you
                                  make this an error */
                   break;
  +
               case EINVAL: /* input character not complete (yet) */
                   status = APR_INCOMPLETE;
                   break;
  +
               case EILSEQ: /* bad input byte */
                   status = APR_EINVAL;
                   break;
  +
  +             /* Sometimes, iconv is not good about setting errno. */
  +            case 0:
  +                status = APR_INCOMPLETE;
  +                break;
  +
               default:
  -                status = errno;
  +                status = rv;
  +                break;
               }
           }
       }
  
  
  

Mime
View raw message