git://scm.lunaixsky.com
/
lunaix-os.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Support to multi-threading and pthread interface (POSIX.1-2008) (#23)
[lunaix-os.git]
/
lunaix-os
/
libs
/
klibc
/
string
/
strcpy.c
diff --git
a/lunaix-os/libs/klibc/string/strcpy.c
b/lunaix-os/libs/klibc/string/strcpy.c
index 12586064cd6767fe36abb89139dc4eb2f180a45a..86032d91ec03dbceab54e2e3ecc5bb14258c19c8 100644
(file)
--- a/
lunaix-os/libs/klibc/string/strcpy.c
+++ b/
lunaix-os/libs/klibc/string/strcpy.c
@@
-1,23
+1,26
@@
#include <klibc/string.h>
char*
#include <klibc/string.h>
char*
-strcpy(char* dest, const char* src) {
+strcpy(char* dest, const char* src)
+{
char c;
unsigned int i = 0;
char c;
unsigned int i = 0;
- while ((c = src[i]))
- {
+ while ((c = src[i])) {
dest[i] = c;
i++;
}
dest[i] = c;
i++;
}
- dest[i] = '\0';
- return
dest
;
+ dest[i
++
] = '\0';
+ return
&dest[i]
;
}
char*
}
char*
-strncpy(char* dest, const char* src, size_t n) {
+strncpy(char* dest, const char* src, unsigned long n)
+{
char c;
unsigned int i = 0;
char c;
unsigned int i = 0;
- while ((c = src[i]) && i < n) dest[i++] = c;
- while (i < n) dest[i++] = 0;
+ while ((c = src[i]) && i <= n)
+ dest[i++] = c;
+ while (i <= n)
+ dest[i++] = 0;
return dest;
}
\ No newline at end of file
return dest;
}
\ No newline at end of file