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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [newlib-1.17.0/] [newlib/] [libc/] [string/] [wcpncpy.c] - Blame information for rev 847

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

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

powered by: WebSVN 2.1.0

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