Back to index

glibc  2.9
Functions | Variables
tst-gettext5.c File Reference
#include <libintl.h>
#include <locale.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Go to the source code of this file.

Functions

static void waitfor (int value)
static void setto (int value)
void * thread1_execution (void *arg)
void * thread2_execution (void *arg)
int main (void)

Variables

int result
int flipflop
pthread_mutex_t lock
pthread_cond_t waitqueue

Function Documentation

int main ( void  )

Definition at line 132 of file tst-gettext5.c.

{
  pthread_t thread1;
  pthread_t thread2;

  unsetenv ("LANGUAGE");
  unsetenv ("OUTPUT_CHARSET");
  textdomain ("codeset");
  bindtextdomain ("codeset", OBJPFX "domaindir");
  result = 0;

  flipflop = 1;
  if (pthread_mutex_init (&lock, NULL))
    exit (2);
  if (pthread_cond_init (&waitqueue, NULL))
    exit (2);
  if (pthread_create (&thread1, NULL, &thread1_execution, NULL))
    exit (2);
  if (pthread_create (&thread2, NULL, &thread2_execution, NULL))
    exit (2);
  if (pthread_join (thread2, NULL))
    exit (3);

  return result;
}

Here is the call graph for this function:

static void setto ( int  value) [static]

Definition at line 54 of file tst-gettext5.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void* thread1_execution ( void *  arg)

Definition at line 64 of file tst-gettext5.c.

{
  char *s;

  waitfor (1);
  uselocale (newlocale (LC_ALL_MASK, "de_DE.ISO-8859-1", NULL));
  setto (2);

  /* Here we expect output in ISO-8859-1.  */

  waitfor (1);
  s = gettext ("cheese");
  puts (s);
  if (strcmp (s, "K\344se"))
    {
      fprintf (stderr, "thread 1 call 1 returned: %s\n", s);
      result = 1;
    }
  setto (2);

  waitfor (1);
  s = gettext ("cheese");
  puts (s);
  if (strcmp (s, "K\344se"))
    {
      fprintf (stderr, "thread 1 call 2 returned: %s\n", s);
      result = 1;
    }
  setto (2);

  return NULL;
}

Here is the call graph for this function:

void* thread2_execution ( void *  arg)

Definition at line 98 of file tst-gettext5.c.

{
  char *s;

  waitfor (2);
  uselocale (newlocale (LC_ALL_MASK, "de_DE.UTF-8", NULL));
  setto (1);

  /* Here we expect output in UTF-8.  */

  waitfor (2);
  s = gettext ("cheese");
  puts (s);
  if (strcmp (s, "K\303\244se"))
    {
      fprintf (stderr, "thread 2 call 1 returned: %s\n", s);
      result = 1;
    }
  setto (1);

  waitfor (2);
  s = gettext ("cheese");
  puts (s);
  if (strcmp (s, "K\303\244se"))
    {
      fprintf (stderr, "thread 2 call 2 returned: %s\n", s);
      result = 1;
    }
  setto (1);

  return NULL;
}

Here is the call graph for this function:

static void waitfor ( int  value) [static]

Definition at line 42 of file tst-gettext5.c.

{
  if (pthread_mutex_lock (&lock))
    exit (10);
  while (flipflop != value)
    if (pthread_cond_wait (&waitqueue, &lock))
      exit (11);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 34 of file tst-gettext5.c.

Definition at line 36 of file tst-gettext5.c.

Definition at line 31 of file tst-gettext5.c.

Definition at line 37 of file tst-gettext5.c.