diff options
42 files changed, 229 insertions, 2423 deletions
diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml index 29aa98b..977a944 100644 --- a/.github/workflows/linux-build.yml +++ b/.github/workflows/linux-build.yml @@ -28,6 +28,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + timeout-minutes: 5 - name: Prepare run: | touch tclStubInit.c tclOOStubInit.c tclOOScript.h @@ -38,23 +39,30 @@ jobs: ./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1) env: CFGOPT: ${{ matrix.cfgopt }} + timeout-minutes: 5 - name: Build run: | make all + timeout-minutes: 5 - name: Build Test Harness run: | make tcltest + timeout-minutes: 5 - name: Run Tests run: | make test env: ERROR_ON_FAILURES: 1 + timeout-minutes: 30 - name: Test-Drive Installation run: | make install + timeout-minutes: 5 - name: Create Distribution Package run: | make dist + timeout-minutes: 5 - name: Convert Documentation to HTML run: | make html-tcl + timeout-minutes: 5 diff --git a/.github/workflows/mac-build.yml b/.github/workflows/mac-build.yml index 462bd92..c3593a9 100644 --- a/.github/workflows/mac-build.yml +++ b/.github/workflows/mac-build.yml @@ -18,6 +18,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + timeout-minutes: 5 - name: Prepare run: | touch tclStubInit.c tclOOStubInit.c tclOOScript.h @@ -26,11 +27,13 @@ jobs: run: make all env: CFLAGS: -arch x86_64 -arch arm64 + timeout-minutes: 15 - name: Run Tests run: make test styles=develop env: ERROR_ON_FAILURES: 1 MAC_CI: 1 + timeout-minutes: 15 clang: runs-on: macos-11 strategy: @@ -48,6 +51,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + timeout-minutes: 5 - name: Prepare run: | touch tclStubInit.c tclOOStubInit.c tclOOScript.h @@ -59,14 +63,17 @@ jobs: env: CFLAGS: -arch x86_64 -arch arm64 CFGOPT: ${{ matrix.cfgopt }} + timeout-minutes: 5 - name: Build run: | make all tcltest env: CFLAGS: -arch x86_64 -arch arm64 + timeout-minutes: 15 - name: Run Tests run: | make test env: ERROR_ON_FAILURES: 1 MAC_CI: 1 + timeout-minutes: 15 diff --git a/.github/workflows/onefiledist.yml b/.github/workflows/onefiledist.yml index 5c90701..01b1153 100644 --- a/.github/workflows/onefiledist.yml +++ b/.github/workflows/onefiledist.yml @@ -15,6 +15,7 @@ jobs: defaults: run: shell: bash + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v3 @@ -50,6 +51,7 @@ jobs: defaults: run: shell: bash + timeout-minutes: 10 steps: - name: Checkout uses: actions/checkout@v3 @@ -112,6 +114,7 @@ jobs: defaults: run: shell: msys2 {0} + timeout-minutes: 10 env: CC: gcc CFGOPT: --disable-symbols --disable-shared diff --git a/.github/workflows/win-build.yml b/.github/workflows/win-build.yml index 3809786..54111c5 100644 --- a/.github/workflows/win-build.yml +++ b/.github/workflows/win-build.yml @@ -30,26 +30,31 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 + timeout-minutes: 5 - name: Init MSVC uses: ilammy/msvc-dev-cmd@v1 + timeout-minutes: 5 - name: Build ${{ matrix.cfgopt }} run: | &nmake -f makefile.vc ${{ matrix.cfgopt }} all if ($lastexitcode -ne 0) { throw "nmake exit code: $lastexitcode" } + timeout-minutes: 5 - name: Build Test Harness ${{ matrix.cfgopt }} run: | &nmake -f makefile.vc ${{ matrix.cfgopt }} tcltest if ($lastexitcode -ne 0) { throw "nmake exit code: $lastexitcode" } + timeout-minutes: 5 - name: Run Tests ${{ matrix.cfgopt }} run: | &nmake -f makefile.vc ${{ matrix.cfgopt }} test if ($lastexitcode -ne 0) { throw "nmake exit code: $lastexitcode" } + timeout-minutes: 30 gcc: runs-on: windows-2022 defaults: @@ -73,8 +78,10 @@ jobs: with: msystem: MINGW64 install: git mingw-w64-x86_64-toolchain make + timeout-minutes: 10 - name: Checkout uses: actions/checkout@v3 + timeout-minutes: 5 - name: Prepare run: | touch tclStubInit.c tclOOStubInit.c tclOOScript.h @@ -85,12 +92,16 @@ jobs: ./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1) env: CFGOPT: --enable-64bit ${{ matrix.cfgopt }} + timeout-minutes: 5 - name: Build run: make all + timeout-minutes: 5 - name: Build Test Harness run: make tcltest + timeout-minutes: 5 - name: Run Tests run: make test + timeout-minutes: 30 # If you add builds with Wine, be sure to define the environment variable # CI_USING_WINE when running them so that broken tests know not to run. diff --git a/compat/dirent.h b/compat/dirent.h deleted file mode 100644 index fa6222a..0000000 --- a/compat/dirent.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * dirent.h -- - * - * This file is a replacement for <dirent.h> in systems that - * support the old BSD-style <sys/dir.h> with a "struct direct". - * - * Copyright (c) 1991 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#ifndef _DIRENT -#define _DIRENT - -#include <sys/dir.h> - -#define dirent direct - -#endif /* _DIRENT */ diff --git a/compat/dirent2.h b/compat/dirent2.h deleted file mode 100644 index 5be08ba..0000000 --- a/compat/dirent2.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * dirent.h -- - * - * Declarations of a library of directory-reading procedures - * in the POSIX style ("struct dirent"). - * - * Copyright (c) 1991 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#ifndef _DIRENT -#define _DIRENT - -/* - * Dirent structure, which holds information about a single - * directory entry. - */ - -#define MAXNAMLEN 255 -#define DIRBLKSIZ 512 - -struct dirent { - long d_ino; /* Inode number of entry */ - short d_reclen; /* Length of this record */ - short d_namlen; /* Length of string in d_name */ - char d_name[MAXNAMLEN + 1]; /* Name must be no longer than this */ -}; - -/* - * State that keeps track of the reading of a directory (clients - * should never look inside this structure; the fields should - * only be accessed by the library procedures). - */ - -typedef struct _dirdesc { - int dd_fd; - long dd_loc; - long dd_size; - char dd_buf[DIRBLKSIZ]; -} DIR; - -/* - * Procedures defined for reading directories: - */ - -extern void closedir (DIR *dirp); -extern DIR * opendir (char *name); -extern struct dirent * readdir (DIR *dirp); - -#endif /* _DIRENT */ diff --git a/compat/memcmp.c b/compat/memcmp.c deleted file mode 100644 index c4e25a8..0000000 --- a/compat/memcmp.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * memcmp.c -- - * - * Source code for the "memcmp" library routine. - * - * Copyright (c) 1998 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution of - * this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#include "tclPort.h" - -/* - * Here is the prototype just in case it is not included in tclPort.h. - */ - -int memcmp(const void *s1, const void *s2, size_t n); - -/* - *---------------------------------------------------------------------- - * - * memcmp -- - * - * Compares two bytes sequences. - * - * Results: - * Compares its arguments, looking at the first n bytes (each interpreted - * as an unsigned char), and returns an integer less than, equal to, or - * greater than 0, according as s1 is less than, equal to, or greater - * than s2 when taken to be unsigned 8 bit numbers. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -memcmp( - const void *s1, /* First string. */ - const void *s2, /* Second string. */ - size_t n) /* Length to compare. */ -{ - const unsigned char *ptr1 = (const unsigned char *) s1; - const unsigned char *ptr2 = (const unsigned char *) s2; - - for ( ; n-- ; ptr1++, ptr2++) { - unsigned char u1 = *ptr1, u2 = *ptr2; - - if (u1 != u2) { - return (u1-u2); - } - } - return 0; -} - -/* - * Local Variables: - * mode: c - * c-basic-offset: 4 - * fill-column: 78 - * End: - */ diff --git a/compat/opendir.c b/compat/opendir.c deleted file mode 100644 index 23803ff..0000000 --- a/compat/opendir.c +++ /dev/null @@ -1,109 +0,0 @@ -/* - * opendir.c -- - * - * This file provides dirent-style directory-reading procedures for V7 - * Unix systems that don't have such procedures. The origin of this code - * is unclear, but it seems to have come originally from Larry Wall. - */ - -#include "tclInt.h" - -#undef DIRSIZ -#define DIRSIZ(dp) \ - ((sizeof(struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3)) - -/* - * open a directory. - */ - -DIR * -opendir( - char *name) -{ - DIR *dirp; - int fd; - const char *myname; - - myname = ((*name == '\0') ? "." : name); - if ((fd = open(myname, 0, 0)) == -1) { - return NULL; - } - dirp = (DIR *) Tcl_AttemptAlloc(sizeof(DIR)); - if (dirp == NULL) { - close(fd); - return NULL; - } - dirp->dd_fd = fd; - dirp->dd_loc = 0; - return dirp; -} - -/* - * read an old style directory entry and present it as a new one - */ -#ifndef pyr -#define ODIRSIZ 14 - -struct olddirect { - ino_t od_ino; - char od_name[ODIRSIZ]; -}; -#else /* a Pyramid in the ATT universe */ -#define ODIRSIZ 248 - -struct olddirect { - long od_ino; - short od_fill1, od_fill2; - char od_name[ODIRSIZ]; -}; -#endif - -/* - * get next entry in a directory. - */ - -struct dirent * -readdir( - DIR *dirp) -{ - struct olddirect *dp; - static struct dirent dir; - - for (;;) { - if (dirp->dd_loc == 0) { - dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ); - if (dirp->dd_size <= 0) { - return NULL; - } - } - if (dirp->dd_loc >= dirp->dd_size) { - dirp->dd_loc = 0; - continue; - } - dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc); - dirp->dd_loc += sizeof(struct olddirect); - if (dp->od_ino == 0) { - continue; - } - dir.d_ino = dp->od_ino; - strncpy(dir.d_name, dp->od_name, ODIRSIZ); - dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */ - dir.d_namlen = strlen(dir.d_name); - dir.d_reclen = DIRSIZ(&dir); - return &dir; - } -} - -/* - * close a directory. - */ - -void -closedir( - DIR *dirp) -{ - close(dirp->dd_fd); - dirp->dd_fd = -1; - dirp->dd_loc = 0; - Tcl_Free(dirp); -} diff --git a/compat/stdint.h b/compat/stdint.h deleted file mode 100644 index 88383b0..0000000 --- a/compat/stdint.h +++ /dev/null @@ -1,919 +0,0 @@ -/* A portable stdint.h - **************************************************************************** - * BSD License: - **************************************************************************** - * - * Copyright (c) 2005-2016 Paul Hsieh - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - **************************************************************************** - * - * Version 0.1.16.0 - * - * The ANSI C standard committee, for the C99 standard, specified the - * inclusion of a new standard include file called stdint.h. This is - * a very useful and long desired include file which contains several - * very precise definitions for integer scalar types that is critically - * important for making several classes of applications portable - * including cryptography, hashing, variable length integer libraries - * and so on. But for most developers its likely useful just for - * programming sanity. - * - * The problem is that some compiler vendors chose to ignore the C99 - * standard and some older compilers have no opportunity to be updated. - * Because of this situation, simply including stdint.h in your code - * makes it unportable. - * - * So that's what this file is all about. It's an attempt to build a - * single universal include file that works on as many platforms as - * possible to deliver what stdint.h is supposed to. Even compilers - * that already come with stdint.h can use this file instead without - * any loss of functionality. A few things that should be noted about - * this file: - * - * 1) It is not guaranteed to be portable and/or present an identical - * interface on all platforms. The extreme variability of the - * ANSI C standard makes this an impossibility right from the - * very get go. Its really only meant to be useful for the vast - * majority of platforms that possess the capability of - * implementing usefully and precisely defined, standard sized - * integer scalars. Systems which are not intrinsically 2s - * complement may produce invalid constants. - * - * 2) There is an unavoidable use of non-reserved symbols. - * - * 3) Other standard include files are invoked. - * - * 4) This file may come in conflict with future platforms that do - * include stdint.h. The hope is that one or the other can be - * used with no real difference. - * - * 5) In the current version, if your platform can't represent - * int32_t, int16_t and int8_t, it just dumps out with a compiler - * error. - * - * 6) 64 bit integers may or may not be defined. Test for their - * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX. - * Note that this is different from the C99 specification which - * requires the existence of 64 bit support in the compiler. If - * this is not defined for your platform, yet it is capable of - * dealing with 64 bits then it is because this file has not yet - * been extended to cover all of your system's capabilities. - * - * 7) (u)intptr_t may or may not be defined. Test for its presence - * with the test: #ifdef PTRDIFF_MAX. If this is not defined - * for your platform, then it is because this file has not yet - * been extended to cover all of your system's capabilities, not - * because its optional. - * - * 8) The following might not been defined even if your platform is - * capable of defining it: - * - * WCHAR_MIN - * WCHAR_MAX - * (u)int64_t - * PTRDIFF_MIN - * PTRDIFF_MAX - * (u)intptr_t - * - * 9) The following have not been defined: - * - * WINT_MIN - * WINT_MAX - * - * 10) The criteria for defining (u)int_least(*)_t isn't clear, - * except for systems which don't have a type that precisely - * defined 8, 16, or 32 bit types (which this include file does - * not support anyways). Default definitions have been given. - * - * 11) The criteria for defining (u)int_fast(*)_t isn't something I - * would trust to any particular compiler vendor or the ANSI C - * committee. It is well known that "compatible systems" are - * commonly created that have very different performance - * characteristics from the systems they are compatible with, - * especially those whose vendors make both the compiler and the - * system. Default definitions have been given, but its strongly - * recommended that users never use these definitions for any - * reason (they do *NOT* deliver any serious guarantee of - * improved performance -- not in this file, nor any vendor's - * stdint.h). - * - * 12) The following macros: - * - * PRINTF_INTMAX_MODIFIER - * PRINTF_INT64_MODIFIER - * PRINTF_INT32_MODIFIER - * PRINTF_INT16_MODIFIER - * PRINTF_LEAST64_MODIFIER - * PRINTF_LEAST32_MODIFIER - * PRINTF_LEAST16_MODIFIER - * PRINTF_INTPTR_MODIFIER - * - * are strings which have been defined as the modifiers required - * for the "d", "u" and "x" printf formats to correctly output - * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t, - * (u)least32_t, (u)least16_t and (u)intptr_t types respectively. - * PRINTF_INTPTR_MODIFIER is not defined for some systems which - * provide their own stdint.h. PRINTF_INT64_MODIFIER is not - * defined if INT64_MAX is not defined. These are an extension - * beyond what C99 specifies must be in stdint.h. - * - * In addition, the following macros are defined: - * - * PRINTF_INTMAX_HEX_WIDTH - * PRINTF_INT64_HEX_WIDTH - * PRINTF_INT32_HEX_WIDTH - * PRINTF_INT16_HEX_WIDTH - * PRINTF_INT8_HEX_WIDTH - * PRINTF_INTMAX_DEC_WIDTH - * PRINTF_INT64_DEC_WIDTH - * PRINTF_INT32_DEC_WIDTH - * PRINTF_INT16_DEC_WIDTH - * PRINTF_UINT8_DEC_WIDTH - * PRINTF_UINTMAX_DEC_WIDTH - * PRINTF_UINT64_DEC_WIDTH - * PRINTF_UINT32_DEC_WIDTH - * PRINTF_UINT16_DEC_WIDTH - * PRINTF_UINT8_DEC_WIDTH - * - * Which specifies the maximum number of characters required to - * print the number of that type in either hexadecimal or decimal. - * These are an extension beyond what C99 specifies must be in - * stdint.h. - * - * Compilers tested (all with 0 warnings at their highest respective - * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32 - * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio - * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3 - * - * This file should be considered a work in progress. Suggestions for - * improvements, especially those which increase coverage are strongly - * encouraged. - * - * Acknowledgements - * - * The following people have made significant contributions to the - * development and testing of this file: - * - * Chris Howie - * John Steele Scott - * Dave Thorup - * John Dill - * Florian Wobbe - * Christopher Sean Morrison - * Mikkel Fahnoe Jorgensen - * - */ - -#include <stddef.h> -#include <limits.h> -#include <signal.h> - -/* - * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and - * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_. - */ - -#if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED) -#include <stdint.h> -#define _PSTDINT_H_INCLUDED -# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__)) -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "l" -# endif -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -# else -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# ifndef PRINTF_INT32_MODIFIER -# if (UINT_MAX == UINT32_MAX) -# define PRINTF_INT32_MODIFIER "" -# else -# define PRINTF_INT32_MODIFIER "l" -# endif -# endif -# endif -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "h" -# endif -# ifndef PRINTF_INTMAX_MODIFIER -# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER -# endif -# ifndef PRINTF_INT64_HEX_WIDTH -# define PRINTF_INT64_HEX_WIDTH "16" -# endif -# ifndef PRINTF_UINT64_HEX_WIDTH -# define PRINTF_UINT64_HEX_WIDTH "16" -# endif -# ifndef PRINTF_INT32_HEX_WIDTH -# define PRINTF_INT32_HEX_WIDTH "8" -# endif -# ifndef PRINTF_UINT32_HEX_WIDTH -# define PRINTF_UINT32_HEX_WIDTH "8" -# endif -# ifndef PRINTF_INT16_HEX_WIDTH -# define PRINTF_INT16_HEX_WIDTH "4" -# endif -# ifndef PRINTF_UINT16_HEX_WIDTH -# define PRINTF_UINT16_HEX_WIDTH "4" -# endif -# ifndef PRINTF_INT8_HEX_WIDTH -# define PRINTF_INT8_HEX_WIDTH "2" -# endif -# ifndef PRINTF_UINT8_HEX_WIDTH -# define PRINTF_UINT8_HEX_WIDTH "2" -# endif -# ifndef PRINTF_INT64_DEC_WIDTH -# define PRINTF_INT64_DEC_WIDTH "19" -# endif -# ifndef PRINTF_UINT64_DEC_WIDTH -# define PRINTF_UINT64_DEC_WIDTH "20" -# endif -# ifndef PRINTF_INT32_DEC_WIDTH -# define PRINTF_INT32_DEC_WIDTH "10" -# endif -# ifndef PRINTF_UINT32_DEC_WIDTH -# define PRINTF_UINT32_DEC_WIDTH "10" -# endif -# ifndef PRINTF_INT16_DEC_WIDTH -# define PRINTF_INT16_DEC_WIDTH "5" -# endif -# ifndef PRINTF_UINT16_DEC_WIDTH -# define PRINTF_UINT16_DEC_WIDTH "5" -# endif -# ifndef PRINTF_INT8_DEC_WIDTH -# define PRINTF_INT8_DEC_WIDTH "3" -# endif -# ifndef PRINTF_UINT8_DEC_WIDTH -# define PRINTF_UINT8_DEC_WIDTH "3" -# endif -# ifndef PRINTF_INTMAX_HEX_WIDTH -# define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH -# endif -# ifndef PRINTF_UINTMAX_HEX_WIDTH -# define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH -# endif -# ifndef PRINTF_INTMAX_DEC_WIDTH -# define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH -# endif -# ifndef PRINTF_UINTMAX_DEC_WIDTH -# define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH -# endif - -/* - * Something really weird is going on with Open Watcom. Just pull some of - * these duplicated definitions from Open Watcom's stdint.h file for now. - */ - -# if defined (__WATCOMC__) && __WATCOMC__ >= 1250 -# if !defined (INT64_C) -# define INT64_C(x) (x + (INT64_MAX - INT64_MAX)) -# endif -# if !defined (UINT64_C) -# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX)) -# endif -# if !defined (INT32_C) -# define INT32_C(x) (x + (INT32_MAX - INT32_MAX)) -# endif -# if !defined (UINT32_C) -# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX)) -# endif -# if !defined (INT16_C) -# define INT16_C(x) (x) -# endif -# if !defined (UINT16_C) -# define UINT16_C(x) (x) -# endif -# if !defined (INT8_C) -# define INT8_C(x) (x) -# endif -# if !defined (UINT8_C) -# define UINT8_C(x) (x) -# endif -# if !defined (UINT64_MAX) -# define UINT64_MAX 18446744073709551615ULL -# endif -# if !defined (INT64_MAX) -# define INT64_MAX 9223372036854775807LL -# endif -# if !defined (UINT32_MAX) -# define UINT32_MAX 4294967295UL -# endif -# if !defined (INT32_MAX) -# define INT32_MAX 2147483647L -# endif -# if !defined (INTMAX_MAX) -# define INTMAX_MAX INT64_MAX -# endif -# if !defined (INTMAX_MIN) -# define INTMAX_MIN INT64_MIN -# endif -# endif -#endif - -/* - * I have no idea what is the truly correct thing to do on older Solaris. - * From some online discussions, this seems to be what is being - * recommended. For people who actually are developing on older Solaris, - * what I would like to know is, does this define all of the relevant - * macros of a complete stdint.h? Remember, in pstdint.h 64 bit is - * considered optional. - */ - -#if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED) -#include <sys/inttypes.h> -#define _PSTDINT_H_INCLUDED -#endif - -#ifndef _PSTDINT_H_INCLUDED -#define _PSTDINT_H_INCLUDED - -#ifndef SIZE_MAX -# define SIZE_MAX ((size_t)-1) -#endif - -/* - * Deduce the type assignments from limits.h under the assumption that - * integer sizes in bits are powers of 2, and follow the ANSI - * definitions. - */ - -#ifndef UINT8_MAX -# define UINT8_MAX 0xff -#endif -#if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks) -# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S) - typedef unsigned char uint8_t; -# define UINT8_C(v) ((uint8_t) v) -# else -# error "Platform not supported" -# endif -#endif - -#ifndef INT8_MAX -# define INT8_MAX 0x7f -#endif -#ifndef INT8_MIN -# define INT8_MIN INT8_C(0x80) -#endif -#if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks) -# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S) - typedef signed char int8_t; -# define INT8_C(v) ((int8_t) v) -# else -# error "Platform not supported" -# endif -#endif - -#ifndef UINT16_MAX -# define UINT16_MAX 0xffff -#endif -#if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks) -#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S) - typedef unsigned int uint16_t; -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "" -# endif -# define UINT16_C(v) ((uint16_t) (v)) -#elif (USHRT_MAX == UINT16_MAX) - typedef unsigned short uint16_t; -# define UINT16_C(v) ((uint16_t) (v)) -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "h" -# endif -#else -#error "Platform not supported" -#endif -#endif - -#ifndef INT16_MAX -# define INT16_MAX 0x7fff -#endif -#ifndef INT16_MIN -# define INT16_MIN INT16_C(0x8000) -#endif -#if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks) -#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S) - typedef signed int int16_t; -# define INT16_C(v) ((int16_t) (v)) -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "" -# endif -#elif (SHRT_MAX == INT16_MAX) - typedef signed short int16_t; -# define INT16_C(v) ((int16_t) (v)) -# ifndef PRINTF_INT16_MODIFIER -# define PRINTF_INT16_MODIFIER "h" -# endif -#else -#error "Platform not supported" -#endif -#endif - -#ifndef UINT32_MAX -# define UINT32_MAX (0xffffffffUL) -#endif -#if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks) -#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S) - typedef unsigned long uint32_t; -# define UINT32_C(v) v ## UL -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "l" -# endif -#elif (UINT_MAX == UINT32_MAX) - typedef unsigned int uint32_t; -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -# define UINT32_C(v) v ## U -#elif (USHRT_MAX == UINT32_MAX) - typedef unsigned short uint32_t; -# define UINT32_C(v) ((unsigned short) (v)) -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -#else -#error "Platform not supported" -#endif -#endif - -#ifndef INT32_MAX -# define INT32_MAX (0x7fffffffL) -#endif -#ifndef INT32_MIN -# define INT32_MIN INT32_C(0x80000000) -#endif -#if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks) -#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S) - typedef signed long int32_t; -# define INT32_C(v) v ## L -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "l" -# endif -#elif (INT_MAX == INT32_MAX) - typedef signed int int32_t; -# define INT32_C(v) v -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -#elif (SHRT_MAX == INT32_MAX) - typedef signed short int32_t; -# define INT32_C(v) ((short) (v)) -# ifndef PRINTF_INT32_MODIFIER -# define PRINTF_INT32_MODIFIER "" -# endif -#else -#error "Platform not supported" -#endif -#endif - -/* - * The macro stdint_int64_defined is temporarily used to record - * whether or not 64 integer support is available. It must be - * defined for any 64 integer extensions for new platforms that are - * added. - */ - -#undef stdint_int64_defined -#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S) -# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S) -# define stdint_int64_defined - typedef long long int64_t; - typedef unsigned long long uint64_t; -# define UINT64_C(v) v ## ULL -# define INT64_C(v) v ## LL -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# endif -#endif - -#if !defined (stdint_int64_defined) -# if defined(__GNUC__) && !defined(vxWorks) -# define stdint_int64_defined - __extension__ typedef long long int64_t; - __extension__ typedef unsigned long long uint64_t; -# define UINT64_C(v) v ## ULL -# define INT64_C(v) v ## LL -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S) -# define stdint_int64_defined - typedef long long int64_t; - typedef unsigned long long uint64_t; -# define UINT64_C(v) v ## ULL -# define INT64_C(v) v ## LL -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "ll" -# endif -# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC) -# define stdint_int64_defined - typedef __int64 int64_t; - typedef unsigned __int64 uint64_t; -# define UINT64_C(v) v ## UI64 -# define INT64_C(v) v ## I64 -# ifndef PRINTF_INT64_MODIFIER -# define PRINTF_INT64_MODIFIER "I64" -# endif -# endif -#endif - -#if !defined (LONG_LONG_MAX) && defined (INT64_C) -# define LONG_LONG_MAX INT64_C (9223372036854775807) -#endif -#ifndef ULONG_LONG_MAX -# define ULONG_LONG_MAX UINT64_C (18446744073709551615) -#endif - -#if !defined (INT64_MAX) && defined (INT64_C) -# define INT64_MAX INT64_C (9223372036854775807) -#endif -#if !defined (INT64_MIN) && defined (INT64_C) -# define INT64_MIN INT64_C (-9223372036854775808) -#endif -#if !defined (UINT64_MAX) && defined (INT64_C) -# define UINT64_MAX UINT64_C (18446744073709551615) -#endif - -/* - * Width of hexadecimal for number field. - */ - -#ifndef PRINTF_INT64_HEX_WIDTH -# define PRINTF_INT64_HEX_WIDTH "16" -#endif -#ifndef PRINTF_INT32_HEX_WIDTH -# define PRINTF_INT32_HEX_WIDTH "8" -#endif -#ifndef PRINTF_INT16_HEX_WIDTH -# define PRINTF_INT16_HEX_WIDTH "4" -#endif -#ifndef PRINTF_INT8_HEX_WIDTH -# define PRINTF_INT8_HEX_WIDTH "2" -#endif -#ifndef PRINTF_INT64_DEC_WIDTH -# define PRINTF_INT64_DEC_WIDTH "19" -#endif -#ifndef PRINTF_INT32_DEC_WIDTH -# define PRINTF_INT32_DEC_WIDTH "10" -#endif -#ifndef PRINTF_INT16_DEC_WIDTH -# define PRINTF_INT16_DEC_WIDTH "5" -#endif -#ifndef PRINTF_INT8_DEC_WIDTH -# define PRINTF_INT8_DEC_WIDTH "3" -#endif -#ifndef PRINTF_UINT64_DEC_WIDTH -# define PRINTF_UINT64_DEC_WIDTH "20" -#endif -#ifndef PRINTF_UINT32_DEC_WIDTH -# define PRINTF_UINT32_DEC_WIDTH "10" -#endif -#ifndef PRINTF_UINT16_DEC_WIDTH -# define PRINTF_UINT16_DEC_WIDTH "5" -#endif -#ifndef PRINTF_UINT8_DEC_WIDTH -# define PRINTF_UINT8_DEC_WIDTH "3" -#endif - -/* - * Ok, lets not worry about 128 bit integers for now. Moore's law says - * we don't need to worry about that until about 2040 at which point - * we'll have bigger things to worry about. - */ - -#ifdef stdint_int64_defined - typedef int64_t intmax_t; - typedef uint64_t uintmax_t; -# define INTMAX_MAX INT64_MAX -# define INTMAX_MIN INT64_MIN -# define UINTMAX_MAX UINT64_MAX -# define UINTMAX_C(v) UINT64_C(v) -# define INTMAX_C(v) INT64_C(v) -# ifndef PRINTF_INTMAX_MODIFIER -# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER -# endif -# ifndef PRINTF_INTMAX_HEX_WIDTH -# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH -# endif -# ifndef PRINTF_INTMAX_DEC_WIDTH -# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH -# endif -#else - typedef int32_t intmax_t; - typedef uint32_t uintmax_t; -# define INTMAX_MAX INT32_MAX -# define UINTMAX_MAX UINT32_MAX -# define UINTMAX_C(v) UINT32_C(v) -# define INTMAX_C(v) INT32_C(v) -# ifndef PRINTF_INTMAX_MODIFIER -# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER -# endif -# ifndef PRINTF_INTMAX_HEX_WIDTH -# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH -# endif -# ifndef PRINTF_INTMAX_DEC_WIDTH -# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH -# endif -#endif - -/* - * Because this file currently only supports platforms which have - * precise powers of 2 as bit sizes for the default integers, the - * least definitions are all trivial. Its possible that a future - * version of this file could have different definitions. - */ - -#ifndef stdint_least_defined - typedef int8_t int_least8_t; - typedef uint8_t uint_least8_t; - typedef int16_t int_least16_t; - typedef uint16_t uint_least16_t; - typedef int32_t int_least32_t; - typedef uint32_t uint_least32_t; -# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER -# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER -# define UINT_LEAST8_MAX UINT8_MAX -# define INT_LEAST8_MAX INT8_MAX -# define UINT_LEAST16_MAX UINT16_MAX -# define INT_LEAST16_MAX INT16_MAX -# define UINT_LEAST32_MAX UINT32_MAX -# define INT_LEAST32_MAX INT32_MAX -# define INT_LEAST8_MIN INT8_MIN -# define INT_LEAST16_MIN INT16_MIN -# define INT_LEAST32_MIN INT32_MIN -# ifdef stdint_int64_defined - typedef int64_t int_least64_t; - typedef uint64_t uint_least64_t; -# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER -# define UINT_LEAST64_MAX UINT64_MAX -# define INT_LEAST64_MAX INT64_MAX -# define INT_LEAST64_MIN INT64_MIN -# endif -#endif -#undef stdint_least_defined - -/* - * The ANSI C committee has defined *int*_fast*_t types as well. This, - * of course, defies rationality -- you can't know what will be fast - * just from the type itself. Even for a given architecture, compatible - * implementations might have different performance characteristics. - * Developers are warned to stay away from these types when using this - * or any other stdint.h. - */ - -typedef int_least8_t int_fast8_t; -typedef uint_least8_t uint_fast8_t; -typedef int_least16_t int_fast16_t; -typedef uint_least16_t uint_fast16_t; -typedef int_least32_t int_fast32_t; -typedef uint_least32_t uint_fast32_t; -#define UINT_FAST8_MAX UINT_LEAST8_MAX -#define INT_FAST8_MAX INT_LEAST8_MAX -#define UINT_FAST16_MAX UINT_LEAST16_MAX -#define INT_FAST16_MAX INT_LEAST16_MAX -#define UINT_FAST32_MAX UINT_LEAST32_MAX -#define INT_FAST32_MAX INT_LEAST32_MAX -#define INT_FAST8_MIN INT_LEAST8_MIN -#define INT_FAST16_MIN INT_LEAST16_MIN -#define INT_FAST32_MIN INT_LEAST32_MIN -#ifdef stdint_int64_defined - typedef int_least64_t int_fast64_t; - typedef uint_least64_t uint_fast64_t; -# define UINT_FAST64_MAX UINT_LEAST64_MAX -# define INT_FAST64_MAX INT_LEAST64_MAX -# define INT_FAST64_MIN INT_LEAST64_MIN -#endif - -#undef stdint_int64_defined - -/* - * Whatever piecemeal, per compiler thing we can do about the wchar_t - * type limits. - */ - -#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks) -# include <wchar.h> -# ifndef WCHAR_MIN -# define WCHAR_MIN 0 -# endif -# ifndef WCHAR_MAX -# define WCHAR_MAX ((wchar_t)-1) -# endif -#endif - -/* - * Whatever piecemeal, per compiler/platform thing we can do about the - * (u)intptr_t types and limits. - */ - -#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T) -# define STDINT_H_UINTPTR_T_DEFINED -#endif - -#ifndef STDINT_H_UINTPTR_T_DEFINED -# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__) -# define stdint_intptr_bits 64 -# elif defined (__WATCOMC__) || defined (__TURBOC__) -# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__) -# define stdint_intptr_bits 16 -# else -# define stdint_intptr_bits 32 -# endif -# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__) -# define stdint_intptr_bits 32 -# elif defined (__INTEL_COMPILER) -/* TODO -- what did Intel do about x86-64? */ -# else -/* #error "This platform might not be supported yet" */ -# endif - -# ifdef stdint_intptr_bits -# define stdint_intptr_glue3_i(a,b,c) a##b##c -# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c) -# ifndef PRINTF_INTPTR_MODIFIER -# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER) -# endif -# ifndef PTRDIFF_MAX -# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) -# endif -# ifndef PTRDIFF_MIN -# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) -# endif -# ifndef UINTPTR_MAX -# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX) -# endif -# ifndef INTPTR_MAX -# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX) -# endif -# ifndef INTPTR_MIN -# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN) -# endif -# ifndef INTPTR_C -# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x) -# endif -# ifndef UINTPTR_C -# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x) -# endif - typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t; - typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t; -# else -/* TODO -- This following is likely wrong for some platforms, and does - nothing for the definition of uintptr_t. */ - typedef ptrdiff_t intptr_t; -# endif -# define STDINT_H_UINTPTR_T_DEFINED -#endif - -/* - * Assumes sig_atomic_t is signed and we have a 2s complement machine. - */ - -#ifndef SIG_ATOMIC_MAX -# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1) -#endif - -#endif - -#if defined (__TEST_PSTDINT_FOR_CORRECTNESS) - -/* - * Please compile with the maximum warning settings to make sure macros are - * not defined more than once. - */ - -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#define glue3_aux(x,y,z) x ## y ## z -#define glue3(x,y,z) glue3_aux(x,y,z) - -#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0); -#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0); - -#define DECL(us,bits) glue3(DECL,us,) (bits) - -#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits) - -#define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; } - -#define X_SIZE_MAX ((size_t)-1) - -int main () { - int err_n = 0; - int err_first = 0; - DECL(I,8) - DECL(U,8) - DECL(I,16) - DECL(U,16) - DECL(I,32) - DECL(U,32) -#ifdef INT64_MAX - DECL(I,64) - DECL(U,64) -#endif - intmax_t imax = INTMAX_C(0); - uintmax_t umax = UINTMAX_C(0); - char str0[256], str1[256]; - - sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647)); - if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); - if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH)); - sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295)); - if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0)); - if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH)); -#ifdef INT64_MAX - sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807)); - if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); - if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1))); - sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591)); - if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1)); - if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1))); -#endif - - sprintf (str0, "%d %x\n", 0, ~0); - - sprintf (str1, "%d %x\n", i8, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1)); - sprintf (str1, "%u %x\n", u8, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1)); - sprintf (str1, "%d %x\n", i16, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1)); - sprintf (str1, "%u %x\n", u16, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1)); - sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1)); - sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1)); -#ifdef INT64_MAX - sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1)); -#endif - sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1)); - sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0); - if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1)); - - TESTUMAX(8); - TESTUMAX(16); - TESTUMAX(32); -#ifdef INT64_MAX - TESTUMAX(64); -#endif - -#define STR(v) #v -#define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v)); - if (err_n) { - printf ("pstdint.h is not correct. Please use sizes below to correct it:\n"); - } - - Q(int) - Q(unsigned) - Q(long int) - Q(short int) - Q(int8_t) - Q(int16_t) - Q(int32_t) -#ifdef INT64_MAX - Q(int64_t) -#endif - -#if UINT_MAX < X_SIZE_MAX - printf ("UINT_MAX < X_SIZE_MAX\n"); -#else - printf ("UINT_MAX >= X_SIZE_MAX\n"); -#endif - printf ("%" PRINTF_INT64_MODIFIER "u vs %" PRINTF_INT64_MODIFIER "u\n", UINT_MAX, X_SIZE_MAX); - - return EXIT_SUCCESS; -} - -#endif diff --git a/compat/stdlib.h b/compat/stdlib.h deleted file mode 100644 index 2f7eaf4..0000000 --- a/compat/stdlib.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * stdlib.h -- - * - * Declares facilities exported by the "stdlib" portion of the C library. - * This file isn't complete in the ANSI-C sense; it only declares things - * that are needed by Tcl. This file is needed even on many systems with - * their own stdlib.h (e.g. SunOS) because not all stdlib.h files declare - * all the procedures needed here (such as strtol/strtoul). - * - * Copyright (c) 1991 The Regents of the University of California. - * Copyright (c) 1994-1998 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution of - * this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#ifndef _STDLIB -#define _STDLIB - -extern void abort(void); -extern double atof(const char *string); -extern int atoi(const char *string); -extern long atol(const char *string); -extern void * calloc(unsigned long numElements, unsigned long size); -extern void exit(int status); -extern void free(void *blockPtr); -extern char * getenv(const char *name); -extern void * malloc(unsigned long numBytes); -extern void qsort(void *base, unsigned long n, unsigned long size, int (*compar)( - const void *element1, const void *element2)); -extern void * realloc(void *ptr, unsigned long numBytes); -extern char * realpath(const char *path, char *resolved_path); -extern int mkstemps(char *templ, int suffixlen); -extern int mkstemp(char *templ); -extern char * mkdtemp(char *templ); -extern long strtol(const char *string, char **endPtr, int base); -extern unsigned long strtoul(const char *string, char **endPtr, int base); - -#endif /* _STDLIB */ diff --git a/compat/strstr.c b/compat/strstr.c deleted file mode 100644 index 35386d0..0000000 --- a/compat/strstr.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - * strstr.c -- - * - * Source code for the "strstr" library routine. - * - * Copyright (c) 1988-1993 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution of - * this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#include "tcl.h" -#ifndef NULL -#define NULL 0 -#endif - -/* - *---------------------------------------------------------------------- - * - * strstr -- - * - * Locate the first instance of a substring in a string. - * - * Results: - * If string contains substring, the return value is the location of the - * first matching instance of substring in string. If string doesn't - * contain substring, the return value is 0. Matching is done on an exact - * character-for-character basis with no wildcards or special characters. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -char * -strstr( - const char *string, /* String to search. */ - const char *substring) /* Substring to try to find in string. */ -{ - const char *a, *b; - - /* - * First scan quickly through the two strings looking for a - * single-character match. When it's found, then compare the rest of the - * substring. - */ - - b = substring; - if (*b == 0) { - return (char *)string; - } - for ( ; *string != 0; string += 1) { - if (*string != *b) { - continue; - } - a = string; - while (1) { - if (*b == 0) { - return (char *)string; - } - if (*a++ != *b++) { - break; - } - } - b = substring; - } - return NULL; -} diff --git a/compat/strtol.c b/compat/strtol.c deleted file mode 100644 index a9866f4..0000000 --- a/compat/strtol.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * strtol.c -- - * - * Source code for the "strtol" library procedure. - * - * Copyright (c) 1988 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution of - * this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#include "tclInt.h" - -/* - *---------------------------------------------------------------------- - * - * strtol -- - * - * Convert an ASCII string into an integer. - * - * Results: - * The return value is the integer equivalent of string. If endPtr is - * non-NULL, then *endPtr is filled in with the character after the last - * one that was part of the integer. If string doesn't contain a valid - * integer value, then zero is returned and *endPtr is set to string. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -long int -strtol( - const char *string, /* String of ASCII digits, possibly preceded - * by white space. For bases greater than 10, - * either lower- or upper-case digits may be - * used. */ - char **endPtr, /* Where to store address of terminating - * character, or NULL. */ - int base) /* Base for conversion. Must be less than 37. - * If 0, then the base is chosen from the - * leading characters of string: "0x" means - * hex, "0" means octal, anything else means - * decimal. */ -{ - const char *p; - long result; - - /* - * Skip any leading blanks. - */ - - p = string; - while (isspace(UCHAR(*p))) { - p += 1; - } - - /* - * Check for a sign. - */ - - if (*p == '-') { - p += 1; - result = -(strtoul(p, endPtr, base)); - } else { - if (*p == '+') { - p += 1; - } - result = strtoul(p, endPtr, base); - } - if ((result == 0) && (endPtr != 0) && (*endPtr == p)) { - *endPtr = (char *) string; - } - return result; -} diff --git a/compat/strtoul.c b/compat/strtoul.c deleted file mode 100644 index af63036..0000000 --- a/compat/strtoul.c +++ /dev/null @@ -1,214 +0,0 @@ -/* - * strtoul.c -- - * - * Source code for the "strtoul" library procedure. - * - * Copyright (c) 1988 The Regents of the University of California. - * Copyright (c) 1994 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution of - * this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#include "tclInt.h" - -/* - * The table below is used to convert from ASCII digits to a numerical - * equivalent. It maps from '0' through 'z' to integers (100 for non-digit - * characters). - */ - -static const char cvtIn[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* '0' - '9' */ - 100, 100, 100, 100, 100, 100, 100, /* punctuation */ - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'A' - 'Z' */ - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35, - 100, 100, 100, 100, 100, 100, /* punctuation */ - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'a' - 'z' */ - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31, 32, 33, 34, 35}; - -/* - *---------------------------------------------------------------------- - * - * strtoul -- - * - * Convert an ASCII string into an integer. - * - * Results: - * The return value is the integer equivalent of string. If endPtr is - * non-NULL, then *endPtr is filled in with the character after the last - * one that was part of the integer. If string doesn't contain a valid - * integer value, then zero is returned and *endPtr is set to string. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -unsigned long int -strtoul( - const char *string, /* String of ASCII digits, possibly preceded - * by white space. For bases greater than 10, - * either lower- or upper-case digits may be - * used. */ - char **endPtr, /* Where to store address of terminating - * character, or NULL. */ - int base) /* Base for conversion. Must be less than 37. - * If 0, then the base is chosen from the - * leading characters of string: "0x" means - * hex, "0" means octal, anything else means - * decimal. */ -{ - const char *p; - unsigned long int result = 0; - unsigned digit; - int anyDigits = 0; - int negative=0; - int overflow=0; - - /* - * Skip any leading blanks. - */ - - p = string; - while (isspace(UCHAR(*p))) { - p += 1; - } - if (*p == '-') { - negative = 1; - p += 1; - } else { - if (*p == '+') { - p += 1; - } - } - - /* - * If no base was provided, pick one from the leading characters of the - * string. - */ - - if (base == 0) { - if (*p == '0') { - p += 1; - if ((*p == 'x') || (*p == 'X')) { - p += 1; - base = 16; - } else { - /* - * Must set anyDigits here, otherwise "0" produces a "no - * digits" error. - */ - - anyDigits = 1; - base = 8; - } - } else { - base = 10; - } - } else if (base == 16) { - /* - * Skip a leading "0x" from hex numbers. - */ - - if ((p[0] == '0') && ((p[1] == 'x') || (p[1] == 'X'))) { - p += 2; - } - } - - /* - * Sorry this code is so messy, but speed seems important. Do different - * things for base 8, 10, 16, and other. - */ - - if (base == 8) { - unsigned long maxres = ULONG_MAX >> 3; - - for ( ; ; p += 1) { - digit = *p - '0'; - if (digit > 7) { - break; - } - if (result > maxres) { overflow = 1; } - result = (result << 3); - if (digit > (ULONG_MAX - result)) { overflow = 1; } - result += digit; - anyDigits = 1; - } - } else if (base == 10) { - unsigned long maxres = ULONG_MAX / 10; - - for ( ; ; p += 1) { - digit = *p - '0'; - if (digit > 9) { - break; - } - if (result > maxres) { overflow = 1; } - result *= 10; - if (digit > (ULONG_MAX - result)) { overflow = 1; } - result += digit; - anyDigits = 1; - } - } else if (base == 16) { - unsigned long maxres = ULONG_MAX >> 4; - - for ( ; ; p += 1) { - digit = *p - '0'; - if (digit > ('z' - '0')) { - break; - } - digit = cvtIn[digit]; - if (digit > 15) { - break; - } - if (result > maxres) { overflow = 1; } - result = (result << 4); - if (digit > (ULONG_MAX - result)) { overflow = 1; } - result += digit; - anyDigits = 1; - } - } else if (base >= 2 && base <= 36) { - unsigned long maxres = ULONG_MAX / base; - - for ( ; ; p += 1) { - digit = *p - '0'; - if (digit > ('z' - '0')) { - break; - } - digit = cvtIn[digit]; - if (digit >= ( (unsigned) base )) { - break; - } - if (result > maxres) { overflow = 1; } - result *= base; - if (digit > (ULONG_MAX - result)) { overflow = 1; } - result += digit; - anyDigits = 1; - } - } - - /* - * See if there were any digits at all. - */ - - if (!anyDigits) { - p = string; - } - - if (endPtr != 0) { - /* unsafe, but required by the strtoul prototype */ - *endPtr = (char *) p; - } - - if (overflow) { - errno = ERANGE; - return ULONG_MAX; - } - if (negative) { - return -result; - } - return result; -} diff --git a/generic/tclArithSeries.c b/generic/tclArithSeries.c index caa69a0..caf701b 100755 --- a/generic/tclArithSeries.c +++ b/generic/tclArithSeries.c @@ -152,6 +152,9 @@ ArithSeriesGetInternalRep(Tcl_Obj *objPtr) return irPtr ? (ArithSeries *)irPtr->twoPtrValue.ptr1 : NULL; } +/* + * Compute number of significant factional digits + */ static inline int Precision(double d) { @@ -161,10 +164,13 @@ Precision(double d) off = strchr(tmp, '.'); return (off ? strlen(off+1) : 0); } + +/* + * Find longest number of digits after the decimal point. + */ static inline int maxPrecision(double start, double end, double step) { - // Find longest number of digits after the decimal point. int dp = Precision(step); int i = Precision(start); dp = i>dp ? i : dp; @@ -211,15 +217,17 @@ ArithSeriesLenInt(Tcl_WideInt start, Tcl_WideInt end, Tcl_WideInt step) } static Tcl_WideInt -ArithSeriesLenDbl(double start, double end, double step) +ArithSeriesLenDbl(double start, double end, double step, int precision) { - Tcl_WideInt len; - + double istart, iend, istep, ilen; if (step == 0) { return 0; } - len = ((end-start+step)/step); - return (len < 0) ? -1 : len; + istart = start * pow(10,precision); + iend = end * pow(10,precision); + istep = step * pow(10,precision); + ilen = ((iend-istart+istep)/istep); + return floor(ilen); } @@ -533,7 +541,8 @@ TclNewArithSeriesObj( assert(dstep!=0); if (!lenObj) { if (useDoubles) { - len = ArithSeriesLenDbl(dstart, dend, dstep); + int precision = maxPrecision(dstart,dend,dstep); + len = ArithSeriesLenDbl(dstart, dend, dstep, precision); } else { len = ArithSeriesLenInt(start, end, step); } @@ -668,7 +677,6 @@ TclArithSeriesObjStep( return TCL_OK; } - /* *---------------------------------------------------------------------- * @@ -798,7 +806,8 @@ TclArithSeriesObjRange( arithSeriesDblRepPtr->end = end; arithSeriesDblRepPtr->step = step; arithSeriesDblRepPtr->precision = maxPrecision(start, end, step); - arithSeriesDblRepPtr->len = ArithSeriesLenDbl(start, end, step); + arithSeriesDblRepPtr->len = + ArithSeriesLenDbl(start, end, step, arithSeriesDblRepPtr->precision); arithSeriesDblRepPtr->elements = NULL; } else { diff --git a/generic/tclCompCmdsGR.c b/generic/tclCompCmdsGR.c index f35cd50..892387e 100644 --- a/generic/tclCompCmdsGR.c +++ b/generic/tclCompCmdsGR.c @@ -49,8 +49,8 @@ static int IndexTailVarIfKnown(Tcl_Interp *interp, int TclGetIndexFromToken( Tcl_Token *tokenPtr, - size_t before, - size_t after, + int before, + int after, int *indexPtr) { Tcl_Obj *tmpObj; diff --git a/generic/tclCompile.h b/generic/tclCompile.h index 22abb46..558742f 100644 --- a/generic/tclCompile.h +++ b/generic/tclCompile.h @@ -1138,7 +1138,7 @@ MODULE_SCOPE int TclFixupForwardJump(CompileEnv *envPtr, MODULE_SCOPE void TclFreeCompileEnv(CompileEnv *envPtr); MODULE_SCOPE void TclFreeJumpFixupArray(JumpFixupArray *fixupArrayPtr); MODULE_SCOPE int TclGetIndexFromToken(Tcl_Token *tokenPtr, - size_t before, size_t after, int *indexPtr); + int before, int after, int *indexPtr); MODULE_SCOPE ByteCode * TclInitByteCode(CompileEnv *envPtr); MODULE_SCOPE ByteCode * TclInitByteCodeObj(Tcl_Obj *objPtr, const Tcl_ObjType *typePtr, CompileEnv *envPtr); diff --git a/generic/tclEncoding.c b/generic/tclEncoding.c index 3ab3de9..b02a422 100644 --- a/generic/tclEncoding.c +++ b/generic/tclEncoding.c @@ -4058,11 +4058,8 @@ EscapeToUtfProc( if ((checked == dataPtr->numSubTables + 2) || (flags & TCL_ENCODING_END)) { if (!PROFILE_STRICT(flags)) { - /* - * Skip the unknown escape sequence. TODO - bug? - * May be replace with UNICODE_REPLACE_CHAR? - */ - + /* Unknown escape sequence */ + dst += Tcl_UniCharToUtf(UNICODE_REPLACE_CHAR, dst); src += longest; continue; } diff --git a/generic/tclExecute.c b/generic/tclExecute.c index 2be02c6..ef3a0f9 100644 --- a/generic/tclExecute.c +++ b/generic/tclExecute.c @@ -8985,7 +8985,7 @@ ValidatePcAndStackTop( } if (checkStack && (stackTop > stackUpperBound)) { - size_t numChars; + Tcl_Size numChars; const char *cmd = GetSrcInfoForPc(pc, codePtr, &numChars, NULL, NULL); fprintf(stderr, "\nBad stack top %" TCL_Z_MODIFIER "u at pc %" TCL_Z_MODIFIER "u in TclNRExecuteByteCode (min 0, max %" TCL_Z_MODIFIER "u)", @@ -9525,7 +9525,8 @@ EvalStatsCmd( double numInstructions, currentHeaderBytes; size_t numCurrentByteCodes, numByteCodeLits; size_t refCountSum, literalMgmtBytes, sum, decadeHigh, length; - size_t numSharedMultX, numSharedOnce, minSizeDecade, maxSizeDecade, i; + size_t numSharedMultX, numSharedOnce, minSizeDecade, maxSizeDecade; + Tcl_Size i; char *litTableStats; LiteralEntry *entryPtr; Tcl_Obj *objPtr; diff --git a/generic/tclInt.h b/generic/tclInt.h index 01fae8f..09db24f 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -66,11 +66,8 @@ #include <ctype.h> #include <stdarg.h> -#ifdef NO_STDLIB_H -# include "../compat/stdlib.h" -#else -# include <stdlib.h> -#endif +#include <stdlib.h> +#include <stdint.h> #ifdef NO_STRING_H #include "../compat/string.h" #else diff --git a/generic/tclListObj.c b/generic/tclListObj.c index 4b7705a..2e5dda3 100644 --- a/generic/tclListObj.c +++ b/generic/tclListObj.c @@ -2934,6 +2934,9 @@ TclLsetFlat( } indexArray++; + if ((index == TCL_SIZE_MAX) && (elemCount == 0)) { + index = 0; + } if (index < 0 || index > elemCount || (valueObj == NULL && index >= elemCount)) { /* ...the index points outside the sublist. */ diff --git a/generic/tclOOScript.h b/generic/tclOOScript.h index b7c1f1d..eb6a96e 100644 --- a/generic/tclOOScript.h +++ b/generic/tclOOScript.h @@ -164,12 +164,13 @@ static const char *tclOOSetupScript = "\t\tmethod -appendifnew -export args {\n" "\t\t\tset my [namespace which my]\n" "\t\t\tset current [uplevel 1 [list $my Get]]\n" -"\t\t\tset args [lmap a $args {\n" +"\t\t\tforeach a $args {\n" "\t\t\t\tset a [uplevel 1 [list $my Resolve $a]]\n" -"\t\t\t\tif {$a in $current} continue\n" -"\t\t\t\tset a\n" -"\t\t\t}]\n" -"\t\t\ttailcall my Set [list {*}$current {*}$args]\n" +"\t\t\t\tif {$a ni $current} {\n" +"\t\t\t\t\tlappend current $a\n" +"\t\t\t\t}\n" +"\t\t\t}\n" +"\t\t\ttailcall my Set $current\n" "\t\t}\n" "\t\tmethod -clear -export {} {tailcall my Set {}}\n" "\t\tmethod -prepend -export args {\n" diff --git a/generic/tclTestABSList.c b/generic/tclTestABSList.c index 8c2a26e..d8a6e5a 100644 --- a/generic/tclTestABSList.c +++ b/generic/tclTestABSList.c @@ -819,7 +819,7 @@ UpdateStringOfLString(Tcl_Obj *objPtr) for (bytesNeeded = 0, i = 0; i < llen; i++) { Tcl_Obj *elemObj; const char *elemStr; - int elemLen; + Tcl_Size elemLen; flagPtr[i] = (i ? TCL_DONT_QUOTE_HASH : 0); typePtr->indexProc(NULL, objPtr, i, &elemObj); Tcl_IncrRefCount(elemObj); @@ -844,7 +844,7 @@ UpdateStringOfLString(Tcl_Obj *objPtr) for (i = 0; i < llen; i++) { Tcl_Obj *elemObj; const char *elemStr; - int elemLen; + Tcl_Size elemLen; flagPtr[i] |= (i ? TCL_DONT_QUOTE_HASH : 0); typePtr->indexProc(NULL, objPtr, i, &elemObj); Tcl_IncrRefCount(elemObj); diff --git a/generic/tclTomMath.h b/generic/tclTomMath.h index 26db082..41e5b1d 100644 --- a/generic/tclTomMath.h +++ b/generic/tclTomMath.h @@ -1,13 +1,7 @@ #ifndef BN_TCL_H_ #define BN_TCL_H_ -#ifdef MP_NO_STDINT -# ifdef HAVE_STDINT_H -# include <stdint.h> -# else -# include "../compat/stdint.h" -# endif -#endif +#include <stdint.h> #if defined(TCL_NO_TOMMATH_H) typedef size_t mp_digit; typedef int mp_sign; diff --git a/generic/tclUtil.c b/generic/tclUtil.c index 218b80f..ac292db 100644 --- a/generic/tclUtil.c +++ b/generic/tclUtil.c @@ -138,7 +138,7 @@ TclLengthOne( { return 1; } - + /* * * STRING REPRESENTATION OF LISTS * * * * @@ -1572,7 +1572,8 @@ Tcl_Merge( { #define LOCAL_SIZE 64 char localFlags[LOCAL_SIZE], *flagPtr = NULL; - Tcl_Size i, bytesNeeded = 0; + Tcl_Size i; + size_t bytesNeeded = 0; char *result, *dst; /* @@ -1581,6 +1582,9 @@ Tcl_Merge( */ if (argc <= 0) { + if (argc < 0) { + Tcl_Panic("Tcl_Merge called with negative argc (%" TCL_SIZE_MODIFIER "d)", argc); + } result = (char *)Tcl_Alloc(1); result[0] = '\0'; return result; @@ -2749,8 +2753,7 @@ Tcl_DStringAppendElement( newSize += 1; /* For terminating nul */ if (newSize > dsPtr->spaceAvl) { if (dsPtr->string == dsPtr->staticSpace) { - char *newString; - newString = (char *) TclAllocEx(newSize, &dsPtr->spaceAvl); + char *newString = (char *) TclAllocEx(newSize, &dsPtr->spaceAvl); memcpy(newString, dsPtr->string, dsPtr->length); dsPtr->string = newString; } else { @@ -2763,7 +2766,7 @@ Tcl_DStringAppendElement( offset = element - dsPtr->string; } dsPtr->string = - (char *)TclReallocEx(dsPtr->string, newSize, &dsPtr->spaceAvl); + (char *)TclReallocEx(dsPtr->string, newSize, &dsPtr->spaceAvl); if (offset >= 0) { element = dsPtr->string + offset; } @@ -2936,7 +2939,7 @@ Tcl_DStringGetResult( * of interp. */ { Tcl_Obj *obj = Tcl_GetObjResult(interp); - char *bytes = TclGetString(obj); + const char *bytes = TclGetString(obj); Tcl_DStringFree(dsPtr); Tcl_DStringAppend(dsPtr, bytes, obj->length); @@ -3377,12 +3380,15 @@ GetWideForIndex( if (numType == TCL_NUMBER_INT) { /* objPtr holds an integer in the signed wide range */ *widePtr = *(Tcl_WideInt *)cd; + if ((*widePtr < 0)) { + *widePtr = (endValue == -1) ? WIDE_MIN : -1; + } return TCL_OK; } if (numType == TCL_NUMBER_BIG) { /* objPtr holds an integer outside the signed wide range */ /* Truncate to the signed wide range. */ - *widePtr = ((mp_isneg((mp_int *)cd)) ? WIDE_MIN : WIDE_MAX); + *widePtr = ((mp_isneg((mp_int *)cd)) ? ((endValue == -1) ? WIDE_MIN : -1) : WIDE_MAX); return TCL_OK; } } @@ -3404,14 +3410,12 @@ GetWideForIndex( * (0..TCL_SIZE_MAX) it is returned. Higher values are returned as * TCL_SIZE_MAX. Negative values are returned as TCL_INDEX_NONE (-1). * - * Callers should pass reasonable values for endValue - one in the - * valid index range or TCL_INDEX_NONE (-1), for example for an empty - * list. * * Results: * TCL_OK * - * The index is stored at the address given by by 'indexPtr'. + * The index is stored at the address given by by 'indexPtr'. If + * 'objPtr' has the value "end", the value stored is 'endValue'. * * TCL_ERROR * @@ -3419,9 +3423,10 @@ GetWideForIndex( * 'interp' is non-NULL, an error message is left in the interpreter's * result object. * - * Side effects: + * Effect * - * The internal representation contained within objPtr may shimmer. + * The object referenced by 'objPtr' is converted, as needed, to an + * integer, wide integer, or end-based-index object. * *---------------------------------------------------------------------- */ @@ -3443,13 +3448,14 @@ Tcl_GetIntForIndex( return TCL_ERROR; } if (indexPtr != NULL) { - /* Note: check against TCL_SIZE_MAX needed for 32-bit builds */ - if (wide >= 0 && wide <= TCL_SIZE_MAX) { - *indexPtr = (Tcl_Size)wide; + if ((wide < 0) && (endValue >= 0)) { + *indexPtr = TCL_INDEX_NONE; } else if (wide > TCL_SIZE_MAX) { *indexPtr = TCL_SIZE_MAX; + } else if (wide < -1-TCL_SIZE_MAX) { + *indexPtr = -1-TCL_SIZE_MAX; } else { - *indexPtr = TCL_INDEX_NONE; + *indexPtr = (Tcl_Size) wide; } } return TCL_OK; @@ -3689,26 +3695,17 @@ GetEndOffsetFromObj( offset = irPtr->wideValue; if (offset == WIDE_MAX) { - /* - * Encodes end+1. This is distinguished from end+n as noted above - * NOTE: this may wrap around if the caller passes (as lset does) - * listLen-1 as endValue and and listLen is 0. The -1 will be - * interpreted as FF...FF and adding 1 will result in 0 which - * is what we want. 2's complements shenanigans but it is what - * it is ... - */ - *widePtr = endValue + 1; + *widePtr = (endValue == -1) ? WIDE_MAX : endValue + 1; } else if (offset == WIDE_MIN) { - /* -1 - position before first */ *widePtr = -1; + } else if (endValue == -1) { + *widePtr = offset; } else if (offset < 0) { - /* end-(n-1) - Different signs, sum cannot overflow */ - *widePtr = endValue + offset + 1; + /* Different signs, sum cannot overflow */ + *widePtr = (size_t)endValue + offset + 1; } else if (offset < WIDE_MAX) { - /* 0:WIDE_MAX-1 - plain old index. */ *widePtr = offset; } else { - /* Huh, what case remains here? */ *widePtr = WIDE_MAX; } return TCL_OK; @@ -3733,26 +3730,19 @@ GetEndOffsetFromObj( *---------------------------------------------------------------------- * * TclIndexEncode -- - * IMPORTANT: function only encodes indices in the range that fits within - * an "int" type. Do NOT change this as the byte code compiler and engine - * which call this function cannot handle wider index types. Indices - * outside the range will result in the function returning an error. * * Parse objPtr to determine if it is an index value. Two cases * are possible. The value objPtr might be parsed as an absolute - * index value in the Tcl_Size range. Note that this includes + * index value in the C signed int range. Note that this includes * index values that are integers as presented and it includes index - * arithmetic expressions. - * - * The largest string supported in Tcl 8 has byte length TCL_SIZE_MAX. - * This means the largest supported character length is also TCL_SIZE_MAX, - * and the index of the last character in a string of length TCL_SIZE_MAX - * is TCL_SIZE_MAX-1. Thus the absolute index values that can be + * arithmetic expressions. The absolute index values that can be * directly meaningful as an index into either a list or a string are - * integer values in the range 0 to TCL_SIZE_MAX - 1. - * - * This function however can only handle integer indices in the range - * 0 : INT_MAX-1. + * those integer values >= TCL_INDEX_START (0) + * and < INT_MAX. + * The largest string supported in Tcl 8 has bytelength INT_MAX. + * This means the largest supported character length is also INT_MAX, + * and the index of the last character in a string of length INT_MAX + * is INT_MAX-1. * * Any absolute index value parsed outside that range is encoded * using the before and after values passed in by the @@ -3777,9 +3767,12 @@ GetEndOffsetFromObj( * if the tokens "end-0x7FFFFFFF" or "end+-0x80000000" are parsed, * they can be encoded with the before value. * + * These details will require re-examination whenever string and + * list length limits are increased, but that will likely also + * mean a revised routine capable of returning Tcl_WideInt values. + * * Returns: - * TCL_OK if parsing succeeded, and TCL_ERROR if it failed or the - * index does not fit in an int type. + * TCL_OK if parsing succeeded, and TCL_ERROR if it failed. * * Side effects: * When TCL_OK is returned, the encoded index value is written @@ -3792,138 +3785,51 @@ int TclIndexEncode( Tcl_Interp *interp, /* For error reporting, may be NULL */ Tcl_Obj *objPtr, /* Index value to parse */ - int before, /* Value to return for index before beginning */ + int before, /* Value to return for index before beginning */ int after, /* Value to return for index after end */ int *indexPtr) /* Where to write the encoded answer, not NULL */ { Tcl_WideInt wide; int idx; - const Tcl_WideInt ENDVALUE = 2 * (Tcl_WideInt) INT_MAX; - assert(ENDVALUE < WIDE_MAX); - if (TCL_OK != GetWideForIndex(interp, objPtr, ENDVALUE, &wide)) { - return TCL_ERROR; - } - /* - * We passed 2*INT_MAX as the "end value" to GetWideForIndex. The computed - * index will be in one of the following ranges that need to be - * distinguished for encoding purposes in the following code. - * (1) 0:INT_MAX when - * (a) objPtr was a pure non-negative numeric value in that range - * (b) objPtr was a numeric computation M+/-N with a result in that range - * (c) objPtr was of the form end-N where N was in range INT_MAX:2*INT_MAX - * (2) INT_MAX+1:2*INT_MAX when - * (a,b) as above - * (c) objPtr was of the form end-N where N was in range 0:INT_MAX-1 - * (3) 2*INT_MAX:WIDE_MAX when - * (a,b) as above - * (c) objPtr was of the form end+N - * (4) (2*INT_MAX)-TCL_SIZE_MAX : -1 when - * (a,b) as above - * (c) objPtr was of the form end-N where N was in the range 0:TCL_SIZE_MAX - * (5) WIDE_MIN:(2*INT_MAX)-TCL_SIZE_MAX - * (a,b) as above - * (c) objPtr was of the form end-N where N was > TCL_SIZE_MAX - * - * For all cases (b) and (c), the internal representation of objPtr - * will be shimmered to endOffsetType. That allows us to distinguish between - * (for example) 1a (encodable) and 1c (not encodable) though the computed - * index value is the same. - * - * Further note, the values TCL_SIZE_MAX < N < WIDE_MAX come into play - * only in the 32-bit builds as TCL_SIZE_MAX == WIDE_MAX for 64-bits. - */ - - const Tcl_ObjInternalRep *irPtr = - TclFetchInternalRep(objPtr, &endOffsetType); - - if (irPtr && irPtr->wideValue >= 0) { - /* - * "int[+-]int" syntax, works the same here as "int". - * Note same does not hold for negative integers. - * Distinguishes 1b and 1c where wide will be in 0:INT_MAX for - * both but irPtr->wideValue will be negative for 1c. - */ - irPtr = NULL; - } - - if (irPtr == NULL) { - /* objPtr can be treated as a purely numeric value. */ - - /* - * On 64-bit systems, indices in the range INT_MAX:TCL_SIZE_MAX are - * valid indices but are not in the encodable range. Thus an - * error is raised. On 32-bit systems, indices in that range indicate - * the position after the end and so do not raise an error. - */ - if ((sizeof(int) != sizeof(Tcl_Size)) && - (wide > INT_MAX) && (wide < WIDE_MAX-1)) { - /* 2(a,b) on 64-bit systems*/ - goto rangeerror; - } - if (wide > INT_MAX) { - /* - * 3(a,b) on 64-bit systems and 2(a,b), 3(a,b) on 32-bit systems - * Because of the check above, this case holds for indices - * greater than INT_MAX on 32-bit systems and > TCL_SIZE_MAX - * on 64-bit systems. Always maps to the element after the end. - */ - idx = after; - } else if (wide < 0) { - /* 4(a,b) (32-bit systems), 5(a,b) - before the beginning */ - idx = before; - } else { - /* 1(a,b) Encodable range */ - idx = (int)wide; + if (TCL_OK == GetWideForIndex(interp, objPtr, (unsigned)TCL_INDEX_END , &wide)) { + const Tcl_ObjInternalRep *irPtr = TclFetchInternalRep(objPtr, &endOffsetType); + if (irPtr && irPtr->wideValue >= 0) { + /* "int[+-]int" syntax, works the same here as "int" */ + irPtr = NULL; } - } else { - /* objPtr is not purely numeric (end etc.) */ - /* - * On 64-bit systems, indices in the range end-LIST_MAX:end-INT_MAX - * are valid indices (with max size strings/lists) but are not in - * the encodable range. Thus an error is raised. On 32-bit systems, - * indices in that range indicate the position before the beginning - * and so do not raise an error. + * We parsed an end+offset index value. + * wide holds the offset value in the range WIDE_MIN...WIDE_MAX. */ - if ((sizeof(int) != sizeof(Tcl_Size)) && - (wide > (ENDVALUE - LIST_MAX)) && (wide <= INT_MAX)) { - /* 1(c), 4(a,b) on 64-bit systems */ - goto rangeerror; - } - if (wide > ENDVALUE) { + if ((irPtr ? ((wide < INT_MIN) && ((Tcl_Size)-wide <= LIST_MAX)) + : ((wide > INT_MAX) && ((Tcl_Size)wide <= LIST_MAX))) && (sizeof(int) != sizeof(Tcl_Size))) { + if (interp) { + Tcl_SetObjResult(interp, Tcl_ObjPrintf( + "index \"%s\" out of range", + TclGetString(objPtr))); + Tcl_SetErrorCode(interp, "TCL", "VALUE", "INDEX" + "OUTOFRANGE", NULL); + } + return TCL_ERROR; + } else if (wide > (unsigned)(irPtr ? TCL_INDEX_END : INT_MAX)) { /* - * 2(c) (32-bit systems), 3(c) - * All end+positive or end-negative expressions + * All end+postive or end-negative expressions * always indicate "after the end". - * Note we will not reach here for a pure numeric value in this - * range because irPtr will be NULL in that case. */ idx = after; - } else if (wide <= INT_MAX) { - /* 1(c) (32-bit systems), 4(c) (32-bit systems), 5(c) */ + } else if (wide <= (irPtr ? INT_MAX : -1)) { + /* These indices always indicate "before the beginning" */ idx = before; } else { - /* 2(c) Encodable end-positive (or end+negative) */ + /* Encoded end-positive (or end+negative) are offset */ idx = (int)wide; } + } else { + return TCL_ERROR; } *indexPtr = idx; return TCL_OK; - -rangeerror: - if (interp) { - Tcl_SetObjResult( - interp, - Tcl_ObjPrintf("index \"%s\" out of range", TclGetString(objPtr))); - Tcl_SetErrorCode(interp, - "TCL", - "VALUE", - "INDEX" - "OUTOFRANGE", - NULL); - } - return TCL_ERROR; } /* @@ -3949,9 +3855,8 @@ TclIndexDecode( if (encoded > TCL_INDEX_END) { return encoded; } - endValue += encoded - TCL_INDEX_END; - if (endValue >= 0) { - return endValue; + if ((size_t)endValue >= (size_t)TCL_INDEX_END - encoded) { + return endValue + encoded - TCL_INDEX_END; } return TCL_INDEX_NONE; } diff --git a/libtommath/tommath.h b/libtommath/tommath.h index 4bd8f6c..a235210 100644 --- a/libtommath/tommath.h +++ b/libtommath/tommath.h @@ -4,10 +4,7 @@ #ifndef BN_H_ #define BN_H_ -#if !defined(MP_NO_STDINT) && !defined(_STDINT_H) && !defined(_STDINT_H_) \ - && !defined(__CLANG_STDINT_H) && !defined(_STDINT) -# include <stdint.h> -#endif +#include <stdint.h> #include <stddef.h> #include <limits.h> diff --git a/libtommath/tommath_private.h b/libtommath/tommath_private.h index 5123f53..f5ee285 100644 --- a/libtommath/tommath_private.h +++ b/libtommath/tommath_private.h @@ -4,13 +4,7 @@ #ifndef TOMMATH_PRIV_H_ #define TOMMATH_PRIV_H_ -#ifdef MP_NO_STDINT -#ifdef HAVE_STDINT_H -# include <stdint.h> -#else -# include "../compat/stdint.h" -#endif -#endif +#include <stdint.h> #include "tclTomMath.h" #include "tommath_class.h" diff --git a/tests/bigdata.test b/tests/bigdata.test index 5eb7b89..b7afbbc 100644 --- a/tests/bigdata.test +++ b/tests/bigdata.test @@ -112,8 +112,10 @@ proc bigPatlenMultiple {limit} { set ::bigLengths(intmax) 0x7fffffff set ::bigLengths(uintmax) 0xffffffff # Some tests are more convenient if operands are multiple of pattern length +if {[testConstraint bigdata]} { set ::bigLengths(patlenmultiple) [bigPatlenMultiple $::bigLengths(intmax)] set ::bigLengths(upatlenmultiple) [bigPatlenMultiple $::bigLengths(uintmax)] +} # # script limits diff --git a/tests/encoding.test b/tests/encoding.test index 506ab2c..6220cb2 100644 --- a/tests/encoding.test +++ b/tests/encoding.test @@ -588,13 +588,13 @@ test encoding-16.22 {Utf16ToUtfProc, strict, bug [db7a085bd9]} -body { test encoding-16.23 {Utf16ToUtfProc, strict, bug [db7a085bd9]} -body { encoding convertfrom -profile strict utf-16le \x00\xDC } -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\x00'} -test {encoding-24.4 utf-8 invalid strict} {Parse invalid utf-8, strict} -body { - string length [encoding convertfrom -profile strict utf-8 "\xC0\x80"] -} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC0'} -test {encoding-24.4 utf-8 invalid tcl8} {UtfToUtfProc utf-8} { - encoding convertfrom -profile tcl8 utf-8 \xC0\x80 -} \x00 -test encoding-16.25 {Utf32ToUtfProc} -body { +test encoding-16.24 {Utf32ToUtfProc} -body { + encoding convertfrom utf-32 "\xFF\xFF\xFF\xFF" +} -result \uFFFD +test {encoding-16.25 strict} {Utf32ToUtfProc} -body { + encoding convertfrom -profile strict utf-32 "\x01\x00\x00\x01" +} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\x01'} +test {encoding-16.25 tcl8} {Utf32ToUtfProc} -body { encoding convertfrom -profile tcl8 utf-32 "\x01\x00\x00\x01" } -result \uFFFD @@ -779,9 +779,12 @@ test encoding-24.3 {EscapeFreeProc on open channels} {stdio} { list $count [viewable $line] } [list 3 "乎乞也 (\\u4E4E\\u4E5E\\u4E5F)"] -test encoding-24.4 {Parse valid or invalid utf-8} { - string length [encoding convertfrom -profile tcl8 utf-8 "\xC0\x80"] -} 1 +test {encoding-24.4 utf-8 invalid strict} {Parse invalid utf-8, strict} -body { + encoding convertfrom -profile strict utf-8 "\xC0\x80" +} -returnCodes 1 -result {unexpected byte sequence starting at index 0: '\xC0'} +test {encoding-24.4 utf-8 invalid tcl8} {UtfToUtfProc utf-8} { + encoding convertfrom -profile tcl8 utf-8 \xC0\x80 +} \x00 test encoding-24.5 {Parse valid or invalid utf-8} { string length [encoding convertfrom -profile tcl8 utf-8 "\xC0\x81"] } 2 @@ -1159,6 +1162,15 @@ test encoding-30.3 {encoding convertfrom large strings > 4GB} -constraints { list [string length [set s [string repeat A 0x100000000]]] [string equal $s [encoding convertfrom ascii $s]] } -result {4294967296 1} +test encoding-bug-6a3e2cb0f0-1 {Bug [6a3e2cb0f0] - invalid bytes in escape encodings} -body { + encoding convertfrom -profile tcl8 iso2022-jp x\x1b\x7aaby +} -result x\uFFFDy +test encoding-bug-6a3e2cb0f0-2 {Bug [6a3e2cb0f0] - invalid bytes in escape encodings} -body { + encoding convertfrom -profile strict iso2022-jp x\x1b\x7aaby +} -returnCodes error -result {unexpected byte sequence starting at index 1: '\x1B'} +test encoding-bug-6a3e2cb0f0-3 {Bug [6a3e2cb0f0] - invalid bytes in escape encodings} -body { + encoding convertfrom -profile replace iso2022-jp x\x1b\x7aaby +} -result x\uFFFDy # cleanup namespace delete ::tcl::test::encoding diff --git a/tests/indexObj.test b/tests/indexObj.test index 4c01210..f8cdf3e 100644 --- a/tests/indexObj.test +++ b/tests/indexObj.test @@ -200,22 +200,28 @@ test indexObj-8.9 {Tcl_GetIntForIndex end} testgetintforindex { } 2147483647 test indexObj-8.10 {Tcl_GetIntForIndex end-1} testgetintforindex { testgetintforindex end-1 -1 -} -1 +} -2 test indexObj-8.11 {Tcl_GetIntForIndex end-1} testgetintforindex { testgetintforindex end-1 -2 -} -1 +} [expr {[testConstraint has64BitLengths] ? -3 : 2147483647}] test indexObj-8.12 {Tcl_GetIntForIndex end} testgetintforindex { testgetintforindex end -1 } -1 test indexObj-8.13 {Tcl_GetIntForIndex end} testgetintforindex { testgetintforindex end -2 -} -1 +} [expr {[testConstraint has64BitLengths] ? -2 : 2147483647}] test indexObj-8.14 {Tcl_GetIntForIndex end+1} testgetintforindex { testgetintforindex end+1 -1 -} 0 +} [expr {[testConstraint has64BitLengths] ? 9223372036854775807 : 2147483647}] test indexObj-8.15 {Tcl_GetIntForIndex end+1} testgetintforindex { testgetintforindex end+1 -2 } -1 +test indexObj-8.16 {Tcl_GetIntForIndex integer} testgetintforindex { + testgetintforindex -1 -1 +} [expr {[testConstraint has64BitLengths] ? -9223372036854775808 : -2147483648}] +test indexObj-8.17 {Tcl_GetIntForIndex integer} testgetintforindex { + testgetintforindex -2 -1 +} [expr {[testConstraint has64BitLengths] ? -9223372036854775808 : -2147483648}] # cleanup ::tcltest::cleanupTests diff --git a/tests/lseq.test b/tests/lseq.test index a4055b1..923db3d 100644 --- a/tests/lseq.test +++ b/tests/lseq.test @@ -611,7 +611,7 @@ test lseq-4.12 {bug lseq} -constraints has64BitLengths -body { llength [lseq 0x100000000] } -result {4294967296} -test lseq-4.13 {bug lseq} -constraints has64BitLengths -body { +test lseq-4.13 {bug lseq} -constraints {has64BitLengths knownBug} -body { set l [lseq 0x7fffffffffffffff] list \ [llength $l] \ diff --git a/unix/Makefile.in b/unix/Makefile.in index 5b6c542..d35074e 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -279,7 +279,7 @@ VALGRINDARGS = --tool=memcheck --num-callers=24 \ STUB_CC_SWITCHES = -I"${BUILD_DIR}" -I${UNIX_DIR} -I${GENERIC_DIR} -I${TOMMATH_DIR} \ ${CFLAGS} ${CFLAGS_WARNING} ${SHLIB_CFLAGS} \ ${AC_FLAGS} ${ENV_FLAGS} ${EXTRA_CFLAGS} @EXTRA_CC_SWITCHES@ \ - ${NO_DEPRECATED_FLAGS} -DMP_FIXED_CUTOFFS -DMP_NO_STDINT + ${NO_DEPRECATED_FLAGS} -DMP_FIXED_CUTOFFS CC_SWITCHES = $(STUB_CC_SWITCHES) -DBUILD_tcl @@ -1890,27 +1890,12 @@ tclXtTest.o: $(UNIX_DIR)/tclXtTest.c # relocatable. #-------------------------------------------------------------------------- -opendir.o: $(COMPAT_DIR)/opendir.c - $(CC) -c $(STUB_CC_SWITCHES) $(COMPAT_DIR)/opendir.c - mkstemp.o: $(COMPAT_DIR)/mkstemp.c $(CC) -c $(STUB_CC_SWITCHES) $(COMPAT_DIR)/mkstemp.c -memcmp.o: $(COMPAT_DIR)/memcmp.c - $(CC) -c $(STUB_CC_SWITCHES) $(COMPAT_DIR)/memcmp.c - strncasecmp.o: $(COMPAT_DIR)/strncasecmp.c $(CC) -c $(STUB_CC_SWITCHES) $(COMPAT_DIR)/strncasecmp.c -strstr.o: $(COMPAT_DIR)/strstr.c - $(CC) -c $(STUB_CC_SWITCHES) $(COMPAT_DIR)/strstr.c - -strtol.o: $(COMPAT_DIR)/strtol.c - $(CC) -c $(STUB_CC_SWITCHES) $(COMPAT_DIR)/strtol.c - -strtoul.o: $(COMPAT_DIR)/strtoul.c - $(CC) -c $(STUB_CC_SWITCHES) $(COMPAT_DIR)/strtoul.c - waitpid.o: $(COMPAT_DIR)/waitpid.c $(CC) -c $(STUB_CC_SWITCHES) $(COMPAT_DIR)/waitpid.c diff --git a/unix/configure b/unix/configure index c0f7a32..3f93ef3 100755 --- a/unix/configure +++ b/unix/configure @@ -1604,53 +1604,6 @@ fi } # ac_fn_c_try_compile -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -printf "%s\n" "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - } -then : - ac_retval=0 -else $as_nop - printf "%s\n" "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in @@ -1722,6 +1675,53 @@ fi } # ac_fn_c_try_cpp +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +printf "%s\n" "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + } +then : + ac_retval=0 +else $as_nop + printf "%s\n" "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -4158,102 +4158,6 @@ printf "%s\n" "$ac_cv_path_EGREP" >&6; } - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dirent.h" >&5 -printf %s "checking dirent.h... " >&6; } -if test ${tcl_cv_dirent_h+y} -then : - printf %s "(cached) " >&6 -else $as_nop - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <sys/types.h> -#include <dirent.h> -int -main (void) -{ - -#ifndef _POSIX_SOURCE -# ifdef __Lynx__ - /* - * Generate compilation error to make the test fail: Lynx headers - * are only valid if really in the POSIX environment. - */ - - missing_procedure(); -# endif -#endif -DIR *d; -struct dirent *entryPtr; -char *p; -d = opendir("foobar"); -entryPtr = readdir(d); -p = entryPtr->d_name; -closedir(d); - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO" -then : - tcl_cv_dirent_h=yes -else $as_nop - tcl_cv_dirent_h=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam \ - conftest$ac_exeext conftest.$ac_ext -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_dirent_h" >&5 -printf "%s\n" "$tcl_cv_dirent_h" >&6; } - - if test $tcl_cv_dirent_h = no; then - -printf "%s\n" "#define NO_DIRENT_H 1" >>confdefs.h - - fi - - ac_fn_c_check_header_compile "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = xyes -then : - tcl_ok=1 -else $as_nop - tcl_ok=0 -fi - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "strtol" >/dev/null 2>&1 -then : - -else $as_nop - tcl_ok=0 -fi -rm -rf conftest* - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "strtoul" >/dev/null 2>&1 -then : - -else $as_nop - tcl_ok=0 -fi -rm -rf conftest* - - if test $tcl_ok = 0; then - -printf "%s\n" "#define NO_STDLIB_H 1" >>confdefs.h - - fi ac_fn_c_check_header_compile "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default" if test "x$ac_cv_header_string_h" = xyes then : @@ -8120,32 +8024,6 @@ else $as_nop esac fi -ac_fn_c_check_func "$LINENO" "opendir" "ac_cv_func_opendir" -if test "x$ac_cv_func_opendir" = xyes -then : - printf "%s\n" "#define HAVE_OPENDIR 1" >>confdefs.h - -else $as_nop - case " $LIBOBJS " in - *" opendir.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS opendir.$ac_objext" - ;; -esac - -fi -ac_fn_c_check_func "$LINENO" "strtol" "ac_cv_func_strtol" -if test "x$ac_cv_func_strtol" = xyes -then : - printf "%s\n" "#define HAVE_STRTOL 1" >>confdefs.h - -else $as_nop - case " $LIBOBJS " in - *" strtol.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtol.$ac_objext" - ;; -esac - -fi ac_fn_c_check_func "$LINENO" "waitpid" "ac_cv_func_waitpid" if test "x$ac_cv_func_waitpid" = xyes then : @@ -9537,77 +9415,6 @@ fi #-------------------------------------------------------------------- -# Some system have no memcmp or it does not work with 8 bit data, this -# checks it and add memcmp.o to LIBOBJS if needed -#-------------------------------------------------------------------- - -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working memcmp" >&5 -printf %s "checking for working memcmp... " >&6; } -if test ${ac_cv_func_memcmp_working+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes -then : - ac_cv_func_memcmp_working=no -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -$ac_includes_default -int -main (void) -{ - - /* Some versions of memcmp are not 8-bit clean. */ - char c0 = '\100', c1 = '\200', c2 = '\201'; - if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) - return 1; - - /* The Next x86 OpenStep bug shows up only when comparing 16 bytes - or more and with at least one buffer not starting on a 4-byte boundary. - William Lewis provided this test program. */ - { - char foo[21]; - char bar[21]; - int i; - for (i = 0; i < 4; i++) - { - char *a = foo + i; - char *b = bar + i; - strcpy (a, "--------01111111"); - strcpy (b, "--------10000000"); - if (memcmp (a, b, 16) >= 0) - return 1; - } - return 0; - } - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - ac_cv_func_memcmp_working=yes -else $as_nop - ac_cv_func_memcmp_working=no -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_memcmp_working" >&5 -printf "%s\n" "$ac_cv_func_memcmp_working" >&6; } -test $ac_cv_func_memcmp_working = no && case " $LIBOBJS " in - *" memcmp.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" - ;; -esac - - - -#-------------------------------------------------------------------- # Some system like SunOS 4 and other BSD like systems have no memmove # (we assume they have bcopy instead). {The replacement define is in # compat/string.h} @@ -9629,136 +9436,6 @@ fi #-------------------------------------------------------------------- -# On some systems strstr is broken: it returns a pointer even if -# the original string is empty. -#-------------------------------------------------------------------- - - - ac_fn_c_check_func "$LINENO" "strstr" "ac_cv_func_strstr" -if test "x$ac_cv_func_strstr" = xyes -then : - tcl_ok=1 -else $as_nop - tcl_ok=0 -fi - - if test "$tcl_ok" = 1; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking proper strstr implementation" >&5 -printf %s "checking proper strstr implementation... " >&6; } -if test ${tcl_cv_strstr_unbroken+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes -then : - tcl_cv_strstr_unbroken=unknown -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include <stdlib.h> -#include <string.h> -int main() { - exit(strstr("\0test", "test") ? 1 : 0); -} -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - tcl_cv_strstr_unbroken=ok -else $as_nop - tcl_cv_strstr_unbroken=broken -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_strstr_unbroken" >&5 -printf "%s\n" "$tcl_cv_strstr_unbroken" >&6; } - if test "$tcl_cv_strstr_unbroken" = "ok"; then - tcl_ok=1 - else - tcl_ok=0 - fi - fi - if test "$tcl_ok" = 0; then - case " $LIBOBJS " in - *" strstr.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strstr.$ac_objext" - ;; -esac - - USE_COMPAT=1 - fi - - -#-------------------------------------------------------------------- -# Check for strtoul function. This is tricky because under some -# versions of AIX strtoul returns an incorrect terminator -# pointer for the string "0". -#-------------------------------------------------------------------- - - - ac_fn_c_check_func "$LINENO" "strtoul" "ac_cv_func_strtoul" -if test "x$ac_cv_func_strtoul" = xyes -then : - tcl_ok=1 -else $as_nop - tcl_ok=0 -fi - - if test "$tcl_ok" = 1; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking proper strtoul implementation" >&5 -printf %s "checking proper strtoul implementation... " >&6; } -if test ${tcl_cv_strtoul_unbroken+y} -then : - printf %s "(cached) " >&6 -else $as_nop - if test "$cross_compiling" = yes -then : - tcl_cv_strtoul_unbroken=unknown -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -#include <stdlib.h> -#include <string.h> -int main() { - char *term, *string = "0"; - exit(strtoul(string,&term,0) != 0 || term != string+1); -} -_ACEOF -if ac_fn_c_try_run "$LINENO" -then : - tcl_cv_strtoul_unbroken=ok -else $as_nop - tcl_cv_strtoul_unbroken=broken -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_strtoul_unbroken" >&5 -printf "%s\n" "$tcl_cv_strtoul_unbroken" >&6; } - if test "$tcl_cv_strtoul_unbroken" = "ok"; then - tcl_ok=1 - else - tcl_ok=0 - fi - fi - if test "$tcl_ok" = 0; then - case " $LIBOBJS " in - *" strtoul.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS strtoul.$ac_objext" - ;; -esac - - USE_COMPAT=1 - fi - - -#-------------------------------------------------------------------- # Check for various typedefs and provide substitutes if # they don't exist. #-------------------------------------------------------------------- @@ -9917,24 +9594,6 @@ fi #-------------------------------------------------------------------- -# If a system doesn't have an opendir function (man, that's old!) -# then we have to supply a different version of dirent.h which -# is compatible with the substitute version of opendir that's -# provided. This version only works with V7-style directories. -#-------------------------------------------------------------------- - -ac_fn_c_check_func "$LINENO" "opendir" "ac_cv_func_opendir" -if test "x$ac_cv_func_opendir" = xyes -then : - -else $as_nop - -printf "%s\n" "#define USE_DIRENT2_H 1" >>confdefs.h - -fi - - -#-------------------------------------------------------------------- # The check below checks whether <sys/wait.h> defines the type # "union wait" correctly. It's needed because of weirdness in # HP-UX where "union wait" is defined in both the BSD and SYS-V diff --git a/unix/configure.ac b/unix/configure.ac index 17da218..f7538c3 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -229,7 +229,7 @@ AC_CHECK_FUNCS(getcwd, , [AC_DEFINE(USEGETWD, 1, [Is getcwd Posix-compliant?])]) # Nb: if getcwd uses popen and pwd(1) (like SunOS 4) we should really # define USEGETWD even if the posix getcwd exists. Add a test ? -AC_REPLACE_FUNCS(mkstemp opendir strtol waitpid) +AC_REPLACE_FUNCS(mkstemp waitpid) AC_CHECK_FUNC(strerror, , [AC_DEFINE(NO_STRERROR, 1, [Do we have strerror()])]) AC_CHECK_FUNC(getwd, , [AC_DEFINE(NO_GETWD, 1, [Do we have getwd()])]) AC_CHECK_FUNC(wait3, , [AC_DEFINE(NO_WAIT3, 1, [Do we have wait3()])]) @@ -377,13 +377,6 @@ AC_CHECK_TYPES([blkcnt_t]) AC_CHECK_FUNC(fstatfs, , [AC_DEFINE(NO_FSTATFS, 1, [Do we have fstatfs()?])]) #-------------------------------------------------------------------- -# Some system have no memcmp or it does not work with 8 bit data, this -# checks it and add memcmp.o to LIBOBJS if needed -#-------------------------------------------------------------------- - -AC_FUNC_MEMCMP - -#-------------------------------------------------------------------- # Some system like SunOS 4 and other BSD like systems have no memmove # (we assume they have bcopy instead). {The replacement define is in # compat/string.h} @@ -394,26 +387,6 @@ AC_CHECK_FUNC(memmove, , [ AC_DEFINE(NO_STRING_H, 1, [Do we have <string.h>?]) ]) #-------------------------------------------------------------------- -# On some systems strstr is broken: it returns a pointer even if -# the original string is empty. -#-------------------------------------------------------------------- - -SC_TCL_CHECK_BROKEN_FUNC(strstr, [ - exit(strstr("\0test", "test") ? 1 : 0); -]) - -#-------------------------------------------------------------------- -# Check for strtoul function. This is tricky because under some -# versions of AIX strtoul returns an incorrect terminator -# pointer for the string "0". -#-------------------------------------------------------------------- - -SC_TCL_CHECK_BROKEN_FUNC(strtoul, [ - char *term, *string = "0"; - exit(strtoul(string,&term,0) != 0 || term != string+1); -]) - -#-------------------------------------------------------------------- # Check for various typedefs and provide substitutes if # they don't exist. #-------------------------------------------------------------------- @@ -439,15 +412,6 @@ AC_CHECK_TYPES([intptr_t, uintptr_t],,,[[ ]]) #-------------------------------------------------------------------- -# If a system doesn't have an opendir function (man, that's old!) -# then we have to supply a different version of dirent.h which -# is compatible with the substitute version of opendir that's -# provided. This version only works with V7-style directories. -#-------------------------------------------------------------------- - -AC_CHECK_FUNC(opendir, , [AC_DEFINE(USE_DIRENT2_H, 1, [May we include <dirent2.h>?])]) - -#-------------------------------------------------------------------- # The check below checks whether <sys/wait.h> defines the type # "union wait" correctly. It's needed because of weirdness in # HP-UX where "union wait" is defined in both the BSD and SYS-V diff --git a/unix/dltest/Makefile.in b/unix/dltest/Makefile.in index e8dce2f..418f2bd 100644 --- a/unix/dltest/Makefile.in +++ b/unix/dltest/Makefile.in @@ -79,7 +79,7 @@ pkgooa.o: $(SRC_DIR)/pkgooa.c $(CC) -c $(CC_SWITCHES) $(SRC_DIR)/pkgooa.c embtest: embtest.o - $(CC) -o $@ embtest.o ${SHLIB_LD_LIBS} + $(SHLIB_LD) -o $@ embtest.o ${SHLIB_LD_LIBS} tcl9pkgπ${SHLIB_SUFFIX}: pkgπ.o ${SHLIB_LD} -o $@ pkgπ.o ${SHLIB_LD_LIBS} diff --git a/unix/tcl.m4 b/unix/tcl.m4 index 5ac917c..9dc39f2 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1932,8 +1932,6 @@ dnl # preprocessing tests use only CPPFLAGS. # Results: # # Defines some of the following vars: -# NO_DIRENT_H -# NO_STDLIB_H # NO_STRING_H # NO_SYS_WAIT_H # NO_DLFCN_H @@ -1943,38 +1941,6 @@ dnl # preprocessing tests use only CPPFLAGS. #-------------------------------------------------------------------- AC_DEFUN([SC_MISSING_POSIX_HEADERS], [ - AC_CACHE_CHECK([dirent.h], tcl_cv_dirent_h, [ - AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h> -#include <dirent.h>]], [[ -#ifndef _POSIX_SOURCE -# ifdef __Lynx__ - /* - * Generate compilation error to make the test fail: Lynx headers - * are only valid if really in the POSIX environment. - */ - - missing_procedure(); -# endif -#endif -DIR *d; -struct dirent *entryPtr; -char *p; -d = opendir("foobar"); -entryPtr = readdir(d); -p = entryPtr->d_name; -closedir(d); -]])],[tcl_cv_dirent_h=yes],[tcl_cv_dirent_h=no])]) - - if test $tcl_cv_dirent_h = no; then - AC_DEFINE(NO_DIRENT_H, 1, [Do we have <dirent.h>?]) - fi - - AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0) - AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0) - AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0) - if test $tcl_ok = 0; then - AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?]) - fi AC_CHECK_HEADER(string.h, tcl_ok=1, tcl_ok=0) AC_EGREP_HEADER(strstr, string.h, , tcl_ok=0) AC_EGREP_HEADER(strerror, string.h, , tcl_ok=0) @@ -2388,7 +2354,7 @@ AC_DEFUN([SC_TCL_64BIT_FLAGS], [ case 1: case (sizeof(long long)==sizeof(long)): ; }]])],[tcl_cv_type_64bit="long long"],[])]) if test "${tcl_cv_type_64bit}" = none ; then - AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, ['long' and 'long long' have the same size]) + AC_DEFINE(TCL_WIDE_INT_IS_LONG, 1, [Do 'long' and 'long long' have the same size (64-bit)?]) AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) diff --git a/unix/tclConfig.h.in b/unix/tclConfig.h.in index c7573ef..fe2c6d9 100644 --- a/unix/tclConfig.h.in +++ b/unix/tclConfig.h.in @@ -178,9 +178,6 @@ /* Define to 1 if you have the `open64' function. */ #undef HAVE_OPEN64 -/* Define to 1 if you have the `opendir' function. */ -#undef HAVE_OPENDIR - /* Define to 1 if you have the `OSSpinLockLock' function. */ #undef HAVE_OSSPINLOCKLOCK @@ -217,9 +214,6 @@ /* Define to 1 if you have the <string.h> header file. */ #undef HAVE_STRING_H -/* Define to 1 if you have the `strtol' function. */ -#undef HAVE_STRTOL - /* Define to 1 if the system has the type `struct addrinfo'. */ #undef HAVE_STRUCT_ADDRINFO @@ -334,9 +328,6 @@ /* Is Darwin CoreFoundation unavailable for 64-bit? */ #undef NO_COREFOUNDATION_64 -/* Do we have <dirent.h>? */ -#undef NO_DIRENT_H - /* Do we have <dlfcn.h>? */ #undef NO_DLFCN_H @@ -364,9 +355,6 @@ /* Do we have realpath() */ #undef NO_REALPATH -/* Do we have <stdlib.h>? */ -#undef NO_STDLIB_H - /* Do we have strerror() */ #undef NO_STRERROR @@ -447,7 +435,7 @@ /* Does this platform have wide high-resolution clicks? */ #undef TCL_WIDE_CLICKS -/* 'long' and 'long long' have the same size */ +/* Do 'long' and 'long long' have the same size (64-bit)? */ #undef TCL_WIDE_INT_IS_LONG /* Tcl with external libtommath */ @@ -456,9 +444,6 @@ /* Is getcwd Posix-compliant? */ #undef USEGETWD -/* May we include <dirent2.h>? */ -#undef USE_DIRENT2_H - /* Are we building with DTrace support? */ #undef USE_DTRACE diff --git a/unix/tclUnixPort.h b/unix/tclUnixPort.h index cb1adc5..33c8971 100644 --- a/unix/tclUnixPort.h +++ b/unix/tclUnixPort.h @@ -7,7 +7,7 @@ * file that contains #ifdefs to handle different flavors of UNIX. This * file sets up the union of all UNIX-related things needed by any of the * Tcl core files. This file depends on configuration #defines such as - * NO_DIRENT_H that are set up by the "configure" script. + * HAVE_SYS_PARAM_H that are set up by the "configure" script. * * Much of the material in this file was originally contributed by Karl * Lehenbauer, Mark Diekhans and Peter da Silva. @@ -40,15 +40,7 @@ # include <sys/param.h> #endif #include <sys/types.h> -#ifdef USE_DIRENT2_H -# include "../compat/dirent2.h" -#else -#ifdef NO_DIRENT_H -# include "../compat/dirent.h" -#else -# include <dirent.h> -#endif -#endif +#include <dirent.h> /* *--------------------------------------------------------------------------- @@ -155,11 +147,6 @@ extern "C" { # include <inttypes.h> #endif #include <limits.h> -#ifdef HAVE_STDINT_H -# include <stdint.h> -#else -# include "../compat/stdint.h" -#endif #include <unistd.h> MODULE_SCOPE int TclUnixSetBlockingMode(int fd, int mode); diff --git a/win/Makefile.in b/win/Makefile.in index 2bde8b6..04ae08f 100644 --- a/win/Makefile.in +++ b/win/Makefile.in @@ -82,7 +82,7 @@ CFLAGS_OPTIMIZE = @CFLAGS_OPTIMIZE@ #CFLAGS = $(CFLAGS_DEBUG) #CFLAGS = $(CFLAGS_OPTIMIZE) #CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_OPTIMIZE) -CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DMP_FIXED_CUTOFFS -D__USE_MINGW_ANSI_STDIO=0 -DMP_NO_STDINT +CFLAGS = @CFLAGS@ @CFLAGS_DEFAULT@ -DMP_FIXED_CUTOFFS -D__USE_MINGW_ANSI_STDIO=0 # To compile without backward compatibility and deprecated code uncomment the # following diff --git a/win/configure b/win/configure index d47fc6cb..23c1dda 100755 --- a/win/configure +++ b/win/configure @@ -4779,53 +4779,6 @@ printf "%s\n" "#define EXCEPTION_DISPOSITION int" >>confdefs.h fi - # Check to see if winnt.h defines CHAR, SHORT, and LONG - # even if VOID has already been #defined. The win32api - # used by mingw and cygwin is known to do this. - - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for winnt.h that ignores VOID define" >&5 -printf %s "checking for winnt.h that ignores VOID define... " >&6; } -if test ${tcl_cv_winnt_ignore_void+y} -then : - printf %s "(cached) " >&6 -else $as_nop - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - - #define VOID void - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - #undef WIN32_LEAN_AND_MEAN - -int -main (void) -{ - - CHAR c; - SHORT s; - LONG l; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - tcl_cv_winnt_ignore_void=yes -else $as_nop - tcl_cv_winnt_ignore_void=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_winnt_ignore_void" >&5 -printf "%s\n" "$tcl_cv_winnt_ignore_void" >&6; } - if test "$tcl_cv_winnt_ignore_void" = "yes" ; then - -printf "%s\n" "#define HAVE_WINNT_IGNORE_VOID 1" >>confdefs.h - - fi - ac_fn_c_check_header_compile "$LINENO" "stdbool.h" "ac_cv_header_stdbool_h" "$ac_includes_default" if test "x$ac_cv_header_stdbool_h" = xyes then : diff --git a/win/tcl.dsp b/win/tcl.dsp index db2b896..8dd4835 100644 --- a/win/tcl.dsp +++ b/win/tcl.dsp @@ -136,14 +136,6 @@ CFG=tcl - Win32 Debug Static # PROP Default_Filter ""
# Begin Source File
-SOURCE=..\compat\dirent.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\compat\dirent2.h
-# End Source File
-# Begin Source File
-
SOURCE=..\compat\dlfcn.h
# End Source File
# Begin Source File
@@ -156,48 +148,12 @@ SOURCE=..\compat\limits.h # End Source File
# Begin Source File
-SOURCE=..\compat\memcmp.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\compat\opendir.c
-# End Source File
-# Begin Source File
-
SOURCE=..\compat\README
# End Source File
# Begin Source File
-SOURCE=..\compat\stdlib.h
-# End Source File
-# Begin Source File
-
SOURCE=..\compat\string.h
# End Source File
-# Begin Source File
-
-SOURCE=..\compat\strncasecmp.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\compat\strstr.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\compat\strtol.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\compat\strtoul.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\compat\tclErrno.h
-# End Source File
-# Begin Source File
-
-SOURCE=..\compat\waitpid.c
-# End Source File
# End Group
# Begin Group "doc"
@@ -938,30 +938,6 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ [Defined when cygwin/mingw does not support EXCEPTION DISPOSITION]) fi - # Check to see if winnt.h defines CHAR, SHORT, and LONG - # even if VOID has already been #defined. The win32api - # used by mingw and cygwin is known to do this. - - AC_CACHE_CHECK(for winnt.h that ignores VOID define, - tcl_cv_winnt_ignore_void, - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - #define VOID void - #define WIN32_LEAN_AND_MEAN - #include <windows.h> - #undef WIN32_LEAN_AND_MEAN - ]], [[ - CHAR c; - SHORT s; - LONG l; - ]])], - [tcl_cv_winnt_ignore_void=yes], - [tcl_cv_winnt_ignore_void=no]) - ) - if test "$tcl_cv_winnt_ignore_void" = "yes" ; then - AC_DEFINE(HAVE_WINNT_IGNORE_VOID, 1, - [Defined when cygwin/mingw ignores VOID define in winnt.h]) - fi - AC_CHECK_HEADER(stdbool.h, [AC_DEFINE(HAVE_STDBOOL_H, 1, [Do we have <stdbool.h>?])],) # See if the compiler supports casting to a union type. diff --git a/win/tclWinPort.h b/win/tclWinPort.h index cc9453b..f549420 100644 --- a/win/tclWinPort.h +++ b/win/tclWinPort.h @@ -92,12 +92,6 @@ typedef DWORD_PTR * PDWORD_PTR; # include <inttypes.h> #endif #include <limits.h> -#ifdef HAVE_STDINT_H -# include <stdint.h> -#else -# include "../compat/stdint.h" -#endif - #ifndef __GNUC__ # define strncasecmp _strnicmp # define strcasecmp _stricmp |
