+2009-02-22 Bruno Haible <bruno@clisp.org>
+
+ * lib/uninorm/u-normalize-internal.h (FUNC): At the end, handle
+ zero-length results and shrink excess allocated memory.
+ * tests/uninorm/test-u8-nfc.c (test_u8_nfc): Check empty string result.
+ * tests/uninorm/test-u8-nfd.c (test_u8_nfd): Likewise.
+ * tests/uninorm/test-u8-nfkc.c (test_u8_nfkc): Likewise.
+ * tests/uninorm/test-u8-nfkd.c (test_u8_nfkd): Likewise.
+ * tests/uninorm/test-u16-nfc.c (test_u16_nfc): Likewise.
+ * tests/uninorm/test-u16-nfd.c (test_u16_nfd): Likewise.
+ * tests/uninorm/test-u16-nfkc.c (test_u16_nfkc): Likewise.
+ * tests/uninorm/test-u16-nfkd.c (test_u16_nfkd): Likewise.
+ * tests/uninorm/test-u32-nfc.c (test_u32_nfc): Likewise.
+ * tests/uninorm/test-u32-nfd.c (test_u32_nfd): Likewise.
+ * tests/uninorm/test-u32-nfkc.c (test_u32_nfkc): Likewise.
+ * tests/uninorm/test-u32-nfkd.c (test_u32_nfkd): Likewise.
+
2009-02-21 Bruno Haible <bruno@clisp.org>
* doc/gnulib.texi: Include safe-alloc.texi earlier.
}
}
+ if (length == 0)
+ {
+ if (result == NULL)
+ {
+ /* Return a non-NULL value. NULL means error. */
+ result = (UNIT *) malloc (1);
+ if (result == NULL)
+ {
+ errno = ENOMEM;
+ goto fail;
+ }
+ }
+ }
+ else if (result != resultbuf && length < allocated)
+ {
+ /* Shrink the allocated memory if possible. */
+ UNIT *memory;
+
+ memory = (UNIT *) realloc (result, length * sizeof (UNIT));
+ if (memory != NULL)
+ result = memory;
+ }
+
if (sortbuf_count > 0)
abort ();
if (sortbuf != sortbuf_preallocated)
void
test_u16_nfc (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint16_t input[] = { 0x0020 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u16_nfd (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint16_t input[] = { 0x0020 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u16_nfkc (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint16_t input[] = { 0x0020 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u16_nfkd (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint16_t input[] = { 0x0020 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u32_nfc (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint32_t input[] = { 0x0020 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u32_nfd (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint32_t input[] = { 0x0020 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u32_nfkc (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint32_t input[] = { 0x0020 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u32_nfkd (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint32_t input[] = { 0x0020 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u8_nfc (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint8_t input[] = { 0x20 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u8_nfd (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint8_t input[] = { 0x20 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u8_nfkc (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint8_t input[] = { 0x20 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);
void
test_u8_nfkd (void)
{
+ { /* Empty string. */
+ ASSERT (check (NULL, 0, NULL, 0) == 0);
+ }
{ /* SPACE */
static const uint8_t input[] = { 0x20 };
ASSERT (check (input, SIZEOF (input), input, SIZEOF (input)) == 0);