stpcpy.3, stpncpy.3: Correct history
PATCH 1/1 stpcpy.3, stpncpy.3: Correct history
Hi,
i just noticed that the stpcpy(3) manual contains a speculation that appears to be untrue on closer investigation: That function did not originate in MS DOS, but in Lattice C on AmigaDOS.
Here is a patch against the git master HEAD to fix that, and add
some more historical information. To provide some background and
allow you to more easily verify the correctness of the patch, i'm
appending my mail to <[email protected]>, where i'm giving some more details about the history and pointing to some primary sources.
That mail also contains the (similar, but shorter) patch i just
committed to the OpenBSD manual page.
Yours,
Ingo
man3/stpcpy.3 +4 -3
@@ -76,9 +76,10 @@ function is thread-safe. .SH 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. +the C or POSIX.1 standards, nor customary on UNIX systems. +It first appeared in the Lattice C AmigaDOS compiler (1986 or earlier), +then in the GNU fileutils and GNU textutils in 1989, +and in the GNU C library until 1992. It is also present on the BSDs. .SH BUGS This function may overrun the buffer
man3/stpncpy.3 +1 -0
@@ -96,6 +96,7 @@ function is thread-safe. .SH CONFORMING TO This function was added to POSIX.1-2008. Before that, it was a GNU extension. +It first appeared in version 1.07 of the GNU C library in 1993. .SH SEE ALSO .BR strncpy (3), .BR wcpncpy (3)
P.S.
I'd like to apologize that our linker is using strong language to express its opinion regarding these functions; back in 2012, the developer implementing them wasn't exactly amused that they finally made it into POSIX... ;-)
----- Forwarded message from Ingo Schwarze <[email protected]> -----
From: Ingo Schwarze <[email protected]>
Date: Sun, 23 Feb 2014 23:29:19 +0100
Cc: [email protected]
Subject: Re: while trying to compile gettext 0.18.3.2 I see questionable
messages
Hi Lorenzo,
Lorenzo Beretta wrote on Sun, Feb 23, 2014 at 05:29:54PM +0100:
Quoted 11 lines
[email protected] wrote on Sun, Feb 23, 2014 at 08:54:34AM -0500:
Quoted 2 lines
../gnulib-lib/.libs/libgettextlib.so: warning:
stpcpy()is dangerous GNU crap; don't use itYet 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
stpcpy.3 +5 -3
@@ -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 .
----- End forwarded message -----
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello Ingo,
Quoted 48 lines · Ingo Schwarze
Hi,
i just noticed that the stpcpy(3) manual contains a speculation that appears to be untrue on closer investigation: That function did not originate in MS DOS, but in Lattice C on AmigaDOS.
Here is a patch against the git master HEAD to fix that, and add
some more historical information. To provide some background and
allow you to more easily verify the correctness of the patch, i'm
appending my mail to <[email protected]>, where i'm giving some more details about the history and pointing to some primary sources.
That mail also contains the (similar, but shorter) patch i just
committed to the OpenBSD manual page.Yours,
Ingoman3/stpcpy.3 +4
-3@@ -76,9 +76,10 @@ function is thread-safe. .SH 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. +the C or POSIX.1 standards, nor customary on UNIX systems. +It first appeared in the Lattice C AmigaDOS compiler (1986 or earlier), +then in the GNU fileutils and GNU textutils in 1989, +and in the GNU C library until 1992. It is also present on the BSDs. .SH BUGS This function may overrun the bufferman3/stpncpy.3 +1
-0@@ -96,6 +96,7 @@ function is thread-safe. .SH CONFORMING TO This function was added to POSIX.1-2008. Before that, it was a GNU extension. +It first appeared in version 1.07 of the GNU C library in 1993. .SH SEE ALSO .BR strncpy (3), .BR wcpncpy (3)
Quoted 5 lines
P.S.
I'd like to apologize that our linker is using strong language to express its opinion regarding these functions; back in 2012, the developer implementing them wasn't exactly amused that they finally made it into POSIX... ;-)
Thanks for this note.
Now, leaving aside the fingerpointing ;-).... the patch seems more or less okay to me, but given that The ImagaDOS compiler is the merely the oldest instance you could find, I'd prefer a slightly more open wording. How would this be:
[[
man3/stpcpy.3 +5 -3
@@ -76,9 +76,11 @@ function is thread-safe. .SH 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. +the C or POSIX.1 standards, nor customary on UNIX systems. +It first appeared at least as early as 1986, +in the Lattice C AmigaDOS compiler, +then in the GNU fileutils and GNU textutils in 1989, +and in the GNU C library until 1992. It is also present on the BSDs. .SH BUGS This function may overrun the buffer
]]
?
Cheers,
Michael
PS It does seem sad that it ended up in POSIX. I wonder how that came about.
Quoted 111 lines
----- Forwarded message from Ingo Schwarze <[email protected]> -----
From: Ingo Schwarze <[email protected]>
Date: Sun, 23 Feb 2014 23:29:19 +0100
Cc: [email protected]
Subject: Re: while trying to compile gettext 0.18.3.2 I see questionable
messagesHi Lorenzo,
Lorenzo Beretta wrote on Sun, Feb 23, 2014 at 05:29:54PM +0100:
Quoted 11 lines
[email protected] wrote on Sun, Feb 23, 2014 at 08:54:34AM -0500:
Quoted 2 lines
../gnulib-lib/.libs/libgettextlib.so: warning:
stpcpy()is dangerous GNU crap; don't use itYet 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 SCCSThe 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.cwith 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 filesysdeps/generic/stpcpy.csays "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 himselfThe 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 itwould be slightly more accurate, but given who pushed it during the early years,
stpcpy()is dangerous GNU crap; don't use itisn't that far off the mark, either.
Anyway, we should update our manual, see below.
Yours,
IngoIndex: stpcpy.3
===================================================================
RCS file: /cvs/src/lib/libc/string/stpcpy.3,v
retrieving revision 1.5
diff -u -p -r1.5 stpcpy.3stpcpy.3 +5
-4@@ -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 . ----- End forwarded message -----
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Michael,
Michael Kerrisk (man-pages) wrote on Fri, May 02, 2014 at 03:58:36PM +0200:
Quoted 24 lines
the patch seems more or less okay to me, but given that The AmigaDOS compiler is the merely the oldest instance you could find, I'd prefer a slightly more open wording.
How would this be:[[
man3/stpcpy.3 +5
-3@@ -76,9 +76,11 @@ function is thread-safe. .SH 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. +the C or POSIX.1 standards, nor customary on UNIX systems. +It first appeared at least as early as 1986, +in the Lattice C AmigaDOS compiler, +then in the GNU fileutils and GNU textutils in 1989, +and in the GNU C library until 1992. It is also present on the BSDs. .SH BUGS This function may overrun the buffer
Quoted 3 lines
]]
?
Yes, that seems a safer claim, and it reads very well. I like your wording.
Thank you for looking into this,
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Ingo,
Quoted 9 lines · Ingo Schwarze
Hi Michael,
Michael Kerrisk (man-pages) wrote on Fri, May 02, 2014 at 03:58:36PM +0200:
Quoted 5 lines
the patch seems more or less okay to me, but given that The AmigaDOS compiler is the merely the oldest instance you could find, I'd prefer a slightly more open wording.
How would this be:
Quoted 15 lines
Quoted 5 lines
[[
man3/stpcpy.3 +0
-0@@ -76,9 +76,11 @@ function is thread-safe. .SH CONFORMING TOman3/stpcpy.3 function is thread-safe. · line 83
Quoted 10 lines
man3/stpcpy.3 +5
-3This 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. +the C or POSIX.1 standards, nor customary on UNIX systems. +It first appeared at least as early as 1986, +in the Lattice C AmigaDOS compiler, +then in the GNU fileutils and GNU textutils in 1989, +and in the GNU C library until 1992.
Just fixed: s/until/in/
Quoted 4 lines
Quoted 4 lines
man3/stpcpy.3 +0
-0It is also present on the BSDs. .SH BUGS This function may overrun the buffer
Quoted 8 lines
Quoted 3 lines
]]
?
Yes, that seems a safer claim, and it reads very well. I like your wording.
Thank you for looking into this,
You're welcome. Thanks for the patch!
Cheers,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Michael,
Michael Kerrisk (man-pages) wrote on Thu, May 08, 2014 at 11:55:36AM +0200:
Quoted 17 lines · Ingo Schwarze
Quoted 16 lines
Michael Kerrisk (man-pages) wrote on Fri, May 02, 2014 at 03:58:36PM +0200:
Quoted 14 lines
the patch seems more or less okay to me, but given that The AmigaDOS compiler is the merely the oldest instance you could find, I'd prefer a slightly more open wording.
How would this be:[[
man3/stpcpy.3 +0
-2@@ -76,9 +76,11 @@ function is thread-safe. .SH 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.
Quoted 8 lines
Quoted 6 lines
man3/stpcpy.3 function is thread-safe. · line 83
Quoted 6 lines
man3/stpcpy.3 +5
-1-Perhaps it came from MS-DOS. +the C or POSIX.1 standards, nor customary on UNIX systems. +It first appeared at least as early as 1986, +in the Lattice C AmigaDOS compiler, +then in the GNU fileutils and GNU textutils in 1989, +and in the GNU C library until 1992.Just fixed: s/until/in/
Actually, what i intended to express with that "until" was:
"in the GNU C library at least as early as 1992"
Glibc development started in 1987. Clearly glibc didn't have stpcpy before 1989, or early textutils/fileutils wouldn't have had their own copy with a 1989 FSF Copyright. The glibc ChangeLog says Roland McGrath fixed a bug in stpcpy in 1992, and *after that*, the file has a 1992 FSF Copyright.
That doesn't strictly exclude stpcpy may have appeared in glibc in 1989, 1990, or 1991.
Yours,
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hello Ingo,
Quoted 33 lines · Ingo Schwarze
Hi Michael,
Michael Kerrisk (man-pages) wrote on Thu, May 08, 2014 at 11:55:36AM +0200:
Quoted 17 lines · Ingo Schwarze
Quoted 16 lines
Michael Kerrisk (man-pages) wrote on Fri, May 02, 2014 at 03:58:36PM +0200:
Quoted 14 lines
the patch seems more or less okay to me, but given that The AmigaDOS compiler is the merely the oldest instance you could find, I'd prefer a slightly more open wording.
How would this be:[[
man3/stpcpy.3 +0
-2@@ -76,9 +76,11 @@ function is thread-safe. .SH 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.Quoted 8 lines
Quoted 6 lines
man3/stpcpy.3 function is thread-safe. · line 83
Quoted 6 lines
man3/stpcpy.3 +5
-1-Perhaps it came from MS-DOS. +the C or POSIX.1 standards, nor customary on UNIX systems. +It first appeared at least as early as 1986, +in the Lattice C AmigaDOS compiler, +then in the GNU fileutils and GNU textutils in 1989, +and in the GNU C library until 1992.Just fixed: s/until/in/
Actually, what i intended to express with that "until" was:
"in the GNU C library at least as early as 1992"
Quoted 8 lines
Glibc development started in 1987. Clearly glibc didn't have stpcpy before 1989, or early textutils/fileutils wouldn't have had their own copy with a 1989 FSF Copyright. The glibc ChangeLog says Roland McGrath fixed a bug in stpcpy in 1992, and *after that*, the file has a 1992 FSF Copyright.
That doesn't strictly exclude stpcpy may have appeared in glibc in 1989, 1990, or 1991.
Ahhh got it now. I changed 'in' to 'by'. (Das deutsches Wort 'bis' kann auf englisch entweder 'by' oder 'until' sein. 'By' für eine Sache, die _an_ einem bestimmten Zeitpunkt abgeschlossen ist, 'until' für eine Sache, die _dauert_ bis zu einem bestimmten Zeitpunkt. Ganz normale Fehler von deutsch nach englisch; I should have spotted it already ;-).)
Mfg aus Muenchen,
Michael
Signature · 7 lines
Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/ -- To unsubscribe from this list: send the line "unsubscribe linux-man" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html