summaryrefslogtreecommitdiffstats
path: root/contrib/cvs/src/log.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cvs/src/log.c')
-rw-r--r--contrib/cvs/src/log.c148
1 files changed, 86 insertions, 62 deletions
diff --git a/contrib/cvs/src/log.c b/contrib/cvs/src/log.c
index ce9ba5c0..1de1b94 100644
--- a/contrib/cvs/src/log.c
+++ b/contrib/cvs/src/log.c
@@ -115,9 +115,10 @@ struct log_data_and_rcs
static int rlog_proc PROTO((int argc, char **argv, char *xwhere,
char *mwhere, char *mfile, int shorten,
int local_specified, char *mname, char *msg));
-static Dtype log_dirproc PROTO ((void *callerdat, char *dir,
- char *repository, char *update_dir,
- List *entries));
+static Dtype log_dirproc PROTO ((void *callerdat, const char *dir,
+ const char *repository,
+ const char *update_dir,
+ List *entries));
static int log_fileproc PROTO ((void *callerdat, struct file_info *finfo));
static struct option_revlist *log_parse_revlist PROTO ((const char *));
static void log_parse_date PROTO ((struct log_data *, const char *));
@@ -224,7 +225,7 @@ cvslog (argc, argv)
int local = 0;
struct option_revlist **prl;
- is_rlog = (strcmp (command_name, "rlog") == 0);
+ is_rlog = (strcmp (cvs_cmd_name, "rlog") == 0);
if (argc == -1)
usage (log_usage);
@@ -486,39 +487,46 @@ rlog_proc (argc, argv, xwhere, mwhere, mfile, shorten, local, mname, msg)
if (is_rlog)
{
- repository = xmalloc (strlen (current_parsed_root->directory) + strlen (argv[0])
+ 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)
+ (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]);
- /* if mfile isn't null, we need to set up to do only part of the module */
+ /* If mfile isn't null, we need to set up to do only part of theu
+ * module.
+ */
if (mfile != NULL)
{
char *cp;
char *path;
- /* if the portion of the module is a path, put the dir part on repos */
+ /* 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);
+ (void)strcat (repository, "/");
+ (void)strcat (repository, mfile);
+ (void)strcat (where, "/");
+ (void)strcat (where, mfile);
mfile = cp + 1;
}
/* take care of the rest */
path = xmalloc (strlen (repository) + strlen (mfile) + 5);
- (void) sprintf (path, "%s/%s", repository, mfile);
+ (void)sprintf (path, "%s/%s", repository, mfile);
if (isdir (path))
{
/* directory means repository gets the dir tacked on */
- (void) strcpy (repository, path);
- (void) strcat (where, "/");
- (void) strcat (where, mfile);
+ (void)strcpy (repository, path);
+ (void)strcat (where, "/");
+ (void)strcat (where, mfile);
}
else
{
@@ -531,19 +539,20 @@ rlog_proc (argc, argv, xwhere, mwhere, mfile, shorten, local, mname, msg)
}
/* cd to the starting repository */
- if ( CVS_CHDIR (repository) < 0)
+ if (CVS_CHDIR (repository) < 0)
{
error (0, errno, "cannot chdir to %s", repository);
free (repository);
- return (1);
+ free (where);
+ return 1;
}
- free (repository);
/* End section which is identical to patch_proc. */
which = W_REPOS | W_ATTIC;
}
else
{
+ repository = NULL;
where = NULL;
which = W_LOCAL | W_REPOS | W_ATTIC;
}
@@ -551,15 +560,19 @@ rlog_proc (argc, argv, xwhere, mwhere, mfile, shorten, local, mname, msg)
err = start_recursion (log_fileproc, (FILESDONEPROC) NULL, log_dirproc,
(DIRLEAVEPROC) NULL, (void *) &log_data,
argc - 1, argv + 1, local, which, 0, CVS_LOCK_READ,
- where, 1);
+ where, 1, repository);
+
+ if (!(which & W_LOCAL)) free (repository);
+ if (where) free (where);
+
return err;
}
+
/*
* Parse a revision list specification.
*/
-
static struct option_revlist *
log_parse_revlist (argstring)
const char *argstring;
@@ -783,6 +796,8 @@ printlock_proc (lock, foo)
return 0;
}
+
+
/*
* Do an rlog on a file
*/
@@ -796,7 +811,7 @@ log_fileproc (callerdat, finfo)
int selrev = -1;
RCSNode *rcsfile;
char buf[50];
- struct revlist *revlist;
+ struct revlist *revlist = NULL;
struct log_data_and_rcs log_data_and_rcs;
if ((rcsfile = finfo->rcs) == NULL)
@@ -805,22 +820,21 @@ log_fileproc (callerdat, finfo)
p = findnode (finfo->entries, finfo->file);
if (p != NULL)
{
- Entnode *e;
-
- e = (Entnode *) p->data;
+ Entnode *e = p->data;
+
if (e->version[0] == '0' && e->version[1] == '\0')
{
if (!really_quiet)
error (0, 0, "%s has been added, but not committed",
finfo->file);
- return(0);
+ return 0;
}
}
if (!really_quiet)
error (0, 0, "nothing known about %s", finfo->file);
- return (1);
+ return 1;
}
if (log_data->sup_header || !log_data->nameonly)
@@ -833,7 +847,8 @@ log_fileproc (callerdat, finfo)
revisions. */
revlist = log_expand_revlist (rcsfile, log_data->revlist,
log_data->default_branch);
- if (log_data->sup_header || (!log_data->header && !log_data->long_header))
+ if (log_data->sup_header
+ || (!log_data->header && !log_data->long_header))
{
log_data_and_rcs.log_data = log_data;
log_data_and_rcs.revlist = revlist;
@@ -846,11 +861,15 @@ log_fileproc (callerdat, finfo)
start date for each specific revision. */
if (log_data->singledatelist != NULL)
walklist (rcsfile->versions, log_fix_singledate,
- (void *) &log_data_and_rcs);
+ (void *)&log_data_and_rcs);
selrev = walklist (rcsfile->versions, log_count_print,
- (void *) &log_data_and_rcs);
- if (log_data->sup_header && selrev == 0) return 0;
+ (void *)&log_data_and_rcs);
+ if (log_data->sup_header && selrev == 0)
+ {
+ log_free_revlist (revlist);
+ return 0;
+ }
}
}
@@ -859,6 +878,7 @@ log_fileproc (callerdat, finfo)
{
cvs_output (rcsfile->path, 0);
cvs_output ("\n", 1);
+ log_free_revlist (revlist);
return 0;
}
@@ -915,7 +935,7 @@ log_fileproc (callerdat, finfo)
cvs_output ("\n\t", 2);
cp2 = cp;
- while (! isspace ((unsigned char) *cp2) && *cp2 != '\0')
+ while (!isspace ((unsigned char) *cp2) && *cp2 != '\0')
++cp2;
cvs_output (cp, cp2 - cp);
cp = cp2;
@@ -924,7 +944,7 @@ log_fileproc (callerdat, finfo)
}
}
- if (! log_data->notags)
+ if (!log_data->notags)
{
List *syms;
@@ -952,14 +972,14 @@ log_fileproc (callerdat, finfo)
cvs_output ("\n", 1);
- if (! log_data->header || log_data->long_header)
+ if (!log_data->header || log_data->long_header)
{
cvs_output ("description:\n", 0);
if (rcsfile->desc != NULL)
cvs_output (rcsfile->desc, 0);
}
- if (! log_data->header && ! log_data->long_header && rcsfile->head != NULL)
+ if (!log_data->header && ! log_data->long_header && rcsfile->head != NULL)
{
p = findnode (rcsfile->versions, rcsfile->head);
if (p == NULL)
@@ -967,9 +987,8 @@ log_fileproc (callerdat, finfo)
finfo->fullname);
while (p != NULL)
{
- RCSVers *vers;
+ RCSVers *vers = p->data;
- vers = (RCSVers *) p->data;
log_version (log_data, revlist, rcsfile, vers, 1);
if (vers->next == NULL)
p = NULL;
@@ -1009,6 +1028,8 @@ log_fileproc (callerdat, finfo)
return 0;
}
+
+
/*
* Fix up a revision list in order to compare it against versions.
* Expand any symbolic revisions.
@@ -1109,26 +1130,21 @@ log_expand_revlist (rcs, revlist, default_branch)
does. This code is a bit cryptic for my tastes, but
keeping the same implementation as rlog ensures a
certain degree of compatibility. */
- if (r->first == NULL)
+ if (r->first == NULL && nr->last != NULL)
{
- if (nr->last == NULL)
- nr->fields = 0;
+ nr->fields = numdots (nr->last) + 1;
+ if (nr->fields < 2)
+ nr->first = xstrdup (".0");
else
{
- nr->fields = numdots (nr->last) + 1;
- if (nr->fields < 2)
- nr->first = xstrdup (".0");
- else
- {
- char *cp;
+ char *cp;
- nr->first = xstrdup (nr->last);
- cp = strrchr (nr->first, '.');
- strcpy (cp + 1, "0");
- }
+ nr->first = xstrdup (nr->last);
+ cp = strrchr (nr->first, '.');
+ strcpy (cp + 1, "0");
}
}
- else if (r->last == NULL)
+ else if (r->last == NULL && nr->first != NULL)
{
nr->fields = numdots (nr->first) + 1;
nr->last = xstrdup (nr->first);
@@ -1377,6 +1393,8 @@ log_version_requested (log_data, revlist, rcs, vnode)
return 1;
}
+
+
/*
* Output a single symbol. This is called via walklist.
*/
@@ -1393,6 +1411,8 @@ log_symbol (p, closure)
return 0;
}
+
+
/*
* Count the number of entries on a list. This is called via walklist.
*/
@@ -1405,6 +1425,8 @@ log_count (p, closure)
return 1;
}
+
+
/*
* Sort out a single date specification by narrowing down the date
* until we find the specific selected revision.
@@ -1424,7 +1446,7 @@ log_fix_singledate (p, closure)
if (pv == NULL)
error (1, 0, "missing version `%s' in RCS file `%s'",
p->key, data->rcs->path);
- vnode = (RCSVers *) pv->data;
+ vnode = pv->data;
/* We are only interested if this revision passes any other tests.
Temporarily clear log_data->singledatelist to avoid confusing
@@ -1464,6 +1486,8 @@ log_fix_singledate (p, closure)
return 0;
}
+
+
/*
* Count the number of revisions we are going to print.
*/
@@ -1480,7 +1504,7 @@ log_count_print (p, closure)
error (1, 0, "missing version `%s' in RCS file `%s'",
p->key, data->rcs->path);
if (log_version_requested (data->log_data, data->revlist, data->rcs,
- (RCSVers *) pv->data))
+ pv->data))
return 1;
else
return 0;
@@ -1504,7 +1528,7 @@ log_tree (log_data, revlist, rcs, ver)
if (p == NULL)
error (1, 0, "missing version `%s' in RCS file `%s'",
ver, rcs->path);
- vnode = (RCSVers *) p->data;
+ vnode = p->data;
if (vnode->next != NULL)
log_tree (log_data, revlist, rcs, vnode->next);
if (vnode->branches != NULL)
@@ -1540,7 +1564,7 @@ log_abranch (log_data, revlist, rcs, ver)
if (p == NULL)
error (1, 0, "missing version `%s' in RCS file `%s'",
ver, rcs->path);
- vnode = (RCSVers *) p->data;
+ vnode = p->data;
if (vnode->next != NULL)
log_abranch (log_data, revlist, rcs, vnode->next);
log_version (log_data, revlist, rcs, vnode, 0);
@@ -1611,7 +1635,7 @@ log_version (log_data, revlist, rcs, ver, trunk)
if (nextp == NULL)
error (1, 0, "missing version `%s' in `%s'", ver->next,
rcs->path);
- nextver = (RCSVers *) nextp->data;
+ nextver = nextp->data;
pdel = findnode (nextver->other, ";add");
padd = findnode (nextver->other, ";delete");
}
@@ -1640,14 +1664,14 @@ log_version (log_data, revlist, rcs, ver, trunk)
would be the p == NULL case would mean an RCS file which was
missing the "log" keyword (which is illegal according to
rcsfile.5). */
- if (p == NULL || p->data == NULL || p->data[0] == '\0')
+ if (p == NULL || p->data == NULL || *(char *)p->data == '\0')
cvs_output ("*** empty log message ***\n", 0);
else
{
/* FIXME: Technically, the log message could contain a null
byte. */
cvs_output (p->data, 0);
- if (p->data[strlen (p->data) - 1] != '\n')
+ if (((char *)p->data)[strlen (p->data) - 1] != '\n')
cvs_output ("\n", 1);
}
}
@@ -1685,9 +1709,9 @@ log_branch (p, closure)
static Dtype
log_dirproc (callerdat, dir, repository, update_dir, entries)
void *callerdat;
- char *dir;
- char *repository;
- char *update_dir;
+ const char *dir;
+ const char *repository;
+ const char *update_dir;
List *entries;
{
if (!isdir (dir))
OpenPOWER on IntegriCloud