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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [string/] [wcsnlen.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
        <<wcsnlen>>---get fixed-size wide-character string length
4
 
5
INDEX
6
        wcsnlen
7
 
8
ANSI_SYNOPSIS
9
        #include <wchar.h>
10
        size_t wcsnlen(const wchar_t *<[s]>, size_t <[maxlen]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <wchar.h>
14
        size_t wcsnlen(<[s]>, <[maxlen]>)
15
        wchar_t *<[s]>;
16
        size_t <[maxlen]>;
17
 
18
DESCRIPTION
19
        The <<wcsnlen>> function computes the number of wide-character codes
20
        in the wide-character string pointed to by <[s]> not including the
21
        terminating L'\0' wide character but at most <[maxlen]> wide
22
        characters.
23
 
24
RETURNS
25
        <<wcsnlen>> returns the length of <[s]> if it is less then <[maxlen]>,
26
        or <[maxlen]> if there is no L'\0' wide character in first <[maxlen]>
27
        characters.
28
 
29
PORTABILITY
30
<<wcsnlen>> is a GNU extension.
31
 
32
<<wcsnlen>> requires no supporting OS subroutines.
33
*/
34
 
35
/*
36
 * Copyright (c) 2003, Artem B. Bityuckiy (dedekind@mail.ru).
37
 *
38
 * Redistribution and use in source and binary forms, with or without
39
 * modification, are permitted provided that the above copyright notice,
40
 * this condition statement, and the following disclaimer are retained
41
 * in any redistributions of the source code.
42
 *
43
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
44
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
47
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
53
 * SUCH DAMAGE.
54
 */
55
 
56
#include <_ansi.h>
57
#include <sys/types.h>
58
#include <wchar.h>
59
 
60
size_t
61
_DEFUN(wcsnlen, (s, maxlen),
62
                 _CONST wchar_t *s _AND
63
                 size_t maxlen)
64
{
65
  _CONST wchar_t *p;
66
 
67
  p = s;
68
  while (*p && maxlen-- > 0)
69
    p++;
70
 
71
  return (size_t)(p - s);
72
}
73
 
74
 
75
 

powered by: WebSVN 2.1.0

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