diff options
author | peter <peter@FreeBSD.org> | 1995-12-10 22:31:58 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1995-12-10 22:31:58 +0000 |
commit | c3c3e9aba6d002529b8e3b6651ea485f81b879ad (patch) | |
tree | a30333a66eed74477c5cb0ebe9623b52e9e9a385 /gnu/usr.bin/cvs/lib | |
parent | 2dbe609ba8a4cefd78f3867f74b53b3a507b9883 (diff) | |
download | FreeBSD-src-c3c3e9aba6d002529b8e3b6651ea485f81b879ad.zip FreeBSD-src-c3c3e9aba6d002529b8e3b6651ea485f81b879ad.tar.gz |
Import CVS-1.6.3-951211.. Basically, this is the cvs-1.6.2 release
plus a couple of minor changes..
Some highlights of the new stuff that was not in the old version:
- remote access support.. full checkout/commit/log/etc..
- much improved dead file support..
- speed improvements
- better $CVSROOT handling
- $Name$ support
- support for a "cvsadmin" group to cut down rampant use of "cvs admin -o"
- safer setuid/setgid support
- many bugs fixed.. :-)
- probably some new ones.. :-(
- more that I cannot remember offhand..
Diffstat (limited to 'gnu/usr.bin/cvs/lib')
-rw-r--r-- | gnu/usr.bin/cvs/lib/argmatch.c | 4 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/config.h | 110 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/error.c | 87 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/getdate.y | 8 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/getopt.c | 6 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/hash.c | 15 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/hash.h | 17 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/myndbm.c | 4 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/sighandle.c | 33 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/subr.c | 817 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/system.h | 338 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/version.c | 20 | ||||
-rw-r--r-- | gnu/usr.bin/cvs/lib/wait.h | 3 |
13 files changed, 545 insertions, 917 deletions
diff --git a/gnu/usr.bin/cvs/lib/argmatch.c b/gnu/usr.bin/cvs/lib/argmatch.c index 327a27d..cc360ee 100644 --- a/gnu/usr.bin/cvs/lib/argmatch.c +++ b/gnu/usr.bin/cvs/lib/argmatch.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include <sys/types.h> + #include <stdio.h> #ifdef STDC_HEADERS #include <string.h> @@ -39,7 +41,7 @@ argmatch (arg, optlist) char **optlist; { int i; /* Temporary index in OPTLIST. */ - int arglen; /* Length of ARG. */ + size_t arglen; /* Length of ARG. */ int matchind = -1; /* Index of first nonexact match. */ int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */ diff --git a/gnu/usr.bin/cvs/lib/config.h b/gnu/usr.bin/cvs/lib/config.h index cd1b857..ce06c62 100644 --- a/gnu/usr.bin/cvs/lib/config.h +++ b/gnu/usr.bin/cvs/lib/config.h @@ -1,11 +1,20 @@ /* config.h. Generated automatically by configure. */ /* config.h.in. Generated automatically from configure.in by autoheader. */ +/* Define if on AIX 3. + System headers sometimes define this. + We just want to avoid a redefinition error message. */ +#ifndef _ALL_SOURCE +/* #undef _ALL_SOURCE */ +#endif + /* Define if using alloca.c. */ /* #undef C_ALLOCA */ /* Define if type char is unsigned and you are not using gcc. */ +#ifndef __CHAR_UNSIGNED__ /* #undef __CHAR_UNSIGNED__ */ +#endif /* Define to empty if the keyword does not work. */ /* #undef const */ @@ -17,21 +26,33 @@ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef gid_t */ +/* Define if you have alloca, as a function or macro. */ +#define HAVE_ALLOCA 1 + /* Define if you have <alloca.h> and it should be used (not on Ultrix). */ /* #undef HAVE_ALLOCA_H */ /* Define if you support file names longer than 14 characters. */ #define HAVE_LONG_FILE_NAMES 1 +/* Define if you have <sys/wait.h> that is POSIX.1 compatible. */ +#define HAVE_SYS_WAIT_H 1 + /* Define if utime(file, NULL) sets file's timestamp to the present. */ #define HAVE_UTIME_NULL 1 +/* Define as __inline if that's what the C compiler calls it. */ +/* #undef inline */ + /* Define if on MINIX. */ /* #undef _MINIX */ /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef mode_t */ +/* Define to `int' if <sys/types.h> doesn't define. */ +/* #undef pid_t */ + /* Define if the system does not provide POSIX.1 features except with this defined. */ /* #undef _POSIX_1_SOURCE */ @@ -54,15 +75,43 @@ */ /* #undef STACK_DIRECTION */ +/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */ +/* #undef STAT_MACROS_BROKEN */ + /* Define if you have the ANSI C header files. */ #define STDC_HEADERS 1 -/* Define if your <sys/time.h> declares struct tm. */ -/* #undef TM_IN_SYS_TIME */ +/* Define if you can safely include both <sys/time.h> and <time.h>. */ +#define TIME_WITH_SYS_TIME 1 /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef uid_t */ +/* Define if you have MIT Kerberos version 4 available. */ +/* #undef HAVE_KERBEROS */ + +/* Define if you want CVS to be able to be a remote repository client. */ +#define CLIENT_SUPPORT 1 + +/* Define if you want CVS to be able to serve repositories to remote + clients. */ +#define SERVER_SUPPORT 1 + +/* the path to the gnu diff program on your system */ +#define DIFF "/usr/bin/diff -a" + +/* The number of bytes in a int. */ +#define SIZEOF_INT 4 + +/* The number of bytes in a long. */ +#define SIZEOF_LONG 4 + +/* Define if you have the connect function. */ +/* #undef HAVE_CONNECT */ + +/* Define if you have the fchdir function. */ +#define HAVE_FCHDIR 1 + /* Define if you have the fchmod function. */ #define HAVE_FCHMOD 1 @@ -75,6 +124,12 @@ /* Define if you have the ftruncate function. */ #define HAVE_FTRUNCATE 1 +/* Define if you have the getpagesize function. */ +#define HAVE_GETPAGESIZE 1 + +/* Define if you have the krb_get_err_text function. */ +/* #undef HAVE_KRB_GET_ERR_TEXT */ + /* Define if you have the mkfifo function. */ #define HAVE_MKFIFO 1 @@ -84,12 +139,33 @@ /* Define if you have the setvbuf function. */ #define HAVE_SETVBUF 1 +/* Define if you have the sigaction function. */ +#define HAVE_SIGACTION 1 + +/* Define if you have the sigblock function. */ +#define HAVE_SIGBLOCK 1 + +/* Define if you have the sigprocmask function. */ +#define HAVE_SIGPROCMASK 1 + +/* Define if you have the sigsetmask function. */ +#define HAVE_SIGSETMASK 1 + +/* Define if you have the sigvec function. */ +#define HAVE_SIGVEC 1 + +/* Define if you have the timezone function. */ +#define HAVE_TIMEZONE 1 + /* Define if you have the vfork function. */ #define HAVE_VFORK 1 /* Define if you have the vprintf function. */ #define HAVE_VPRINTF 1 +/* Define if you have the <direct.h> header file. */ +/* #undef HAVE_DIRECT_H */ + /* Define if you have the <dirent.h> header file. */ #define HAVE_DIRENT_H 1 @@ -99,6 +175,9 @@ /* Define if you have the <fcntl.h> header file. */ #define HAVE_FCNTL_H 1 +/* Define if you have the <io.h> header file. */ +/* #undef HAVE_IO_H */ + /* Define if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 @@ -111,23 +190,44 @@ /* Define if you have the <string.h> header file. */ #define HAVE_STRING_H 1 +/* Define if you have the <sys/bsdtypes.h> header file. */ +/* #undef HAVE_SYS_BSDTYPES_H */ + /* Define if you have the <sys/dir.h> header file. */ /* #undef HAVE_SYS_DIR_H */ /* Define if you have the <sys/ndir.h> header file. */ /* #undef HAVE_SYS_NDIR_H */ +/* Define if you have the <sys/param.h> header file. */ +#define HAVE_SYS_PARAM_H 1 + +/* Define if you have the <sys/resource.h> header file. */ +#define HAVE_SYS_RESOURCE_H 1 + /* Define if you have the <sys/select.h> header file. */ #define HAVE_SYS_SELECT_H 1 +/* Define if you have the <sys/time.h> header file. */ +#define HAVE_SYS_TIME_H 1 + /* Define if you have the <sys/timeb.h> header file. */ #define HAVE_SYS_TIMEB_H 1 -/* Define if you have the <sys/wait.h> header file. */ -#define HAVE_SYS_WAIT_H 1 - /* Define if you have the <unistd.h> header file. */ #define HAVE_UNISTD_H 1 /* Define if you have the <utime.h> header file. */ #define HAVE_UTIME_H 1 + +/* Define if you have the inet library (-linet). */ +/* #undef HAVE_LIBINET */ + +/* Define if you have the nsl library (-lnsl). */ +/* #undef HAVE_LIBNSL */ + +/* Define if you have the nsl_s library (-lnsl_s). */ +/* #undef HAVE_LIBNSL_S */ + +/* Define if you have the socket library (-lsocket). */ +/* #undef HAVE_LIBSOCKET */ diff --git a/gnu/usr.bin/cvs/lib/error.c b/gnu/usr.bin/cvs/lib/error.c index 6734c02..0398103 100644 --- a/gnu/usr.bin/cvs/lib/error.c +++ b/gnu/usr.bin/cvs/lib/error.c @@ -18,26 +18,20 @@ /* David MacKenzie */ /* Brian Berliner added support for CVS */ +#include "cvs.h" + #ifndef lint -static char rcsid[] = "$CVSid: @(#)error.c 1.13 94/09/30 $"; +static const char rcsid[] = "$CVSid: @(#)error.c 1.13 94/09/30 $"; +USE(rcsid); #endif /* not lint */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include <stdio.h> -/* turn on CVS support by default, since this is the CVS distribution */ -#define CVS_SUPPORT - -#ifdef CVS_SUPPORT -#if __STDC__ -void Lock_Cleanup(void); -#else -void Lock_Cleanup(); -#endif /* __STDC__ */ -#endif /* CVS_SUPPORT */ +/* If non-zero, error will use the CVS protocol to stdout to report error + messages. This will only be set in the CVS server parent process; + most other code is run via do_cvs_command, which forks off a child + process and packages up its stderr in the protocol. */ +int error_use_protocol; #ifdef HAVE_VPRINTF @@ -74,6 +68,20 @@ void exit (); extern char *strerror (); +typedef void (*fn_returning_void) (); + +/* Function to call before exiting. */ +static fn_returning_void cleanup_fn; + +fn_returning_void +error_set_cleanup (arg) + fn_returning_void arg; +{ + fn_returning_void retval = cleanup_fn; + cleanup_fn = arg; + return retval; +} + /* Print the program name and error message MESSAGE, which is a printf-style format string with optional args. If ERRNUM is nonzero, print its corresponding system error message. @@ -81,60 +89,58 @@ extern char *strerror (); /* VARARGS */ void #if defined (HAVE_VPRINTF) && __STDC__ -error (int status, int errnum, char *message, ...) +error (int status, int errnum, const char *message, ...) #else error (status, errnum, message, va_alist) int status; int errnum; - char *message; + const char *message; va_dcl #endif { + FILE *out = stderr; extern char *program_name; -#ifdef CVS_SUPPORT extern char *command_name; -#endif #ifdef HAVE_VPRINTF va_list args; #endif -#ifdef CVS_SUPPORT + if (error_use_protocol) + { + out = stdout; + printf ("E "); + } + if (command_name && *command_name) if (status) - fprintf (stderr, "%s [%s aborted]: ", program_name, command_name); + fprintf (out, "%s [%s aborted]: ", program_name, command_name); else - fprintf (stderr, "%s %s: ", program_name, command_name); + fprintf (out, "%s %s: ", program_name, command_name); else - fprintf (stderr, "%s: ", program_name); -#else - fprintf (stderr, "%s: ", program_name); -#endif + fprintf (out, "%s: ", program_name); #ifdef HAVE_VPRINTF VA_START (args, message); - vfprintf (stderr, message, args); + vfprintf (out, message, args); va_end (args); #else #ifdef HAVE_DOPRNT - _doprnt (message, &args, stderr); + _doprnt (message, &args, out); #else - fprintf (stderr, message, a1, a2, a3, a4, a5, a6, a7, a8); + fprintf (out, message, a1, a2, a3, a4, a5, a6, a7, a8); #endif #endif if (errnum) - fprintf (stderr, ": %s", strerror (errnum)); - putc ('\n', stderr); - fflush (stderr); + fprintf (out, ": %s", strerror (errnum)); + putc ('\n', out); + fflush (out); if (status) { -#ifdef CVS_SUPPORT - Lock_Cleanup(); -#endif + if (cleanup_fn) + (*cleanup_fn) (); exit (status); } } -#ifdef CVS_SUPPORT - /* Print the program name and error message MESSAGE, which is a printf-style format string with optional args to the file specified by FP. If ERRNUM is nonzero, print its corresponding system error message. @@ -175,11 +181,8 @@ fperror (fp, status, errnum, message, va_alist) fflush (fp); if (status) { -#ifdef CVS_SUPPORT - Lock_Cleanup(); -#endif + if (cleanup_fn) + (*cleanup_fn) (); exit (status); } } - -#endif /* CVS_SUPPORT */ diff --git a/gnu/usr.bin/cvs/lib/getdate.y b/gnu/usr.bin/cvs/lib/getdate.y index 5769e9c..baa1731 100644 --- a/gnu/usr.bin/cvs/lib/getdate.y +++ b/gnu/usr.bin/cvs/lib/getdate.y @@ -92,6 +92,14 @@ struct timeb { #define bcopy(from, to, len) memcpy ((to), (from), (len)) #endif +#if defined (STDC_HEADERS) +#include <stdlib.h> +#endif + +#if defined (HAVE_ALLOCA_H) +#include <alloca.h> +#endif + extern struct tm *gmtime(); extern struct tm *localtime(); diff --git a/gnu/usr.bin/cvs/lib/getopt.c b/gnu/usr.bin/cvs/lib/getopt.c index 446a8e4..f1d8dfa 100644 --- a/gnu/usr.bin/cvs/lib/getopt.c +++ b/gnu/usr.bin/cvs/lib/getopt.c @@ -47,6 +47,10 @@ #include <stdio.h> +#ifdef HAVE_STRING_H +#include <string.h> +#endif + /* Comment out all this code if we are using the GNU C Library, and are not actually compiling the library itself. This code is part of the GNU C Library, but also included in many other GNU distributions. Compiling @@ -494,7 +498,7 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only) for (p = longopts, option_index = 0; p->name; p++, option_index++) if (!strncmp (p->name, nextchar, nameend - nextchar)) { - if (nameend - nextchar == strlen (p->name)) + if (nameend - nextchar == (int) strlen (p->name)) { /* Exact match found. */ pfound = p; diff --git a/gnu/usr.bin/cvs/lib/hash.c b/gnu/usr.bin/cvs/lib/hash.c index afc554d..8ac9323 100644 --- a/gnu/usr.bin/cvs/lib/hash.c +++ b/gnu/usr.bin/cvs/lib/hash.c @@ -10,8 +10,8 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "$CVSid: @(#)hash.c 1.19 94/09/23 $"; -USE(rcsid) +static const char rcsid[] = "$CVSid: @(#)hash.c 1.19 94/09/23 $"; +USE(rcsid); #endif /* global caches */ @@ -23,7 +23,7 @@ static void freenode_mem PROTO((Node * p)); /* hash function */ static int hashp (key) - char *key; + const char *key; { unsigned int h = 0; unsigned int g; @@ -254,7 +254,7 @@ addnode (list, p) Node * findnode (list, key) List *list; - char *key; + const char *key; { Node *head, *p; @@ -277,7 +277,7 @@ findnode (list, key) int walklist (list, proc, closure) List *list; - int (*proc) (); + int (*proc) PROTO ((Node *, void *)); void *closure; { Node *head, *p; @@ -298,7 +298,7 @@ walklist (list, proc, closure) void sortlist (list, comp) List *list; - int (*comp) (); + int (*comp) PROTO ((const Node *, const Node *)); { Node *head, *remain, *p, *q; @@ -363,7 +363,8 @@ nodetypestring (type) return("<trash>"); } -int +static int printnode PROTO ((Node *, void *)); +static int printnode (node, closure) Node *node; void *closure; diff --git a/gnu/usr.bin/cvs/lib/hash.h b/gnu/usr.bin/cvs/lib/hash.h index 8e10e81..e30511a 100644 --- a/gnu/usr.bin/cvs/lib/hash.h +++ b/gnu/usr.bin/cvs/lib/hash.h @@ -44,23 +44,12 @@ struct list }; typedef struct list List; -struct entnode -{ - char *version; - char *timestamp; - char *options; - char *tag; - char *date; - char *conflict; -}; -typedef struct entnode Entnode; - List *getlist PROTO((void)); -Node *findnode PROTO((List * list, char *key)); +Node *findnode PROTO((List * list, const char *key)); Node *getnode PROTO((void)); int addnode PROTO((List * list, Node * p)); -int walklist PROTO((List * list, int PROTO((*proc)) PROTO((Node *n, void *closure)), void *closure)); +int walklist PROTO((List * list, int (*)(Node *n, void *closure), void *closure)); void dellist PROTO((List ** listp)); void delnode PROTO((Node * p)); void freenode PROTO((Node * p)); -void sortlist PROTO((List * list, int PROTO((*comp))())); +void sortlist PROTO((List * list, int (*)(const Node *, const Node *))); diff --git a/gnu/usr.bin/cvs/lib/myndbm.c b/gnu/usr.bin/cvs/lib/myndbm.c index 33ef49c..fef3265 100644 --- a/gnu/usr.bin/cvs/lib/myndbm.c +++ b/gnu/usr.bin/cvs/lib/myndbm.c @@ -18,8 +18,8 @@ #ifdef MY_NDBM #ifndef lint -static char rcsid[] = "$CVSid: @(#)myndbm.c 1.7 94/09/23 $"; -USE(rcsid) +static const char rcsid[] = "$CVSid: @(#)myndbm.c 1.7 94/09/23 $"; +USE(rcsid); #endif static void mydbm_load_file (); diff --git a/gnu/usr.bin/cvs/lib/sighandle.c b/gnu/usr.bin/cvs/lib/sighandle.c index 1db4177..a225983 100644 --- a/gnu/usr.bin/cvs/lib/sighandle.c +++ b/gnu/usr.bin/cvs/lib/sighandle.c @@ -37,6 +37,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif +#include "system.h" #include <sys/types.h> #include <stdio.h> @@ -54,10 +55,6 @@ char *malloc(); #endif /* __STDC__ */ #endif /* STDC_HEADERS */ -#ifdef _MINIX -#undef POSIX /* Minix 1.6 doesn't support POSIX.1 sigaction yet */ -#endif - /* Define the highest signal number (usually) */ #ifndef SIGMAX #define SIGMAX 64 @@ -78,7 +75,7 @@ static struct SIG_hlist **SIG_handlers; /* Define array of default signal vectors */ -#ifdef POSIX +#ifdef POSIX_SIGNALS static struct sigaction *SIG_defaults; #else #ifdef BSD_SIGNALS @@ -90,7 +87,7 @@ static RETSIGTYPE (**SIG_defaults)(); /* Critical section housekeeping */ static int SIG_crSectNest = 0; /* Nesting level */ -#ifdef POSIX +#ifdef POSIX_SIGNALS static sigset_t SIG_crSectMask; /* Signal mask */ #else static int SIG_crSectMask; /* Signal mask */ @@ -103,14 +100,14 @@ static int SIG_crSectMask; /* Signal mask */ static int SIG_init() { int i; -#ifdef POSIX +#ifdef POSIX_SIGNALS sigset_t sigset_test; #endif if (SIG_defaults && SIG_handlers) /* already allocated */ return (0); -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigfillset(&sigset_test); for (i = 1; i < SIGMAX && sigismember(&sigset_test, i) == 1; i++) ; @@ -175,7 +172,7 @@ RETSIGTYPE (*fn)(); { int val; struct SIG_hlist *this; -#ifdef POSIX +#ifdef POSIX_SIGNALS struct sigaction act; sigset_t sigset_mask, sigset_omask; #else @@ -191,7 +188,7 @@ RETSIGTYPE (*fn)(); val = 0; /* Block this signal while we look at handler chain */ -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigemptyset(&sigset_mask); (void) sigaddset(&sigset_mask, sig); (void) sigprocmask(SIG_BLOCK, &sigset_mask, &sigset_omask); @@ -220,7 +217,7 @@ RETSIGTYPE (*fn)(); if (SIG_handlers[sig] == (struct SIG_hlist *) NULL) { -#ifdef POSIX +#ifdef POSIX_SIGNALS act.sa_handler = SIG_handle; (void) sigemptyset(&act.sa_mask); act.sa_flags = 0; @@ -257,7 +254,7 @@ RETSIGTYPE (*fn)(); } /* Unblock the signal */ -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigprocmask(SIG_SETMASK, &sigset_omask, NULL); #else #ifdef BSD_SIGNALS @@ -280,7 +277,7 @@ RETSIGTYPE (*fn)(); int val; struct SIG_hlist *this; struct SIG_hlist *last; -#ifdef POSIX +#ifdef POSIX_SIGNALS sigset_t sigset_mask, sigset_omask; #else #ifdef BSD_SIGNALS @@ -295,7 +292,7 @@ RETSIGTYPE (*fn)(); last = (struct SIG_hlist *) NULL; /* Block this signal while we look at handler chain */ -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigemptyset(&sigset_mask); (void) sigaddset(&sigset_mask, sig); (void) sigprocmask(SIG_BLOCK, &sigset_mask, &sigset_omask); @@ -330,7 +327,7 @@ RETSIGTYPE (*fn)(); /* Restore default behavior if there are no registered handlers */ if (SIG_handlers[sig] == (struct SIG_hlist *) NULL) { -#ifdef POSIX +#ifdef POSIX_SIGNALS val = sigaction(sig, &SIG_defaults[sig], (struct sigaction *) NULL); #else @@ -344,7 +341,7 @@ RETSIGTYPE (*fn)(); } /* Unblock the signal */ -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigprocmask(SIG_SETMASK, &sigset_omask, NULL); #else #ifdef BSD_SIGNALS @@ -365,7 +362,7 @@ void SIG_beginCrSect() { if (SIG_crSectNest == 0) { -#ifdef POSIX +#ifdef POSIX_SIGNALS sigset_t sigset_mask; (void) sigfillset(&sigset_mask); @@ -394,7 +391,7 @@ void SIG_endCrSect() SIG_crSectNest--; if (SIG_crSectNest == 0) { -#ifdef POSIX +#ifdef POSIX_SIGNALS (void) sigprocmask(SIG_SETMASK, &SIG_crSectMask, NULL); #else #ifdef BSD_SIGNALS diff --git a/gnu/usr.bin/cvs/lib/subr.c b/gnu/usr.bin/cvs/lib/subr.c index d3d40b1..228581c 100644 --- a/gnu/usr.bin/cvs/lib/subr.c +++ b/gnu/usr.bin/cvs/lib/subr.c @@ -11,248 +11,11 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "$CVSid: @(#)subr.c 1.64 94/10/07 $"; -USE(rcsid) +static const char rcsid[] = "$CVSid: @(#)subr.c 1.64 94/10/07 $"; +USE(rcsid); #endif -#ifdef _MINIX -#undef POSIX /* Minix 1.6 doesn't support POSIX.1 sigaction yet */ -#endif - -#ifdef HAVE_VPRINTF -#if defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__) -#include <stdarg.h> -#define VA_START(args, lastarg) va_start(args, lastarg) -#else -#include <varargs.h> -#define VA_START(args, lastarg) va_start(args) -#endif -#else -#define va_alist a1, a2, a3, a4, a5, a6, a7, a8 -#define va_dcl char *a1, *a2, *a3, *a4, *a5, *a6, *a7, *a8; -#endif - -/* - * I don't know of a convenient way to test this at configure time, or else - * I'd certainly do it there. - */ -#if defined(NeXT) -#define LOSING_TMPNAM_FUNCTION -#ifndef _POSIX_SOURCE -/* - * NeXT doesn't define these without _POSIX_SOURCE, - * but that changes a lot of things. - */ -#define WEXITSTATUS(x) ((x).w_retcode) -#define WTERMSIG(x) ((x).w_termsig) -#endif -#endif - -static void run_add_arg PROTO((char *s)); -static void run_init_prog PROTO((void)); - extern char *getlogin (); -extern char *strtok (); - -/* - * Copies "from" to "to". mallocs a buffer large enough to hold the entire - * file and does one read/one write to do the copy. This is reasonable, - * since source files are typically not too large. - */ -void -copy_file (from, to) - char *from; - char *to; -{ - struct stat sb; - struct utimbuf t; - int fdin, fdout; - char *buf; - - if (trace) - (void) fprintf (stderr, "-> copy(%s,%s)\n", from, to); - if (noexec) - return; - - if ((fdin = open (from, O_RDONLY)) < 0) - error (1, errno, "cannot open %s for copying", from); - if (fstat (fdin, &sb) < 0) - error (1, errno, "cannot fstat %s", from); - if ((fdout = creat (to, (int) sb.st_mode & 07777)) < 0) - error (1, errno, "cannot create %s for copying", to); - if (sb.st_size > 0) - { - buf = xmalloc ((int) sb.st_size); - if (read (fdin, buf, (int) sb.st_size) != (int) sb.st_size) - error (1, errno, "cannot read file %s for copying", from); - if (write (fdout, buf, (int) sb.st_size) != (int) sb.st_size -#ifdef HAVE_FSYNC - || fsync (fdout) == -1 -#endif - ) - { - error (1, errno, "cannot write file %s for copying", to); - } - free (buf); - } - (void) close (fdin); - if (close (fdout) < 0) - error (1, errno, "cannot close %s", to); - - /* now, set the times for the copied file to match those of the original */ - memset ((char *) &t, 0, sizeof (t)); - t.actime = sb.st_atime; - t.modtime = sb.st_mtime; - (void) utime (to, &t); -} - -/* FIXME-krp: these functions would benefit from caching the char * & - stat buf. */ - -/* - * Returns non-zero if the argument file is a directory, or is a symbolic - * link which points to a directory. - */ -int -isdir (file) - char *file; -{ - struct stat sb; - - if (stat (file, &sb) < 0) - return (0); - return (S_ISDIR (sb.st_mode)); -} - -/* - * Returns non-zero if the argument file is a symbolic link. - */ -int -islink (file) - char *file; -{ -#ifdef S_ISLNK - struct stat sb; - - if (lstat (file, &sb) < 0) - return (0); - return (S_ISLNK (sb.st_mode)); -#else - return (0); -#endif -} - -/* - * Returns non-zero if the argument file exists. - */ -int -isfile (file) - char *file; -{ - struct stat sb; - - if (stat (file, &sb) < 0) - return (0); - return (1); -} - -/* - * Returns non-zero if the argument file is readable. - * XXX - must be careful if "cvs" is ever made setuid! - */ -int -isreadable (file) - char *file; -{ - return (access (file, R_OK) != -1); -} - -/* - * Returns non-zero if the argument file is writable - * XXX - muct be careful if "cvs" is ever made setuid! - */ -int -iswritable (file) - char *file; -{ - return (access (file, W_OK) != -1); -} - -/* - * Open a file and die if it fails - */ -FILE * -open_file (name, mode) - char *name; - char *mode; -{ - FILE *fp; - - if ((fp = fopen (name, mode)) == NULL) - error (1, errno, "cannot open %s", name); - return (fp); -} - -/* - * Open a file if allowed and return. - */ -FILE * -Fopen (name, mode) - char *name; - char *mode; -{ - if (trace) - (void) fprintf (stderr, "-> fopen(%s,%s)\n", name, mode); - if (noexec) - return (NULL); - - return (fopen (name, mode)); -} - -/* - * Make a directory and die if it fails - */ -void -make_directory (name) - char *name; -{ - struct stat buf; - - if (stat (name, &buf) == 0 && (!S_ISDIR (buf.st_mode))) - error (0, 0, "%s already exists but is not a directory", name); - if (!noexec && mkdir (name, 0777) < 0) - error (1, errno, "cannot make directory %s", name); -} - -/* - * Make a path to the argument directory, printing a message if something - * goes wrong. - */ -void -make_directories (name) - char *name; -{ - char *cp; - - if (noexec) - return; - - if (mkdir (name, 0777) == 0 || errno == EEXIST) - return; - if (errno != ENOENT) - { - error (0, errno, "cannot make path to %s", name); - return; - } - if ((cp = strrchr (name, '/')) == NULL) - return; - *cp = '\0'; - make_directories (name); - *cp++ = '/'; - if (*cp == '\0') - return; - (void) mkdir (name, 0777); -} /* * malloc some data and die if it fails @@ -263,7 +26,14 @@ xmalloc (bytes) { char *cp; - if ((cp = malloc (bytes)) == NULL) + /* Parts of CVS try to xmalloc zero bytes and then free it. Some + systems have a malloc which returns NULL for zero byte + allocations but a free which can't handle NULL, so compensate. */ + if (bytes == 0) + bytes = 1; + + cp = malloc (bytes); + if (cp == NULL) error (1, 0, "can not allocate %lu bytes", (unsigned long) bytes); return (cp); } @@ -295,7 +65,7 @@ xrealloc (ptr, bytes) */ char * xstrdup (str) - char *str; + const char *str; { char *s; @@ -306,143 +76,16 @@ xstrdup (str) return (s); } -/* - * Change the mode of a file, either adding write permissions, or removing - * all write permissions. Adding write permissions honors the current umask - * setting. - */ +/* Remove trailing newlines from STRING, destructively. */ void -xchmod (fname, writable) - char *fname; - int writable; +strip_trailing_newlines (str) + char *str; { - struct stat sb; - mode_t mode, oumask; + int len; + len = strlen (str) - 1; - if (stat (fname, &sb) < 0) - { - if (!noexec) - error (0, errno, "cannot stat %s", fname); - return; - } - if (writable) - { - oumask = umask (0); - (void) umask (oumask); - mode = sb.st_mode | ((S_IWRITE | S_IWGRP | S_IWOTH) & ~oumask); - } - else - { - mode = sb.st_mode & ~(S_IWRITE | S_IWGRP | S_IWOTH); - } - - if (trace) - (void) fprintf (stderr, "-> chmod(%s,%o)\n", fname, mode); - if (noexec) - return; - - if (chmod (fname, mode) < 0) - error (0, errno, "cannot change mode of file %s", fname); -} - -/* - * Rename a file and die if it fails - */ -void -rename_file (from, to) - char *from; - char *to; -{ - if (trace) - (void) fprintf (stderr, "-> rename(%s,%s)\n", from, to); - if (noexec) - return; - - if (rename (from, to) < 0) - error (1, errno, "cannot rename file %s to %s", from, to); -} - -/* - * link a file, if possible. - */ -int -link_file (from, to) - char *from, *to; -{ - if (trace) - (void) fprintf (stderr, "-> link(%s,%s)\n", from, to); - if (noexec) - return (0); - - return (link (from, to)); -} - -/* - * unlink a file, if possible. - */ -int -unlink_file (f) - char *f; -{ - if (trace) - (void) fprintf (stderr, "-> unlink(%s)\n", f); - if (noexec) - return (0); - - return (unlink (f)); -} - -/* - * Compare "file1" to "file2". Return non-zero if they don't compare exactly. - * - * mallocs a buffer large enough to hold the entire file and does two reads to - * load the buffer and calls memcmp to do the cmp. This is reasonable, since - * source files are typically not too large. - */ - -/* richfix: this *could* exploit mmap. */ - -int -xcmp (file1, file2) - char *file1; - char *file2; -{ - register char *buf1, *buf2; - struct stat sb; - off_t size; - int ret, fd1, fd2; - - if ((fd1 = open (file1, O_RDONLY)) < 0) - error (1, errno, "cannot open file %s for comparing", file1); - if ((fd2 = open (file2, O_RDONLY)) < 0) - error (1, errno, "cannot open file %s for comparing", file2); - if (fstat (fd1, &sb) < 0) - error (1, errno, "cannot fstat %s", file1); - size = sb.st_size; - if (fstat (fd2, &sb) < 0) - error (1, errno, "cannot fstat %s", file2); - if (size == sb.st_size) - { - if (size == 0) - ret = 0; - else - { - buf1 = xmalloc ((int) size); - buf2 = xmalloc ((int) size); - if (read (fd1, buf1, (int) size) != (int) size) - error (1, errno, "cannot read file %s for comparing", file1); - if (read (fd2, buf2, (int) size) != (int) size) - error (1, errno, "cannot read file %s for comparing", file2); - ret = memcmp(buf1, buf2, (int) size); - free (buf1); - free (buf2); - } - } - else - ret = 1; - (void) close (fd1); - (void) close (fd2); - return (ret); + while (str[len] == '\n') + str[len--] = '\0'; } /* @@ -451,7 +94,7 @@ xcmp (file1, file2) void free_names (pargc, argv) int *pargc; - char *argv[]; + char **argv; { register int i; @@ -470,7 +113,7 @@ free_names (pargc, argv) void line2argv (pargc, argv, line) int *pargc; - char *argv[]; + char **argv; char *line; { char *cp; @@ -488,14 +131,13 @@ line2argv (pargc, argv, line) */ int numdots (s) - char *s; + const char *s; { - char *cp; int dots = 0; - for (cp = s; *cp; cp++) + for (; *s; s++) { - if (*cp == '.') + if (*s == '.') dots++; } return (dots); @@ -518,394 +160,18 @@ getcaller () if (uid == (uid_t) 0) { /* super-user; try getlogin() to distinguish */ - if (((name = getenv("LOGNAME")) || (name = getenv("USER")) || - (name = getlogin ())) && *name) + if (((name = getlogin ()) || (name = getenv("LOGNAME")) || + (name = getenv("USER"))) && *name) return (name); } if ((pw = (struct passwd *) getpwuid (uid)) == NULL) { - (void) sprintf (uidname, "uid%d", (unsigned long) uid); + (void) sprintf (uidname, "uid%lu", (unsigned long) uid); return (uidname); } return (pw->pw_name); } -/* - * To exec a program under CVS, first call run_setup() to setup any initial - * arguments. The options to run_setup are essentially like printf(). The - * arguments will be parsed into whitespace separated words and added to the - * global run_argv list. - * - * Then, optionally call run_arg() for each additional argument that you'd like - * to pass to the executed program. - * - * Finally, call run_exec() to execute the program with the specified arguments. - * The execvp() syscall will be used, so that the PATH is searched correctly. - * File redirections can be performed in the call to run_exec(). - */ -static char *run_prog; -static char **run_argv; -static int run_argc; -static int run_argc_allocated; - -/* VARARGS */ -#if defined (HAVE_VPRINTF) && (defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)) -void -run_setup (char *fmt,...) -#else -void -run_setup (fmt, va_alist) - char *fmt; - va_dcl - -#endif -{ -#ifdef HAVE_VPRINTF - va_list args; - -#endif - char *cp; - int i; - - run_init_prog (); - - /* clean out any malloc'ed values from run_argv */ - for (i = 0; i < run_argc; i++) - { - if (run_argv[i]) - { - free (run_argv[i]); - run_argv[i] = (char *) 0; - } - } - run_argc = 0; - - /* process the varargs into run_prog */ -#ifdef HAVE_VPRINTF - VA_START (args, fmt); - (void) vsprintf (run_prog, fmt, args); - va_end (args); -#else - (void) sprintf (run_prog, fmt, a1, a2, a3, a4, a5, a6, a7, a8); -#endif - - /* put each word into run_argv, allocating it as we go */ - for (cp = strtok (run_prog, " \t"); cp; cp = strtok ((char *) NULL, " \t")) - run_add_arg (cp); -} - -void -run_arg (s) - char *s; -{ - run_add_arg (s); -} - -/* VARARGS */ -#if defined (HAVE_VPRINTF) && (defined (USE_PROTOTYPES) ? USE_PROTOTYPES : defined (__STDC__)) -void -run_args (char *fmt,...) -#else -void -run_args (fmt, va_alist) - char *fmt; - va_dcl - -#endif -{ -#ifdef HAVE_VPRINTF - va_list args; - -#endif - - run_init_prog (); - - /* process the varargs into run_prog */ -#ifdef HAVE_VPRINTF - VA_START (args, fmt); - (void) vsprintf (run_prog, fmt, args); - va_end (args); -#else - (void) sprintf (run_prog, fmt, a1, a2, a3, a4, a5, a6, a7, a8); -#endif - - /* and add the (single) argument to the run_argv list */ - run_add_arg (run_prog); -} - -static void -run_add_arg (s) - char *s; -{ - /* allocate more argv entries if we've run out */ - if (run_argc >= run_argc_allocated) - { - run_argc_allocated += 50; - run_argv = (char **) xrealloc ((char *) run_argv, - run_argc_allocated * sizeof (char **)); - } - - if (s) - run_argv[run_argc++] = xstrdup (s); - else - run_argv[run_argc] = (char *) 0;/* not post-incremented on purpose! */ -} - -static void -run_init_prog () -{ - /* make sure that run_prog is allocated once */ - if (run_prog == (char *) 0) - run_prog = xmalloc (10 * 1024); /* 10K of args for _setup and _arg */ -} - -int -run_exec (stin, stout, sterr, flags) - char *stin; - char *stout; - char *sterr; - int flags; -{ - int shin, shout, sherr; - int mode_out, mode_err; -#if defined(NeXT) && !defined(_POSIX_SOURCE) - union wait status; -#else - int status; -#endif - int rc = -1; - int rerrno = 0; - int pid, w; - -#ifdef POSIX - sigset_t sigset_mask, sigset_omask; - struct sigaction act, iact, qact; - -#else -#ifdef BSD_SIGNALS - int mask; - struct sigvec vec, ivec, qvec; - -#else - RETSIGTYPE (*istat) (), (*qstat) (); -#endif -#endif - - if (trace) - { - (void) fprintf (stderr, "-> system("); - run_print (stderr); - (void) fprintf (stderr, ")\n"); - } - if (noexec && (flags & RUN_REALLY) == 0) - return (0); - - /* make sure that we are null terminated, since we didn't calloc */ - run_add_arg ((char *) 0); - - /* setup default file descriptor numbers */ - shin = 0; - shout = 1; - sherr = 2; - - /* set the file modes for stdout and stderr */ - mode_out = mode_err = O_WRONLY | O_CREAT; - mode_out |= ((flags & RUN_STDOUT_APPEND) ? O_APPEND : O_TRUNC); - mode_err |= ((flags & RUN_STDERR_APPEND) ? O_APPEND : O_TRUNC); - - if (stin && (shin = open (stin, O_RDONLY)) == -1) - { - rerrno = errno; - error (0, errno, "cannot open %s for reading (prog %s)", - stin, run_argv[0]); - goto out0; - } - if (stout && (shout = open (stout, mode_out, 0666)) == -1) - { - rerrno = errno; - error (0, errno, "cannot open %s for writing (prog %s)", - stout, run_argv[0]); - goto out1; - } - if (sterr && (flags & RUN_COMBINED) == 0) - { - if ((sherr = open (sterr, mode_err, 0666)) == -1) - { - rerrno = errno; - error (0, errno, "cannot open %s for writing (prog %s)", - sterr, run_argv[0]); - goto out2; - } - } - - /* Make sure we don't flush this twice, once in the subprocess. */ - fflush (stdout); - fflush (stderr); - - /* The output files, if any, are now created. Do the fork and dups */ -#ifdef HAVE_VFORK - pid = vfork (); -#else - pid = fork (); -#endif - if (pid == 0) - { - if (shin != 0) - { - (void) dup2 (shin, 0); - (void) close (shin); - } - if (shout != 1) - { - (void) dup2 (shout, 1); - (void) close (shout); - } - if (flags & RUN_COMBINED) - (void) dup2 (1, 2); - else if (sherr != 2) - { - (void) dup2 (sherr, 2); - (void) close (sherr); - } - - /* dup'ing is done. try to run it now */ - (void) execvp (run_argv[0], run_argv); - error (0, errno, "cannot exec %s", run_argv[0]); - _exit (127); - } - else if (pid == -1) - { - rerrno = errno; - goto out; - } - - /* the parent. Ignore some signals for now */ -#ifdef POSIX - if (flags & RUN_SIGIGNORE) - { - act.sa_handler = SIG_IGN; - (void) sigemptyset (&act.sa_mask); - act.sa_flags = 0; - (void) sigaction (SIGINT, &act, &iact); - (void) sigaction (SIGQUIT, &act, &qact); - } - else - { - (void) sigemptyset (&sigset_mask); - (void) sigaddset (&sigset_mask, SIGINT); - (void) sigaddset (&sigset_mask, SIGQUIT); - (void) sigprocmask (SIG_SETMASK, &sigset_mask, &sigset_omask); - } -#else -#ifdef BSD_SIGNALS - if (flags & RUN_SIGIGNORE) - { - memset ((char *) &vec, 0, sizeof (vec)); - vec.sv_handler = SIG_IGN; - (void) sigvec (SIGINT, &vec, &ivec); - (void) sigvec (SIGQUIT, &vec, &qvec); - } - else - mask = sigblock (sigmask (SIGINT) | sigmask (SIGQUIT)); -#else - istat = signal (SIGINT, SIG_IGN); - qstat = signal (SIGQUIT, SIG_IGN); -#endif -#endif - - /* wait for our process to die and munge return status */ -#ifdef POSIX - while ((w = waitpid (pid, &status, 0)) == -1 && errno == EINTR) - ; -#else - while ((w = wait (&status)) != pid) - { - if (w == -1 && errno != EINTR) - break; - } -#endif - if (w == -1) - { - rc = -1; - rerrno = errno; - } - else if (WIFEXITED (status)) - rc = WEXITSTATUS (status); - else if (WIFSIGNALED (status)) - { - if (WTERMSIG (status) == SIGPIPE) - error (1, 0, "broken pipe"); - rc = 2; - } - else - rc = 1; - - /* restore the signals */ -#ifdef POSIX - if (flags & RUN_SIGIGNORE) - { - (void) sigaction (SIGINT, &iact, (struct sigaction *) NULL); - (void) sigaction (SIGQUIT, &qact, (struct sigaction *) NULL); - } - else - (void) sigprocmask (SIG_SETMASK, &sigset_omask, (sigset_t *) NULL); -#else -#ifdef BSD_SIGNALS - if (flags & RUN_SIGIGNORE) - { - (void) sigvec (SIGINT, &ivec, (struct sigvec *) NULL); - (void) sigvec (SIGQUIT, &qvec, (struct sigvec *) NULL); - } - else - (void) sigsetmask (mask); -#else - (void) signal (SIGINT, istat); - (void) signal (SIGQUIT, qstat); -#endif -#endif - - /* cleanup the open file descriptors */ - out: - if (sterr) - (void) close (sherr); - out2: - if (stout) - (void) close (shout); - out1: - if (stin) - (void) close (shin); - - out0: - if (rerrno) - errno = rerrno; - return (rc); -} - -void -run_print (fp) - FILE *fp; -{ - int i; - - for (i = 0; i < run_argc; i++) - { - (void) fprintf (fp, "%s", run_argv[i]); - if (i != run_argc - 1) - (void) fprintf (fp, " "); - } -} - -FILE * -Popen (cmd, mode) - char *cmd, *mode; -{ - if (trace) - (void) fprintf (stderr, "-> Popen(%s,%s)\n", cmd, mode); - if (noexec) - return (NULL); - return (popen (cmd, mode)); -} - #ifdef lint #ifndef __GNUC__ /* ARGSUSED */ @@ -1031,19 +297,26 @@ gca (rev1, rev2) return (xstrdup (gca)); } -#ifdef LOSING_TMPNAM_FUNCTION -char *tmpnam(char *s) +/* + * Sanity checks and any required fix-up on message passed to RCS via '-m'. + * RCS 5.7 requires that a non-total-whitespace, non-null message be provided + * with '-m'. + */ +char * +make_message_rcslegal (message) + char *message; { - static char value[L_tmpnam+1]; + if ((message == NULL) || (*message == '\0') || isspace (*message)) + { + char *t; + + if (message) + for (t = message; *t; t++) + if (!isspace (*t)) + return message; - if (s){ - strcpy(s,"/tmp/cvsXXXXXX"); - mktemp(s); - return s; - }else{ - strcpy(value,"/tmp/cvsXXXXXX"); - mktemp(s); - return value; + return "*** empty log message ***\n"; } + + return message; } -#endif diff --git a/gnu/usr.bin/cvs/lib/system.h b/gnu/usr.bin/cvs/lib/system.h index 1f35065..20539de 100644 --- a/gnu/usr.bin/cvs/lib/system.h +++ b/gnu/usr.bin/cvs/lib/system.h @@ -17,45 +17,162 @@ /* $CVSid: @(#)system.h 1.18 94/09/25 $ */ +#ifdef __GNUC__ +#ifndef alloca +#define alloca __builtin_alloca +#endif +#else +#ifdef HAVE_ALLOCA_H +#include <alloca.h> +#else +#ifdef _AIX +/* AIX alloca decl has to be the first thing in the file, bletch! */ + #pragma alloca +#else /* not _AIX */ +#ifdef ALLOCA_IN_STDLIB + /* then we need do nothing */ +#else +char *alloca (); +#endif /* not ALLOCA_IN_STDLIB */ +#endif /* not _AIX */ +#endif /* not HAVE_ALLOCA_H */ +#endif /* not __GNUS__ */ + #include <sys/types.h> #include <sys/stat.h> -#ifndef S_ISREG /* Doesn't have POSIX.1 stat stuff. */ -#ifndef mode_t -#define mode_t unsigned short -#endif + +#ifdef STAT_MACROS_BROKEN +#undef S_ISBLK +#undef S_ISCHR +#undef S_ISDIR +#undef S_ISREG +#undef S_ISFIFO +#undef S_ISLNK +#undef S_ISSOCK +#undef S_ISMPB +#undef S_ISMPC +#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. */ + #if !defined(S_ISBLK) && defined(S_IFBLK) -#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +# if defined(S_IFMT) +# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +# else +# define S_ISBLK(m) ((m) & S_IFBLK) +# endif #endif + #if !defined(S_ISCHR) && defined(S_IFCHR) -#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +# if defined(S_IFMT) +# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +# else +# define S_ISCHR(m) ((m) & S_IFCHR) +# endif #endif + #if !defined(S_ISDIR) && defined(S_IFDIR) -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# if defined(S_IFMT) +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +# else +# define S_ISDIR(m) ((m) & S_IFDIR) +# endif #endif + #if !defined(S_ISREG) && defined(S_IFREG) -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +# if defined(S_IFMT) +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +# else +# define S_ISREG(m) ((m) & S_IFREG) +# endif #endif + #if !defined(S_ISFIFO) && defined(S_IFIFO) -#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +# if defined(S_IFMT) +# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +# else +# define S_ISFIFO(m) ((m) & S_IFIFO) +# endif #endif + #if !defined(S_ISLNK) && defined(S_IFLNK) -#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +# if defined(S_IFMT) +# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +# else +# define S_ISLNK(m) ((m) & S_IFLNK) +# endif #endif + #if !defined(S_ISSOCK) && defined(S_IFSOCK) -#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +# if defined(S_IFMT) +# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +# else +# define S_ISSOCK(m) ((m) & S_IFSOCK) +# endif #endif + #if !defined(S_ISMPB) && defined(S_IFMPB) /* V7 */ -#define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) -#define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) +# if defined(S_IFMT) +# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB) +# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC) +# else +# define S_ISMPB(m) ((m) & S_IFMPB) +# define S_ISMPC(m) ((m) & S_IFMPC) +# endif #endif + #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ -#define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) +# if defined(S_IFMT) +# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) +# else +# define S_ISNWK(m) ((m) & S_IFNWK) +# endif #endif + #if !defined(HAVE_MKFIFO) #define mkfifo(path, mode) (mknod ((path), (mode) | S_IFIFO, 0)) #endif +#ifdef NEED_DECOY_PERMISSIONS /* OS/2, really */ + +#define S_IRUSR S_IREAD +#define S_IWUSR S_IWRITE +#define S_IXUSR S_IEXEC +#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) +#define S_IRGRP S_IREAD +#define S_IWGRP S_IWRITE +#define S_IXGRP S_IEXEC +#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP) +#define S_IROTH S_IREAD +#define S_IWOTH S_IWRITE +#define S_IXOTH S_IEXEC +#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH) + +#else /* ! NEED_DECOY_PERMISSIONS */ + +#ifndef S_IRUSR +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#define S_IXUSR 0100 +/* Read, write, and execute by owner. */ +#define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR) + +#define S_IRGRP (S_IRUSR >> 3) /* Read by group. */ +#define S_IWGRP (S_IWUSR >> 3) /* Write by group. */ +#define S_IXGRP (S_IXUSR >> 3) /* Execute by group. */ +/* Read, write, and execute by group. */ +#define S_IRWXG (S_IRWXU >> 3) + +#define S_IROTH (S_IRGRP >> 3) /* Read by others. */ +#define S_IWOTH (S_IWGRP >> 3) /* Write by others. */ +#define S_IXOTH (S_IXGRP >> 3) /* Execute by others. */ +/* Read, write, and execute by others. */ +#define S_IRWXO (S_IRWXG >> 3) +#endif /* !def S_IRUSR */ +#endif /* NEED_DECOY_PERMISSIONS */ + #if defined(POSIX) || defined(HAVE_UNISTD_H) #include <unistd.h> #include <limits.h> @@ -63,25 +180,38 @@ off_t lseek (); #endif -#ifdef TM_IN_SYS_TIME -#include <sys/time.h> +#if TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> #else -#include <time.h> +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif + +#ifdef HAVE_IO_H +#include <io.h> +#endif + +#ifdef HAVE_DIRECT_H +#include <direct.h> #endif -#ifndef HAVE_SYS_TIMEB_H +#ifdef timezone +#undef timezone /* needed for sgi */ +#endif + +#ifdef HAVE_SYS_TIMEB_H +#include <sys/timeb.h> +#else struct timeb { time_t time; /* Seconds since the epoch */ unsigned short millitm; /* Field not used */ -#ifdef timezone - short tzone; -#else short timezone; -#endif short dstflag; /* Field not used */ }; -#else -#include <sys/timeb.h> #endif #if !defined(HAVE_FTIME) && !defined(HAVE_TIMEZONE) @@ -106,10 +236,17 @@ extern long timezone; ** PATH_MAX in terms of MAXPATHLEN. ** 3. If neither is defined, include limits.h and check for ** PATH_MAX again. +** 3.1 If we now have PATHSIZE, define PATH_MAX in terms of that. +** and ignore the rest. Since _POSIX_PATH_MAX (checked for +** next) is the *most* restrictive (smallest) value, if we +** trust _POSIX_PATH_MAX, several of our buffers are too small. ** 4. If PATH_MAX is still not defined but _POSIX_PATH_MAX is, ** then define PATH_MAX in terms of _POSIX_PATH_MAX. ** 5. And if even _POSIX_PATH_MAX doesn't exist just put in ** a reasonable value. +** *. All in all, this is an excellent argument for using pathconf() +** when at all possible. Or better yet, dynamically allocate +** our buffers and use getcwd() not getwd(). ** ** This works on: ** Sun Sparc 10 SunOS 4.1.3 & Solaris 1.2 @@ -118,12 +255,16 @@ extern long timezone; ** IBM RS6000 AIX 3.2 ** Dec Alpha OSF 1 ???? ** Intel 386 BSDI BSD/386 +** Intel 386 SCO OpenServer Release 5 ** Apollo Domain 10.4 ** NEC SVR4 */ -/* On MOST systems this will get you MAXPATHLEN */ +/* On MOST systems this will get you MAXPATHLEN. + Windows NT doesn't have this file, tho. */ +#ifdef HAVE_SYS_PARAM_H #include <sys/param.h> +#endif #ifndef PATH_MAX # ifdef MAXPATHLEN @@ -131,20 +272,28 @@ extern long timezone; # else # include <limits.h> # ifndef PATH_MAX -# ifdef _POSIX_PATH_MAX -# define PATH_MAX _POSIX_PATH_MAX -# else -# define PATH_MAX 1024 -# endif /* _POSIX_PATH_MAX */ -# endif /* PATH_MAX */ +# ifdef PATHSIZE +# define PATH_MAX PATHSIZE +# else /* no PATHSIZE */ +# ifdef _POSIX_PATH_MAX +# define PATH_MAX _POSIX_PATH_MAX +# else +# define PATH_MAX 1024 +# endif /* no _POSIX_PATH_MAX */ +# endif /* no PATHSIZE */ +# endif /* no PATH_MAX */ # endif /* MAXPATHLEN */ #endif /* PATH_MAX */ - - -#ifdef HAVE_UTIME_H +/* The NeXT (without _POSIX_SOURCE, which we don't want) has a utime.h + which doesn't define anything. It would be cleaner to have configure + check for struct utimbuf, but for now I'm checking NeXT here (so I don't + have to debug the configure check across all the machines). */ +#if defined (HAVE_UTIME_H) && !defined (NeXT) #include <utime.h> +#elif defined (HAVE_SYS_UTIME_H) +# include <sys/utime.h> #else #ifndef ALTOS struct utimbuf @@ -179,12 +328,31 @@ int utime (); #define bzero(s, n) memset ((s), 0, (n)) #endif /* bzero */ -#else /* not STDC_HJEADERS and not HAVE_STRING_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 <errno.h> + +/* Not all systems set the same error code on a non-existent-file + error. This tries to ask the question somewhat portably. + On systems that don't have ENOTEXIST, this should behave just like + x == ENOENT. "x" is probably errno, of course. */ + +#ifdef ENOTEXIST +# ifdef EOS2ERR +# define existence_error(x) \ + (((x) == ENOTEXIST) || ((x) == ENOENT) || ((x) == EOS2ERR)) +# else +# define existence_error(x) \ + (((x) == ENOTEXIST) || ((x) == ENOENT)) +# endif +#else +# define existence_error(x) ((x) == ENOENT) +#endif + + #ifdef STDC_HEADERS #include <stdlib.h> #else @@ -201,6 +369,29 @@ char *getcwd (); char *getwd (); #endif +/* check for POSIX signals */ +#if defined(HAVE_SIGACTION) && defined(HAVE_SIGPROCMASK) +# define POSIX_SIGNALS +#endif + +/* MINIX 1.6 doesn't properly support sigaction */ +#if defined(_MINIX) +# undef POSIX_SIGNALS +#endif + +/* If !POSIX, try for BSD.. Reason: 4.4BSD implements these as wrappers */ +#if !defined(POSIX_SIGNALS) +# if defined(HAVE_SIGVEC) && defined(HAVE_SIGSETMASK) && defined(HAVE_SIGBLOCK) +# define BSD_SIGNALS +# endif +#endif + +/* Under OS/2, this must be included _after_ stdio.h; that's why we do + it here. */ +#ifdef USE_OWN_TCPIP_H +#include "tcpip.h" +#endif + #ifdef HAVE_FCNTL_H #include <fcntl.h> #else @@ -220,23 +411,22 @@ char *getwd (); #define R_OK 4 #endif -/* unistd.h defines _POSIX_VERSION on POSIX.1 systems. */ -#if defined(DIRENT) || defined(_POSIX_VERSION) -#include <dirent.h> -#define NLENGTH(dirent) (strlen((dirent)->d_name)) -#else /* not (DIRENT or _POSIX_VERSION) */ -#define dirent direct -#define NLENGTH(dirent) ((dirent)->d_namlen) -#ifdef HAVE_SYS_NDIR_H -#include <sys/ndir.h> -#endif -#ifdef HAVE_SYS_DIR_H -#include <sys/dir.h> -#endif -#ifdef HAVE_NDIR_H -#include <ndir.h> -#endif -#endif /* not (DIRENT or _POSIX_VERSION) */ +#if HAVE_DIRENT_H +# include <dirent.h> +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include <sys/ndir.h> +# endif +# if HAVE_SYS_DIR_H +# include <sys/dir.h> +# endif +# if HAVE_NDIR_H +# include <ndir.h> +# endif +#endif /* Convert B 512-byte blocks to kilobytes if K is nonzero, otherwise return it unchanged. */ @@ -260,3 +450,47 @@ char *getwd (); #define S_IWOTH 0000002 /* write permission, other */ #endif +/* Under MS-DOS and its derivatives (like Windows NT), mkdir takes only one + argument; permission is handled very differently on those systems than in + in Unix. So we leave such systems a hook on which they can hang their + own definitions. */ +#ifndef CVS_MKDIR +#define CVS_MKDIR mkdir +#endif + +/* 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 + to lower case. Under Windows NT, / and \ are both path component + separators, so FOLD_FN_CHAR would map them both to /. */ +#ifndef FOLD_FN_CHAR +#define FOLD_FN_CHAR(c) (c) +#define fnfold(filename) (filename) +#define fncmp strcmp +#endif + +/* Different file systems have different path component separators. + For the VMS port we might need to abstract further back than this. */ +#ifndef ISDIRSEP +#define ISDIRSEP(c) ((c) == '/') +#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) +#define FOPEN_BINARY_READ ("rb") +#define FOPEN_BINARY_WRITE ("wb") +#else +#define OPEN_BINARY (0) +#define FOPEN_BINARY_READ ("r") +#define FOPEN_BINARY_WRITE ("w") +#endif diff --git a/gnu/usr.bin/cvs/lib/version.c b/gnu/usr.bin/cvs/lib/version.c index 071b112..2eb66cd 100644 --- a/gnu/usr.bin/cvs/lib/version.c +++ b/gnu/usr.bin/cvs/lib/version.c @@ -13,8 +13,22 @@ #include "cvs.h" #ifndef lint -static char rcsid[] = "$CVSid: @(#)version.c 1.15 94/10/03 $"; -USE(rcsid) +static const char rcsid[] = "$CVSid: @(#)version.c 1.15 94/10/03 $"; +USE(rcsid); #endif -char *version_string = "\nConcurrent Versions System (CVS) 1.4 Alpha-2\n"; +char *version_string = "\nConcurrent Versions System (CVS) 1.6.3"; + +#ifdef CLIENT_SUPPORT +#ifdef SERVER_SUPPORT +char *config_string = " (client/server)\n"; +#else +char *config_string = " (client)\n"; +#endif +#else +#ifdef SERVER_SUPPORT +char *config_string = " (server)\n"; +#else +char *config_string = "\n"; +#endif +#endif diff --git a/gnu/usr.bin/cvs/lib/wait.h b/gnu/usr.bin/cvs/lib/wait.h index 2e47773..db60434 100644 --- a/gnu/usr.bin/cvs/lib/wait.h +++ b/gnu/usr.bin/cvs/lib/wait.h @@ -17,6 +17,9 @@ #ifdef HAVE_SYS_WAIT_H #include <sys/types.h> /* For pid_t. */ +#ifdef HAVE_SYS_RESOURCE_H +#include <sys/resource.h> /* for rusage */ +#endif #include <sys/wait.h> #else #define WIFSTOPPED(w) (((w) & 0xff) == 0x7f) |