3 <<wcsnlen>>---get fixed-size wide-character string length
10 size_t wcsnlen(const wchar_t *<[s]>, size_t <[maxlen]>);
13 The <<wcsnlen>> function computes the number of wide-character codes
14 in the wide-character string pointed to by <[s]> not including the
15 terminating L'\0' wide character but at most <[maxlen]> wide
19 <<wcsnlen>> returns the length of <[s]> if it is less then <[maxlen]>,
20 or <[maxlen]> if there is no L'\0' wide character in first <[maxlen]>
24 <<wcsnlen>> is a GNU extension.
26 <<wcsnlen>> requires no supporting OS subroutines.
30 * Copyright (c) 2003, Artem B. Bityuckiy (dedekind@mail.ru).
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the above copyright notice,
34 * this condition statement, and the following disclaimer are retained
35 * in any redistributions of the source code.
37 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
38 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
39 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
40 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
41 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
42 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
43 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
44 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
45 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
46 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51 #include <sys/types.h>
55 wcsnlen (const wchar_t *s
,
61 while (*p
&& maxlen
-- > 0)
64 return (size_t)(p
- s
);