annotate src/strcat.c @ 5602:c9e5612f5424

Support the MP library on recent FreeBSD, have it pass relevant tests. src/ChangeLog addition: 2011-11-26 Aidan Kehoe <kehoea@parhasard.net> * number-mp.c (bignum_to_string): Don't overwrite the accumulator we've just set up for this function. * number-mp.c (BIGNUM_TO_TYPE): mp_itom() doesn't necessarily do what this code used to think with negative numbers, it can treat them as unsigned ints. Subtract numbers from bignum_zero instead of multiplying them by -1 to convert them to their negative equivalents. * number-mp.c (bignum_to_int): * number-mp.c (bignum_to_uint): * number-mp.c (bignum_to_long): * number-mp.c (bignum_to_ulong): * number-mp.c (bignum_to_double): Use the changed BIGNUM_TO_TYPE() in these functions. * number-mp.c (bignum_ceil): * number-mp.c (bignum_floor): In these functions, be more careful about rounding to positive and negative infinity, respectively. Don't use the sign of QUOTIENT when working out out whether to add or subtract one, rather use the sign QUOTIENT would have if arbitrary-precision division were done. * number-mp.h: * number-mp.h (MP_GCD): Wrap #include <mp.h> in BEGIN_C_DECLS/END_C_DECLS. * number.c (Fbigfloat_get_precision): * number.c (Fbigfloat_set_precision): Don't attempt to call XBIGFLOAT_GET_PREC if this build doesn't support big floats.
author Aidan Kehoe <kehoea@parhasard.net>
date Sat, 26 Nov 2011 17:59:14 +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 }