less verbose...
[unix-history] / usr / src / usr.bin / window / string.c
index 2b82f5e..10b83af 100644 (file)
@@ -1,11 +1,27 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)string.c    3.5 84/03/23";
-#endif
+static char sccsid[] = "@(#)string.c   3.11 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "string.h"
 
 char *malloc();
 
 #include "string.h"
 
 char *malloc();
-char *sprintf();
 
 char *
 str_cpy(s)
 
 char *
 str_cpy(s)
@@ -22,6 +38,26 @@ register char *s;
        return str;
 }
 
        return str;
 }
 
+char *
+str_ncpy(s, n)
+register char *s;
+register n;
+{
+       int l = strlen(s);
+       char *str;
+       register char *p;
+
+       if (n > l)
+               n = l;
+       str = p = str_alloc(n + 1);
+       if (p == 0)
+               return 0;
+       while (--n >= 0)
+               *p++ = *s++;
+       *p = 0;
+       return str;
+}
+
 char *
 str_itoa(i)
 int i;
 char *
 str_itoa(i)
 int i;