Hi tech,
there is a dirty if statement in rlog.c, that checks if there is a valid
locker, state or writer and returns if not.
With help from jca - thanks for that - I removed the dirty if statement and
check for valid data in the sections.
I tested it and it behaves like the previous one with the dirty if - I hope I
didn't missed something.
fritjof
Index: rlog.c
===================================================================
RCS file: /cvs/src/usr.bin/rcs/rlog.c,v
retrieving revision 1.67
diff -u -p -r1.67 rlog.c
--- rlog.c 7 Jan 2014 14:08:16 -0000 1.67
+++ rlog.c 25 May 2014 22:24:39 -0000
@@ -426,20 +426,16 @@ rlog_file(const char *fname, RCSFILE *fi
static void
rlog_rev_print(struct rcs_delta *rdp)
{
- int i, found;
+ int i, found_locker, found_state, found_writer;
struct tm t;
- char *author, numb[RCS_REV_BUFSZ], *fmt, timeb[RCS_TIME_BUFSZ];
+ char numb[RCS_REV_BUFSZ], *fmt, timeb[RCS_TIME_BUFSZ];
struct rcs_argvector *largv, *sargv, *wargv;
struct rcs_branch *rb;
struct rcs_delta *nrdp;
- i = found = 0;
- author = NULL;
-
/* -l[lockers] */
if (lflag == 1) {
- if (rdp->rd_locker != NULL)
- found++;
+ found_locker = 0;
if (llist != NULL) {
/* if locker is empty, no need to go further. */
@@ -449,57 +445,59 @@ rlog_rev_print(struct rcs_delta *rdp)
for (i = 0; largv->argv[i] != NULL; i++) {
if (strcmp(rdp->rd_locker, largv->argv[i])
== 0) {
- found++;
+ found_locker = 1;
break;
}
- found = 0;
}
rcs_argv_destroy(largv);
- }
+ } else if (rdp->rd_locker != NULL)
+ found_locker = 1;
+ if (!found_locker)
+ return;
}
/* -sstates */
if (slist != NULL) {
+ found_state = 0;
+
sargv = rcs_strsplit(slist, ",");
for (i = 0; sargv->argv[i] != NULL; i++) {
if (strcmp(rdp->rd_state, sargv->argv[i]) == 0) {
- found++;
+ found_state = 1;
break;
}
- found = 0;
}
rcs_argv_destroy(sargv);
+
+ if (!found_state)
+ return;
}
/* -w[logins] */
if (wflag == 1) {
+ found_writer = 0;
+
if (wlist != NULL) {
wargv = rcs_strsplit(wlist, ",");
for (i = 0; wargv->argv[i] != NULL; i++) {
- if (strcmp(rdp->rd_author, wargv->argv[i])
- == 0) {
- found++;
+ if (!strcmp(rdp->rd_author, wargv->argv[i])) {
+ found_writer = 1;
break;
}
- found = 0;
}
rcs_argv_destroy(wargv);
} else {
+ char *author;
+
if ((author = getlogin()) == NULL)
err(1, "getlogin");
if (strcmp(rdp->rd_author, author) == 0)
- found++;
+ found_writer = 1;
}
+ if (!found_writer)
+ return;
}
-
- /* XXX dirty... */
- if ((((slist != NULL && wflag == 1) ||
- (slist != NULL && lflag == 1) ||
- (lflag == 1 && wflag == 1)) && found < 2) ||
- (((slist != NULL && lflag == 1 && wflag == 1) ||
- (slist != NULL || lflag == 1 || wflag == 1)) && found == 0))
- return;
printf("%s\n", REVSEP);