OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [string/] [wcwidth.c] - Diff between revs 148 and 158

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 148 Rev 158
/*
/*
FUNCTION
FUNCTION
        <<wcwidth>>---number of column positions of a wide-character code
        <<wcwidth>>---number of column positions of a wide-character code
 
 
INDEX
INDEX
        wcwidth
        wcwidth
 
 
ANSI_SYNOPSIS
ANSI_SYNOPSIS
        #include <wchar.h>
        #include <wchar.h>
        int wcwidth(const wchar_t <[wc]>);
        int wcwidth(const wchar_t <[wc]>);
 
 
TRAD_SYNOPSIS
TRAD_SYNOPSIS
        #include <wchar.h>
        #include <wchar.h>
        int wcwidth(<[wc]>)
        int wcwidth(<[wc]>)
        wchar_t *<[wc]>;
        wchar_t *<[wc]>;
 
 
DESCRIPTION
DESCRIPTION
        The <<wcwidth>> function shall determine the number of column
        The <<wcwidth>> function shall determine the number of column
        positions required for the wide character <[wc]>. The application
        positions required for the wide character <[wc]>. The application
        shall ensure that the value of <[wc]> is a character representable
        shall ensure that the value of <[wc]> is a character representable
        as a wchar_t, and is a wide-character code corresponding to a
        as a wchar_t, and is a wide-character code corresponding to a
        valid character in the current locale.
        valid character in the current locale.
 
 
RETURNS
RETURNS
        The <<wcwidth>> function shall either return 0 (if <[wc]> is a null
        The <<wcwidth>> function shall either return 0 (if <[wc]> is a null
        wide-character code), or return the number of column positions to
        wide-character code), or return the number of column positions to
        be occupied by the wide-character code <[wc]>, or return -1 (if <[wc]>
        be occupied by the wide-character code <[wc]>, or return -1 (if <[wc]>
        does not correspond to a printable wide-character code).
        does not correspond to a printable wide-character code).
 
 
        The current implementation of <<wcwidth>> simply sets the width
        The current implementation of <<wcwidth>> simply sets the width
        of all printable characters to 1 since newlib has no character
        of all printable characters to 1 since newlib has no character
        tables around.
        tables around.
 
 
PORTABILITY
PORTABILITY
<<wcwidth>> has been introduced in the Single UNIX Specification Volume 2.
<<wcwidth>> has been introduced in the Single UNIX Specification Volume 2.
<<wcwidth>> has been marked as an extension in the Single UNIX Specification Volume 3.
<<wcwidth>> has been marked as an extension in the Single UNIX Specification Volume 3.
*/
*/
 
 
#include <_ansi.h>
#include <_ansi.h>
#include <wchar.h>
#include <wchar.h>
#include <wctype.h>
#include <wctype.h>
 
 
int
int
_DEFUN (wcwidth, (wc),
_DEFUN (wcwidth, (wc),
        _CONST wchar_t wc)
        _CONST wchar_t wc)
 
 
{
{
  if (iswprint (wc))
  if (iswprint (wc))
    return 1;
    return 1;
  if (iswcntrl (wc) || wc == L'\0')
  if (iswcntrl (wc) || wc == L'\0')
    return 0;
    return 0;
  return -1;
  return -1;
}
}
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.