summaryrefslogtreecommitdiff
path: root/lib/unistr/u8-to-u32.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unistr/u8-to-u32.c')
-rw-r--r--lib/unistr/u8-to-u32.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/lib/unistr/u8-to-u32.c b/lib/unistr/u8-to-u32.c
index 2a0ad39..de2a35e 100644
--- a/lib/unistr/u8-to-u32.c
+++ b/lib/unistr/u8-to-u32.c
@@ -1,5 +1,5 @@
/* Convert UTF-8 string to UTF-32 string.
- Copyright (C) 2002, 2006-2007 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2006-2007, 2009-2010 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2002.
This program is free software: you can redistribute it and/or modify it
@@ -58,57 +58,57 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
int count;
/* Fetch a Unicode character from the input string. */
- count = u8_mbtouc (&uc, s, s_end - s);
+ count = u8_mbtoucr (&uc, s, s_end - s);
if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- errno = EILSEQ;
- return NULL;
- }
+ {
+ if (!(result == resultbuf || result == NULL))
+ free (result);
+ errno = EILSEQ;
+ return NULL;
+ }
s += count;
/* Store it in the output string. */
if (length + 1 > allocated)
- {
- DST_UNIT *memory;
-
- allocated = (allocated > 0 ? 2 * allocated : 12);
- if (length + 1 > allocated)
- allocated = length + 1;
- 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;
- }
+ {
+ DST_UNIT *memory;
+
+ allocated = (allocated > 0 ? 2 * allocated : 12);
+ if (length + 1 > allocated)
+ allocated = length + 1;
+ 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;
+ }
result[length++] = uc;
}
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)
{
@@ -117,7 +117,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;