cvs-cvs
[Top][All Lists]
Advanced

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

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


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src ChangeLog client.c subr.c subr.h
Date: Tue, 11 Jul 2006 21:48:43 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Derek Robert Price <dprice>     06/07/11 21:48:43

Modified files:
        src            : ChangeLog client.c subr.c subr.h 

Log message:
        * subr.c (isParentPath): New function.
        * subr.h (isParentPath): New proto.
        * client.c (is_arg_a_parent_or_listed_dir): Use new function.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3472&r2=1.3473
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/client.c?cvsroot=cvs&r1=1.458&r2=1.459
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/subr.c?cvsroot=cvs&r1=1.154&r2=1.155
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/subr.h?cvsroot=cvs&r1=1.11&r2=1.12

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3472
retrieving revision 1.3473
diff -u -b -r1.3472 -r1.3473
--- ChangeLog   11 Jul 2006 20:29:06 -0000      1.3472
+++ ChangeLog   11 Jul 2006 21:48:43 -0000      1.3473
@@ -1,5 +1,9 @@
 2006-07-11  Derek Price  <address@hidden>
 
+       * subr.c (isParentPath): New function.
+       * subr.h (isParentPath): New proto.
+       * client.c (is_arg_a_parent_or_listed_dir): Use new function.
+
        * server.c (do_cvs_command): Initialize var to suppress warning.
 
 2006-07-11  Larry Jones  <address@hidden>

Index: client.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/client.c,v
retrieving revision 1.458
retrieving revision 1.459
diff -u -b -r1.458 -r1.459
--- client.c    6 Jul 2006 02:14:08 -0000       1.458
+++ client.c    11 Jul 2006 21:48:43 -0000      1.459
@@ -135,26 +135,7 @@
 static int
 is_arg_a_parent_or_listed_dir (Node *n, void *d)
 {
-    char *directory = n->key;          /* name of the dir sent to server */
-    char *this_argv_elem = xstrdup (d);        /* this argv element */
-    int retval;
-
-    /* Say we should send this argument if the argument matches the
-       beginning of a directory name sent to the server.  This way,
-       the server will know to start at the top of that directory
-       hierarchy and descend. */
-
-    strip_trailing_slashes (this_argv_elem);
-    if (strlen (directory) >= strlen (this_argv_elem)
-       && !strncmp (directory, this_argv_elem, strlen (this_argv_elem))
-       && (strlen (directory) == strlen (this_argv_elem)
-           || ISSLASH (directory[strlen (this_argv_elem)])))
-       retval = 1;
-    else
-       retval = 0;
-
-    free (this_argv_elem);
-    return retval;
+    return isParentPath (d, n->key);
 }
 
 

Index: subr.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/subr.c,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -b -r1.154 -r1.155
--- subr.c      5 Jul 2006 15:27:13 -0000       1.154
+++ subr.c      11 Jul 2006 21:48:43 -0000      1.155
@@ -2102,6 +2102,41 @@
 
 
 
+bool
+isParentPath (const char *maybe_parent, const char *maybe_child)
+{
+    char *p1, *p2;
+    bool isparent;
+
+    if (strlen (maybe_parent) <= strlen (maybe_child)
+       && !strncmp (maybe_parent, maybe_child, strlen (maybe_parent))
+       && (maybe_child[strlen (maybe_parent)] == '\0'
+           || ISSLASH (maybe_child[strlen (maybe_parent)])))
+       return true;
+
+    /* Path didn't match, but try to resolve any links that may be
+     * present.
+     */
+    if (!isdir (maybe_parent) || !isfile (maybe_child))
+       /* To be resolvable, paths must exist on this server.  */
+       return false;
+
+    p1 = xcanonicalize_file_name (maybe_parent);
+    p2 = xcanonicalize_file_name (maybe_child);
+    if (strlen (p1) <= strlen (p2)
+       && !strncmp (p1, p2, strlen (p1))
+       && (p2[strlen (p1)] == '\0' || ISSLASH (p2[strlen (p1)])))
+       isparent = true;
+    else
+       isparent = false;
+
+    free (p1);
+    free (p2);
+    return isparent;
+}
+
+
+
 #ifdef HAVE_CVS_ADMIN_GROUP
 /* Return true if the current user should be allowed to run CVS admin commands,
  * false otherwise.

Index: subr.h
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/subr.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- subr.h      3 Jul 2006 11:54:42 -0000       1.11
+++ subr.h      11 Jul 2006 21:48:43 -0000      1.12
@@ -108,6 +108,7 @@
 char *xcanonicalize_file_name (const char *path);
 bool isThisHost (const char *otherhost);
 bool isSamePath (const char *path1_in, const char *path2_in);
+bool isParentPath (const char *maybe_parent, const char *maybe_child);
 
 # ifdef HAVE_CVS_ADMIN_GROUP
 bool is_admin (void);




reply via email to

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