Subversion Repositories Kolibri OS

Rev

Rev 1408 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1408 Rev 1627
Line 1... Line -...
1
#      strncpy()                                       Author: Kees J. Bot
-
 
2
#                                                              1 Jan 1994
-
 
3
# char *strncpy(char *s1, const char *s2, size_t n)
1
/*	strncpy()					Author: Kees J. Bot */
4
#       Copy string s2 to s1.
2
/*								1 Jan 1994 */
5
#
-
 
Line -... Line 3...
-
 
3
 
-
 
4
/* char *strncpy(char *s1, const char *s2, size_t n) */
-
 
5
/*	Copy string s2 to s1. */
6
 
6
/* */
Line -... Line 7...
-
 
7
#include "asm.h"
-
 
8
 
-
 
9
ENTRY(strncpy)
-
 
10
	push	%ebp
7
.intel_syntax
11
	movl	%esp, %ebp
-
 
12
	push	%esi
-
 
13
	push	%edi
-
 
14
	movl	16(%ebp), %ecx	/* Maximum length */
Line 8... Line -...
8
 
-
 
9
.text
-
 
10
 
-
 
11
.globl _strncpy
-
 
12
 
-
 
13
.align  16
-
 
14
_strncpy:
-
 
15
	push	ebp
-
 
16
	mov	ebp, esp
-
 
17
	push	esi
-
 
18
	push	edi
-
 
19
        mov     ecx, [ebp+16]   # Maximum length
-
 
20
        call    __strncpy       # Common code
15
	call	_C_LABEL(_strncpy) /* Common code */
21
        mov     ecx, edx        # Number of bytes not copied
16
	movl	%edx, %ecx	/* Number of bytes not copied */
22
	rep
17
 
23
        stosb                   # strncpy always copies n bytes by null padding
18
	rep stosb	/* strncpy always copies n bytes by null padding */
24
        mov     eax, [ebp+8]     # Return s1
19
	movl	8(%ebp), %eax	/* Return s1 */
25
	pop	edi
20
	pop	%edi