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/] [wcswidth.c] - Blame information for rev 455

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
        <<wcswidth>>---number of column positions of a wide-character string
4
 
5
INDEX
6
        wcswidth
7
 
8
ANSI_SYNOPSIS
9
        #include <wchar.h>
10
        int wcswidth(const wchar_t *<[pwcs]>, size_t <[n]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <wchar.h>
14
        int wcswidth(<[pwcs]>, <[n]>)
15
        wchar_t *<[wc]>;
16
        size_t <[n]>;
17
 
18
DESCRIPTION
19
        The <<wcswidth>> function shall determine the number of column
20
        positions required for <[n]> wide-character codes (or fewer than <[n]>
21
        wide-character codes if a null wide-character code is encountered
22
        before <[n]> wide-character codes are exhausted) in the string pointed
23
        to by <[pwcs]>.
24
 
25
RETURNS
26
        The <<wcswidth>> function either shall return 0 (if <[pwcs]> points to a
27
        null wide-character code), or return the number of column positions
28
        to be occupied by the wide-character string pointed to by <[pwcs]>, or
29
        return -1 (if any of the first <[n]> wide-character codes in the
30
        wide-character string pointed to by <[pwcs]> is not a printable
31
        wide-character code).
32
 
33
PORTABILITY
34
<<wcswidth>> has been introduced in the Single UNIX Specification Volume 2.
35
<<wcswidth>> has been marked as an extension in the Single UNIX Specification Volume 3.
36
*/
37
 
38
#include <_ansi.h>
39
#include <wchar.h>
40
 
41
int
42
_DEFUN (wcswidth, (pwcs, n),
43
        _CONST wchar_t *pwcs _AND
44
        size_t n)
45
 
46
{
47
  int w, len = 0;
48
  if (!pwcs || n == 0)
49
    return 0;
50
  do {
51
    if ((w = wcwidth (*pwcs)) < 0)
52
      return -1;
53
    len += w;
54
  } while (*pwcs++ && --n > 0);
55
  return len;
56
}

powered by: WebSVN 2.1.0

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