diff packages/redboot/current/src/misc_funs.c @ 156:b939e9cada46

Merge from eCos master repository on 2001-03-29-21:44:39-BST
author jlarmour
date Fri, 06 Apr 2001 17:20:13 +0000
parents 6b5f480c6929
children f62680ef1804
line wrap: on
line diff
--- a/packages/redboot/current/src/misc_funs.c
+++ b/packages/redboot/current/src/misc_funs.c
@@ -66,6 +66,27 @@ strcmp(const char *s1, const char *s2)
 }
 
 char *
+strncpy(char *s1, const char *s2, unsigned long n)
+{
+    char c;
+    char *_s1 = s1;
+
+    if (n) {
+        n--;                            // leave space for terminator
+        while (n != 0 && (c = *s2++) != '\0') {
+            *s1++ = c;
+            n--;
+        }
+        *s1 = '\0';
+        while (n != 0) {                // fill remainder with zero
+            *s1++ = 0;
+            n--;
+        }
+    }
+    return _s1;
+}
+
+char *
 strcpy(char *s1, const char *s2)
 {
     char c;