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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [string/] [strxfrm.c] - Blame information for rev 158

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/*
2
FUNCTION
3
        <<strxfrm>>---transform string
4
 
5
INDEX
6
        strxfrm
7
 
8
ANSI_SYNOPSIS
9
        #include <string.h>
10
        size_t strxfrm(char *<[s1]>, const char *<[s2]>, size_t <[n]>);
11
 
12
TRAD_SYNOPSIS
13
        #include <string.h>
14
        size_t strxfrm(<[s1]>, <[s2]>, <[n]>);
15
        char *<[s1]>;
16
        char *<[s2]>;
17
        size_t <[n]>;
18
 
19
DESCRIPTION
20
        This function transforms the string pointed to by <[s2]> and
21
        places the resulting string into the array pointed to by
22
        <[s1]>. The transformation is such that if the <<strcmp>>
23
        function is applied to the two transformed strings, it returns
24
        a value greater than, equal to, or less than zero,
25
        correspoinding to the result of a <<strcoll>> function applied
26
        to the same two original strings.
27
 
28
        No more than <[n]> characters are placed into the resulting
29
        array pointed to by <[s1]>, including the terminating null
30
        character. If <[n]> is zero, <[s1]> may be a null pointer. If
31
        copying takes place between objects that overlap, the behavior
32
        is undefined.
33
 
34
        With a C locale, this function just copies.
35
 
36
RETURNS
37
        The <<strxfrm>> function returns the length of the transformed string
38
        (not including the terminating null character). If the value returned
39
        is <[n]> or more, the contents of the array pointed to by
40
        <[s1]> are indeterminate.
41
 
42
PORTABILITY
43
<<strxfrm>> is ANSI C.
44
 
45
<<strxfrm>> requires no supporting OS subroutines.
46
 
47
QUICKREF
48
        strxfrm ansi pure
49
*/
50
 
51
#include <string.h>
52
 
53
size_t
54
_DEFUN (strxfrm, (s1, s2, n),
55
        char *s1 _AND
56
        _CONST char *s2 _AND
57
        size_t n)
58
{
59
  size_t res;
60
  res = 0;
61
  while (n-- > 0)
62
    {
63
      if ((*s1++ = *s2++) != '\0')
64
        ++res;
65
      else
66
        return res;
67
    }
68
  while (*s2)
69
    {
70
      ++s2;
71
      ++res;
72
    }
73
 
74
  return res;
75
}

powered by: WebSVN 2.1.0

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