cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] ccvs/src ChangeLog log.c recurse.c recurse.h su...


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src ChangeLog log.c recurse.c recurse.h su...
Date: Mon, 29 Sep 2008 17:46:29 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Derek Robert Price <dprice>     08/09/29 17:46:29

Modified files:
        src            : ChangeLog log.c recurse.c recurse.h subr.h 
                         update.c 

Log message:
        * log.c (rlog_proc): Avoid adding trailing /. to repository.  Some
        cleanup.
        * recurse.c (repository, struct recursion_frame, start_recursion):
        Declare repository const char *.
        (do_recursion, do_dir_proc): Ditto.  Some cleanup.
        * recurse.h (start_recursion): Update prototype to match.
        * subr.h (REPLACE): New convenience macro.
        * update.c (do_update): Cleanup traces.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3623&r2=1.3624
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/log.c?cvsroot=cvs&r1=1.116&r2=1.117
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/recurse.c?cvsroot=cvs&r1=1.137&r2=1.138
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/recurse.h?cvsroot=cvs&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/subr.h?cvsroot=cvs&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/update.c?cvsroot=cvs&r1=1.285&r2=1.286

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3623
retrieving revision 1.3624
diff -u -b -r1.3623 -r1.3624
--- ChangeLog   29 Sep 2008 16:06:44 -0000      1.3623
+++ ChangeLog   29 Sep 2008 17:46:23 -0000      1.3624
@@ -1,5 +1,14 @@
 2008-09-29  Derek R. Price  <address@hidden>
 
+       * log.c (rlog_proc): Avoid adding trailing /. to repository.  Some
+       cleanup.
+       * recurse.c (repository, struct recursion_frame, start_recursion):
+       Declare repository const char *.
+       (do_recursion, do_dir_proc): Ditto.  Some cleanup.
+       * recurse.h (start_recursion): Update prototype to match.
+       * subr.h (REPLACE): New convenience macro.
+       * update.c (do_update): Cleanup traces.
+
        * client.c (is_cvsroot_level): Improve commenting, minor cleanup.
 
 2008-09-28  Derek R. Price  <address@hidden>

Index: log.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/log.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -b -r1.116 -r1.117
--- log.c       22 Sep 2008 17:36:27 -0000      1.116
+++ log.c       29 Sep 2008 17:46:27 -0000      1.117
@@ -497,57 +497,38 @@
     char *myargv[2];
     int err = 0;
     int which;
-    char *repository = NULL;
+    char *repository;
     char *where;
 
     if (is_rlog)
     {
-       repository = xmalloc (strlen (current_parsed_root->directory)
-                              + strlen (argv[0])
-                             + (mfile == NULL ? 0 : strlen (mfile) + 1) + 2);
-       (void)sprintf (repository, "%s/%s",
-                       current_parsed_root->directory, argv[0]);
-       where = xmalloc (strlen (argv[0])
-                         + (mfile == NULL ? 0 : strlen (mfile) + 1)
-                        + 1);
-       (void)strcpy (where, argv[0]);
+       repository = dir_append (current_parsed_root->directory, argv[0]);
+       where = xstrdup (argv[0]);
 
        /* If mfile isn't null, we need to set up to do only part of theu
          * module.
          */
-       if (mfile != NULL)
+       if (mfile)
        {
-           char *cp;
-           char *path;
-
            /* If the portion of the module is a path, put the dir part on
              * repos.
              */
-           if ((cp = strrchr (mfile, '/')) != NULL)
-           {
-               *cp = '\0';
-               (void)strcat (repository, "/");
-               (void)strcat (repository, mfile);
-               (void)strcat (where, "/");
-               (void)strcat (where, mfile);
-               mfile = cp + 1;
-           }
-
-           /* take care of the rest */
-           path = Xasprintf ("%s/%s", repository, mfile);
+           char *path = dir_append (repository, mfile);
            if (isdir (path))
            {
-               /* directory means repository gets the dir tacked on */
-               (void)strcpy (repository, path);
-               (void)strcat (where, "/");
-               (void)strcat (where, mfile);
+               REPLACE (repository, dir_append (repository, mfile));
+               REPLACE (where, dir_append (repository, mfile));
            }
            else
            {
+               char *d = dir_name (mfile);
+               REPLACE (repository, dir_append (repository, d));
+               REPLACE (where, dir_append (where, d));
                myargv[0] = argv[0];
-               myargv[1] = mfile;
+               myargv[1] = last_component (mfile);
                argc = 2;
                argv = myargv;
+               free (d);
            }
            free (path);
        }
@@ -555,7 +536,7 @@
        /* cd to the starting repository */
        if (CVS_CHDIR (repository) < 0)
        {
-           error (0, errno, "cannot chdir to %s", repository);
+           error (0, errno, "cannot chdir to %s", quote (repository));
            free (repository);
            free (where);
            return 1;
@@ -576,7 +557,7 @@
                           argc - 1, argv + 1, local, which, 0, CVS_LOCK_READ,
                           where, 1, repository);
 
-    if (!(which & W_LOCAL)) free (repository);
+    if (repository) free (repository);
     if (where) free (where);
 
     return err;

Index: recurse.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/recurse.c,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -b -r1.137 -r1.138
--- recurse.c   29 Sep 2008 02:28:50 -0000      1.137
+++ recurse.c   29 Sep 2008 17:46:28 -0000      1.138
@@ -45,7 +45,7 @@
 static void addfile (List **listp, char *dir, char *file);
 
 static char *update_dir;
-static char *repository = NULL;
+static const char *repository = NULL;
 static List *filelist = NULL; /* holds list of files on which to operate */
 static List *dirlist = NULL; /* holds list of directories on which to operate 
*/
 
@@ -60,7 +60,7 @@
     int aflag;
     enum cvs_lock_type locktype;
     int dosrcs;
-    char *repository;                  /* Keep track of repository for rtag */
+    const char *repository;            /* Keep track of repository for rtag */
 };
 
 static int do_recursion (struct recursion_frame *frame);
@@ -193,7 +193,7 @@
                  void *callerdat, int argc, char **argv, int local,
                  int which, int aflag, enum cvs_lock_type locktype,
                  const char *update_preload, int dosrcs,
-                char *repository_in)
+                const char *repository_in)
 {
     int i, err = 0;
 #ifdef CLIENT_SUPPORT
@@ -208,7 +208,7 @@
       "                      callerdat=%s, argc=%d, argv=%s,\n"
       "                      local=%d, which=%d, aflag=%d,\n"
       "                      locktype=%d, update_preload=%s\n"
-      "                      dosrcs=%d, repository_in=%s )",
+      "                      dosrcs=%d, repository_in=%s)",
           TRACE_PTR (fileproc, 0), TRACE_PTR (filesdoneproc, 1),
           TRACE_PTR (direntproc, 2), TRACE_PTR (dirleaveproc, 3),
           TRACE_PTR (callerdat, 4), argc, TRACE_PTR (argv, 5),
@@ -227,24 +227,14 @@
     frame.locktype = locktype;
     frame.dosrcs = dosrcs;
 
-    /* If our repository_in has a trailing "/.", remove it before storing it
-     * for do_recursion().
-     *
-     * FIXME: This is somewhat of a hack in the sense that many of our callers
-     * painstakingly compute and add the trailing '.' we now remove.
-     */
-    while (repository_in && strlen (repository_in) >= 2
-           && repository_in[strlen (repository_in) - 2] == '/'
-           && repository_in[strlen (repository_in) - 1] == '.')
-    {
-       /* Beware the case where the string is exactly "/." or "//.".
-        * Paths with a leading "//" are special on some early UNIXes.
+    /* Callers used to painstakingly append a '/.' to toplevel repository
+     * references, which was then removed here.  Verify this won't happen
+     * anymore.
         */
-       if (strlen (repository_in) == 2 || strlen (repository_in) == 3)
-           repository_in[strlen (repository_in) - 1] = '\0';
-       else
-           repository_in[strlen (repository_in) - 2] = '\0';
-    }
+    assert (!repository_in || strlen (repository_in) < 2
+           || !ISSLASH (repository_in[strlen (repository_in) - 2])
+           || repository_in[strlen (repository_in) - 1] != '.');
+
     frame.repository = repository_in;
 
     expand_wild (argc, argv, &argc, &argv);
@@ -254,12 +244,6 @@
     else
        update_dir = xstrdup (update_preload);
 
-    /* clean up from any previous calls to start_recursion */
-    if (repository)
-    {
-       free (repository);
-       repository = NULL;
-    }
     if (filelist)
        dellist (&filelist); /* FIXME-krp: no longer correct. */
     if (dirlist)
@@ -722,17 +706,15 @@
     if (frame->which & W_LOCAL)
     {
        if (isdir (CVSADM))
-       {
-           repository = Name_Repository (NULL, update_dir);
-           srepository = repository;           /* remember what to free */
-       }
+           /* Use SREPOSITORY to remember what to free.  */
+           repository = srepository = Name_Repository (NULL, update_dir);
        else
            repository = NULL;
     }
     else
     {
        repository = frame->repository;
-       assert (repository != NULL);
+       assert (repository);
     }
 
     fileattr_startdir (repository);
@@ -968,11 +950,8 @@
     struct recursion_frame xframe;
     char *dir = p->key;
     char *newrepos;
-    List *sdirlist;
-    char *srepository;
     Dtype dir_return = R_PROCESS;
     int err = 0;
-    struct saved_cwd cwd;
     char *saved_update_dir;
     bool process_this_directory = true;
 
@@ -1137,11 +1116,13 @@
     /* only process the dir if the return code was 0 */
     if (dir_return != R_SKIP_ALL)
     {
+       const char *srepository = repository;
+       List *sdirlist = dirlist;
+       struct saved_cwd cwd;
+
        /* save our current directory and static vars */
         if (save_cwd (&cwd))
            error (1, errno, "Failed to save current directory.");
-       sdirlist = dirlist;
-       srepository = repository;
        dirlist = NULL;
 
        /* cd to the sub-directory */
@@ -1166,12 +1147,15 @@
        err += do_recursion (&xframe);
        if (xframe.repository)
        {
-           free (xframe.repository);
+           /* If this is set, then it is okay to free it because we just
+            * allocated it a few lines up.
+            */
+           free ((void *)xframe.repository);
            xframe.repository = NULL;
        }
 
        /* call-back dir leave proc (if any) */
-       if (process_this_directory && frame->dirleaveproc != NULL)
+       if (process_this_directory && frame->dirleaveproc)
            err = frame->dirleaveproc (frame->callerdat, dir, err, update_dir,
                                       frent->entries);
 
@@ -1190,6 +1174,8 @@
     return err;
 }
 
+
+
 /*
  * Add a node to a list allocating the list if necessary.
  */

Index: recurse.h
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/recurse.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- recurse.h   1 Jan 2008 23:12:42 -0000       1.4
+++ recurse.h   29 Sep 2008 17:46:29 -0000      1.5
@@ -63,6 +63,7 @@
                     DIRENTPROC direntproc, DIRLEAVEPROC dirleaveproc,
                     void *callerdat, int argc, char *argv[], int local,
                     int which, int aflag, enum cvs_lock_type locktype,
-                    const char *update_preload, int dosrcs, char *repository);
+                    const char *update_preload, int dosrcs,
+                    const char *repository);
 
 #endif /* RECURSE_H */

Index: subr.h
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/subr.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- subr.h      25 Sep 2008 13:24:36 -0000      1.24
+++ subr.h      29 Sep 2008 17:46:29 -0000      1.25
@@ -181,4 +181,9 @@
 /* Convenience macro for equating a NULL pointer and the empty string.  */
 #define NULL2MT(s) (s ? s : "")
 
+/* Replace pointer D with S, freeing D afterwards.  This is useful when S
+ * is an expression containing D.
+ */
+#define REPLACE(d, s)  {void *tmp = (d); d = (s); free (tmp);}
+
 #endif /* !SUBR_H */

Index: update.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/update.c,v
retrieving revision 1.285
retrieving revision 1.286
diff -u -b -r1.285 -r1.286
--- update.c    25 Sep 2008 13:24:37 -0000      1.285
+++ update.c    29 Sep 2008 17:46:29 -0000      1.286
@@ -482,14 +482,12 @@
 
     TRACE (TRACE_FUNCTION,
 "do_update (%s, %s, %s, %d, %d, %d, %d, %d, %d, %d, %s, %s, %s, %s, %s, %d, 
%s)",
-           xoptions ? xoptions : "(null)", xtag ? xtag : "(null)",
-          xdate ? xdate : "(null)", xforce, local, xbuild, xaflag, xprune,
-          xpipeout, which, xjoin_rev1 ? xjoin_rev1 : "(null)",
-          xjoin_date1 ? xjoin_date1 : "(null)",
-          xjoin_rev2 ? xjoin_rev2 : "(null)",
-          xjoin_date2 ? xjoin_date2 : "(null)",
-          preload_update_dir ? preload_update_dir : "(null)", xdotemplate,
-          repository ? repository : "(null)");
+           TRACE_NULL (xoptions), TRACE_NULL (xtag),
+          TRACE_NULL (xdate), xforce, local, xbuild, xaflag, xprune,
+          xpipeout, which, TRACE_NULL (xjoin_rev1), TRACE_NULL (xjoin_date1),
+          TRACE_NULL (xjoin_rev2), TRACE_NULL (xjoin_date2),
+          TRACE_NULL (preload_update_dir), xdotemplate,
+          TRACE_NULL (repository));
 
     /* Set globals.  */
     if (server_active && server_use_bases ())




reply via email to

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