summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/string.c b/string.c
index 0a92cca..2f9fc25 100644
--- a/string.c
+++ b/string.c
@@ -56,8 +56,20 @@ strncmp(const char *p, const char *q, uint n)
n--, p++, q++;
if(n == 0)
return 0;
- else
- return (int) ((uchar) *p - (uchar) *q);
+ return (uchar)*p - (uchar)*q;
+}
+
+char*
+strncpy(char *s, const char *t, int n)
+{
+ char *os;
+
+ os = s;
+ while(n-- > 0 && (*s++ = *t++) != 0)
+ ;
+ while(n-- > 0)
+ *s++ = 0;
+ return os;
}
// Like strncpy but guaranteed to NUL-terminate.