From 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 Mon Sep 17 00:00:00 2001 From: Joe Hunkeler Date: Tue, 11 Aug 2015 16:51:37 -0400 Subject: Repatch (from linux) of OSX IRAF --- sys/libc/strncpy.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 sys/libc/strncpy.c (limited to 'sys/libc/strncpy.c') 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 + + +/* 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); +} -- cgit