summaryrefslogtreecommitdiffstats
path: root/compat
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2023-06-27 06:55:41 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2023-06-27 06:55:41 (GMT)
commit7f18f499d0213379c1af47cc57c59b872b2e9533 (patch)
tree7972d19659b876b78ec7f68bbd3d85d33b2ccd86 /compat
parente8d619b292256c1d44b578c2d54319527e4c5d23 (diff)
parent04d66a25716cb7738dad3170cca4d0a4683db08a (diff)
downloadtcl-7f18f499d0213379c1af47cc57c59b872b2e9533.zip
tcl-7f18f499d0213379c1af47cc57c59b872b2e9533.tar.gz
tcl-7f18f499d0213379c1af47cc57c59b872b2e9533.tar.bz2
Merge 8.7
Diffstat (limited to 'compat')
-rw-r--r--compat/dirent.h21
-rw-r--r--compat/dirent2.h53
-rw-r--r--compat/memcmp.c64
-rw-r--r--compat/opendir.c109
-rw-r--r--compat/strstr.c70
-rw-r--r--compat/strtol.c77
-rw-r--r--compat/strtoul.c214
7 files changed, 0 insertions, 608 deletions
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/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;
-}