cvs-cvs
[Top][All Lists]
Advanced

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

[Cvs-cvs] ccvs/src ChangeLog Makefile.in add.c checkout.c...


From: Derek Robert Price
Subject: [Cvs-cvs] ccvs/src ChangeLog Makefile.in add.c checkout.c...
Date: Thu, 06 Jul 2006 02:14:09 +0000

CVSROOT:        /cvsroot/cvs
Module name:    ccvs
Changes by:     Derek Robert Price <dprice>     06/07/06 02:14:09

Modified files:
        src            : ChangeLog Makefile.in add.c checkout.c client.c 
                         filesubr.c filesubr.h recurse.c 

Log message:
        * add.c, checkout.c, client.c, recurse.c: Use new last_component() API.
        * filesubr.c, filesubr.h: Remove original last_component().

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3467&r2=1.3468
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/Makefile.in?cvsroot=cvs&r1=1.175&r2=1.176
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/add.c?cvsroot=cvs&r1=1.126&r2=1.127
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/checkout.c?cvsroot=cvs&r1=1.146&r2=1.147
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/client.c?cvsroot=cvs&r1=1.457&r2=1.458
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/filesubr.c?cvsroot=cvs&r1=1.109&r2=1.110
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/filesubr.h?cvsroot=cvs&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/recurse.c?cvsroot=cvs&r1=1.116&r2=1.117

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3467
retrieving revision 1.3468
diff -u -b -r1.3467 -r1.3468
--- ChangeLog   5 Jul 2006 19:10:32 -0000       1.3467
+++ ChangeLog   6 Jul 2006 02:14:08 -0000       1.3468
@@ -1,5 +1,8 @@
 2006-07-05  Derek Price  <address@hidden>
 
+       * add.c, checkout.c, client.c, recurse.c: Use new last_component() API.
+       * filesubr.c, filesubr.h: Remove original last_component().
+
        * sanity.sh (abspath-2a.*): Insert `r' to remote test name variants.
        Misc cleanup.
 

Index: Makefile.in
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/Makefile.in,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -b -r1.175 -r1.176
--- Makefile.in 3 Jul 2006 02:12:57 -0000       1.175
+++ Makefile.in 6 Jul 2006 02:14:08 -0000       1.176
@@ -60,6 +60,7 @@
        $(srcdir)/cvsbug.in $(srcdir)/sanity.config.sh.in ChangeLog
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/_inttypes_h.m4 \
+       $(top_srcdir)/m4/absolute-header.m4 \
        $(top_srcdir)/m4/acx_extract_cpp_defn.m4 \
        $(top_srcdir)/m4/acx_with_external_zlib.m4 \
        $(top_srcdir)/m4/acx_with_gssapi.m4 $(top_srcdir)/m4/alloca.m4 \
@@ -73,14 +74,14 @@
        $(top_srcdir)/m4/cvs_func_printf_ptr.m4 \
        $(top_srcdir)/m4/d-ino.m4 $(top_srcdir)/m4/d-type.m4 \
        $(top_srcdir)/m4/dirname.m4 $(top_srcdir)/m4/dos.m4 \
-       $(top_srcdir)/m4/dup2.m4 $(top_srcdir)/m4/eealloc.m4 \
-       $(top_srcdir)/m4/eoverflow.m4 $(top_srcdir)/m4/error.m4 \
-       $(top_srcdir)/m4/exitfail.m4 $(top_srcdir)/m4/extensions.m4 \
-       $(top_srcdir)/m4/fcntl-safer.m4 \
+       $(top_srcdir)/m4/double-slash-root.m4 $(top_srcdir)/m4/dup2.m4 \
+       $(top_srcdir)/m4/eealloc.m4 $(top_srcdir)/m4/eoverflow.m4 \
+       $(top_srcdir)/m4/error.m4 $(top_srcdir)/m4/exitfail.m4 \
+       $(top_srcdir)/m4/extensions.m4 $(top_srcdir)/m4/fcntl-safer.m4 \
        $(top_srcdir)/m4/filenamecat.m4 $(top_srcdir)/m4/fnmatch.m4 \
        $(top_srcdir)/m4/fpending.m4 $(top_srcdir)/m4/ftruncate.m4 \
-       $(top_srcdir)/m4/full-header-path.m4 \
        $(top_srcdir)/m4/getaddrinfo.m4 \
+       $(top_srcdir)/m4/getcwd-abort-bug.m4 \
        $(top_srcdir)/m4/getcwd-path-max.m4 $(top_srcdir)/m4/getcwd.m4 \
        $(top_srcdir)/m4/getdate.m4 $(top_srcdir)/m4/getdelim.m4 \
        $(top_srcdir)/m4/gethostname.m4 $(top_srcdir)/m4/getline.m4 \
@@ -117,6 +118,7 @@
        $(top_srcdir)/m4/stdint.m4 $(top_srcdir)/m4/stdint_h.m4 \
        $(top_srcdir)/m4/strcase.m4 $(top_srcdir)/m4/strdup.m4 \
        $(top_srcdir)/m4/strerror.m4 $(top_srcdir)/m4/strftime.m4 \
+       $(top_srcdir)/m4/strndup.m4 $(top_srcdir)/m4/strnlen.m4 \
        $(top_srcdir)/m4/strstr.m4 $(top_srcdir)/m4/strtoimax.m4 \
        $(top_srcdir)/m4/strtol.m4 $(top_srcdir)/m4/strtoll.m4 \
        $(top_srcdir)/m4/strtoul.m4 $(top_srcdir)/m4/strtoull.m4 \
@@ -132,8 +134,8 @@
        $(top_srcdir)/m4/wchar_t.m4 $(top_srcdir)/m4/wcwidth.m4 \
        $(top_srcdir)/m4/wint_t.m4 $(top_srcdir)/m4/xalloc.m4 \
        $(top_srcdir)/m4/xgetcwd.m4 $(top_srcdir)/m4/xreadlink.m4 \
-       $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/yesno.m4 \
-       $(top_srcdir)/configure.in
+       $(top_srcdir)/m4/xsize.m4 $(top_srcdir)/m4/xstrndup.m4 \
+       $(top_srcdir)/m4/yesno.m4 $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
 mkinstalldirs = $(install_sh) -d
@@ -180,6 +182,8 @@
 ETAGS = etags
 CTAGS = ctags
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ABSOLUTE_STDINT_H = @ABSOLUTE_STDINT_H@
+ABSOLUTE_SYS_STAT_H = @ABSOLUTE_SYS_STAT_H@
 ACLOCAL = @ACLOCAL@
 ALLOCA = @ALLOCA@
 ALLOCA_H = @ALLOCA_H@
@@ -215,8 +219,6 @@
 EOVERFLOW = @EOVERFLOW@
 EXEEXT = @EXEEXT@
 FNMATCH_H = @FNMATCH_H@
-FULL_PATH_STDINT_H = @FULL_PATH_STDINT_H@
-FULL_PATH_SYS_STAT_H = @FULL_PATH_SYS_STAT_H@
 GETOPT_H = @GETOPT_H@
 GLOB_H = @GLOB_H@
 GL_COND_LIBTOOL_FALSE = @GL_COND_LIBTOOL_FALSE@

Index: add.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/add.c,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -b -r1.126 -r1.127
--- add.c       31 May 2006 16:03:02 -0000      1.126
+++ add.c       6 Jul 2006 02:14:08 -0000       1.127
@@ -229,14 +229,18 @@
                    error (1, errno, "Failed to save current directory.");
 
                filedir = xstrdup (argv[j]);
-                /* Deliberately discard the const below since we know we just
-                 * allocated filedir and can do what we like with it.
-                 */
-               p = (char *)last_component (filedir);
+               p = last_component (filedir);
                if (p == filedir)
                {
                    update_dir = "";
                }
+               else if (!*p)
+               {
+                   error (1, 0, "Cannot add root directory `%s': no parent",
+                          filedir);
+                   /* The above exits, but placate gcc -Wall: */
+                   update_dir = NULL;
+               }
                else
                {
                    p[-1] = '\0';
@@ -320,15 +324,17 @@
 
        finfo.fullname = xstrdup (argv[i]);
        filename = xstrdup (argv[i]);
-       /* We know we can discard the const below since we just allocated
-        * filename and can do as we like with it.
-         */
-       p = (char *)last_component (filename);
+       p = last_component (filename);
        if (p == filename)
        {
            finfo.update_dir = "";
            finfo.file = p;
        }
+       else if (!*p)
+       {
+           error (1, 0, "Cannot add root directory `%s': no parent",
+                  filename);
+       }
        else
        {
            p[-1] = '\0';

Index: checkout.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/checkout.c,v
retrieving revision 1.146
retrieving revision 1.147
diff -u -b -r1.146 -r1.147
--- checkout.c  24 Apr 2006 18:50:25 -0000      1.146
+++ checkout.c  6 Jul 2006 02:14:08 -0000       1.147
@@ -483,20 +483,12 @@
            }
            else if (errno == ENOENT)
            {
-               /* where_this_pass - last_component (where_this_pass) */
-               char *parent;
-
-               /* It's okay to cast out the const below since we know we
-                * allocated where_this_pass and have control of it.
+               /* walk up the tree by setting
+                * WHERE_THIS_PASS = WHERE_THIS_PASS
+                *                   - last_component (WHERE_THIS_PASS)
                 */
-               if ((parent = (char *)last_component (where_this_pass))
-                       != where_this_pass)
-               {
-                   /* strip the last_component */
-                   parent[-1] = '\0';
-                   /* continue */
-               }
-               else
+               char *parent = last_component (where_this_pass);
+               if (parent == where_this_pass)
                {
                    /* ERRNO == ENOENT
                     *   && last_component (where_this_pass) == where_this_pass
@@ -507,6 +499,22 @@
                    free (where_this_pass);
                    break;
                }
+               else if (!*parent)
+               {
+                   /* Under UNIX, it shouldn't be possible for cd'ing to a
+                    * root directory to return ENOENT, but under Windows, it
+                    * might (e.g. `chdir ("F:\\")', with F: unmounted).
+                    */
+                   error (1, errno, "\
+could not change directory to requested checkout directory `%s'",
+                          where_this_pass);
+               }
+               else
+               {
+                   /* strip the last_component */
+                   parent[-1] = '\0';
+                   /* continue */
+               }
            }
            else
                /* we don't know how to handle other errors, so fail */
@@ -1193,14 +1201,22 @@
     while (dirs != NULL)
     {
        const char *dir = last_component (dirs->dirpath);
-       int made_dir = 0;
+       bool made_dir = false;
 
+       if (*dir)
+       {
        made_dir = !mkdir_if_needed (dir);
        if (made_dir) Subdir_Register (NULL, NULL, dir);
+       }
+       else
+           /* Assume the (or a, under Windows) root directory need not be
+            * created.
+            */
+           dir = dirs->dirpath;
 
        if (CVS_CHDIR (dir) < 0)
        {
-           error (0, errno, "cannot chdir to %s", dir);
+           error (0, errno, "cannot chdir to `%s'", dir);
            retval = 1;
            goto out;
        }

Index: client.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/client.c,v
retrieving revision 1.457
retrieving revision 1.458
diff -u -b -r1.457 -r1.458
--- client.c    30 Jun 2006 00:38:39 -0000      1.457
+++ client.c    6 Jul 2006 02:14:08 -0000       1.458
@@ -5835,10 +5835,7 @@
            /* Split the argument onto the stack.  */
            stack = getlist();
            r = xstrdup (argv[i]);
-            /* It's okay to discard the const from the last_component return
-             * below since we know we passed in an arg that was not const.
-             */
-           while ((q = (char *)last_component (r)) != r)
+           while ((q = last_component (r)) != r && *q)
            {
                push (stack, xstrdup (q));
                *--q = '\0';

Index: filesubr.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/filesubr.c,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -b -r1.109 -r1.110
--- filesubr.c  23 May 2006 17:47:39 -0000      1.109
+++ filesubr.c  6 Jul 2006 02:14:08 -0000       1.110
@@ -815,21 +815,6 @@
 
 
 
-/* Return a pointer into PATH's last component.  */
-const char *
-last_component (const char *path)
-{
-    const char *last = strrchr (path, '/');
-
-    assert (path);
-    if (last && (last != path))
-        return last + 1;
-    else
-        return path;
-}
-
-
-
 /* Return the home directory.  Returns a pointer to storage
    managed by this function or its callees (currently getenv).
    This function will return the same thing every time it is

Index: filesubr.h
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/filesubr.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- filesubr.h  24 Apr 2006 18:50:26 -0000      1.2
+++ filesubr.h  6 Jul 2006 02:14:08 -0000       1.3
@@ -32,7 +32,6 @@
 bool isreadable (const char *file);
 bool iswritable (const char *file);
 bool isaccessible (const char *file, const int mode);
-const char *last_component (const char *path);
 char *get_homedir (void);
 char *strcat_filename_onto_homedir (const char *, const char *);
 char *cvs_temp_name (void);

Index: recurse.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/recurse.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -b -r1.116 -r1.117
--- recurse.c   24 Apr 2006 18:50:27 -0000      1.116
+++ recurse.c   6 Jul 2006 02:14:08 -0000       1.117
@@ -399,20 +399,26 @@
             * string.
             */
            dir = xstrdup (argv[i]);
-           /* It's okay to cast out last_component's const below since we know
-            * we just allocated dir here and have control of it.
-            */
-           comp = (char *)last_component (dir);
+           comp = last_component (dir);
            if (comp == dir)
            {
                /* no dir component.  What we have is an implied "./" */
-               dir = xstrdup(".");
+               dir = xstrdup (".");
            }
-           else
+           else if (*comp)
            {
                comp[-1] = '\0';
                comp = xstrdup (comp);
            }
+           else
+           {
+               /* A root directory would have existed under UNIX and a missing
+                * one specified on the command line (for instance,
+                * `cvs up F:\' without drive F: mounted) is a fatal error
+                * under Windows.
+                */
+               error (1, ENOENT, "cannot process root directory `%s'", dir);
+           }
 
            /* if this argument exists as a file in the current
               working directory tree, then add it to the files list.  */




reply via email to

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