2000-09-07 05:49:56 +02:00
|
|
|
#include <mcheck.h>
|
|
|
|
#include <nl_types.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
|
|
static const char *msgs[] =
|
|
|
|
{
|
|
|
|
#define INPUT(str)
|
|
|
|
#define OUTPUT(str) str,
|
|
|
|
#include <intl/msgs.h>
|
|
|
|
};
|
|
|
|
#define nmsgs (sizeof (msgs) / sizeof (msgs[0]))
|
|
|
|
|
|
|
|
#define ROUNDS 5
|
|
|
|
|
|
|
|
int
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
int rnd;
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
mtrace ();
|
|
|
|
|
|
|
|
/* We do this a few times to stress the memory handling. */
|
|
|
|
for (rnd = 0; rnd < ROUNDS; ++rnd)
|
|
|
|
{
|
|
|
|
nl_catd cd = catopen ("libc", 0);
|
2002-09-24 06:24:25 +02:00
|
|
|
size_t cnt;
|
2000-09-07 05:49:56 +02:00
|
|
|
|
|
|
|
if (cd == (nl_catd) -1)
|
|
|
|
{
|
|
|
|
printf ("cannot load catalog: %m\n");
|
|
|
|
result = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Go through all the messages and compare the result. */
|
|
|
|
for (cnt = 0; cnt < nmsgs; ++cnt)
|
|
|
|
{
|
|
|
|
char *trans;
|
|
|
|
|
|
|
|
trans = catgets (cd, 1, 1 + cnt,
|
2002-07-17 02:03:55 +02:00
|
|
|
"+#+# if this comes backs it's an error");
|
2000-09-07 05:49:56 +02:00
|
|
|
|
|
|
|
if (trans == NULL)
|
|
|
|
{
|
2002-09-30 09:47:16 +02:00
|
|
|
printf ("catgets return NULL for %zd\n", cnt);
|
2000-09-07 05:49:56 +02:00
|
|
|
result = 1;
|
|
|
|
}
|
2002-07-17 02:03:55 +02:00
|
|
|
else if (strcmp (trans, msgs[cnt]) != 0 && msgs[cnt][0] != '\0')
|
2000-09-07 05:49:56 +02:00
|
|
|
{
|
|
|
|
printf ("expected \"%s\", got \"%s\"\n", msgs[cnt], trans);
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (catclose (cd) != 0)
|
|
|
|
{
|
|
|
|
printf ("catclose failed: %m\n");
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|