delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/2000/07/24/11:54:04

Message-ID: <397C6815.D6D69CE5@softhome.net>
Date: Mon, 24 Jul 2000 18:00:21 +0200
From: Laurynas Biveinis <lauras AT softhome DOT net>
X-Mailer: Mozilla 4.73 [en] (Win98; U)
X-Accept-Language: lt,en
MIME-Version: 1.0
To: djgpp-workers AT delorie DOT com
CC: "Richard E. Stone" <restone AT skypoint DOT com>
Subject: Re: stpncpy
References: <200007241052 DOT MAA00257 AT lws256 DOT lu DOT erisoft DOT se>
Reply-To: djgpp-workers AT delorie DOT com

Martin Stromberg wrote:
> 
> Here's a reference to a patch that's gone missing (I never saw any
> discussion):
> <http://www.delorie.com/djgpp/mail-archives/browse.cgi?p=djgpp-workers/2000/06/16/00:21:31>.
> Perhaps Laurunas feels like applying it if nobody have something to say?

Silence is a sign of agreement, isn't it ;)
Below is what I've applied. Note that I've added new wc204.txi entry.

Laurynas
---------
Index: djgpp/include/string.h
===================================================================
RCS file: /cvs/djgpp/djgpp/include/string.h,v
retrieving revision 1.3
diff -u -r1.3 string.h
--- string.h	2000/05/13 02:04:35	1.3
+++ string.h	2000/07/24 14:51:26
@@ -58,6 +58,7 @@
 int	memicmp(const void *_s1, const void *_s2, size_t _n);
 char *  rindex(const char *_string, int _c);
 char *	stpcpy(char *_dest, const char *_src);
+char *	stpncpy(char *_dest, const char *_src, size_t _n);
 char *	strdup(const char *_s);
 char *	strlwr(char *_s);
 int	strcasecmp(const char *_s1, const char *_s2);
Index: djgpp/src/libc/compat/string/stpncpy.c
===================================================================
RCS file: stpncpy.c
diff -N stpncpy.c
--- /dev/null	Tue May  5 16:32:27 1998
+++ STPNCPY.C	Mon Jul 24 10:51:36 2000
@@ -0,0 +1,23 @@
+/* Copyright (C) 2000 DJ Delorie, see COPYING.DJ for details */
+#include <string.h>
+
+char *
+stpncpy(char *dst, const char *src, size_t n)
+{
+  if (!dst || !src)
+    return 0;
+
+  if (n != 0) {
+    do {
+      if ((*dst++ = *src++) == 0)
+      {
+	dst += n - 1;
+	do {
+	  *--dst = 0;
+	} while (--n != 0);
+	break;
+      }
+    } while (--n != 0);
+  }
+  return dst;
+}
Index: djgpp/src/libc/compat/string/stpncpy.txh
===================================================================
RCS file: stpncpy.TXH
diff -N stpncpy.TXH
--- /dev/null	Tue May  5 16:32:27 1998
+++ STPNCPY.TXH	Mon Jul 24 10:51:37 2000
@@ -0,0 +1,23 @@
+@node stpncpy, string
+@subheading Syntax
+
+@example
+#include <string.h>
+
+char *stpncpy(char *_dest, const char *_src, size_t _n);
+@end example
+
+@subheading Description
+
+Copies exactly @var{_n} characters from @var{_src} to @var{_dest}.
+If need be, @var{_dest} is padded with zeros to make @var{_n} characters.
+Like @code{strncpy} (@pxref{strncpy}), but return value different.
+
+@subheading Return Value
+
+Returns a pointer to the character following the last nonzero written.
+
+@subheading Portability
+
+@portability !ansi, !posix
+
Index: djgpp/src/libc/compat/string/makefile
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/compat/string/makefile,v
retrieving revision 1.4
diff -u -r1.4 makefile
--- makefile	1999/12/24 20:47:58	1.4
+++ makefile	2000/07/24 14:51:37
@@ -6,6 +6,7 @@
 SRC += memccpy.c
 SRC += memicmp.c
 SRC += stpcpy.c
+SRC += stpncpy.c
 SRC += strcasec.S
 SRC += strdup.c
 SRC += stricmp.c
Index: wc204.txi
===================================================================
RCS file: /cvs/djgpp/djgpp/src/docs/kb/wc204.txi,v
retrieving revision 1.12
diff -u -r1.12 wc204.txi
--- wc204.txi   2000/07/24 11:37:11     1.12
+++ wc204.txi   2000/07/24 15:49:34
@@ -78,3 +78,7 @@
 @findex getlogin AT r{, and @code{USERNAME} variable}
 @code{getlogin} now examines the environment variable @code{USERNAME} to
 determine the user's name, in addition to @code{USER} and @code{LOGNAME}.
+
+@findex stpncpy
+New function @code{stpncpy} has been added, thanks to
+@email{restone@@skypoint.com, Richard E. Stone}.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019