/* PSPP - a program for statistical analysis.
- Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009, 2010, 2012, 2014 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <string.h>
#include "libpspp/compiler.h"
+#include "libpspp/i18n.h"
#include "libpspp/str.h"
\f
/* Exit with a failure code.
If not, prints a message citing the calling line number and
terminates. */
#define check(EXPR) check_func ((EXPR), __LINE__)
-
-/* Prints a message about memory exhaustion and exits with a
- failure code. */
-static void
-xalloc_die (void)
-{
- printf ("virtual memory exhausted\n");
- exit (EXIT_FAILURE);
-}
-
-static void *xmalloc (size_t n) MALLOC_LIKE;
-static void *xnmalloc (size_t n, size_t m) MALLOC_LIKE;
-static void *xmemdup (const void *p, size_t n) MALLOC_LIKE;
-
-/* Allocates and returns N bytes of memory. */
-static void *
-xmalloc (size_t n)
-{
- if (n != 0)
- {
- void *p = malloc (n);
- if (p == NULL)
- xalloc_die ();
-
- return p;
- }
- else
- return NULL;
-}
-
-static void *
-xmemdup (const void *p, size_t n)
-{
- void *q = xmalloc (n);
- memcpy (q, p, n);
- return q;
-}
-
-/* Clone STRING. */
-static char *
-xstrdup (const char *string)
-{
- return xmemdup (string, strlen (string) + 1);
-}
-
-/* Allocates and returns N * M bytes of memory. */
-static void *
-xnmalloc (size_t n, size_t m)
-{
- if ((size_t) -1 / m <= n)
- xalloc_die ();
- return xmalloc (n * m);
-}
\f
/* Support routines. */
if (*s == NULL)
{
*s = xmalloc (16);
- str_format_26adic (value + 1, *s, 16);
+ str_format_26adic (value + 1, true, *s, 16);
}
return *s;
}
node = stringi_set_find_node (set, string);
check (node != NULL);
- check (!strcasecmp (string, stringi_set_node_get_string (node)));
+ check (!utf8_strcasecmp (string, stringi_set_node_get_string (node)));
}
/* Checks that SET contains the CNT strings in DATA, that its structure is
check (s == array[i]);
for (j = 0; j < left; j++)
- if (!strcasecmp (s, make_string (data_copy[j])))
+ if (!utf8_strcasecmp (s, make_string (data_copy[j])))
{
data_copy[j] = data_copy[--left];
goto next;
for (i = 0; i < cnt; i++)
{
if (i > 0)
- check (strcasecmp (array[i - 1], array[i]) < 0);
+ check (utf8_strcasecmp (array[i - 1], array[i]) < 0);
check (stringi_set_contains (set, array[i]));
}
free (array);