3 <<wcsnlen>>---get fixed-size wide character string length
10 size_t wcsnlen(const wchar_t *<[s]>, size_t <[maxlen]>);
14 size_t wcsnlen(<[s]>, <[maxlen]>)
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
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]>
30 <<wcsnlen>> is GNU extension..
31 <<wcsnlen>> requires no supporting OS subroutines.
35 * Copyright (c) 2003, Artem B. Bityuckiy (dedekind@mail.ru).
37 * Redistribution and use in source and binary forms, with or without
38 * modification, are permitted provided that the above copyright notice,
39 * this condition statement, and the following disclaimer are retained
40 * in any redistributions of the source code.
42 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
43 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 #include <sys/types.h>
60 _DEFUN(wcsnlen
, (s
, maxlen
),
61 _CONST
wchar_t *s _AND
67 while (*p
&& maxlen
-- > 0)
70 return (size_t)(p
- s
);