bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CVSADM env patch


From: Don Mahurin
Subject: CVSADM env patch
Date: Thu, 04 Mar 2004 16:34:02 -0800
User-agent: Mozilla Thunderbird 0.5b (X11/20040202)

Attached is a patch to allow the CVSADM evironment variable to override the internal adm directory name.

This is useful if ones setup prevents using the default 'CVS' directory name. Spefically, I am using cvs as a strange file system backup mechanism. In the process I will end up needing to commit both cvs repositories and checkouts into cvs.
diff -ru cvs-1.12.5/src/client.c cvs-1.12.5-cvsadm/src/client.c
--- cvs-1.12.5/src/client.c     2003-11-25 12:51:59.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/client.c      2004-01-28 10:09:49.000000000 -0800
@@ -4135,7 +4135,7 @@
      * This case will happen when checking out a module defined as
      * ``-a .''.
      */
-    cvsadm_name = xmalloc (strlen (dir) + sizeof (CVSADM) + 10);
+    cvsadm_name = xmalloc (strlen (dir) + strlen (CVSADM) + 11);
     sprintf (cvsadm_name, "%s/%s", dir, CVSADM);
     dir_exists = isdir (cvsadm_name);
     free (cvsadm_name);
diff -ru cvs-1.12.5/src/commit.c cvs-1.12.5-cvsadm/src/commit.c
--- cvs-1.12.5/src/commit.c     2003-12-09 11:38:58.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/commit.c      2004-01-28 10:09:52.000000000 -0800
@@ -1687,8 +1687,8 @@
     ret = Checkin ('A', finfo, rev, tag, options, saved_message);
     if (ret == 0)
     {
-       char *tmp = xmalloc (strlen (finfo->file) + sizeof (CVSADM)
-                            + sizeof (CVSEXT_LOG) + 10);
+       char *tmp = xmalloc (strlen (finfo->file) + strlen (CVSADM)
+                            + sizeof (CVSEXT_LOG) + 11);
        (void) sprintf (tmp, "%s/%s%s", CVSADM, finfo->file, CVSEXT_LOG);
        if (unlink_file (tmp) < 0
            && !existence_error (errno))
@@ -1858,8 +1858,8 @@
 
        /* this is the first time we have ever seen this file; create
           an RCS file.  */
-       fname = xmalloc (strlen (file) + sizeof (CVSADM)
-                        + sizeof (CVSEXT_LOG) + 10);
+       fname = xmalloc (strlen (file) + strlen (CVSADM)
+                        + sizeof (CVSEXT_LOG) + 11);
        (void) sprintf (fname, "%s/%s%s", CVSADM, file, CVSEXT_LOG);
        /* If the file does not exist, no big deal.  In particular, the
           server does not (yet at least) create CVSEXT_LOG files.  */
@@ -1973,8 +1973,8 @@
            int retcode;
 
            /* move the new file out of the way. */
-           fname = xmalloc (strlen (file) + sizeof (CVSADM)
-                            + sizeof (CVSPREFIX) + 10);
+           fname = xmalloc (strlen (file) + strlen (CVSADM)
+                            + sizeof (CVSPREFIX) + 11);
            (void) sprintf (fname, "%s/%s%s", CVSADM, CVSPREFIX, file);
            rename_file (file, fname);
 
diff -ru cvs-1.12.5/src/cvs.h cvs-1.12.5-cvsadm/src/cvs.h
--- cvs-1.12.5/src/cvs.h        2003-12-08 11:43:00.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/cvs.h 2004-01-28 10:07:49.000000000 -0800
@@ -97,39 +97,41 @@
 /* Definitions for the CVS Administrative directory and the files it contains.
    Here as #define's to make changing the names a simple task.  */
 
+char *get_CVSADM(char *file, int secondary);
+
 #ifdef USE_VMS_FILENAMES
-#define CVSADM          "CVS"
-#define CVSADM_ENT      "CVS/Entries."
-#define CVSADM_ENTBAK   "CVS/Entries.Backup"
-#define CVSADM_ENTLOG   "CVS/Entries.Log"
-#define CVSADM_ENTSTAT  "CVS/Entries.Static"
-#define CVSADM_REP      "CVS/Repository."
-#define CVSADM_ROOT     "CVS/Root."
-#define CVSADM_TAG      "CVS/Tag."
-#define CVSADM_NOTIFY   "CVS/Notify."
-#define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
-#define CVSADM_BASE      "CVS/Base"
-#define CVSADM_BASEREV   "CVS/Baserev."
-#define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
-#define CVSADM_TEMPLATE "CVS/Template."
+#define CVSADM          get_CVSADM(NULL,0)
+#define CVSADM_ENT      get_CVSADM("Entries.",0)
+#define CVSADM_ENTBAK   get_CVSADM("Entries.Backup",1)
+#define CVSADM_ENTLOG   get_CVSADM("Entries.Log",0)
+#define CVSADM_ENTSTAT  get_CVSADM("Entries.Static",0)
+#define CVSADM_REP      get_CVSADM("Repository.",0)
+#define CVSADM_ROOT     get_CVSADM("Root.",0)
+#define CVSADM_TAG      get_CVSADM("Tag.",0)
+#define CVSADM_NOTIFY   get_CVSADM("Notify.",0)
+#define CVSADM_NOTIFYTMP get_CVSADM("Notify.tmp",1)
+#define CVSADM_BASE      get_CVSADM("Base",0)
+#define CVSADM_BASEREV   get_CVSADM("Baserev.",0)
+#define CVSADM_BASEREVTMP get_CVSADM("Baserev.tmp",1)
+#define CVSADM_TEMPLATE get_CVSADM("Template.",0)
 #else /* USE_VMS_FILENAMES */
-#define        CVSADM          "CVS"
-#define        CVSADM_ENT      "CVS/Entries"
-#define        CVSADM_ENTBAK   "CVS/Entries.Backup"
-#define CVSADM_ENTLOG  "CVS/Entries.Log"
-#define        CVSADM_ENTSTAT  "CVS/Entries.Static"
-#define        CVSADM_REP      "CVS/Repository"
-#define        CVSADM_ROOT     "CVS/Root"
-#define        CVSADM_TAG      "CVS/Tag"
-#define CVSADM_NOTIFY  "CVS/Notify"
-#define CVSADM_NOTIFYTMP "CVS/Notify.tmp"
+#define        CVSADM          get_CVSADM(NULL,0)
+#define        CVSADM_ENT      get_CVSADM("Entries",0)
+#define        CVSADM_ENTBAK   get_CVSADM("Entries.Backup",1)
+#define CVSADM_ENTLOG  get_CVSADM("Entries.Log",0)
+#define        CVSADM_ENTSTAT  get_CVSADM("Entries.Static",0)
+#define        CVSADM_REP      get_CVSADM("Repository",0)
+#define        CVSADM_ROOT     get_CVSADM("Root",0)
+#define        CVSADM_TAG      get_CVSADM("Tag",0)
+#define CVSADM_NOTIFY  get_CVSADM("Notify",0)
+#define CVSADM_NOTIFYTMP get_CVSADM("Notify.tmp",1)
 /* A directory in which we store base versions of files we currently are
    editing with "cvs edit".  */
-#define CVSADM_BASE     "CVS/Base"
-#define CVSADM_BASEREV  "CVS/Baserev"
-#define CVSADM_BASEREVTMP "CVS/Baserev.tmp"
+#define CVSADM_BASE     get_CVSADM("Base",0)
+#define CVSADM_BASEREV  get_CVSADM("Baserev",0)
+#define CVSADM_BASEREVTMP get_CVSADM("Baserev.tmp",1)
 /* File which contains the template for use in log messages.  */
-#define CVSADM_TEMPLATE "CVS/Template"
+#define CVSADM_TEMPLATE get_CVSADM("Template",0)
 #endif /* USE_VMS_FILENAMES */
 
 /* This is the special directory which we use to store various extra
@@ -140,7 +142,7 @@
    
    See fileattr.h for details about file attributes, the only thing stored
    in CVSREP currently.  */
-#define CVSREP "CVS"
+#define CVSREP get_CVSADM(NULL,0)
 
 /*
  * Definitions for the CVSROOT Administrative directory and the files it
diff -ru cvs-1.12.5/src/diff.c cvs-1.12.5-cvsadm/src/diff.c
--- cvs-1.12.5/src/diff.c       2003-11-25 08:11:47.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/diff.c        2004-01-28 10:07:57.000000000 -0800
@@ -588,9 +588,9 @@
     {
        /* Backup the current version of the file to CVS/,,filename */
        fname = xmalloc (strlen (finfo->file)
-                        + sizeof CVSADM
+                        + strlen(CVSADM)
                         + sizeof CVSPREFIX
-                        + 10);
+                        + 11);
        sprintf(fname,"%s/%s%s",CVSADM, CVSPREFIX, finfo->file);
        if (unlink_file_dir (fname) < 0)
            if (! existence_error (errno))
diff -ru cvs-1.12.5/src/edit.c cvs-1.12.5-cvsadm/src/edit.c
--- cvs-1.12.5/src/edit.c       2003-12-09 11:39:02.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/edit.c        2004-01-28 10:09:57.000000000 -0800
@@ -316,7 +316,7 @@
        trying to create the output file fails.  But copy_file isn't
        set up to facilitate that.  */
     mkdir_if_needed (CVSADM_BASE);
-    basefilename = xmalloc (10 + sizeof CVSADM_BASE + strlen (finfo->file));
+    basefilename = xmalloc (11 + strlen(CVSADM_BASE) + strlen (finfo->file));
     strcpy (basefilename, CVSADM_BASE);
     strcat (basefilename, "/");
     strcat (basefilename, finfo->file);
@@ -445,7 +445,7 @@
     if (noexec)
        return 0;
 
-    basefilename = xmalloc (10 + sizeof CVSADM_BASE + strlen (finfo->file));
+    basefilename = xmalloc (11 + strlen(CVSADM_BASE) + strlen (finfo->file));
     strcpy (basefilename, CVSADM_BASE);
     strcat (basefilename, "/");
     strcat (basefilename, finfo->file);
diff -ru cvs-1.12.5/src/entries.c cvs-1.12.5-cvsadm/src/entries.c
--- cvs-1.12.5/src/entries.c    2003-09-30 14:44:08.000000000 -0700
+++ cvs-1.12.5-cvsadm/src/entries.c     2004-01-28 10:07:56.000000000 -0800
@@ -632,8 +632,8 @@
        return;
 
     tmp = xmalloc ((dir ? strlen (dir) : 0)
-                  + sizeof (CVSADM_TAG)
-                  + 10);
+                  + strlen (CVSADM_TAG)
+                  + 11);
     if (dir == NULL)
        (void) strcpy (tmp, CVSADM_TAG);
     else
@@ -826,8 +826,8 @@
        else
        {
            entfilename = xmalloc (strlen (parent)
-                                  + sizeof CVSADM_ENTLOG
-                                  + 10);
+                                  + strlen(CVSADM_ENTLOG)
+                                  + 11);
            sprintf (entfilename, "%s/%s", parent, CVSADM_ENTLOG);
        }
 
@@ -987,13 +987,13 @@
        computation probably should be broken out into a separate function,
        as recurse.c does it too and places like Entries_Open should be
        doing it.  */
-    baserev_fullname = xmalloc (sizeof (CVSADM_BASEREV)
+    baserev_fullname = xmalloc (strlen (CVSADM_BASEREV)
                                + strlen (finfo->update_dir)
-                               + 2);
+                               + 3);
     baserev_fullname[0] = '\0';
-    baserevtmp_fullname = xmalloc (sizeof (CVSADM_BASEREVTMP)
+    baserevtmp_fullname = xmalloc (strlen (CVSADM_BASEREVTMP)
                                   + strlen (finfo->update_dir)
-                                  + 2);
+                                  + 3);
     baserevtmp_fullname[0] = '\0';
     if (finfo->update_dir[0] != '\0')
     {
diff -ru cvs-1.12.5/src/find_names.c cvs-1.12.5-cvsadm/src/find_names.c
--- cvs-1.12.5/src/find_names.c 2003-07-23 13:40:07.000000000 -0700
+++ cvs-1.12.5-cvsadm/src/find_names.c  2004-01-28 10:08:02.000000000 -0800
@@ -375,7 +375,7 @@
            expand_string (&tmp,
                           &tmp_size,
                           (strlen (dir) + strlen (dp->d_name)
-                           + sizeof (CVSADM) + 10));
+                           + strlen (CVSADM) + 11));
            (void) sprintf (tmp, "%s/%s/%s", dir, dp->d_name, CVSADM);
            if (!isdir (tmp))
                goto do_it_again;
diff -ru cvs-1.12.5/src/ignore.c cvs-1.12.5-cvsadm/src/ignore.c
--- cvs-1.12.5/src/ignore.c     2003-07-25 13:11:18.000000000 -0700
+++ cvs-1.12.5-cvsadm/src/ignore.c      2004-01-28 10:10:04.000000000 -0800
@@ -34,7 +34,7 @@
                                         * is held */
 
 const char *ign_default = ". .. core RCSLOG tags TAGS RCS SCCS .make.state\
- .nse_depinfo #* .#* cvslog.* ,* CVS CVS.adm .del-* *.a *.olb *.o *.obj\
+ .nse_depinfo #* .#* cvslog.* ,* CVS.adm .del-* *.a *.olb *.o *.obj\
  *.so *.Z *~ *.old *.elc *.ln *.bak *.BAK *.orig *.rej *.exe _$* *$";
 
 #define IGN_GROW 16                    /* grow the list by 16 elements at a
@@ -62,6 +62,7 @@
     tmp = xstrdup (ign_default);
     ign_add (tmp, 0);
     free (tmp);
+    ign_add(CVSADM, 0);
 
 #ifdef CLIENT_SUPPORT
     /* The client handles another way, by (after it does its own ignore file
@@ -298,8 +299,11 @@
     else
     {
        while (*cpp)
+       {
+//             printf("ign m %s\n", *cpp);
            if (CVS_FNMATCH (*cpp++, name, 0) == 0)
                return 1;
+       }
        return 0;
     }
 }
@@ -422,7 +426,7 @@
                   this directory if there is a CVS subdirectory.
                   This will normally be the case, but the user may
                   have messed up the working directory somehow.  */
-               p = xmalloc (strlen (file) + sizeof CVSADM + 10);
+               p = xmalloc (strlen (file) + strlen(CVSADM) + 11);
                sprintf (p, "%s/%s", file, CVSADM);
                dir = isdir (p);
                free (p);
@@ -456,7 +460,7 @@
                {
                    char *temp;
 
-                   temp = xmalloc (strlen (file) + sizeof (CVSADM) + 10);
+                   temp = xmalloc (strlen (file) + strlen (CVSADM) + 11);
                    (void) sprintf (temp, "%s/%s", file, CVSADM);
                    if (isdir (temp))
                    {
diff -ru cvs-1.12.5/src/main.c cvs-1.12.5-cvsadm/src/main.c
--- cvs-1.12.5/src/main.c       2003-11-25 08:11:47.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/main.c        2004-01-28 10:08:14.000000000 -0800
@@ -1188,3 +1188,18 @@
 
 /* vim:tabstop=8:shiftwidth=4
  */
+
+char *get_CVSADM(char *file, int secondary)
+{
+       static char dirs[2][50];
+       char *dir = dirs[secondary];
+       char *cvsadm = getenv("CVSADM");
+       if(cvsadm == NULL) cvsadm = "CVS";
+       strcpy(dir, cvsadm);
+       if(file != NULL)
+       {
+               strcat(dir, "/");
+               strcat(dir, file);
+       }
+       return dir;
+}
diff -ru cvs-1.12.5/src/recurse.c cvs-1.12.5-cvsadm/src/recurse.c
--- cvs-1.12.5/src/recurse.c    2003-12-08 10:40:01.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/recurse.c     2004-01-28 10:08:29.000000000 -0800
@@ -1053,8 +1053,8 @@
        char *cvsadmdir;
 
        cvsadmdir = xmalloc (strlen (dir)
-                            + sizeof (CVSADM_REP)
-                            + sizeof (CVSADM_ENT)
+                            + strlen (CVSADM_REP)
+                            + strlen (CVSADM_ENT)
                             + 80);
 
        strcpy (cvsadmdir, dir);
diff -ru cvs-1.12.5/src/remove.c cvs-1.12.5-cvsadm/src/remove.c
--- cvs-1.12.5/src/remove.c     2003-11-10 08:35:15.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/remove.c      2004-01-28 10:10:29.000000000 -0800
@@ -194,9 +194,9 @@
         * entries file.  */
        Scratch_Entry (finfo->entries, finfo->file);
        fname = xmalloc (strlen (finfo->file)
-                        + sizeof (CVSADM)
+                        + strlen (CVSADM)
                         + sizeof (CVSEXT_LOG)
-                        + 10);
+                        + 11);
        (void) sprintf (fname, "%s/%s%s", CVSADM, finfo->file, CVSEXT_LOG);
        if (unlink_file (fname) < 0
            && !existence_error (errno))
diff -ru cvs-1.12.5/src/repos.c cvs-1.12.5-cvsadm/src/repos.c
--- cvs-1.12.5/src/repos.c      2003-11-10 16:55:54.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/repos.c       2004-01-28 10:08:30.000000000 -0800
@@ -35,7 +35,7 @@
 
     if (dir != NULL)
     {
-       tmp = xmalloc (strlen (dir) + sizeof (CVSADM_REP) + 10);
+       tmp = xmalloc (strlen (dir) + strlen (CVSADM_REP) + 11);
        (void) sprintf (tmp, "%s/%s", dir, CVSADM_REP);
     }
     else
@@ -54,7 +54,7 @@
 
        if (dir != NULL)
        {
-           cvsadm = xmalloc (strlen (dir) + sizeof (CVSADM) + 10);
+           cvsadm = xmalloc (strlen (dir) + strlen (CVSADM) + 11);
            (void) sprintf (cvsadm, "%s/%s", dir, CVSADM);
        }
        else
diff -ru cvs-1.12.5/src/root.c cvs-1.12.5-cvsadm/src/root.c
--- cvs-1.12.5/src/root.c       2003-11-25 08:11:50.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/root.c        2004-01-28 10:08:31.000000000 -0800
@@ -42,9 +42,9 @@
 
     if (dir != NULL)
     {
-       cvsadm = xmalloc (strlen (dir) + sizeof (CVSADM) + 10);
+       cvsadm = xmalloc (strlen (dir) + strlen (CVSADM) + 11);
        (void) sprintf (cvsadm, "%s/%s", dir, CVSADM);
-       tmp = xmalloc (strlen (dir) + sizeof (CVSADM_ROOT) + 10);
+       tmp = xmalloc (strlen (dir) + strlen (CVSADM_ROOT) + 11);
        (void) sprintf (tmp, "%s/%s", dir, CVSADM_ROOT);
     }
     else
@@ -153,7 +153,7 @@
     {
         if (dir != NULL)
        {
-           tmp = xmalloc (strlen (dir) + sizeof (CVSADM_ROOT) + 10);
+           tmp = xmalloc (strlen (dir) + strlen (CVSADM_ROOT) + 11);
            (void) sprintf (tmp, "%s/%s", dir, CVSADM_ROOT);
        }
         else
diff -ru cvs-1.12.5/src/update.c cvs-1.12.5-cvsadm/src/update.c
--- cvs-1.12.5/src/update.c     2003-11-25 08:12:03.000000000 -0800
+++ cvs-1.12.5-cvsadm/src/update.c      2004-01-28 10:09:23.000000000 -0800
@@ -967,7 +967,7 @@
        {
            char *tmp;
 
-           tmp = xmalloc (strlen (dir) + sizeof (CVSADM_ENTSTAT) + 10);
+           tmp = xmalloc (strlen (dir) + strlen (CVSADM_ENTSTAT) + 11);
            (void) sprintf (tmp, "%s/%s", dir, CVSADM_ENTSTAT);
            if (unlink_file (tmp) < 0 && ! existence_error (errno))
                error (1, errno, "cannot remove file %s", tmp);
@@ -1210,9 +1210,9 @@
        )
     {
        backup = xmalloc (strlen (finfo->file)
-                         + sizeof (CVSADM)
+                         + strlen (CVSADM)
                          + sizeof (CVSPREFIX)
-                         + 10);
+                         + 11);
        (void) sprintf (backup, "%s/%s%s", CVSADM, CVSPREFIX, finfo->file);
        if (isfile (finfo->file))
            rename_file (finfo->file, backup);
@@ -1562,9 +1562,9 @@
     }
 
     backup = xmalloc (strlen (finfo->file)
-                     + sizeof (CVSADM)
+                     + strlen (CVSADM)
                      + sizeof (CVSPREFIX)
-                     + 10);
+                     + 11);
     (void) sprintf (backup, "%s/%s%s", CVSADM, CVSPREFIX, finfo->file);
     if (isfile (finfo->file))
         rename_file (finfo->file, backup);
@@ -1576,14 +1576,14 @@
     }
 
     file1 = xmalloc (strlen (finfo->file)
-                    + sizeof (CVSADM)
+                    + strlen (CVSADM)
                     + sizeof (CVSPREFIX)
-                    + 10);
+                    + 11);
     (void) sprintf (file1, "%s/%s%s-1", CVSADM, CVSPREFIX, finfo->file);
     file2 = xmalloc (strlen (finfo->file)
-                    + sizeof (CVSADM)
+                    + strlen (CVSADM)
                     + sizeof (CVSPREFIX)
-                    + 10);
+                    + 11);
     (void) sprintf (file2, "%s/%s%s-2", CVSADM, CVSPREFIX, finfo->file);
 
     fail = 0;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]