summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/lib
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1998-01-26 03:09:57 +0000
committerpeter <peter@FreeBSD.org>1998-01-26 03:09:57 +0000
commite6e45661e44f15cb8c5c6f063080509bd910b98d (patch)
treea9812ba7ade0fde6f62c1626b45d522ba104c314 /contrib/cvs/lib
parent571cfa0005d94d99d1341bf8ab02be04d4df5f9f (diff)
downloadFreeBSD-src-e6e45661e44f15cb8c5c6f063080509bd910b98d.zip
FreeBSD-src-e6e45661e44f15cb8c5c6f063080509bd910b98d.tar.gz
Import cvs-1.9.23 as at 19980123. There are a number of really nice
things fixed in here, including the '-ko' vs. -A problem with remote cvs which caused all files with -ko to be resent each time (which is damn painful over a modem, I can tell you). It also found a heap of stray empty directories that should have been pruned with the -P flag to cvs update but were not for some reason. It also has the fully integrated rcs and diff, so no more fork/exec overheads for rcs,ci,patch,diff,etc. This means that it parses the control data in the rcs files only once rather than twice or more. If the 'cvs diff' vs. Index thing is going to be fixed for future patch compatability, this is the place to do it.
Diffstat (limited to 'contrib/cvs/lib')
-rw-r--r--contrib/cvs/lib/ChangeLog74
-rw-r--r--contrib/cvs/lib/Makefile.in6
-rw-r--r--contrib/cvs/lib/fncase.c115
-rw-r--r--contrib/cvs/lib/getdate.y32
-rw-r--r--contrib/cvs/lib/getline.c34
-rw-r--r--contrib/cvs/lib/system.h80
-rw-r--r--contrib/cvs/lib/xgetwd.c12
7 files changed, 298 insertions, 55 deletions
diff --git a/contrib/cvs/lib/ChangeLog b/contrib/cvs/lib/ChangeLog
index 02a0e1f..3d858ab 100644
--- a/contrib/cvs/lib/ChangeLog
+++ b/contrib/cvs/lib/ChangeLog
@@ -1,3 +1,77 @@
+13 Jan 1998 Jim Kingdon
+
+ * fncase.c: Include config.h before system.h.
+
+ * system.h: Just include string.h unconditionally. We already
+ include it unconditionally elsewhere.
+
+Tue Jan 13 16:51:59 1998 Ian Lance Taylor <ian@cygnus.com>
+
+ * fncase.c: New file, taken from windows-NT/filesubr.c.
+ * system.h: If __CYGWIN32__ or WIN32 are defined, define
+ FOLD_FN_CHAR, FILENAMES_CASE_INSENSITIVE, and ISDIRSEP, and
+ declare fncmp and fnfold. Taken from windows-NT/config.h.
+ * Makefile.in (SOURCES): Add fncase.c.
+
+Sat Jan 10 10:51:26 1998 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * getline.c (getstr): Make sure to set errno when appropriate. I
+ didn't test the error case for the new code but inspection shows
+ the old code was rather broken.
+
+Sat Nov 29 22:03:39 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ getwd and getcwd were a big big mess. Although Jim's fix might
+ indeed be fixing a typo, the code is so tangled that I would guess
+ it probably breaks some system. So clean this up:
+ * xgetwd.c: Always assume we have getcwd (we had been anyway,
+ before Jim's change).
+ * getwd.c: Removed.
+ * Makefile.in: Remove getwd.c
+ * system.h: Remove declarations of getwd and getcwd. Move getcwd
+ declaration to the !HAVE_UNISTD_H section.
+
+1997-11-29 Jim Meyering <meyering@na-net.ornl.gov>
+
+ * xgetwd.c: Fix typo s/ifndef/ifdef/ in test of HAVE_GETWD.
+
+Wed Nov 26 10:12:33 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * system.h: Always use "rb" and "wb". Check for O_BINARY with an
+ #ifdef, not the error-prone LINES_CRLF_TERMINATED.
+
+Thu Sep 25 10:57:39 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * getdate.y (get_date): If gmtime returns NULL, try to cope.
+ * getdate.c: Regenerated using byacc.
+
+ * getdate.y: Remove comment about sending email concerning this file
+ to Rich Salz.
+ * getdate.c: Regenerated using byacc.
+
+Wed Sep 24 10:35:38 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * Makefile.in (OBJECTS): Add regex.o.
+
+Wed Sep 17 16:37:17 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * getdate.y (ToSeconds): For am or pm, a hour of "12" really means 0.
+ * getdate.c: Regenerated using byacc (not bison per comment).
+
+Tue Sep 9 20:51:45 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * build_lib.com: Add vasprintf.c and vasprintf.obj.
+
+ * build_lib.com: Remove strippath.obj from library/create command.
+
+Sun Sep 7 17:35:27 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
+
+ * system.h: Replace comment referring to ChangeLog with a
+ comment based on the ChangeLog entries.
+
+ * strdup.c: Removed, per change to ../configure.in
+ * Makefile.in (SOURCES): Remove strdup.c.
+
Mon Jun 16 18:59:50 1997 Jim Kingdon <kingdon@harvey.cyclic.com>
* system.h: Add CVS_FNMATCH.
diff --git a/contrib/cvs/lib/Makefile.in b/contrib/cvs/lib/Makefile.in
index 9645ae9..9c32d9f 100644
--- a/contrib/cvs/lib/Makefile.in
+++ b/contrib/cvs/lib/Makefile.in
@@ -25,6 +25,7 @@ exec_prefix = @exec_prefix@
SOURCES = \
argmatch.c \
dup2.c \
+ fncase.c \
fnmatch.c \
ftruncate.c \
getdate.c \
@@ -32,7 +33,6 @@ SOURCES = \
getline.c \
getopt.c \
getopt1.c \
- getwd.c \
hostname.c \
md5.c \
mkdir.c \
@@ -40,7 +40,6 @@ SOURCES = \
rename.c \
savecwd.c \
sighandle.c \
- strdup.c \
strstr.c \
strerror.c \
stripslash.c \
@@ -53,6 +52,7 @@ SOURCES = \
HEADERS = getline.h getopt.h fnmatch.h regex.h system.h wait.h md5.h savecwd.h
+# See long comment in ../configure.in concerning inclusion of regex.o.
OBJECTS = \
@LIBOBJS@ \
argmatch.o \
@@ -60,6 +60,7 @@ OBJECTS = \
getopt.o \
getopt1.o \
md5.o \
+ regex.o \
savecwd.o \
sighandle.o \
stripslash.o \
@@ -142,7 +143,6 @@ getdate.c: getdate.y
fnmatch.o: fnmatch.h
getopt1.o: getopt.h
regex.o: regex.h
-getwd.o: system.h
md5.o: md5.h
xlint:
diff --git a/contrib/cvs/lib/fncase.c b/contrib/cvs/lib/fncase.c
new file mode 100644
index 0000000..56e7f51
--- /dev/null
+++ b/contrib/cvs/lib/fncase.c
@@ -0,0 +1,115 @@
+/* fncase.c -- CVS support for case insensitive file systems.
+ Jim Blandy <jimb@cyclic.com>
+
+ This file is part of GNU CVS.
+
+ GNU CVS is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details. */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "system.h"
+
+/* The equivalence class mapping for filenames.
+ Windows NT filenames are case-insensitive, but case-preserving.
+ Both / and \ are path element separators.
+ Thus, this table maps both upper and lower case to lower case, and
+ both / and \ to /. */
+
+#if 0
+main ()
+{
+ int c;
+
+ for (c = 0; c < 256; c++)
+ {
+ int t;
+
+ if (c == '\\')
+ t = '/';
+ else
+ t = tolower (c);
+
+ if ((c & 0x7) == 0x0)
+ printf (" ");
+ printf ("0x%02x,", t);
+ if ((c & 0x7) == 0x7)
+ putchar ('\n');
+ else if ((c & 0x7) == 0x3)
+ putchar (' ');
+ }
+}
+#endif
+
+unsigned char
+WNT_filename_classes[] =
+{
+ 0x00,0x01,0x02,0x03, 0x04,0x05,0x06,0x07,
+ 0x08,0x09,0x0a,0x0b, 0x0c,0x0d,0x0e,0x0f,
+ 0x10,0x11,0x12,0x13, 0x14,0x15,0x16,0x17,
+ 0x18,0x19,0x1a,0x1b, 0x1c,0x1d,0x1e,0x1f,
+ 0x20,0x21,0x22,0x23, 0x24,0x25,0x26,0x27,
+ 0x28,0x29,0x2a,0x2b, 0x2c,0x2d,0x2e,0x2f,
+ 0x30,0x31,0x32,0x33, 0x34,0x35,0x36,0x37,
+ 0x38,0x39,0x3a,0x3b, 0x3c,0x3d,0x3e,0x3f,
+ 0x40,0x61,0x62,0x63, 0x64,0x65,0x66,0x67,
+ 0x68,0x69,0x6a,0x6b, 0x6c,0x6d,0x6e,0x6f,
+ 0x70,0x71,0x72,0x73, 0x74,0x75,0x76,0x77,
+ 0x78,0x79,0x7a,0x5b, 0x2f,0x5d,0x5e,0x5f,
+ 0x60,0x61,0x62,0x63, 0x64,0x65,0x66,0x67,
+ 0x68,0x69,0x6a,0x6b, 0x6c,0x6d,0x6e,0x6f,
+ 0x70,0x71,0x72,0x73, 0x74,0x75,0x76,0x77,
+ 0x78,0x79,0x7a,0x7b, 0x7c,0x7d,0x7e,0x7f,
+ 0x80,0x81,0x82,0x83, 0x84,0x85,0x86,0x87,
+ 0x88,0x89,0x8a,0x8b, 0x8c,0x8d,0x8e,0x8f,
+ 0x90,0x91,0x92,0x93, 0x94,0x95,0x96,0x97,
+ 0x98,0x99,0x9a,0x9b, 0x9c,0x9d,0x9e,0x9f,
+ 0xa0,0xa1,0xa2,0xa3, 0xa4,0xa5,0xa6,0xa7,
+ 0xa8,0xa9,0xaa,0xab, 0xac,0xad,0xae,0xaf,
+ 0xb0,0xb1,0xb2,0xb3, 0xb4,0xb5,0xb6,0xb7,
+ 0xb8,0xb9,0xba,0xbb, 0xbc,0xbd,0xbe,0xbf,
+ 0xc0,0xc1,0xc2,0xc3, 0xc4,0xc5,0xc6,0xc7,
+ 0xc8,0xc9,0xca,0xcb, 0xcc,0xcd,0xce,0xcf,
+ 0xd0,0xd1,0xd2,0xd3, 0xd4,0xd5,0xd6,0xd7,
+ 0xd8,0xd9,0xda,0xdb, 0xdc,0xdd,0xde,0xdf,
+ 0xe0,0xe1,0xe2,0xe3, 0xe4,0xe5,0xe6,0xe7,
+ 0xe8,0xe9,0xea,0xeb, 0xec,0xed,0xee,0xef,
+ 0xf0,0xf1,0xf2,0xf3, 0xf4,0xf5,0xf6,0xf7,
+ 0xf8,0xf9,0xfa,0xfb, 0xfc,0xfd,0xfe,0xff,
+};
+
+/* Like strcmp, but with the appropriate tweaks for file names.
+ Under Windows NT, filenames are case-insensitive but case-preserving,
+ and both \ and / are path element separators. */
+int
+fncmp (const char *n1, const char *n2)
+{
+ while (*n1 && *n2
+ && (WNT_filename_classes[(unsigned char) *n1]
+ == WNT_filename_classes[(unsigned char) *n2]))
+ n1++, n2++;
+ return (WNT_filename_classes[(unsigned char) *n1]
+ - WNT_filename_classes[(unsigned char) *n2]);
+}
+
+/* Fold characters in FILENAME to their canonical forms.
+ If FOLD_FN_CHAR is not #defined, the system provides a default
+ definition for this. */
+void
+fnfold (char *filename)
+{
+ while (*filename)
+ {
+ *filename = FOLD_FN_CHAR (*filename);
+ filename++;
+ }
+}
diff --git a/contrib/cvs/lib/getdate.y b/contrib/cvs/lib/getdate.y
index 8ed565c..fdb177d 100644
--- a/contrib/cvs/lib/getdate.y
+++ b/contrib/cvs/lib/getdate.y
@@ -4,7 +4,6 @@
** at the University of North Carolina at Chapel Hill. Later tweaked by
** a couple of people on Usenet. Completely overhauled by Rich $alz
** <rsalz@bbn.com> and Jim Berets <jberets@bbn.com> in August, 1990;
-** send any email to Rich.
**
** This grammar has 10 shift/reduce conflicts.
**
@@ -604,10 +603,14 @@ ToSeconds(Hours, Minutes, Seconds, Meridian)
case MERam:
if (Hours < 1 || Hours > 12)
return -1;
+ if (Hours == 12)
+ Hours = 0;
return (Hours * 60L + Minutes) * 60L + Seconds;
case MERpm:
if (Hours < 1 || Hours > 12)
return -1;
+ if (Hours == 12)
+ Hours = 0;
return ((Hours + 12) * 60L + Minutes) * 60L + Seconds;
default:
abort ();
@@ -913,17 +916,34 @@ get_date(p, now)
yyInput = p;
if (now == NULL) {
+ struct tm *gmt_ptr;
+
now = &ftz;
(void)time (&nowtime);
- if (! (tm = gmtime (&nowtime)))
- return -1;
- gmt = *tm; /* Make a copy, in case localtime modifies *tm. */
+ gmt_ptr = gmtime (&nowtime);
+ if (gmt_ptr != NULL)
+ {
+ /* Make a copy, in case localtime modifies *tm (I think
+ that comment now applies to *gmt_ptr, but I am too
+ lazy to dig into how gmtime and locatime allocate the
+ structures they return pointers to). */
+ gmt = *gmt_ptr;
+ }
if (! (tm = localtime (&nowtime)))
return -1;
-
- ftz.timezone = difftm (&gmt, tm) / 60;
+
+ if (gmt_ptr != NULL)
+ ftz.timezone = difftm (&gmt, tm) / 60;
+ else
+ /* We are on a system like VMS, where the system clock is
+ in local time and the system has no concept of timezones.
+ Hopefully we can fake this out (for the case in which the
+ user specifies no timezone) by just saying the timezone
+ is zero. */
+ ftz.timezone = 0;
+
if(tm->tm_isdst)
ftz.timezone += 60;
}
diff --git a/contrib/cvs/lib/getline.c b/contrib/cvs/lib/getline.c
index 5f4fba6..5b63fc1 100644
--- a/contrib/cvs/lib/getline.c
+++ b/contrib/cvs/lib/getline.c
@@ -21,6 +21,7 @@ General Public License for more details. */
#include <sys/types.h>
#include <stdio.h>
#include <assert.h>
+#include <errno.h>
#if STDC_HEADERS
#include <stdlib.h>
@@ -35,7 +36,9 @@ char *malloc (), *realloc ();
+ OFFSET (and null-terminate it). *LINEPTR is a pointer returned from
malloc (or NULL), pointing to *N characters of space. It is realloc'd
as necessary. Return the number of characters read (not including the
- null terminator), or -1 on error or EOF. */
+ null terminator), or -1 on error or EOF. On a -1 return, the caller
+ should check feof(), if not then errno has been set to indicate
+ the error. */
int
getstr (lineptr, n, stream, terminator, offset)
@@ -50,14 +53,20 @@ getstr (lineptr, n, stream, terminator, offset)
int ret;
if (!lineptr || !n || !stream)
- return -1;
+ {
+ errno = EINVAL;
+ return -1;
+ }
if (!*lineptr)
{
*n = MIN_CHUNK;
*lineptr = malloc (*n);
if (!*lineptr)
- return -1;
+ {
+ errno = ENOMEM;
+ return -1;
+ }
}
nchars_avail = *n - offset;
@@ -65,8 +74,11 @@ getstr (lineptr, n, stream, terminator, offset)
for (;;)
{
+ int save_errno;
register int c = getc (stream);
+ save_errno = errno;
+
/* We always want at least one char left in the buffer, since we
always (unless we get an error while reading the first char)
NUL-terminate the line buffer. */
@@ -82,12 +94,24 @@ getstr (lineptr, n, stream, terminator, offset)
nchars_avail = *n + *lineptr - read_pos;
*lineptr = realloc (*lineptr, *n);
if (!*lineptr)
- return -1;
+ {
+ errno = ENOMEM;
+ return -1;
+ }
read_pos = *n - nchars_avail + *lineptr;
assert((*lineptr + *n) == (read_pos + nchars_avail));
}
- if (c == EOF || ferror (stream))
+ if (ferror (stream))
+ {
+ /* Might like to return partial line, but there is no
+ place for us to store errno. And we don't want to just
+ lose errno. */
+ errno = save_errno;
+ return -1;
+ }
+
+ if (c == EOF)
{
/* Return partial line, if any. */
if (read_pos == *lineptr)
diff --git a/contrib/cvs/lib/system.h b/contrib/cvs/lib/system.h
index 1a692ff..7648b76 100644
--- a/contrib/cvs/lib/system.h
+++ b/contrib/cvs/lib/system.h
@@ -27,8 +27,14 @@
#undef S_ISNWK
#endif
-/* Not all systems have S_IFMT, but we probably want to use it if we
- do. See ChangeLog for a more detailed discussion. */
+/* Not all systems have S_IFMT, but we want to use it if we have it.
+ The S_IFMT code below looks right (it masks and compares). The
+ non-S_IFMT code looks bogus (are there really systems on which
+ S_IFBLK, S_IFLNK, &c, each have their own bit? I suspect it was
+ written for OS/2 using the IBM C/C++ Tools 2.01 compiler).
+
+ Of course POSIX systems will have S_IS*, so maybe the issue is
+ semi-moot. */
#if !defined(S_ISBLK) && defined(S_IFBLK)
# if defined(S_IFMT)
@@ -147,6 +153,7 @@
#include <limits.h>
#else
off_t lseek ();
+char *getcwd ();
#endif
#if TIME_WITH_SYS_TIME
@@ -276,16 +283,7 @@ int utime ();
# endif
#endif
-#if STDC_HEADERS || HAVE_STRING_H
-# include <string.h>
- /* An ANSI string.h and pre-ANSI memory.h might conflict. */
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif /* not STDC_HEADERS and HAVE_MEMORY_H */
-#else /* not STDC_HEADERS and not HAVE_STRING_H */
-# include <strings.h>
- /* memory.h and strings.h conflict on some systems. */
-#endif /* not STDC_HEADERS and not HAVE_STRING_H */
+#include <string.h>
#ifndef ERRNO_H_MISSING
#include <errno.h>
@@ -329,12 +327,6 @@ extern int errno;
#define EXIT_FAILURE 1
#endif
-#if defined(USG) || defined(POSIX)
-char *getcwd ();
-#else
-char *getwd ();
-#endif
-
/* check for POSIX signals */
#if defined(HAVE_SIGACTION) && defined(HAVE_SIGPROCMASK)
# define POSIX_SIGNALS
@@ -470,6 +462,31 @@ char *getwd ();
#define CVS_FNMATCH fnmatch
#endif
+#if defined (__CYGWIN32__) || defined (WIN32)
+
+/* Under Windows NT, filenames are case-insensitive, and both / and \
+ are path component separators. */
+
+#define FOLD_FN_CHAR(c) (WNT_filename_classes[(unsigned char) (c)])
+extern unsigned char WNT_filename_classes[];
+#define FILENAMES_CASE_INSENSITIVE 1
+
+/* Is the character C a path name separator? Under
+ Windows NT, you can use either / or \. */
+#define ISDIRSEP(c) (FOLD_FN_CHAR(c) == '/')
+
+/* Like strcmp, but with the appropriate tweaks for file names.
+ Under Windows NT, filenames are case-insensitive but case-preserving,
+ and both \ and / are path element separators. */
+extern int fncmp (const char *n1, const char *n2);
+
+/* Fold characters in FILENAME to their canonical forms.
+ If FOLD_FN_CHAR is not #defined, the system provides a default
+ definition for this. */
+extern void fnfold (char *FILENAME);
+
+#endif /* defined (__CYGWIN32__) || defined (WIN32) */
+
/* Some file systems are case-insensitive. If FOLD_FN_CHAR is
#defined, it maps the character C onto its "canonical" form. In a
case-insensitive system, it would map all alphanumeric characters
@@ -488,21 +505,22 @@ char *getwd ();
#endif
-/* On some systems, lines in text files should be terminated with CRLF,
- not just LF, and the read and write routines do this translation
- for you. LINES_CRLF_TERMINATED is #defined on such systems.
- - OPEN_BINARY is the flag to pass to the open function for
- untranslated I/O.
- - FOPEN_BINARY_READ is the string to pass to fopen to get
- untranslated reading.
- - FOPEN_BINARY_WRITE is the string to pass to fopen to get
- untranslated writing. */
-#if LINES_CRLF_TERMINATED
-#define OPEN_BINARY (O_BINARY)
+/* On some systems, we have to be careful about writing/reading files
+ in text or binary mode (so in text mode the system can handle CRLF
+ vs. LF, VMS text file conventions, &c). We decide to just always
+ be careful. That way we don't have to worry about whether text and
+ binary differ on this system. We just have to worry about whether
+ the system has O_BINARY and "rb". The latter is easy; all ANSI C
+ libraries have it, SunOS4 has it, and CVS has used it unguarded
+ some places for a while now without complaints (e.g. "rb" in
+ server.c (server_updated), since CVS 1.8). The former is just an
+ #ifdef. */
+
#define FOPEN_BINARY_READ ("rb")
#define FOPEN_BINARY_WRITE ("wb")
+
+#ifdef O_BINARY
+#define OPEN_BINARY (O_BINARY)
#else
#define OPEN_BINARY (0)
-#define FOPEN_BINARY_READ ("r")
-#define FOPEN_BINARY_WRITE ("w")
#endif
diff --git a/contrib/cvs/lib/xgetwd.c b/contrib/cvs/lib/xgetwd.c
index e2a3baa..bbae81d 100644
--- a/contrib/cvs/lib/xgetwd.c
+++ b/contrib/cvs/lib/xgetwd.c
@@ -1,5 +1,5 @@
/* xgetwd.c -- return current directory with unlimited length
- Copyright (C) 1992 Free Software Foundation, Inc.
+ Copyright (C) 1992, 1997 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -26,14 +26,6 @@ extern int errno;
#endif
#include <sys/types.h>
-#ifndef HAVE_GETWD
-char *getwd ();
-#define GETWD(buf, max) getwd (buf)
-#else
-char *getcwd ();
-#define GETWD(buf, max) getcwd (buf, max)
-#endif
-
/* Amount by which to increase buffer size when allocating more space. */
#define PATH_INCR 32
@@ -57,7 +49,7 @@ xgetwd ()
cwd = xmalloc (path_max);
errno = 0;
- while ((ret = GETWD (cwd, path_max)) == NULL && errno == ERANGE)
+ while ((ret = getcwd (cwd, path_max)) == NULL && errno == ERANGE)
{
path_max += PATH_INCR;
cwd = xrealloc (cwd, path_max);
OpenPOWER on IntegriCloud