repo.or.cz
/
neatlibc.git
/
blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
blame
|
history
|
raw
|
HEAD
ctype: make sure c < 127 in isprint(c)
[neatlibc.git]
/
stringc.c
blob
28a9e1a42bbb5422621c18b540177df2b9e9cbe4
1
#include <string.h>
2
3
char
*
strncpy
(
char
*
d
,
char
*
s
,
long
n
)
4
{
5
int
len
=
strlen
(
s
);
6
if
(
len
>
n
)
7
len
=
n
;
8
memcpy
(
d
,
s
,
len
);
9
memset
(
d
+
len
,
0
,
n
-
len
);
10
return
d
;
11
}
12
13
char
*
strcat
(
char
*
d
,
char
*
s
)
14
{
15
strcpy
(
d
+
strlen
(
d
),
s
);
16
return
d
;
17
}
18
19
char
*
strstr
(
char
*
s
,
char
*
r
)
20
{
21
int
len
=
strlen
(
r
);
22
if
(!
len
)
23
return
s
;
24
while
(
s
) {
25
if
(!
memcmp
(
s
,
r
,
len
))
26
return
s
;
27
s
=
strchr
(
s
+
1
, *
r
);
28
}
29
return
NULL
;
30
}