[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Cvs-cvs] ccvs/src ChangeLog edit.c entries.c find_names....
From: |
Derek Robert Price |
Subject: |
[Cvs-cvs] ccvs/src ChangeLog edit.c entries.c find_names.... |
Date: |
Wed, 12 Sep 2007 15:16:55 +0000 |
CVSROOT: /cvsroot/cvs
Module name: ccvs
Changes by: Derek Robert Price <dprice> 07/09/12 15:16:55
Modified files:
src : ChangeLog edit.c entries.c find_names.c
sanity.sh update.c
Log message:
* edit.c: Alphabetize includes.
* entries.c, find_names.c, update.c: Gratuitous cleanup.
* sanity.sh (errmsg2-16): Fix bug from previous commit.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/ChangeLog?cvsroot=cvs&r1=1.3538&r2=1.3539
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/edit.c?cvsroot=cvs&r1=1.99&r2=1.100
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/entries.c?cvsroot=cvs&r1=1.71&r2=1.72
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/find_names.c?cvsroot=cvs&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/sanity.sh?cvsroot=cvs&r1=1.1188&r2=1.1189
http://cvs.savannah.gnu.org/viewcvs/ccvs/src/update.c?cvsroot=cvs&r1=1.273&r2=1.274
Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/ChangeLog,v
retrieving revision 1.3538
retrieving revision 1.3539
diff -u -b -r1.3538 -r1.3539
--- ChangeLog 12 Sep 2007 13:16:48 -0000 1.3538
+++ ChangeLog 12 Sep 2007 15:16:53 -0000 1.3539
@@ -1,5 +1,9 @@
2007-09-12 Derek Price <address@hidden>
+ * edit.c: Alphabetize includes.
+ * entries.c, find_names.c, update.c: Gratuitous cleanup.
+ * sanity.sh (errmsg2-16): Fix bug from previous commit.
+
* update.c: Include GNULIB's "quote.h".
* main.c (main): Use xstrdup in preference to strdup.
Index: edit.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/edit.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -b -r1.99 -r1.100
--- edit.c 12 Sep 2007 13:07:33 -0000 1.99
+++ edit.c 12 Sep 2007 15:16:53 -0000 1.100
@@ -27,13 +27,13 @@
/* CVS headers. */
#include "base.h"
#include "ignore.h"
+#include "fileattr.h"
#include "lock.h"
#include "recurse.h"
#include "repos.h"
+#include "watch.h"
#include "cvs.h"
-#include "watch.h"
-#include "fileattr.h"
Index: entries.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/entries.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -b -r1.71 -r1.72
--- entries.c 12 Sep 2007 02:45:22 -0000 1.71
+++ entries.c 12 Sep 2007 15:16:54 -0000 1.72
@@ -34,13 +34,6 @@
-static Node *AddEntryNode (List * list, Entnode *entnode);
-
-static Entnode *fgetentent (FILE *, char *, int *);
-static int fputentent (FILE *, Entnode *);
-
-static Entnode *subdir_record (int, const char *, const char *);
-
static FILE *entfile;
static char *entfilename; /* for error messages */
@@ -96,11 +89,11 @@
return ent;
}
+
+
/*
* Destruct an Entnode
*/
-static void Entnode_Destroy (Entnode *);
-
static void
Entnode_Destroy (Entnode *ent)
{
@@ -119,10 +112,55 @@
free (ent);
}
+
+
+static int
+fputentent (FILE *fp, Entnode *p)
+{
+ switch (p->type)
+ {
+ case ENT_FILE:
+ break;
+ case ENT_SUBDIR:
+ if (fprintf (fp, "D") < 0)
+ return 1;
+ break;
+ }
+
+ if (fprintf (fp, "/%s/%s/%s", p->user, p->version, p->timestamp) < 0)
+ return 1;
+ if (p->conflict)
+ {
+ if (fprintf (fp, "+%s", p->conflict) < 0)
+ return 1;
+ }
+ if (fprintf (fp, "/%s/", p->options) < 0)
+ return 1;
+
+ if (p->tag)
+ {
+ if (fprintf (fp, "T%s\n", p->tag) < 0)
+ return 1;
+ }
+ else if (p->date)
+ {
+ if (fprintf (fp, "D%s\n", p->date) < 0)
+ return 1;
+ }
+ else
+ {
+ if (fprintf (fp, "\n") < 0)
+ return 1;
+ }
+
+ return 0;
+}
+
+
+
/*
* Write out the line associated with a node of an entries file
*/
-static int write_ent_proc (Node *, void *);
static int
write_ent_proc (Node *node, void *closure)
{
@@ -137,6 +175,8 @@
return 0;
}
+
+
/*
* write out the current entries file given a list, making a backup copy
* first of course
@@ -257,6 +297,58 @@
/*
+ * Free up the memory associated with the data section of an ENTRIES type
+ * node
+ */
+static void
+Entries_delproc (Node *node)
+{
+ Entnode *p = node->data;
+
+ Entnode_Destroy (p);
+}
+
+
+
+/*
+ * Get an Entries file list node, initialize it, and add it to the specified
+ * list
+ */
+static Node *
+AddEntryNode (List *list, Entnode *entdata)
+{
+ Node *p;
+
+ TRACE (TRACE_FLOW, "AddEntryNode (%s, %s)",
+ entdata->user, entdata->timestamp);
+
+ /* was it already there? */
+ if ((p = findnode_fn (list, entdata->user)) != NULL)
+ {
+ /* take it out */
+ delnode (p);
+ }
+
+ /* get a node and fill in the regular stuff */
+ p = getnode ();
+ p->type = ENTRIES;
+ p->delproc = Entries_delproc;
+
+ /* this one gets a key of the name for hashing */
+ /* FIXME This results in duplicated data --- the hash package shouldn't
+ assume that the key is dynamically allocated. The user's free proc
+ should be responsible for freeing the key. */
+ p->key = xstrdup (entdata->user);
+ p->data = entdata;
+
+ /* put the node into the list */
+ addnode (list, p);
+ return p;
+}
+
+
+
+/*
* Enters the given file name/version/time-stamp into the Entries file,
* removing the old entry first, if necessary.
*/
@@ -307,6 +399,8 @@
}
}
+
+
/*
* Node delete procedure for list-private sticky dir tag/date info
*/
@@ -424,7 +518,6 @@
/* Return the next real Entries line. On end of file, returns NULL.
On error, prints an error message and returns NULL. */
-
static Entnode *
fgetentent (FILE *fpin, char *cmd, int *sawdir)
{
@@ -545,48 +638,6 @@
return ent;
}
-static int
-fputentent (FILE *fp, Entnode *p)
-{
- switch (p->type)
- {
- case ENT_FILE:
- break;
- case ENT_SUBDIR:
- if (fprintf (fp, "D") < 0)
- return 1;
- break;
- }
-
- if (fprintf (fp, "/%s/%s/%s", p->user, p->version, p->timestamp) < 0)
- return 1;
- if (p->conflict)
- {
- if (fprintf (fp, "+%s", p->conflict) < 0)
- return 1;
- }
- if (fprintf (fp, "/%s/", p->options) < 0)
- return 1;
-
- if (p->tag)
- {
- if (fprintf (fp, "T%s\n", p->tag) < 0)
- return 1;
- }
- else if (p->date)
- {
- if (fprintf (fp, "D%s\n", p->date) < 0)
- return 1;
- }
- else
- {
- if (fprintf (fp, "\n") < 0)
- return 1;
- }
-
- return 0;
-}
-
/* Read the entries file into a list, hashing on the file name.
@@ -760,56 +811,6 @@
/*
- * Free up the memory associated with the data section of an ENTRIES type
- * node
- */
-static void
-Entries_delproc (Node *node)
-{
- Entnode *p = node->data;
-
- Entnode_Destroy (p);
-}
-
-/*
- * Get an Entries file list node, initialize it, and add it to the specified
- * list
- */
-static Node *
-AddEntryNode (List *list, Entnode *entdata)
-{
- Node *p;
-
- TRACE (TRACE_FLOW, "AddEntryNode (%s, %s)",
- entdata->user, entdata->timestamp);
-
- /* was it already there? */
- if ((p = findnode_fn (list, entdata->user)) != NULL)
- {
- /* take it out */
- delnode (p);
- }
-
- /* get a node and fill in the regular stuff */
- p = getnode ();
- p->type = ENTRIES;
- p->delproc = Entries_delproc;
-
- /* this one gets a key of the name for hashing */
- /* FIXME This results in duplicated data --- the hash package shouldn't
- assume that the key is dynamically allocated. The user's free proc
- should be responsible for freeing the key. */
- p->key = xstrdup (entdata->user);
- p->data = entdata;
-
- /* put the node into the list */
- addnode (list, p);
- return p;
-}
-
-
-
-/*
* Write out the CVS/Template file.
*/
void
@@ -890,6 +891,8 @@
#endif
}
+
+
/* Parse the CVS/Tag file for the current directory.
If it contains a date, sets *DATEP to the date in a newly malloc'd
@@ -980,12 +983,13 @@
error (0, errno, "cannot open %s", CVSADM_TAG);
}
+
+
/*
* This is called if all subdirectory information is known, but there
* aren't any subdirectories. It records that fact in the list
* private data.
*/
-
void
Subdirs_Known (List *entries)
{
@@ -1022,8 +1026,9 @@
}
}
-/* Record subdirectory information. */
+
+/* Record subdirectory information. */
static Entnode *
subdir_record (int cmd, const char *parent, const char *dir)
{
@@ -1089,13 +1094,14 @@
return entnode;
}
+
+
/*
* Record the addition of a new subdirectory DIR in PARENT. PARENT
* may be NULL, which means the current directory. ENTRIES is the
* current entries list; it may be NULL, which means that it need not
* be updated.
*/
-
void
Subdir_Register (List *entries, const char *parent, const char *dir)
{
Index: find_names.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/find_names.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- find_names.c 12 Sep 2007 02:45:22 -0000 1.47
+++ find_names.c 12 Sep 2007 15:16:54 -0000 1.48
@@ -26,7 +26,7 @@
# include <config.h>
#endif
-/* Verify Interface. */
+/* Verify interface. */
#include "find-names.h"
/* ANSI C */
@@ -43,14 +43,9 @@
-static int find_rcs (const char *dir, List * list);
-static int add_subdir_proc (Node *, void *);
-static int register_subdir_proc (Node *, void *);
-
/*
* add the key from entry on entries list to the files list
*/
-static int add_entries_proc (Node *, void *);
static int
add_entries_proc (Node *node, void *closure)
{
@@ -59,21 +54,70 @@
Entnode *entnode = node->data;
if (entnode->type != ENT_FILE)
- return (0);
+ return 0;
fnode = getnode ();
fnode->type = FILES;
fnode->key = xstrdup (node->key);
- if (addnode (filelist, fnode) != 0)
+ if (addnode (filelist, fnode))
freenode (fnode);
- return (0);
+ return 0;
}
+
+
+/* walklist() proc which strips a trailing RCSEXT from node keys.
+ */
+static int
+strip_rcsext (Node *p, void *closure)
+{
+ char *s = p->key + strlen (p->key) - strlen (RCSEXT);
+ assert (!strcmp (s, RCSEXT));
+ *s = '\0'; /* strip the ,v */
+ return 0;
+}
+
+
+
+/*
+ * Finds all the ,v files in the directory DIR, and adds them to the LIST.
+ * Returns 0 for success and non-zero if DIR cannot be opened, in which case
+ * ERRNO is set to indicate the error. In the error case, LIST is left in some
+ * reasonable state (unchanged, or containing the files which were found before
+ * the error occurred).
+ *
+ * INPUTS
+ * dir The directory to open for read.
+ *
+ * OUTPUTS
+ * list Where to store matching file entries.
+ *
+ * GLOBALS
+ * errno Set on error.
+ *
+ * RETURNS
+ * 0, for success.
+ * <> 0, on error.
+ */
+static int
+find_rcs (dir, list)
+ const char *dir;
+ List *list;
+{
+ List *newlist;
+ if (!(newlist = find_files (dir, RCSPAT)))
+ return 1;
+ walklist (newlist, strip_rcsext, NULL);
+ mergelists (list, &newlist);
+ return 0;
+}
+
+
+
/* Find files in the repository and/or working directory. On error,
may either print a nonfatal error and return NULL, or just give
a fatal error. On success, return non-NULL (even if it is an empty
list). */
-
List *
Find_Names (const char *repository, const char *update_dir,
int which, int aflag, List **optentries)
@@ -95,7 +139,7 @@
walklist (entries, add_entries_proc, files);
/* if our caller wanted the entries list, return it; else free it */
- if (optentries != NULL)
+ if (optentries)
*optentries = entries;
else
Entries_Close (entries, update_dir);
@@ -129,16 +173,18 @@
/* sort the list into alphabetical order and return it */
sortlist (files, fsortcmp);
return files;
+
error_exit:
dellist (&files);
return NULL;
}
+
+
/*
* Add an entry from the subdirs list to the directories list. This
* is called via walklist.
*/
-
static int
add_subdir_proc (Node *p, void *closure)
{
@@ -152,15 +198,16 @@
dnode = getnode ();
dnode->type = DIRS;
dnode->key = xstrdup (entnode->user);
- if (addnode (dirlist, dnode) != 0)
+ if (addnode (dirlist, dnode))
freenode (dnode);
return 0;
}
+
+
/*
* Register a subdirectory. This is called via walklist.
*/
-
/*ARGSUSED*/
static int
register_subdir_proc (Node *p, void *closure)
@@ -200,35 +247,35 @@
skip_emptydir = 1;
/* set up to read the dir */
- if ((dirp = CVS_OPENDIR (dir)) == NULL)
- return (1);
+ if (!(dirp = CVS_OPENDIR (dir)))
+ return 1;
/* read the dir, grabbing sub-dirs */
errno = 0;
- while ((dp = CVS_READDIR (dirp)) != NULL)
+ while (dp = CVS_READDIR (dirp))
{
- if (strcmp (dp->d_name, ".") == 0 ||
- strcmp (dp->d_name, "..") == 0 ||
- strcmp (dp->d_name, CVSATTIC) == 0 ||
- strcmp (dp->d_name, CVSLCK) == 0 ||
- strcmp (dp->d_name, CVSREP) == 0)
+ if (!strcmp (dp->d_name, ".") ||
+ !strcmp (dp->d_name, "..") ||
+ !strcmp (dp->d_name, CVSATTIC) ||
+ !strcmp (dp->d_name, CVSLCK) ||
+ !strcmp (dp->d_name, CVSREP))
goto do_it_again;
/* findnode() is going to be significantly faster than stat()
because it involves no system calls. That is why we bother
with the entries argument, and why we check this first. */
- if (entries != NULL && findnode (entries, dp->d_name) != NULL)
+ if (entries && findnode (entries, dp->d_name))
goto do_it_again;
if (skip_emptydir
- && strcmp (dp->d_name, CVSNULLREPOS) == 0)
+ && !strcmp (dp->d_name, CVSNULLREPOS))
goto do_it_again;
if (!DIRENT_MIGHT_BE_DIR(dp))
goto do_it_again;
/* don't bother stating ,v files */
- if (CVS_FNMATCH (RCSPAT, dp->d_name, 0) == 0)
+ if (!CVS_FNMATCH (RCSPAT, dp->d_name, 0))
goto do_it_again;
if (!DIRENT_MUST_BE(dp, DT_DIR))
@@ -279,7 +326,7 @@
(void) CVS_CLOSEDIR (dirp);
if (tmp != NULL)
free (tmp);
- return (0);
+ return 0;
}
@@ -322,15 +369,16 @@
the subdirectories the hard way, and, if possible, add
it to the Entries file for next time. */
- /* FIXME-maybe: find_dirs is bogus for this usage because
- it skips CVSATTIC and CVSLCK directories--those names
- should be special only in the repository. However, in
- the interests of not perturbing this code, we probably
- should leave well enough alone unless we want to write
- a sanity.sh test case (which would operate by manually
- hacking on the CVS/Entries file). */
-
- if (find_dirs (".", dirlist, 1, tmpentries) != 0)
+ /* find_dirs() is appropriate here. It was originally designed for
+ * use in the repository, so it skips CVSATTIC and CVSLCK
+ * directories, but this is still the right thing to do in a
+ * sandbox since doing otherwise would cause name conflicts when
+ * the directories are imported.
+ *
+ * FIXME: The user should really see a warning about the skipped
+ * directories, however.
+ */
+ if (find_dirs (".", dirlist, 1, tmpentries))
error (1, errno, "cannot open %s", quote (update_dir));
if (tmpentries)
{
@@ -485,51 +533,3 @@
globfree (&glist);
return retval;
}
-
-
-
-/* walklist() proc which strips a trailing RCSEXT from node keys.
- */
-static int
-strip_rcsext (Node *p, void *closure)
-{
- char *s = p->key + strlen (p->key) - strlen (RCSEXT);
- assert (!strcmp (s, RCSEXT));
- *s = '\0'; /* strip the ,v */
- return 0;
-}
-
-
-
-/*
- * Finds all the ,v files in the directory DIR, and adds them to the LIST.
- * Returns 0 for success and non-zero if DIR cannot be opened, in which case
- * ERRNO is set to indicate the error. In the error case, LIST is left in some
- * reasonable state (unchanged, or containing the files which were found before
- * the error occurred).
- *
- * INPUTS
- * dir The directory to open for read.
- *
- * OUTPUTS
- * list Where to store matching file entries.
- *
- * GLOBALS
- * errno Set on error.
- *
- * RETURNS
- * 0, for success.
- * <> 0, on error.
- */
-static int
-find_rcs (dir, list)
- const char *dir;
- List *list;
-{
- List *newlist;
- if (!(newlist = find_files (dir, RCSPAT)))
- return 1;
- walklist (newlist, strip_rcsext, NULL);
- mergelists (list, &newlist);
- return 0;
-}
Index: sanity.sh
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/sanity.sh,v
retrieving revision 1.1188
retrieving revision 1.1189
diff -u -b -r1.1188 -r1.1189
--- sanity.sh 12 Sep 2007 02:45:22 -0000 1.1188
+++ sanity.sh 12 Sep 2007 15:16:54 -0000 1.1189
@@ -17183,7 +17183,8 @@
# message (e.g. the one from local CVS). But at least it is an
# error message.
dotest_fail errmsg2-16 "$testcvs add bogus-dir/file16" \
-"$SPROG \[add aborted\]: there is no version here; do \`$SPROG checkout'
first" \
+"$SPROG add: in directory \`bogus-dir':
+$SPROG \[add aborted\]: there is no version here; do \`$SPROG checkout' first"
\
"$CPROG add: cannot open \`bogus-dir/CVS/Entries' for reading: No such file or
directory
$CPROG \[add aborted\]: no repository"
rm -r bogus-dir
Index: update.c
===================================================================
RCS file: /cvsroot/cvs/ccvs/src/update.c,v
retrieving revision 1.273
retrieving revision 1.274
diff -u -b -r1.273 -r1.274
--- update.c 12 Sep 2007 13:16:48 -0000 1.273
+++ update.c 12 Sep 2007 15:16:54 -0000 1.274
@@ -43,6 +43,9 @@
# include <config.h>
#endif
+/* ANSI C headers. */
+#include <assert.h>
+
/* GNULIB */
#include "quote.h"
#include "save-cwd.h"
@@ -51,15 +54,13 @@
# include "md5.h"
#endif
-/* ANSI C headers. */
-#include <assert.h>
-
/* CVS headers. */
#include "base.h"
#include "buffer.h"
#include "classify.h"
#include "edit.h"
#include "fileattr.h"
+#include "hardlink.h"
#include "ignore.h"
#include "no_diff.h"
#include "recurse.h"
@@ -68,7 +69,6 @@
#include "wrapper.h"
#include "cvs.h"
-#include "hardlink.h"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Cvs-cvs] ccvs/src ChangeLog edit.c entries.c find_names....,
Derek Robert Price <=