cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] ccvs/src ChangeLog commit.c root.c subr.c subr.h


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src ChangeLog commit.c root.c subr.c subr.h
Date: Tue, 09 Sep 2008 16:55:25 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Derek Robert Price <dprice>     08/09/09 16:55:25

Modified files:
        src            : ChangeLog commit.c root.c subr.c subr.h 

Log message:
        * subr.c (dir_append_dirs): Fix block comment.  Accept NULL DIR arg.
        * subr.h (PRINT_UPDATE_DIR): New convenience macro.
        * commit.c (find_dirent_proc, check_dirent_proc): Use new macro.
        * root.c (Name_Root): Ditto.  Also use TRACE_NULL and dir_append to
        further simplify.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3565&r2=1.3566
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/commit.c?cvsroot=cvs&r1=1.279&r2=1.280
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/root.c?cvsroot=cvs&r1=1.132&r2=1.133
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/subr.c?cvsroot=cvs&r1=1.167&r2=1.168
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/subr.h?cvsroot=cvs&r1=1.19&r2=1.20

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3565
retrieving revision 1.3566
diff -u -b -r1.3565 -r1.3566
--- ChangeLog   15 Aug 2008 16:55:10 -0000      1.3565
+++ ChangeLog   9 Sep 2008 16:55:23 -0000       1.3566
@@ -1,3 +1,11 @@
+2008-09-09  Derek R. Price  <address@hidden>
+
+       * subr.c (dir_append_dirs): Fix block comment.  Accept NULL DIR arg.
+       * subr.h (PRINT_UPDATE_DIR): New convenience macro.
+       * commit.c (find_dirent_proc, check_dirent_proc): Use new macro.
+       * root.c (Name_Root): Ditto.  Also use TRACE_NULL and dir_append to
+       further simplify.
+
 2008-08-15  Derek R. Price  <address@hidden>
 
        * update.c (send_dirent_proc): Another simplification via hasAdmin().

Index: commit.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/commit.c,v
retrieving revision 1.279
retrieving revision 1.280
diff -u -b -r1.279 -r1.280
--- commit.c    20 Dec 2007 16:09:25 -0000      1.279
+++ commit.c    9 Sep 2008 16:55:24 -0000       1.280
@@ -173,7 +173,7 @@
        code will never be run during client/server operation and we
        want the messages to match. */
     if (!quiet)
-       error (0, 0, "Examining %s", update_dir);
+       error (0, 0, "Examining %s", PRINT_UPDATE_DIR (update_dir));
 
     return R_PROCESS;
 }
@@ -1186,7 +1186,7 @@
        return R_SKIP_ALL;
 
     if (!quiet)
-       error (0, 0, "Examining %s", update_dir);
+       error (0, 0, "Examining %s", PRINT_UPDATE_DIR (update_dir));
 
     return R_PROCESS;
 }

Index: root.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/root.c,v
retrieving revision 1.132
retrieving revision 1.133
diff -u -b -r1.132 -r1.133
--- root.c      28 Jan 2008 05:33:00 -0000      1.132
+++ root.c      9 Sep 2008 16:55:24 -0000       1.133
@@ -51,7 +51,6 @@
 {
     FILE *fpin;
     cvsroot_t *ret;
-    const char *xupdate_dir;
     char *root = NULL;
     size_t root_allocated = 0;
     char *tmp;
@@ -60,24 +59,10 @@
     int len;
 
     TRACE (TRACE_FLOW, "Name_Root (%s, %s)",
-          dir ? dir : "(null)",
-          update_dir ? update_dir : "(null)");
+          TRACE_NULL (dir), TRACE_NULL (update_dir));
 
-    if (update_dir && *update_dir)
-       xupdate_dir = update_dir;
-    else
-       xupdate_dir = ".";
-
-    if (dir != NULL)
-    {
-       cvsadm = Xasprintf ("%s/%s", dir, CVSADM);
-       tmp = Xasprintf ("%s/%s", dir, CVSADM_ROOT);
-    }
-    else
-    {
-       cvsadm = xstrdup (CVSADM);
-       tmp = xstrdup (CVSADM_ROOT);
-    }
+    cvsadm = dir_append (dir, CVSADM);
+    tmp = dir_append (dir, CVSADM_ROOT);
 
     /*
      * Do not bother looking for a readable file if there is no cvsadm
@@ -104,7 +89,7 @@
        int saved_errno = errno;
        /* FIXME: should be checking for end of file separately; errno
           is not set in that case.  */
-       error (0, 0, "in directory %s:", xupdate_dir);
+       error (0, 0, "in directory %s:", PRINT_UPDATE_DIR (update_dir));
        error (0, saved_errno, "cannot read %s", CVSADM_ROOT);
        error (0, 0, "please correct this problem");
        ret = NULL;
@@ -123,7 +108,7 @@
     ret = parse_cvsroot (root);
     if (ret == NULL)
     {
-       error (0, 0, "in directory %s:", xupdate_dir);
+       error (0, 0, "in directory %s:", PRINT_UPDATE_DIR (update_dir));
        error (0, 0,
               "ignoring %s because it does not contain a valid root.",
               CVSADM_ROOT);
@@ -132,7 +117,7 @@
 
     if (!ret->isremote && !isdir (ret->directory))
     {
-       error (0, 0, "in directory %s:", xupdate_dir);
+       error (0, 0, "in directory %s:", PRINT_UPDATE_DIR (update_dir));
        error (0, 0,
               "ignoring %s because it specifies a non-existent repository %s",
               CVSADM_ROOT, root);

Index: subr.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/subr.c,v
retrieving revision 1.167
retrieving revision 1.168
diff -u -b -r1.167 -r1.168
--- subr.c      15 Aug 2008 16:44:48 -0000      1.167
+++ subr.c      9 Sep 2008 16:55:24 -0000       1.168
@@ -2393,25 +2393,18 @@
  * both DIR and BASE when they are both empty and to ignore BASE when it is "."
  * and return the original DIR or BASE as needed.
  *
+ * A NULL DIR is treated like the empty string.  No BASE may be NULL since that
+ * terminates the va_arg processing.
+ *
  * EXAMPLES
- *    dir_append ("dir", ".", &allocated)      returns the original pointer to
- *                                             "dir"
- *    dir_append ("dir", "", &allocated)       returns the original pointer to
- *                                             "dir"
- *    dir_append ("", ".", &allocated)         returns the original pointer to
- *                                             ""
- *    dir_append (".", "", &allocated)         returns the original pointer to
- *                                             "."
- *    dir_append (".", ".", &allocated)                returns the original 
pointer to
- *                                             the first "."
- *    dir_append ("", "dir", &allocated)       returns the original pointer to
- *                                             "dir"
- *    dir_append (".", "dir", &allocated)      returns "./dir" in allocated
- *                                             memory and sets *allocated to
- *                                             point to it as well.
- *    dir_append ("dir", "sdir", &allocated)   returns "dir/sdir" in allocated
- *                                             memory and sets *allocated to
- *                                             point to it as well.
+ *    dir_append ("dir", ".")          returns "dir"
+ *    dir_append ("dir", "")           returns "dir"
+ *    dir_append ("", ".")             returns ""
+ *    dir_append (".", "")             returns "."
+ *    dir_append (".", ".")            returns "."
+ *    dir_append ("", "dir")           returns "dir"
+ *    dir_append (".", "dir")          returns "./dir"
+ *    dir_append ("dir", "sdir")       returns "dir/sdir"
  */
 char *
 dir_append_dirs (const char *dir, ...)
@@ -2422,7 +2415,7 @@
 
     va_start (args, dir);
 
-    retval = xstrdup (dir);
+    retval = xstrdup (dir ? dir : "");
     while ((append = va_arg (args, const char *)) != NULL)
     {
        char *new;

Index: subr.h
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/subr.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- subr.h      15 Aug 2008 16:44:48 -0000      1.19
+++ subr.h      9 Sep 2008 16:55:24 -0000       1.20
@@ -170,4 +170,9 @@
 # define STRNEQ(a, b, n) (strncmp ((a), (b), (n)) == 0)
 #endif /* HAVE_INLINE */
 
+/* Convenience macro for printing the commonly used but sometimes empty
+ * UPDATE_DIR string.
+ */
+#define PRINT_UPDATE_DIR(u) (*u ? u : ".")
+
 #endif /* !SUBR_H */




reply via email to

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