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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.18.0/] [newlib/] [libc/] [string/] [wcsncpy.c] - Blame information for rev 258

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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