diff options
Diffstat (limited to 'lib/uniconv')
| -rw-r--r-- | lib/uniconv/u-conv-from-enc.h | 44 | ||||
| -rw-r--r-- | lib/uniconv/u-conv-to-enc.h | 92 | ||||
| -rw-r--r-- | lib/uniconv/u-strconv-from-enc.h | 8 | ||||
| -rw-r--r-- | lib/uniconv/u-strconv-to-enc.h | 18 | ||||
| -rw-r--r-- | lib/uniconv/u16-conv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u16-conv-to-enc.c | 106 | ||||
| -rw-r--r-- | lib/uniconv/u16-strconv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u16-strconv-from-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u16-strconv-to-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u16-strconv-to-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-conv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-conv-to-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-strconv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-strconv-from-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-strconv-to-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u32-strconv-to-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u8-conv-from-enc.c | 86 | ||||
| -rw-r--r-- | lib/uniconv/u8-conv-to-enc.c | 60 | ||||
| -rw-r--r-- | lib/uniconv/u8-strconv-from-enc.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u8-strconv-from-locale.c | 2 | ||||
| -rw-r--r-- | lib/uniconv/u8-strconv-to-enc.c | 42 | ||||
| -rw-r--r-- | lib/uniconv/u8-strconv-to-locale.c | 2 | 
22 files changed, 242 insertions, 242 deletions
| diff --git a/lib/uniconv/u-conv-from-enc.h b/lib/uniconv/u-conv-from-enc.h index fa0f0d3d..457bd0f8 100644 --- a/lib/uniconv/u-conv-from-enc.h +++ b/lib/uniconv/u-conv-from-enc.h @@ -1,5 +1,5 @@  /* Conversion to UTF-16/UTF-32 from legacy encodings. -   Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published @@ -26,7 +26,7 @@ FUNC (const char *fromcode,    size_t length = *lengthp * sizeof (UNIT);    if (mem_iconveha (src, srclen, fromcode, UTF_NAME, true, handler, -		    offsets, &result, &length) < 0) +                    offsets, &result, &length) < 0)      return NULL;    if (offsets != NULL)      { @@ -35,8 +35,8 @@ FUNC (const char *fromcode,        size_t *o;        for (o = offsets; o < offsets_end; o++) -	if (*o != (size_t)(-1)) -	  *o = *o / sizeof (UNIT); +        if (*o != (size_t)(-1)) +          *o = *o / sizeof (UNIT);      }    if ((length % sizeof (UNIT)) != 0)      abort (); @@ -49,7 +49,7 @@ FUNC (const char *fromcode,    utf8_string =      u8_conv_from_encoding (fromcode, handler, src, srclen, offsets, -			   NULL, &utf8_length); +                           NULL, &utf8_length);    if (utf8_string == NULL)      return NULL;    result = U8_TO_U (utf8_string, utf8_length, resultbuf, lengthp); @@ -65,25 +65,25 @@ FUNC (const char *fromcode,        size_t length = *lengthp;        size_t *offsets_end = offsets + srclen;        size_t *o; -      size_t off8 = 0;	/* offset into utf8_string */ -      size_t offunit = 0;	/* offset into result */ +      size_t off8 = 0;  /* offset into utf8_string */ +      size_t offunit = 0;       /* offset into result */        for (o = offsets; o < offsets_end; o++) -	if (*o != (size_t)(-1)) -	  { -	    while (off8 < *o) -	      { -		int count8 = u8_mblen (utf8_string + off8, utf8_length - off8); -		int countunit = U_MBLEN (result + offunit, length - offunit); -		if (count8 < 0 || countunit < 0) -		  abort (); -		off8 += count8; -		offunit += countunit; -	      } -	    if (*o != off8) -	      abort (); -	    *o = offunit; -	  } +        if (*o != (size_t)(-1)) +          { +            while (off8 < *o) +              { +                int count8 = u8_mblen (utf8_string + off8, utf8_length - off8); +                int countunit = U_MBLEN (result + offunit, length - offunit); +                if (count8 < 0 || countunit < 0) +                  abort (); +                off8 += count8; +                offunit += countunit; +              } +            if (*o != off8) +              abort (); +            *o = offunit; +          }      }    free (utf8_string);    return result; diff --git a/lib/uniconv/u-conv-to-enc.h b/lib/uniconv/u-conv-to-enc.h index ed715482..43d82c77 100644 --- a/lib/uniconv/u-conv-to-enc.h +++ b/lib/uniconv/u-conv-to-enc.h @@ -1,5 +1,5 @@  /* Conversion from UTF-16/UTF-32 to legacy encodings. -   Copyright (C) 2002, 2006-2009 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published @@ -29,12 +29,12 @@ FUNC (const char *tocode,    if (offsets != NULL && srclen > 0)      {        scaled_offsets = -	(size_t *) malloc (srclen * sizeof (UNIT) * sizeof (size_t)); +        (size_t *) malloc (srclen * sizeof (UNIT) * sizeof (size_t));        if (scaled_offsets == NULL) -	{ -	  errno = ENOMEM; -	  return NULL; -	} +        { +          errno = ENOMEM; +          return NULL; +        }      }    else      scaled_offsets = NULL; @@ -42,9 +42,9 @@ FUNC (const char *tocode,    result = resultbuf;    length = *lengthp;    if (mem_iconveha ((const char *) src, srclen * sizeof (UNIT), -		    UTF_NAME, tocode, -		    handler == iconveh_question_mark, handler, -		    scaled_offsets, &result, &length) < 0) +                    UTF_NAME, tocode, +                    handler == iconveh_question_mark, handler, +                    scaled_offsets, &result, &length) < 0)      {        int saved_errno = errno;        free (scaled_offsets); @@ -55,11 +55,11 @@ FUNC (const char *tocode,    if (offsets != NULL)      {        /* Convert scaled_offsets[srclen * sizeof (UNIT)] to -	 offsets[srclen].  */ +         offsets[srclen].  */        size_t i;        for (i = 0; i < srclen; i++) -	offsets[i] = scaled_offsets[i * sizeof (UNIT)]; +        offsets[i] = scaled_offsets[i * sizeof (UNIT)];        free (scaled_offsets);      } @@ -67,10 +67,10 @@ FUNC (const char *tocode,      {        result = (char *) malloc (1);        if (result == NULL) -	{ -	  errno = ENOMEM; -	  return NULL; -	} +        { +          errno = ENOMEM; +          return NULL; +        }      }    *lengthp = length;    return result; @@ -91,62 +91,62 @@ FUNC (const char *tocode,      {        scaled_offsets = (size_t *) malloc (utf8_srclen * sizeof (size_t));        if (scaled_offsets == NULL) -	{ -	  if (utf8_src != tmpbuf) -	    free (utf8_src); -	  errno = ENOMEM; -	  return NULL; -	} +        { +          if (utf8_src != tmpbuf) +            free (utf8_src); +          errno = ENOMEM; +          return NULL; +        }      }    else      scaled_offsets = NULL;    result = u8_conv_to_encoding (tocode, handler, utf8_src, utf8_srclen, -				scaled_offsets, resultbuf, lengthp); +                                scaled_offsets, resultbuf, lengthp);    if (result == NULL)      {        int saved_errno = errno;        free (scaled_offsets);        if (utf8_src != tmpbuf) -	free (utf8_src); +        free (utf8_src);        errno = saved_errno;        return NULL;      }    if (offsets != NULL)      { -      size_t iunit;	/* offset into src */ -      size_t i8;	/* offset into utf8_src */ +      size_t iunit;     /* offset into src */ +      size_t i8;        /* offset into utf8_src */        for (iunit = 0; iunit < srclen; iunit++) -	offsets[iunit] = (size_t)(-1); +        offsets[iunit] = (size_t)(-1);        iunit = 0;        i8 = 0;        while (iunit < srclen && i8 < utf8_srclen) -	{ -	  int countunit; -	  int count8; - -	  offsets[iunit] = scaled_offsets[i8]; - -	  countunit = U_MBLEN (src + iunit, srclen - iunit); -	  count8 = u8_mblen (utf8_src + i8, utf8_srclen - i8); -	  if (countunit < 0 || count8 < 0) -	    abort (); -	  iunit += countunit; -	  i8 += count8; -	} +        { +          int countunit; +          int count8; + +          offsets[iunit] = scaled_offsets[i8]; + +          countunit = U_MBLEN (src + iunit, srclen - iunit); +          count8 = u8_mblen (utf8_src + i8, utf8_srclen - i8); +          if (countunit < 0 || count8 < 0) +            abort (); +          iunit += countunit; +          i8 += count8; +        }        /* Check that utf8_src has been traversed entirely.  */        if (i8 < utf8_srclen) -	abort (); +        abort ();        /* Check that src has been traversed entirely, except possibly for an -	 incomplete sequence of units at the end.  */ +         incomplete sequence of units at the end.  */        if (iunit < srclen) -	{ -	  offsets[iunit] = *lengthp; -	  if (!(U_MBLEN (src + iunit, srclen - iunit) < 0)) -	    abort (); -	} +        { +          offsets[iunit] = *lengthp; +          if (!(U_MBLEN (src + iunit, srclen - iunit) < 0)) +            abort (); +        }        free (scaled_offsets);      }    if (utf8_src != tmpbuf) diff --git a/lib/uniconv/u-strconv-from-enc.h b/lib/uniconv/u-strconv-from-enc.h index 25813c76..df91c384 100644 --- a/lib/uniconv/u-strconv-from-enc.h +++ b/lib/uniconv/u-strconv-from-enc.h @@ -1,5 +1,5 @@  /* Conversion to UTF-8/UTF-16/UTF-32 from legacy encodings. -   Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published @@ -24,13 +24,13 @@ FUNC (const char *string,    result =      U_CONV_FROM_ENCODING (fromcode, handler, -			  string, strlen (string) + 1, NULL, -			  NULL, &length); +                          string, strlen (string) + 1, NULL, +                          NULL, &length);    if (result == NULL)      return NULL;    /* Verify the result has exactly one NUL unit, at the end.  */    if (!(length > 0 && result[length-1] == 0 -	&& U_STRLEN (result) == length-1)) +        && U_STRLEN (result) == length-1))      {        free (result);        errno = EILSEQ; diff --git a/lib/uniconv/u-strconv-to-enc.h b/lib/uniconv/u-strconv-to-enc.h index b6e6ebb5..c15182f1 100644 --- a/lib/uniconv/u-strconv-to-enc.h +++ b/lib/uniconv/u-strconv-to-enc.h @@ -1,5 +1,5 @@  /* Conversion from UTF-16/UTF-32 to legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published @@ -24,9 +24,9 @@ FUNC (const UNIT *string,    size_t length = 0;    if (mem_iconveha ((const char *) string, (U_STRLEN (string) + 1) * sizeof (UNIT), -		    UTF_NAME, tocode, -		    handler == iconveh_question_mark, handler, -		    NULL, &result, &length) < 0) +                    UTF_NAME, tocode, +                    handler == iconveh_question_mark, handler, +                    NULL, &result, &length) < 0)      return NULL;    /* Verify the result has exactly one NUL byte, at the end.  */    if (!(length > 0 && result[length-1] == '\0' && strlen (result) == length-1)) @@ -49,11 +49,11 @@ FUNC (const UNIT *string,    if (result == NULL)      {        if (utf8_string != tmpbuf) -	{ -	  int saved_errno = errno; -	  free (utf8_string); -	  errno = saved_errno; -	} +        { +          int saved_errno = errno; +          free (utf8_string); +          errno = saved_errno; +        }        return NULL;      }    if (utf8_string != tmpbuf) diff --git a/lib/uniconv/u16-conv-from-enc.c b/lib/uniconv/u16-conv-from-enc.c index f38add30..dc4c21d2 100644 --- a/lib/uniconv/u16-conv-from-enc.c +++ b/lib/uniconv/u16-conv-from-enc.c @@ -1,5 +1,5 @@  /* Conversion to UTF-16 from legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u16-conv-to-enc.c b/lib/uniconv/u16-conv-to-enc.c index ba70736c..cce454d5 100644 --- a/lib/uniconv/u16-conv-to-enc.c +++ b/lib/uniconv/u16-conv-to-enc.c @@ -1,5 +1,5 @@  /* Conversion from UTF-16 to legacy encodings. -   Copyright (C) 2002, 2006-2008 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published @@ -81,69 +81,69 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)        /* Fetch a Unicode character from the input string.  */        count = u16_mbtoucr (&uc, s, s_end - s);        if (count < 0) -	{ -	  if (count == -2) -	    /* Incomplete sequence of units.  */ -	    break; -	  if (!(result == resultbuf || result == NULL)) -	    free (result); -	  errno = EILSEQ; -	  return NULL; -	} +        { +          if (count == -2) +            /* Incomplete sequence of units.  */ +            break; +          if (!(result == resultbuf || result == NULL)) +            free (result); +          errno = EILSEQ; +          return NULL; +        }        s += count;        /* Store it in the output string.  */        count = u8_uctomb (result + length, uc, allocated - length);        if (count == -1) -	{ -	  if (!(result == resultbuf || result == NULL)) -	    free (result); -	  errno = EILSEQ; -	  return NULL; -	} +        { +          if (!(result == resultbuf || result == NULL)) +            free (result); +          errno = EILSEQ; +          return NULL; +        }        if (count == -2) -	{ -	  DST_UNIT *memory; - -	  allocated = (allocated > 0 ? 2 * allocated : 12); -	  if (length + 6 > allocated) -	    allocated = length + 6; -	  if (result == resultbuf || result == NULL) -	    memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT)); -	  else -	    memory = -	      (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT)); - -	  if (memory == NULL) -	    { -	      if (!(result == resultbuf || result == NULL)) -		free (result); -	      errno = ENOMEM; -	      return NULL; -	    } -	  if (result == resultbuf && length > 0) -	    memcpy ((char *) memory, (char *) result, -		    length * sizeof (DST_UNIT)); -	  result = memory; -	  count = u8_uctomb (result + length, uc, allocated - length); -	  if (count < 0) -	    abort (); -	} +        { +          DST_UNIT *memory; + +          allocated = (allocated > 0 ? 2 * allocated : 12); +          if (length + 6 > allocated) +            allocated = length + 6; +          if (result == resultbuf || result == NULL) +            memory = (DST_UNIT *) malloc (allocated * sizeof (DST_UNIT)); +          else +            memory = +              (DST_UNIT *) realloc (result, allocated * sizeof (DST_UNIT)); + +          if (memory == NULL) +            { +              if (!(result == resultbuf || result == NULL)) +                free (result); +              errno = ENOMEM; +              return NULL; +            } +          if (result == resultbuf && length > 0) +            memcpy ((char *) memory, (char *) result, +                    length * sizeof (DST_UNIT)); +          result = memory; +          count = u8_uctomb (result + length, uc, allocated - length); +          if (count < 0) +            abort (); +        }        length += count;      }    if (length == 0)      {        if (result == NULL) -	{ -	  /* Return a non-NULL value.  NULL means error.  */ -	  result = (DST_UNIT *) malloc (1); -	  if (result == NULL) -	    { -	      errno = ENOMEM; -	      return NULL; -	    } -	} +        { +          /* Return a non-NULL value.  NULL means error.  */ +          result = (DST_UNIT *) malloc (1); +          if (result == NULL) +            { +              errno = ENOMEM; +              return NULL; +            } +        }      }    else if (result != resultbuf && length < allocated)      { @@ -152,7 +152,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)        memory = (DST_UNIT *) realloc (result, length * sizeof (DST_UNIT));        if (memory != NULL) -	result = memory; +        result = memory;      }    *lengthp = length; diff --git a/lib/uniconv/u16-strconv-from-enc.c b/lib/uniconv/u16-strconv-from-enc.c index 736d0c4a..ebdd62e0 100644 --- a/lib/uniconv/u16-strconv-from-enc.c +++ b/lib/uniconv/u16-strconv-from-enc.c @@ -1,5 +1,5 @@  /* Conversion to UTF-16 from legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u16-strconv-from-locale.c b/lib/uniconv/u16-strconv-from-locale.c index 63ddeb04..c6695d1f 100644 --- a/lib/uniconv/u16-strconv-from-locale.c +++ b/lib/uniconv/u16-strconv-from-locale.c @@ -1,5 +1,5 @@  /* Conversion to UTF-16 from the locale encoding. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u16-strconv-to-enc.c b/lib/uniconv/u16-strconv-to-enc.c index 10e895e9..c8e00e76 100644 --- a/lib/uniconv/u16-strconv-to-enc.c +++ b/lib/uniconv/u16-strconv-to-enc.c @@ -1,5 +1,5 @@  /* Conversion from UTF-16 to legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u16-strconv-to-locale.c b/lib/uniconv/u16-strconv-to-locale.c index 14fd7b3b..74fcbed3 100644 --- a/lib/uniconv/u16-strconv-to-locale.c +++ b/lib/uniconv/u16-strconv-to-locale.c @@ -1,5 +1,5 @@  /* Conversion from UTF-16 to the locale encoding. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u32-conv-from-enc.c b/lib/uniconv/u32-conv-from-enc.c index bac6301b..f5c6e8e1 100644 --- a/lib/uniconv/u32-conv-from-enc.c +++ b/lib/uniconv/u32-conv-from-enc.c @@ -1,5 +1,5 @@  /* Conversion to UTF-32 from legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u32-conv-to-enc.c b/lib/uniconv/u32-conv-to-enc.c index 9155abaa..7bfc9f46 100644 --- a/lib/uniconv/u32-conv-to-enc.c +++ b/lib/uniconv/u32-conv-to-enc.c @@ -1,5 +1,5 @@  /* Conversion from UTF-32 to legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u32-strconv-from-enc.c b/lib/uniconv/u32-strconv-from-enc.c index aaac74f1..65ff600b 100644 --- a/lib/uniconv/u32-strconv-from-enc.c +++ b/lib/uniconv/u32-strconv-from-enc.c @@ -1,5 +1,5 @@  /* Conversion to UTF-32 from legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u32-strconv-from-locale.c b/lib/uniconv/u32-strconv-from-locale.c index 2cddcb63..103e41b6 100644 --- a/lib/uniconv/u32-strconv-from-locale.c +++ b/lib/uniconv/u32-strconv-from-locale.c @@ -1,5 +1,5 @@  /* Conversion to UTF-32 from the locale encoding. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u32-strconv-to-enc.c b/lib/uniconv/u32-strconv-to-enc.c index c77e0b6e..fd45013e 100644 --- a/lib/uniconv/u32-strconv-to-enc.c +++ b/lib/uniconv/u32-strconv-to-enc.c @@ -1,5 +1,5 @@  /* Conversion from UTF-32 to legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u32-strconv-to-locale.c b/lib/uniconv/u32-strconv-to-locale.c index 64ab59fa..57cc47ed 100644 --- a/lib/uniconv/u32-strconv-to-locale.c +++ b/lib/uniconv/u32-strconv-to-locale.c @@ -1,5 +1,5 @@  /* Conversion from UTF-32 to the locale encoding. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u8-conv-from-enc.c b/lib/uniconv/u8-conv-from-enc.c index 7605e63e..88d666cc 100644 --- a/lib/uniconv/u8-conv-from-enc.c +++ b/lib/uniconv/u8-conv-from-enc.c @@ -1,5 +1,5 @@  /* Conversion to UTF-8 from legacy encodings. -   Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published @@ -31,10 +31,10 @@  uint8_t *  u8_conv_from_encoding (const char *fromcode, -		       enum iconv_ilseq_handler handler, -		       const char *src, size_t srclen, -		       size_t *offsets, -		       uint8_t *resultbuf, size_t *lengthp) +                       enum iconv_ilseq_handler handler, +                       const char *src, size_t srclen, +                       size_t *offsets, +                       uint8_t *resultbuf, size_t *lengthp)  {    if (STRCASEEQ (fromcode, "UTF-8", 'U','T','F','-','8',0,0,0,0))      { @@ -42,40 +42,40 @@ u8_conv_from_encoding (const char *fromcode,        uint8_t *result;        if (u8_check ((const uint8_t *) src, srclen)) -	{ -	  errno = EILSEQ; -	  return NULL; -	} +        { +          errno = EILSEQ; +          return NULL; +        }        if (offsets != NULL) -	{ -	  size_t i; - -	  for (i = 0; i < srclen; ) -	    { -	      int count = u8_mblen ((const uint8_t *) src + i, srclen - i); -	      /* We can rely on count > 0 because of the previous u8_check.  */ -	      if (count <= 0) -		abort (); -	      offsets[i] = i; -	      i++; -	      while (--count > 0) -		offsets[i++] = (size_t)(-1); -	    } -	} +        { +          size_t i; + +          for (i = 0; i < srclen; ) +            { +              int count = u8_mblen ((const uint8_t *) src + i, srclen - i); +              /* We can rely on count > 0 because of the previous u8_check.  */ +              if (count <= 0) +                abort (); +              offsets[i] = i; +              i++; +              while (--count > 0) +                offsets[i++] = (size_t)(-1); +            } +        }        /* Memory allocation.  */        if (resultbuf != NULL && *lengthp >= srclen) -	result = resultbuf; +        result = resultbuf;        else -	{ -	  result = (uint8_t *) malloc (srclen > 0 ? srclen : 1); -	  if (result == NULL) -	    { -	      errno = ENOMEM; -	      return NULL; -	    } -	} +        { +          result = (uint8_t *) malloc (srclen > 0 ? srclen : 1); +          if (result == NULL) +            { +              errno = ENOMEM; +              return NULL; +            } +        }        memcpy ((char *) result, src, srclen);        *lengthp = srclen; @@ -87,18 +87,18 @@ u8_conv_from_encoding (const char *fromcode,        size_t length = *lengthp;        if (mem_iconveha (src, srclen, fromcode, "UTF-8", true, handler, -			offsets, &result, &length) < 0) -	return NULL; +                        offsets, &result, &length) < 0) +        return NULL;        if (result == NULL) /* when (resultbuf == NULL && length == 0)  */ -	{ -	  result = (char *) malloc (1); -	  if (result == NULL) -	    { -	      errno = ENOMEM; -	      return NULL; -	    } -	} +        { +          result = (char *) malloc (1); +          if (result == NULL) +            { +              errno = ENOMEM; +              return NULL; +            } +        }        *lengthp = length;        return (uint8_t *) result;      } diff --git a/lib/uniconv/u8-conv-to-enc.c b/lib/uniconv/u8-conv-to-enc.c index 90acccec..cacf2596 100644 --- a/lib/uniconv/u8-conv-to-enc.c +++ b/lib/uniconv/u8-conv-to-enc.c @@ -1,5 +1,5 @@  /* Conversion from UTF-8 to legacy encodings. -   Copyright (C) 2002, 2006-2007, 2009 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published @@ -31,10 +31,10 @@  char *  u8_conv_to_encoding (const char *tocode, -		     enum iconv_ilseq_handler handler, -		     const uint8_t *src, size_t srclen, -		     size_t *offsets, -		     char *resultbuf, size_t *lengthp) +                     enum iconv_ilseq_handler handler, +                     const uint8_t *src, size_t srclen, +                     size_t *offsets, +                     char *resultbuf, size_t *lengthp)  {    if (STRCASEEQ (tocode, "UTF-8", 'U','T','F','-','8',0,0,0,0))      { @@ -43,24 +43,24 @@ u8_conv_to_encoding (const char *tocode,        /* Conversion from UTF-8 to UTF-8.  No need to go through iconv().  */  #if CONFIG_UNICODE_SAFETY        if (u8_check (src, srclen)) -	{ -	  errno = EILSEQ; -	  return NULL; -	} +        { +          errno = EILSEQ; +          return NULL; +        }  #endif        /* Memory allocation.  */        if (resultbuf != NULL && *lengthp >= srclen) -	result = resultbuf; +        result = resultbuf;        else -	{ -	  result = (char *) malloc (srclen > 0 ? srclen : 1); -	  if (result == NULL) -	    { -	      errno = ENOMEM; -	      return NULL; -	    } -	} +        { +          result = (char *) malloc (srclen > 0 ? srclen : 1); +          if (result == NULL) +            { +              errno = ENOMEM; +              return NULL; +            } +        }        memcpy (result, (const char *) src, srclen);        *lengthp = srclen; @@ -72,20 +72,20 @@ u8_conv_to_encoding (const char *tocode,        size_t length = *lengthp;        if (mem_iconveha ((const char *) src, srclen, -			"UTF-8", tocode, -			handler == iconveh_question_mark, handler, -			offsets, &result, &length) < 0) -	return NULL; +                        "UTF-8", tocode, +                        handler == iconveh_question_mark, handler, +                        offsets, &result, &length) < 0) +        return NULL;        if (result == NULL) /* when (resultbuf == NULL && length == 0)  */ -	{ -	  result = (char *) malloc (1); -	  if (result == NULL) -	    { -	      errno = ENOMEM; -	      return NULL; -	    } -	} +        { +          result = (char *) malloc (1); +          if (result == NULL) +            { +              errno = ENOMEM; +              return NULL; +            } +        }        *lengthp = length;        return result;      } diff --git a/lib/uniconv/u8-strconv-from-enc.c b/lib/uniconv/u8-strconv-from-enc.c index 0f5736fc..e1776661 100644 --- a/lib/uniconv/u8-strconv-from-enc.c +++ b/lib/uniconv/u8-strconv-from-enc.c @@ -1,5 +1,5 @@  /* Conversion to UTF-8 from legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u8-strconv-from-locale.c b/lib/uniconv/u8-strconv-from-locale.c index a901a3d6..e149ce3a 100644 --- a/lib/uniconv/u8-strconv-from-locale.c +++ b/lib/uniconv/u8-strconv-from-locale.c @@ -1,5 +1,5 @@  /* Conversion to UTF-8 from the locale encoding. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published diff --git a/lib/uniconv/u8-strconv-to-enc.c b/lib/uniconv/u8-strconv-to-enc.c index a3f12b6b..d593cf1b 100644 --- a/lib/uniconv/u8-strconv-to-enc.c +++ b/lib/uniconv/u8-strconv-to-enc.c @@ -1,5 +1,5 @@  /* Conversion from UTF-8 to legacy encodings. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published @@ -31,8 +31,8 @@  char *  u8_strconv_to_encoding (const uint8_t *string, -			const char *tocode, -			enum iconv_ilseq_handler handler) +                        const char *tocode, +                        enum iconv_ilseq_handler handler)  {    char *result;    size_t length; @@ -43,17 +43,17 @@ u8_strconv_to_encoding (const uint8_t *string,        length = u8_strlen (string) + 1;  #if CONFIG_UNICODE_SAFETY        if (u8_check (string, length)) -	{ -	  errno = EILSEQ; -	  return NULL; -	} +        { +          errno = EILSEQ; +          return NULL; +        }  #endif        result = (char *) malloc (length);        if (result == NULL) -	{ -	  errno = ENOMEM; -	  return NULL; -	} +        { +          errno = ENOMEM; +          return NULL; +        }        memcpy (result, (const char *) string, length);        return result;      } @@ -62,18 +62,18 @@ u8_strconv_to_encoding (const uint8_t *string,        result = NULL;        length = 0;        if (mem_iconveha ((const char *) string, u8_strlen (string) + 1, -			"UTF-8", tocode, -			handler == iconveh_question_mark, handler, -			NULL, &result, &length) < 0) -	return NULL; +                        "UTF-8", tocode, +                        handler == iconveh_question_mark, handler, +                        NULL, &result, &length) < 0) +        return NULL;        /* Verify the result has exactly one NUL byte, at the end.  */        if (!(length > 0 && result[length-1] == '\0' -	    && strlen (result) == length-1)) -	{ -	  free (result); -	  errno = EILSEQ; -	  return NULL; -	} +            && strlen (result) == length-1)) +        { +          free (result); +          errno = EILSEQ; +          return NULL; +        }        return result;      }  } diff --git a/lib/uniconv/u8-strconv-to-locale.c b/lib/uniconv/u8-strconv-to-locale.c index 27c45fbf..8bdc812f 100644 --- a/lib/uniconv/u8-strconv-to-locale.c +++ b/lib/uniconv/u8-strconv-to-locale.c @@ -1,5 +1,5 @@  /* Conversion from UTF-8 to the locale encoding. -   Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc. +   Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.     This program is free software: you can redistribute it and/or modify it     under the terms of the GNU Lesser General Public License as published | 
