annotate src/strcat.c @ 5927:b58b74274fa2 cygwin

changes from long ago, never committed...
author Henry Thompson <ht@markup.co.uk>
date Wed, 15 Dec 2021 19:02:33 +0000
parents 2aa9cd456ae7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Copyright (C) 1991 Free Software Foundation, Inc.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 This file is part of the GNU C Library.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
5405
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
4 The GNU C Library is free software: you can redistribute it and/or modify it
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
5 under the terms of the GNU General Public License as published by the
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
6 Free Software Foundation, either version 3 of the License, or (at your
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
7 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
5405
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
9 The GNU C Library is distributed in the hope that it will be useful, but WITHOUT
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
10 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
12 for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13
5405
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
14 You should have received a copy of the GNU General Public License
2aa9cd456ae7 Move src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 442
diff changeset
15 along with the GNU C Library. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 /* Synched up with: Not in FSF. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 # include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 # ifndef REGISTER /* Strictly enforced in 20.3 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 # define REGISTER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 # endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /* In HPUX 10 the strcat function references memory past the last byte of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 the string! This will core dump if the memory following the last byte is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 not mapped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
28 Here is a correct version from, glibc 1.09.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 char *strcat (char *dest, const char *src);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 /* Append SRC on the end of DEST. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 strcat (char *dest, const char *src)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 REGISTER char *s1 = dest;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
38 REGISTER const char *s2 = src;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 char c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 /* Find the end of the string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 c = *s1++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 while (c != '\0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 /* Make S1 point before the next character, so we can increment
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 it while memory is read (wins on pipelined cpus). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 s1 -= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 c = *s2++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 *++s1 = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 while (c != '\0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 return dest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 }