diff -urN cvs-1.11.0-orig/Makefile.in cvs-1.11.0/Makefile.in --- cvs-1.11.0-orig/Makefile.in Fri Sep 8 14:28:02 2000 +++ cvs-1.11.0/Makefile.in Mon Oct 23 02:55:59 2000 @@ -37,7 +37,7 @@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ DEFS = @DEFS@ -LIBS = @LIBS@ +LIBS = @LIBS@ -lgdbm INCLUDES = -I. -I../lib @includeopt@ CFLAGS = @CFLAGS@ diff -urN cvs-1.11.0-orig/src/Makefile.in cvs-1.11.0/src/Makefile.in --- cvs-1.11.0-orig/src/Makefile.in Fri Sep 8 14:28:03 2000 +++ cvs-1.11.0/src/Makefile.in Mon Oct 23 02:25:25 2000 @@ -40,21 +40,21 @@ SOURCES = add.c admin.c buffer.c checkin.c checkout.c classify.c client.c \ commit.c create_adm.c cvsrc.c diff.c edit.c entries.c error.c expand_path.c \ fileattr.c find_names.c hardlink.c hash.c history.c ignore.c import.c \ -lock.c log.c login.c logmsg.c main.c mkmodules.c modules.c myndbm.c no_diff.c \ -parseinfo.c patch.c rcs.c rcscmds.c recurse.c release.c remove.c repos.c \ -root.c rtag.c scramble.c server.c status.c subr.c filesubr.c run.c \ +lock.c log.c login.c logmsg.c main.c mkmodules.c modules.c mygdbm.c myndbm.c \ +no_diff.c parseinfo.c patch.c rcs.c rcscmds.c recurse.c release.c remove.c \ +repos.c root.c rtag.c scramble.c server.c status.c subr.c filesubr.c run.c \ tag.c update.c watch.c wrapper.c vers_ts.c version.c zlib.c OBJECTS = add.o admin.o buffer.o checkin.o checkout.o classify.o client.o \ commit.o create_adm.o cvsrc.o diff.o edit.o entries.o expand_path.o \ fileattr.o find_names.o hardlink.o hash.o history.o ignore.o import.o \ -lock.o log.o login.o logmsg.o main.o mkmodules.o modules.o myndbm.o no_diff.o \ -parseinfo.o patch.o rcs.o rcscmds.o recurse.o release.o remove.o repos.o \ -root.o rtag.o scramble.o server.o status.o tag.o update.o \ +lock.o log.o login.o logmsg.o main.o mkmodules.o modules.o mygdbm.o myndbm.o \ +no_diff.o parseinfo.o patch.o rcs.o rcscmds.o recurse.o release.o remove.o \ +repos.o root.o rtag.o scramble.o server.o status.o tag.o update.o \ watch.o wrapper.o vers_ts.o \ subr.o filesubr.o run.o version.o error.o zlib.o -HEADERS = buffer.h cvs.h rcs.h hardlink.h hash.h myndbm.h \ +HEADERS = buffer.h cvs.h rcs.h hardlink.h hash.h myndbm.h mygdbm.h \ update.h server.h client.h error.h fileattr.h edit.h watch.h TAGFILES = $(HEADERS) options.h.in $(SOURCES) diff -urN cvs-1.11.0-orig/src/cvs.h cvs-1.11.0/src/cvs.h --- cvs-1.11.0-orig/src/cvs.h Sat Jul 8 15:57:21 2000 +++ cvs-1.11.0/src/cvs.h Mon Oct 23 02:24:42 2000 @@ -86,9 +86,20 @@ #endif #ifdef MY_NDBM -#include "myndbm.h" +# include "myndbm.h" #else -#include +# ifdef USE_GDBM +# include +# include "mygdbm.h" +# else +# include +# define DBM_OPEN dbm_open +# define DBM_CLOSE dbm_close +# define DBM_FETCH dbm_fetch +# define DBM_FIRSTKEY dbm_firstkey +# define DBM_NEXTKEY dbm_nextkey +# define DBM_STORE dbm_store +# endif /* USE_GDBM */ #endif /* MY_NDBM */ #include "regex.h" diff -urN cvs-1.11.0-orig/src/mkmodules.c cvs-1.11.0/src/mkmodules.c --- cvs-1.11.0-orig/src/mkmodules.c Fri Sep 8 11:28:36 2000 +++ cvs-1.11.0/src/mkmodules.c Mon Oct 23 05:17:59 2000 @@ -400,8 +400,8 @@ case 0: /* everything ok */ #ifdef MY_NDBM /* open it, to generate any duplicate errors */ - if ((db = dbm_open (temp, O_RDONLY, 0666)) != NULL) - dbm_close (db); + if ((db = DBM_OPEN (temp, O_RDONLY, 0666)) != NULL) + DBM_CLOSE (db); #else write_dbmfile (temp); rename_dbmfile (temp); @@ -593,7 +593,7 @@ int len, cont, err = 0; fp = open_file (temp, "r"); - if ((db = dbm_open (temp, O_RDWR | O_CREAT | O_TRUNC, 0666)) == NULL) + if ((db = DBM_OPEN (temp, O_RDWR | O_CREAT | O_TRUNC, 0666)) == NULL) error (1, errno, "cannot open dbm file %s for creation", temp); for (cont = 0; fgets (line, sizeof (line), fp) != NULL;) { @@ -655,14 +655,14 @@ } val.dptr = vp; val.dsize = strlen (vp); - if (dbm_store (db, key, val, DBM_INSERT) == 1) + if (DBM_STORE (db, key, val, DBM_INSERT) == 1) { error (0, 0, "duplicate key found for `%s'", key.dptr); err++; } } } - dbm_close (db); + DBM_CLOSE (db); if (fclose (fp) < 0) error (0, errno, "cannot close %s", temp); if (err) @@ -952,6 +952,13 @@ strcpy (info, adm); strcat (info, "/"); strcat (info, CVSROOTADM_VALTAGS); +#ifndef MY_NDBM +#if defined(USE_GDBM) + strcat (info, ".db"); +#else + strcat (info, ".pag"); +#endif +#endif if (!isfile (info)) { FILE *fp; diff -urN cvs-1.11.0-orig/src/modules.c cvs-1.11.0/src/modules.c --- cvs-1.11.0-orig/src/modules.c Wed Jul 26 15:29:01 2000 +++ cvs-1.11.0/src/modules.c Mon Oct 23 01:06:29 2000 @@ -74,7 +74,7 @@ + sizeof (CVSROOTADM_MODULES) + 20); (void) sprintf (mfile, "%s/%s/%s", CVSroot_directory, CVSROOTADM, CVSROOTADM_MODULES); - retval = dbm_open (mfile, O_RDONLY, 0666); + retval = DBM_OPEN (mfile, O_RDONLY, 0666); free (mfile); return retval; } @@ -87,7 +87,7 @@ DBM *db; { if (db != NULL) - dbm_close (db); + DBM_CLOSE (db); } /* @@ -180,7 +180,7 @@ key.dptr = mname; key.dsize = strlen (key.dptr); if (db != NULL) - val = dbm_fetch (db, key); + val = DBM_FETCH (db, key); else val.dptr = NULL; if (val.dptr != NULL) @@ -318,7 +318,7 @@ /* do the lookup */ if (db != NULL) - val = dbm_fetch (db, key); + val = DBM_FETCH (db, key); else val.dptr = NULL; @@ -936,9 +936,9 @@ if (!(db = open_module ())) error (1, 0, "failed to open the modules file"); - for (key = dbm_firstkey (db); key.dptr != NULL; key = dbm_nextkey (db)) + for (key = DBM_FIRSTKEY (db); key.dptr != NULL; key = DBM_NEXTKEY (db)) { - val = dbm_fetch (db, key); + val = DBM_FETCH (db, key); if (val.dptr != NULL) save_d (key.dptr, key.dsize, val.dptr, val.dsize); } diff -urN cvs-1.11.0-orig/src/mygdbm.c cvs-1.11.0/src/mygdbm.c --- cvs-1.11.0-orig/src/mygdbm.c Wed Dec 31 19:00:00 1969 +++ cvs-1.11.0/src/mygdbm.c Mon Oct 23 05:14:53 2000 @@ -0,0 +1,64 @@ +/* + * + * You may distribute under the terms of the GNU General Public License as + * specified in the README file that comes with the CVS source distribution. + * + * A compatibility layer so that gdbm can be used to provide dbm services. + * Now, gdbm does provide its own ndbm interface, but that one doesn't work + * very well on Win9x cygwin. gdbm's ndbm interface relies on hardlinking + * foo.dir and foo.pag -- but hardlinks fail on Win9x. + * + * This compatibility layer doesn't try to emulate the dir/pag filestructure + * of ndbm; it merely wraps the ndbm calls around a "normal" gdbm database + * and file access. + * + * As it happens, we only need to override dbm_open to make this happen; we + * can still use all of "ordinary" dbm emulation functions that gdbm + * provides. + * + */ + +#include "cvs.h" + +#if defined(USE_GDBM) && !defined(MY_NDBM) + +DBM * +my_gdbm_open (file, flags, mode) + char *file; + int flags; + int mode; +{ + char* db_file; + struct stat db_stat; + GDBM_FILE db; + DBM * ret_val; + + db_file = (char *) xmalloc (strlen (file)+4); + strcpy (db_file, file); + strcat (db_file, ".db"); + + /* Call the actual routine, saving the pointer to the file information. */ + flags &= O_RDONLY | O_RDWR | O_CREAT | O_TRUNC; + if (flags == O_RDONLY) + { + db = gdbm_open (db_file, 0, GDBM_READER, 00444, NULL); + } + else if (flags == (O_RDWR | O_CREAT)) + { + db = gdbm_open (db_file, 0, GDBM_WRCREAT, mode, NULL); + } + else if ( (flags & O_TRUNC) == O_TRUNC) + { + db = gdbm_open (db_file, 0, GDBM_NEWDB, mode, NULL); + } + else + { + db = gdbm_open (db_file, 0, GDBM_WRITER, 00666, NULL); + } + + ret_val = (DBM *) db; + free (db_file); + return (ret_val); +} + +#endif /* USE_GDBM && !MY_NDBM */ diff -urN cvs-1.11.0-orig/src/mygdbm.h cvs-1.11.0/src/mygdbm.h --- cvs-1.11.0-orig/src/mygdbm.h Wed Dec 31 19:00:00 1969 +++ cvs-1.11.0/src/mygdbm.h Mon Oct 23 02:34:11 2000 @@ -0,0 +1,25 @@ +#if defined(USE_GDBM) && !defined(MY_NDBM) + +/* #include */ + +#define DBM_INSERT GDBM_INSERT +#define DBM_REPLACE GDBM_REPLACE +#define DBM_OPEN my_gdbm_open +#define DBM_CLOSE dbm_close +#define DBM_FETCH dbm_fetch +#define DBM_FIRSTKEY dbm_firstkey +#define DBM_NEXTKEY dbm_nextkey +#define DBM_STORE dbm_store + +/* definitions copied from ndbm.h */ +typedef struct {int dummy[10];} DBM; +extern GDBM_EXPORT(void, dbm_close) (); +extern GDBM_EXPORT(datum, dbm_fetch) (); +extern GDBM_EXPORT(int, dbm_store) (); +extern GDBM_EXPORT(int, dbm_delete) (); +extern GDBM_EXPORT(datum, dbm_firstkey) (); +extern GDBM_EXPORT(datum, dbm_nextkey) (); + +DBM * my_gdbm_open PROTO((char *file, int flags, int mode)); +#endif /* USE_GDBM && !MY_NDBM */ + diff -urN cvs-1.11.0-orig/src/myndbm.h cvs-1.11.0/src/myndbm.h --- cvs-1.11.0-orig/src/myndbm.h Wed Jan 8 15:01:27 1997 +++ cvs-1.11.0/src/myndbm.h Mon Oct 23 01:34:27 2000 @@ -26,12 +26,12 @@ * be included by someone's libc, all of my emulation routines are prefixed * by "my" and we define the "standard" ones to be "my" ones here. */ -#define dbm_open mydbm_open -#define dbm_close mydbm_close -#define dbm_fetch mydbm_fetch -#define dbm_firstkey mydbm_firstkey -#define dbm_nextkey mydbm_nextkey -#define dbm_store mydbm_store +#define DBM_OPEN mydbm_open +#define DBM_CLOSE mydbm_close +#define DBM_FETCH mydbm_fetch +#define DBM_FIRSTKEY mydbm_firstkey +#define DBM_NEXTKEY mydbm_nextkey +#define DBM_STORE mydbm_store #define DBM_INSERT 0 #define DBM_REPLACE 1 diff -urN cvs-1.11.0-orig/src/options.h.in cvs-1.11.0/src/options.h.in --- cvs-1.11.0-orig/src/options.h.in Wed Jan 27 17:58:14 1999 +++ cvs-1.11.0/src/options.h.in Mon Oct 23 02:48:46 2000 @@ -22,7 +22,12 @@ generally works fine too. */ #ifndef MY_NDBM -#define MY_NDBM +/* #undef MY_NDBM ** CYGWIN default: use external gdbm library ** */ +#endif + +#ifndef USE_GDBM +#define USE_GDBM /* CYGWIN default - use GDBM-style singlefile database, + not ndbm-style foo.dir/foo.pag splitfile database */ #endif /* diff -urN cvs-1.11.0-orig/src/tag.c cvs-1.11.0/src/tag.c --- cvs-1.11.0-orig/src/tag.c Wed Jun 14 15:32:51 2000 +++ cvs-1.11.0/src/tag.c Mon Oct 23 01:08:38 2000 @@ -797,7 +797,7 @@ strcat (valtags_filename, CVSROOTADM); strcat (valtags_filename, "/"); strcat (valtags_filename, CVSROOTADM_VALTAGS); - db = dbm_open (valtags_filename, O_RDWR, 0666); + db = DBM_OPEN (valtags_filename, O_RDWR, 0666); if (db == NULL) { if (!existence_error (errno)) @@ -810,11 +810,11 @@ { datum val; - val = dbm_fetch (db, mytag); + val = DBM_FETCH (db, mytag); if (val.dptr != NULL) { /* Found. The tag is valid. */ - dbm_close (db); + DBM_CLOSE (db); free (valtags_filename); return; } @@ -871,7 +871,7 @@ if (noexec) { if (db != NULL) - dbm_close (db); + DBM_CLOSE (db); free (valtags_filename); return; } @@ -880,7 +880,7 @@ { mode_t omask; omask = umask (cvsumask); - db = dbm_open (valtags_filename, O_RDWR | O_CREAT | O_TRUNC, 0666); + db = DBM_OPEN (valtags_filename, O_RDWR | O_CREAT | O_TRUNC, 0666); (void) umask (omask); if (db == NULL) @@ -892,10 +892,10 @@ } value.dptr = "y"; value.dsize = 1; - if (dbm_store (db, mytag, value, DBM_REPLACE) < 0) + if (DBM_STORE (db, mytag, value, DBM_REPLACE) < 0) error (0, errno, "cannot store %s into %s", name, valtags_filename); - dbm_close (db); + DBM_CLOSE (db); } free (valtags_filename); }