aboutsummaryrefslogtreecommitdiff
path: root/sys/libc/strncpy.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/libc/strncpy.c
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/libc/strncpy.c')
-rw-r--r--sys/libc/strncpy.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/sys/libc/strncpy.c b/sys/libc/strncpy.c
new file mode 100644
index 00000000..79e99495
--- /dev/null
+++ b/sys/libc/strncpy.c
@@ -0,0 +1,27 @@
+/* Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+*/
+
+#define import_libc
+#include <iraf.h>
+
+
+/* STRNCPY -- Copy exactly N characters from S2 to S1, truncating or null
+** padding S2; the output string may not be null terminated if the length
+** of S2 is N or more.
+*/
+char *
+strncpy (
+ char *s1, /* output string */
+ char *s2, /* string to be moved */
+ int n
+)
+{
+ register char *ip, *op;
+
+ for (ip=s2, op=s1; --n >= 0 && (*op++ = *ip++); )
+ ;
+ while (--n >= 0)
+ *op++ = '\0';
+
+ return (s1);
+}