aboutsummaryrefslogtreecommitdiff
path: root/sys/libc/strncpy.c
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/libc/strncpy.c
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
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);
+}