Diff for /embedaddon/libiconv/lib/gb18030uni.h between versions 1.1.1.1 and 1.1.1.2

version 1.1.1.1, 2012/02/21 22:57:48 version 1.1.1.2, 2021/03/17 13:38:46
Line 1 Line 1
 /*  /*
 * Copyright (C) 1999-2001, 2005 Free Software Foundation, Inc. * Copyright (C) 1999-2001, 2005, 2012, 2016 Free Software Foundation, Inc.
  * This file is part of the GNU LIBICONV Library.   * This file is part of the GNU LIBICONV Library.
  *   *
  * The GNU LIBICONV Library is free software; you can redistribute it   * The GNU LIBICONV Library is free software; you can redistribute it
Line 14 Line 14
  *   *
  * You should have received a copy of the GNU Library General Public   * You should have received a copy of the GNU Library General Public
  * License along with the GNU LIBICONV Library; see the file COPYING.LIB.   * License along with the GNU LIBICONV Library; see the file COPYING.LIB.
 * If not, write to the Free Software Foundation, Inc., 51 Franklin Street, * If not, see <https://www.gnu.org/licenses/>.
 * Fifth Floor, Boston, MA 02110-1301, USA. 
  */   */
   
 /*  /*
Line 168  static const unsigned short gb18030uni_ranges[206] = { Line 167  static const unsigned short gb18030uni_ranges[206] = {
 };  };
   
 static int  static int
gb18030uni_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, int n)gb18030uni_mbtowc (conv_t conv, ucs4_t *pwc, const unsigned char *s, size_t n)
 {  {
   unsigned char c1 = s[0];    unsigned char c1 = s[0];
   if (c1 >= 0x81 && c1 <= 0x84) {    if (c1 >= 0x81 && c1 <= 0x84) {
Line 183  gb18030uni_mbtowc (conv_t conv, ucs4_t *pwc, const uns Line 182  gb18030uni_mbtowc (conv_t conv, ucs4_t *pwc, const uns
               if (c4 >= 0x30 && c4 <= 0x39) {                if (c4 >= 0x30 && c4 <= 0x39) {
                 unsigned int i = (((c1 - 0x81) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30);                  unsigned int i = (((c1 - 0x81) * 10 + (c2 - 0x30)) * 126 + (c3 - 0x81)) * 10 + (c4 - 0x30);
                 if (i >= 0 && i <= 39419) {                  if (i >= 0 && i <= 39419) {
                  unsigned int k1 = 0;                  if (i == 7457) {
                  unsigned int k2 = 205;                    *pwc = 0xe7c7;
                  while (k1 < k2) {                  } else {
                    unsigned int k = (k1 + k2) / 2;                    unsigned int k1 = 0;
                    if (i <= gb18030uni_charset2uni_ranges[2*k+1])                    unsigned int k2 = 205;
                      k2 = k;                    while (k1 < k2) {
                    else if (i >= gb18030uni_charset2uni_ranges[2*k+2])                      unsigned int k = (k1 + k2) / 2;
                      k1 = k + 1;                      if (i <= gb18030uni_charset2uni_ranges[2*k+1])
                    else                        k2 = k;
                      return RET_ILSEQ;                      else if (i >= gb18030uni_charset2uni_ranges[2*k+2])
                         k1 = k + 1;
                       else
                         return RET_ILSEQ;
                     }
                     {
                       unsigned int diff = gb18030uni_ranges[k1];
                       *pwc = (ucs4_t) (i + diff);
                     }
                   }                    }
                  {                  return 4;
                    unsigned int diff = gb18030uni_ranges[k1]; 
                    *pwc = (ucs4_t) (i + diff); 
                    return 4; 
                  } 
                 }                  }
               }                }
               return RET_ILSEQ;                return RET_ILSEQ;
Line 217  gb18030uni_mbtowc (conv_t conv, ucs4_t *pwc, const uns Line 220  gb18030uni_mbtowc (conv_t conv, ucs4_t *pwc, const uns
 }  }
   
 static int  static int
gb18030uni_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, int n)gb18030uni_wctomb (conv_t conv, unsigned char *r, ucs4_t wc, size_t n)
 {  {
   if (n >= 4) {    if (n >= 4) {
     unsigned int i = wc;      unsigned int i = wc;
     if (i >= 0x0080 && i <= 0xffff) {      if (i >= 0x0080 && i <= 0xffff) {
      unsigned int k1 = 0;      if (i == 0xe7c7) {
      unsigned int k2 = 205;        i = 7457;
      while (k1 < k2) {      } else {
        unsigned int k = (k1 + k2) / 2;        unsigned int k1 = 0;
        if (i <= gb18030uni_uni2charset_ranges[2*k+1])        unsigned int k2 = 205;
          k2 = k;        while (k1 < k2) {
        else if (i >= gb18030uni_uni2charset_ranges[2*k+2])          unsigned int k = (k1 + k2) / 2;
          k1 = k + 1;          if (i <= gb18030uni_uni2charset_ranges[2*k+1])
        else            k2 = k;
          return RET_ILUNI;          else if (i >= gb18030uni_uni2charset_ranges[2*k+2])
             k1 = k + 1;
           else
             return RET_ILUNI;
         }
         {
           unsigned int diff = gb18030uni_ranges[k1];
           i -= diff;
         }
       }        }
      {      r[3] = (i % 10) + 0x30; i = i / 10;
        unsigned int diff = gb18030uni_ranges[k1];      r[2] = (i % 126) + 0x81; i = i / 126;
        i -= diff;      r[1] = (i % 10) + 0x30; i = i / 10;
        r[3] = (i % 10) + 0x30; i = i / 10;      r[0] = i + 0x81;
        r[2] = (i % 126) + 0x81; i = i / 126;      return 4;
        r[1] = (i % 10) + 0x30; i = i / 10; 
        r[0] = i + 0x81; 
        return 4; 
      } 
     }      }
     return RET_ILUNI;      return RET_ILUNI;
   }    }

Removed from v.1.1.1.1  
changed lines
  Added in v.1.1.1.2


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>