Print this page
2964 need POSIX 2008 locale object support


  48 
  49 /*
  50  * See the comments in usr/src/cmd/localedef/collate.c for further
  51  * information.  It would also be very helpful to have a copy of the
  52  * POSIX standard for collation (in the locale format manual page)
  53  * handy (www.opengroup.org).
  54  */
  55 
  56 static collate_subst_t          *subst_table[COLL_WEIGHTS_MAX];
  57 static collate_char_t           *char_pri_table;
  58 static collate_large_t          *large_pri_table;
  59 static collate_chain_t          *chain_pri_table;
  60 static char                     *cache = NULL;
  61 static size_t                   cachesz;
  62 static char                     collate_encoding[ENCODING_LEN + 1];
  63 
  64 /* Exposed externally to other parts of libc. */
  65 collate_info_t                  *_collate_info;
  66 int _collate_load_error = 1;
  67 
































  68 
  69 int
  70 _collate_load_tables(const char *encoding)
  71 {
  72         int i, chains, z;
  73         char buf[PATH_MAX];
  74         char *TMP;
  75         char *map;
  76         collate_info_t *info;
  77         struct stat sbuf;
  78         int fd;
  79 
  80         /* 'encoding' must be already checked. */
  81         if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) {
  82                 _collate_load_error = 1;
  83                 return (_LDP_CACHE);
  84         }
  85 
  86         /*
  87          * If the locale name is the same as our cache, use the cache.




  48 
  49 /*
  50  * See the comments in usr/src/cmd/localedef/collate.c for further
  51  * information.  It would also be very helpful to have a copy of the
  52  * POSIX standard for collation (in the locale format manual page)
  53  * handy (www.opengroup.org).
  54  */
  55 
  56 static collate_subst_t          *subst_table[COLL_WEIGHTS_MAX];
  57 static collate_char_t           *char_pri_table;
  58 static collate_large_t          *large_pri_table;
  59 static collate_chain_t          *chain_pri_table;
  60 static char                     *cache = NULL;
  61 static size_t                   cachesz;
  62 static char                     collate_encoding[ENCODING_LEN + 1];
  63 
  64 /* Exposed externally to other parts of libc. */
  65 collate_info_t                  *_collate_info;
  66 int _collate_load_error = 1;
  67 
  68 struct xlocale_collate __xlocale_global_collate = {
  69         {{0}, "C"}, 1, 0
  70 };
  71 
  72 struct xlocale_collate __xlocale_C_collate = {
  73         {{0}, "C"}, 1, 0
  74 };
  75 
  76 static void
  77 destruct_collate(void *t)
  78 {
  79         struct xlocale_collate *table = t;
  80 
  81         /* XXX */;
  82 }
  83 
  84 void *
  85 __collate_load(const char *encoding, locale_t unused)
  86 {
  87         struct xlocale_collate *table;
  88 
  89         if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) {
  90                 return &__xlocale_C_collate;
  91         }
  92 
  93         table = calloc(sizeof(struct xlocale_collate), 1);
  94         if (table == NULL) {
  95                 /* XXX */
  96         }
  97 
  98         return (table);
  99 }
 100 
 101 int
 102 _collate_load_tables(const char *encoding)
 103 {
 104         int i, chains, z;
 105         char buf[PATH_MAX];
 106         char *TMP;
 107         char *map;
 108         collate_info_t *info;
 109         struct stat sbuf;
 110         int fd;
 111 
 112         /* 'encoding' must be already checked. */
 113         if (strcmp(encoding, "C") == 0 || strcmp(encoding, "POSIX") == 0) {
 114                 _collate_load_error = 1;
 115                 return (_LDP_CACHE);
 116         }
 117 
 118         /*
 119          * If the locale name is the same as our cache, use the cache.