Last change
on this file since 444 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
1.3 KB
|
Line | |
---|
1 | /* |
---|
2 | FUNCTION |
---|
3 | <<wcsncpy>>---copy part of a wide-character string |
---|
4 | |
---|
5 | SYNOPSIS |
---|
6 | #include <wchar.h> |
---|
7 | wchar_t *wcsncpy(wchar_t *__restrict <[s1]>, |
---|
8 | const wchar_t *__restrict <[s2]>, size_t <[n]>); |
---|
9 | |
---|
10 | DESCRIPTION |
---|
11 | The <<wcsncpy>> function copies not more than <[n]> wide-character codes |
---|
12 | (wide-character codes that follow a null wide-character code are not |
---|
13 | copied) from the array pointed to by <[s2]> to the array pointed to |
---|
14 | by <[s1]>. If copying takes place between objects that overlap, the |
---|
15 | behaviour is undefined. Note that if <[s1]> contains more than <[n]> |
---|
16 | wide characters before its terminating null, the result is not |
---|
17 | null-terminated. |
---|
18 | |
---|
19 | If the array pointed to by <[s2]> is a wide-character string that is |
---|
20 | shorter than <[n]> wide-character codes, null wide-character codes are |
---|
21 | appended to the copy in the array pointed to by <[s1]>, until <[n]> |
---|
22 | wide-character codes in all are written. |
---|
23 | |
---|
24 | RETURNS |
---|
25 | The <<wcsncpy>> function returns <[s1]>; no return value is reserved to |
---|
26 | indicate an error. |
---|
27 | |
---|
28 | PORTABILITY |
---|
29 | ISO/IEC 9899; POSIX.1. |
---|
30 | |
---|
31 | No supporting OS subroutines are required. |
---|
32 | */ |
---|
33 | |
---|
34 | #include <_ansi.h> |
---|
35 | #include <wchar.h> |
---|
36 | |
---|
37 | wchar_t * |
---|
38 | wcsncpy (wchar_t *__restrict s1, |
---|
39 | const wchar_t *__restrict s2, |
---|
40 | size_t n) |
---|
41 | { |
---|
42 | wchar_t *dscan=s1; |
---|
43 | |
---|
44 | while(n > 0) |
---|
45 | { |
---|
46 | --n; |
---|
47 | if((*dscan++ = *s2++) == L'\0') break; |
---|
48 | } |
---|
49 | while(n-- > 0) *dscan++ = L'\0'; |
---|
50 | |
---|
51 | return s1; |
---|
52 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.