Hi Lorenzo,

Lorenzo Beretta wrote on Sun, Feb 23, 2014 at 05:29:54PM +0100:
> d...@genunix.com wrote on Sun, Feb 23, 2014 at 08:54:34AM -0500:

>> ../gnulib-lib/.libs/libgettextlib.so: warning:
>> stpcpy() is dangerous GNU crap; don't use it

> Yet stpcpy(3) on linux says:
> CONFORMING TO
>        This function was added to POSIX.1-2008.  Before that, it was
>        not part of the C or POSIX.1 standards, nor customary on UNIX
>        systems, but was not a GNU invention either.  Perhaps it came
>        from MS-DOS.  It is also present on the BSDs.

I checked the following without finding any references to stpcpy:
 - AT&T UNIX v3 to v7 including PWB and 32v
 - System III AT&T Unix
 - all versions of CSRG BSD from 1BSD to 4.4BSD-Lite2 including SCCS

The earliest occurrence of stpcpy() i was able to find was in
the Lattice C AmigaDOS Compiler Version 3 Programmers Reference
Guide (1986-09-12)(Lattice Inc.), which explicitly classifies the
function as "TYPE: LATTICE", see
https://archive.org/details/Lattice_C_AmigaDOS_Compiler_Version_3_Programmers_Reference_Guide_1986-09-12_Lattice_Inc.

So the claim by Terry Lambert that it originated in Borland Turbo C
is definitely untrue.  The first release of Borland Turbo C
happened in May 1987.  I can confirm it was in Borland Turbo C 2.0
in 1989, though.

The 386BSD 0.1 release contains GNU textutils-1.3 and GNU fileutils-3.2
which both contain a file lib/stpcpy.c with a 1989 FSF Copyright.
This is confirmed by looking at the initial commits of the git
history of the GNU coreutils package.

The function stpcpy() was contained in the initial git import of
glibc on Feb 18, 1995.  The file string.texi says "@comment Unknown
origin" at this point in time.  The file sysdeps/generic/stpcpy.c
says "Copyright (C) 1992 Free Software Foundation, Inc." at this
point in time.  The ChangeLog reports a bugfix to the function on
Jan 7, 1992 by Roland McGrath.

In the BSDs, here is when it appeared:
 - FreeBSD: Oct 3, 2002 by obrien@, written himself
 - DragonFly: Apr 7, 2009 ported by pavalos@ from FreeBSD
 - NetBSD: May 1, 2009 ported by perry@ from FreeBSD
 - OpenBSD: Jan 17, 2012 by kettenis@, reluctantly written himself

The function stpncpy first appears in glibc with a 1993 FSF Copyright;
according to the ChangeLog, it was introduced on Oct 29, 1993 by
Roland McGrath, and according to the NEWS file, it was first released
with Version 1.07.

So, to summarize, the Linux manual is rather misleading.  Even
though stpcpy() indeed wasn't a GNU invention, it was first introduced
into the UNIX world by extensive use in the GNU coreutils (then
called fileutils and textutils) in 1989, only very few years after
its original appearance.  The glibc was the first UNIX-like C library
to include it only three years later, nearly a decade before FreeBSD,
about 15 years before POSIX, and more than two decades before OpenBSD
reluctantly followed, forced by POSIX.  That said,

  stpcpy() is dangerous DOS crap; don't use it

would be slightly more accurate, but given who pushed it during the
early years,

  stpcpy() is dangerous GNU crap; don't use it
  
isn't that far off the mark, either.

Anyway, we should update our manual, see below.

Yours,
  Ingo


Index: stpcpy.3
===================================================================
RCS file: /cvs/src/lib/libc/string/stpcpy.3,v
retrieving revision 1.5
diff -u -p -r1.5 stpcpy.3
--- stpcpy.3    25 Sep 2013 21:50:18 -0000      1.5
+++ stpcpy.3    23 Feb 2014 22:06:06 -0000
@@ -174,9 +174,11 @@ and
 functions conform to
 .St -p1003.1-2008 .
 .Sh HISTORY
-The
+The function
 .Fn stpcpy
-and
+first appeared in the Lattice C AmigaDOS compiler (1986 or earlier).
+The function
 .Fn stpncpy
-functions first appeared in
+first appeared in the GNU C library version 1.07 (1993).
+Both functions have been available since
 .Ox 5.1 .

Reply via email to