Move to u8-mbtouc-aux.c.
[gnulib.git] / lib / unistr / u8-to-u16.c
index 941db54..734c25b 100644 (file)
@@ -1,5 +1,5 @@
 /* Convert UTF-8 string to UTF-16 string.
-   Copyright (C) 2002, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2006-2007 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
@@ -60,7 +60,7 @@ 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_safe (&uc, s, s_end - s);
+      count = u8_mbtouc (&uc, s, s_end - s);
       if (count < 0)
        {
          if (!(result == resultbuf || result == NULL))
@@ -71,7 +71,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
       s += count;
 
       /* Store it in the output string.  */
-      count = u16_uctomb (result, uc, allocated - length);
+      count = u16_uctomb (result + length, uc, allocated - length);
       if (count == -1)
        {
          if (!(result == resultbuf || result == NULL))
@@ -103,7 +103,7 @@ FUNC (const SRC_UNIT *s, size_t n, DST_UNIT *resultbuf, size_t *lengthp)
            memcpy ((char *) memory, (char *) result,
                    length * sizeof (DST_UNIT));
          result = memory;
-         count = u16_uctomb (result, uc, allocated - length);
+         count = u16_uctomb (result + length, uc, allocated - length);
          if (count < 0)
            abort ();
        }