This source file includes following definitions.
- defaulted_getenv
- print_category
- main
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 #include <config.h>
  20 
  21 #include <locale.h>
  22 #include <stdio.h>
  23 #include <stdlib.h>
  24 
  25 
  26 
  27 #undef setlocale
  28 
  29 
  30 
  31 
  32 
  33 static const char *
  34 defaulted_getenv (const char *variable)
     
  35 {
  36   const char *value = getenv (variable);
  37   return (value != NULL ? value : "");
  38 }
  39 
  40 static void
  41 print_category (int category, const char *variable)
     
  42 {
  43   const char *value = defaulted_getenv (variable);
  44   if (value[0] != '\0' && defaulted_getenv ("LC_ALL")[0] == '\0')
  45     
  46     printf ("%s=%s\n", variable, value);
  47   else
  48     printf ("%s=\"%s\"\n", variable, setlocale (category, NULL));
  49 }
  50 
  51 int
  52 main (void)
     
  53 {
  54   setlocale (LC_ALL, "");
  55 
  56   printf ("LANG=%s\n", defaulted_getenv ("LANG"));
  57   print_category (LC_CTYPE, "LC_CTYPE");
  58   print_category (LC_NUMERIC, "LC_NUMERIC");
  59   print_category (LC_TIME, "LC_TIME");
  60   print_category (LC_COLLATE, "LC_COLLATE");
  61   print_category (LC_MONETARY, "LC_MONETARY");
  62   print_category (LC_MESSAGES, "LC_MESSAGES");
  63 #ifdef LC_PAPER
  64   print_category (LC_PAPER, "LC_PAPER");
  65 #endif
  66 #ifdef LC_NAME
  67   print_category (LC_NAME, "LC_NAME");
  68 #endif
  69 #ifdef LC_ADDRESS
  70   print_category (LC_ADDRESS, "LC_ADDRESS");
  71 #endif
  72 #ifdef LC_TELEPHONE
  73   print_category (LC_TELEPHONE, "LC_TELEPHONE");
  74 #endif
  75 #ifdef LC_MEASUREMENT
  76   print_category (LC_MEASUREMENT, "LC_MEASUREMENT");
  77 #endif
  78 #ifdef LC_IDENTIFICATION
  79   print_category (LC_IDENTIFICATION, "LC_IDENTIFICATION");
  80 #endif
  81 
  82   printf ("LC_ALL=%s\n", defaulted_getenv ("LC_ALL"));
  83 
  84   return 0;
  85 }