Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6557 serge 1
/*
2
FUNCTION
3
	<>---copy part of a wide-character string returning a pointer to its end
4
 
5
ANSI_SYNOPSIS
6
	#include 
7
	wchar_t *wcpncpy(wchar_t *__restrict <[s1]>,
8
			 const wchar_t *__restrict <[s2]>, size_t <[n]>);
9
 
10
TRAD_SYNOPSIS
11
	wchar_t *wcpncpy(<[s1]>, <[s2]>, <[n]>
12
	wchar_t *__restrict <[s1]>;
13
	const wchar_t *__restrict <[s2]>;
14
	size_t <[n]>;
15
 
16
DESCRIPTION
17
	The <> function copies not more than n wide-character codes
18
	(wide-character codes that follow a null wide-character code are not
19
	copied) from the array pointed to by <[s2]> to the array pointed to
20
	by <[s1]>. If copying takes place between objects that overlap, the
21
	behaviour is undefined.
22
 
23
	If the array pointed to by <[s2]> is a wide-character string that is
24
	shorter than <[n]> wide-character codes, null wide-character codes are
25
	appended to the copy in the array pointed to by <[s1]>, until <[n]>
26
	wide-character codes in all are written.
27
 
28
RETURNS
29
	The <> function returns <[s1]>; no return value is reserved to
30
	indicate an error.
31
 
32
PORTABILITY
33
<> is ISO/IEC 9899/AMD1:1995 (ISO C).
34
 
35
No supporting OS subroutines are required.
36
*/
37
 
38
#include <_ansi.h>
39
#include 
40
 
41
wchar_t *
42
_DEFUN (wcpncpy, (dst, src, count),
43
	wchar_t *__restrict dst _AND
44
	_CONST wchar_t *__restrict src _AND
45
	size_t count)
46
{
47
  wchar_t *ret = NULL;
48
 
49
  while (count > 0)
50
    {
51
      --count;
52
      if ((*dst++ = *src++) == L'\0')
53
	{
54
	  ret = dst - 1;
55
	  break;
56
	}
57
    }
58
  while (count-- > 0)
59
    *dst++ = L'\0';
60
 
61
  return ret ? ret : dst;
62
}