Subversion Repositories Kolibri OS

Rev

Rev 1005 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1005 Rev 1764
1
#include "string.h"
1
#include "string.h"
2
 
2
 
-
 
3
#ifndef AUTOBUILD
3
void*  memset(void *mem, int c, unsigned size)
4
void*  memset(void *mem, int c, unsigned size)
4
{
5
{
5
unsigned i;
6
unsigned i;
6
 
7
 
7
for ( i = 0; i < size; i++ )
8
for ( i = 0; i < size; i++ )
8
	 *((char *)mem+i) = (char) c;
9
	 *((char *)mem+i) = (char) c;
9
 
10
 
10
return NULL;	
11
return NULL;	
11
}
12
}
12
 
13
 
13
 
14
 
14
void* memcpy(void *dst, const void *src, unsigned size)
15
void* memcpy(void *dst, const void *src, unsigned size)
15
{
16
{
16
 
17
 
17
unsigned i;
18
unsigned i;
18
 
19
 
19
for ( i = 0; i < size; i++)
20
for ( i = 0; i < size; i++)
20
	*((char *)dst+i) = *((char *)src+i);
21
	*((char *)dst+i) = *((char *)src+i);
21
 
22
 
22
return NULL;
23
return NULL;
23
}
24
}
24
 
25
 
25
 
26
 
26
void strcat(char strDest[], char strSource[])
27
void strcat(char strDest[], char strSource[])
27
{
28
{
28
 
29
 
29
int i, j;
30
int i, j;
30
 
31
 
31
i = j = 0;
32
i = j = 0;
32
while (strDest[i] != '\0')
33
while (strDest[i] != '\0')
33
	i++;
34
	i++;
34
 
35
 
35
while ((strDest[i++] = strSource[j++]) != '\0')
36
while ((strDest[i++] = strSource[j++]) != '\0')
36
             ;
37
             ;
37
}
38
}
38
 
39
 
39
 
40
 
40
int strcmp(const char* string1, const char* string2)
41
int strcmp(const char* string1, const char* string2)
41
{
42
{
42
 
43
 
43
while (1)
44
while (1)
44
{
45
{
45
if (*string1<*string2)
46
if (*string1<*string2)
46
	return -1;
47
	return -1;
47
if (*string1>*string2)
48
if (*string1>*string2)
48
	return 1;
49
	return 1;
49
 
50
 
50
if (*string1=='\0')
51
if (*string1=='\0')
51
	return 0;
52
	return 0;
52
 
53
 
53
string1++;
54
string1++;
54
string2++;
55
string2++;
55
}
56
}
56
 
57
 
57
}
58
}
58
 
59
 
59
 
60
 
60
void strcpy(char strDest[], const char strSource[])
61
void strcpy(char strDest[], const char strSource[])
61
{
62
{
62
unsigned i;
63
unsigned i;
63
 
64
 
64
i = 0;
65
i = 0;
65
while ((strDest[i] = strSource[i]) != '\0')
66
while ((strDest[i] = strSource[i]) != '\0')
66
	i++;
67
	i++;
67
 
68
 
68
}
69
}
69
 
70
 
70
 
71
 
71
char* strncpy(char *strDest, const char *strSource, unsigned n)
72
char* strncpy(char *strDest, const char *strSource, unsigned n)
72
{
73
{
73
unsigned i;
74
unsigned i;
74
 
75
 
75
if (! n )
76
if (! n )
76
	return strDest;
77
	return strDest;
77
 
78
 
78
i = 0;
79
i = 0;
79
while ((strDest[i] = strSource[i]) != '\0')
80
while ((strDest[i] = strSource[i]) != '\0')
80
	if ( (n-1) == i )
81
	if ( (n-1) == i )
81
		break;
82
		break;
82
	else
83
	else
83
		i++;
84
		i++;
84
 
85
 
85
return strDest;
86
return strDest;
86
}
87
}
87
 
88
 
88
 
89
 
89
int strlen(const char* string)
90
int strlen(const char* string)
90
{
91
{
91
int i;
92
int i;
92
 
93
 
93
i=0;
94
i=0;
94
while (*string++) i++;
95
while (*string++) i++;
95
return i;
96
return i;
96
}
97
}
97
 
98
 
98
 
99
 
99
 
100
 
100
char* strchr(const char* string, int c)
101
char* strchr(const char* string, int c)
101
{
102
{
102
	while (*string)
103
	while (*string)
103
	{
104
	{
104
		if (*string==c)
105
		if (*string==c)
105
			return (char*)string;
106
			return (char*)string;
106
		string++;
107
		string++;
107
	}	
108
	}	
108
	return (char*)0;
109
	return (char*)0;
109
}
110
}
110
>
111
 
-
 
112
#endif
-
 
113
>