Print this page
2964 need POSIX 2008 locale object support

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/locale/setrunelocale.c
          +++ new/usr/src/lib/libc/port/locale/setrunelocale.c
   1    1  /*
   2    2   * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
   3    3   * Copyright (c) 1993
   4    4   *      The Regents of the University of California.  All rights reserved.
   5    5   *
   6    6   * This code is derived from software contributed to Berkeley by
   7    7   * Paul Borman at Krystal Technologies.
   8    8   *
        9 + * Copyright (c) 2011 The FreeBSD Foundation
       10 + * All rights reserved.
       11 + * Portions of this software were developed by David Chisnall
       12 + * under sponsorship from the FreeBSD Foundation.
       13 + *
   9   14   * Redistribution and use in source and binary forms, with or without
  10   15   * modification, are permitted provided that the following conditions
  11   16   * are met:
  12   17   * 1. Redistributions of source code must retain the above copyright
  13   18   *    notice, this list of conditions and the following disclaimer.
  14   19   * 2. Redistributions in binary form must reproduce the above copyright
  15   20   *    notice, this list of conditions and the following disclaimer in the
  16   21   *    documentation and/or other materials provided with the distribution.
  17   22   * 4. Neither the name of the University nor the names of its contributors
  18   23   *    may be used to endorse or promote products derived from this software
↓ open down ↓ 21 lines elided ↑ open up ↑
  40   45  #include <stdlib.h>
  41   46  #include <unistd.h>
  42   47  #include <wchar.h>
  43   48  #include "runetype.h"
  44   49  #include "ldpart.h"
  45   50  #include "mblocal.h"
  46   51  #include "setlocale.h"
  47   52  #include "_ctype.h"
  48   53  #include "../i18n/_locale.h"
  49   54  
       55 +/*
       56 + * A cached version of the runes for this thread.  Used by ctype.h
       57 + */
       58 +__thread const _RuneLocale *_ThreadRuneLocale;
       59 +
  50   60  extern _RuneLocale      *_Read_RuneMagi(FILE *);
  51   61  extern unsigned char    __ctype_C[];
  52   62  
  53   63  static int              __setrunelocale(const char *);
  54   64  
  55   65  static int
  56   66  __setrunelocale(const char *encoding)
  57   67  {
  58   68          FILE *fp;
  59   69          char name[PATH_MAX];
↓ open down ↓ 183 lines elided ↑ open up ↑
 243  253  __wrap_setrunelocale(const char *locale)
 244  254  {
 245  255          int ret = __setrunelocale(locale);
 246  256  
 247  257          if (ret != 0) {
 248  258                  errno = ret;
 249  259                  return (_LDP_ERROR);
 250  260          }
 251  261          return (_LDP_LOADED);
 252  262  }
      263 +
      264 +void
      265 +__set_thread_rune_locale(locale_t loc)
      266 +{
      267 +
      268 +        if (loc == NULL) {
      269 +                _ThreadRuneLocale = &_DefaultRuneLocale;
      270 +        } else {
      271 +                _ThreadRuneLocale = XLOCALE_CTYPE(loc)->runes;
      272 +        }
      273 +}
      274 +
      275 +void *
      276 +__ctype_load(const char *locale, locale_t unused)
      277 +{
      278 +        struct xlocale_ctype *l;
      279 +
      280 +        l = calloc(sizeof(struct xlocale_ctype), 1);
      281 +        /* XXX */
      282 +
      283 +        return (l);
      284 +}
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX