Print this page
2964 need POSIX 2008 locale object support
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Approved by: TBD

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libc/port/locale/fputwc.c
          +++ new/usr/src/lib/libc/port/locale/fputwc.c
   1    1  /*
        2 + * Copyright 2013 Garrett D'Amore <garrett@damore.org>
   2    3   * Copyright (c) 2002-2004 Tim J. Robbins.
   3    4   * All rights reserved.
   4    5   *
   5    6   * Redistribution and use in source and binary forms, with or without
   6    7   * modification, are permitted provided that the following conditions
   7    8   * are met:
   8    9   * 1. Redistributions of source code must retain the above copyright
   9   10   *    notice, this list of conditions and the following disclaimer.
  10   11   * 2. Redistributions in binary form must reproduce the above copyright
  11   12   *    notice, this list of conditions and the following disclaimer in the
↓ open down ↓ 53 lines elided ↑ open up ↑
  65   66          size_t          i, len;
  66   67          rmutex_t        *mx;
  67   68  
  68   69          /* If we are given WEOF, then we have to stop */
  69   70          if (wc == WEOF)
  70   71                  return (WEOF);
  71   72  
  72   73          if (MB_CUR_MAX == 1 && wc > 0 && wc <= UCHAR_MAX) {
  73   74                  /*
  74   75                   * Assume single-byte locale with no special encoding.
  75      -                 * A more careful test would be to check
  76      -                 * _CurrentRuneLocale->encoding.
  77   76                   */
  78   77                  *buf = (unsigned char)wc;
  79   78                  len = 1;
  80   79          } else {
  81   80                  /*
  82   81                   * FreeBSD used restartable wcrtomb.  I think we can use
  83   82                   * the simpler wctomb form here.  We should have a complete
  84   83                   * decode.
  85   84                   */
  86   85                  if ((len = wctomb(buf, wc)) == (size_t)-1) {
↓ open down ↓ 52 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX