Restored work-around for hangs when trying to use disk-based handlers
[tangerine.git] / compiler / clib / strncpy.c
blobb7a9b9ba9dcd09620c2f152786eb2cfc5baebffa
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 ANSI C function strncpy().
6 */
8 /*****************************************************************************
10 NAME */
11 #include <string.h>
13 char * strncpy (
15 /* SYNOPSIS */
16 char * dest,
17 const char * src,
18 size_t n)
20 /* FUNCTION
21 Copy a string. Works like an assignment "dest=src;". At most
22 n characters are copied.
24 INPUTS
25 dest - The string is copied into this variable. Make sure it is
26 large enough.
27 src - This is the new contents of dest.
28 n - How many characters to copy at most. If the string src is
29 smaller than that, only strlen(str)+1 bytes are copied.
31 RESULT
32 dest.
34 NOTES
35 No check is beeing made that dest is large enough for src.
37 EXAMPLE
39 BUGS
41 SEE ALSO
42 strncpy(), memcpy(), memmove()
44 INTERNALS
46 ******************************************************************************/
48 char * ptr = dest;
50 while (n && (*ptr = *src))
52 ptr ++;
53 src ++;
54 n--;
57 while (n--)
58 *ptr++ = '\0';
60 return dest;
61 } /* strncpy */