Re: RFC: null-terminated separators for rlog
Jonathan Noack <[email protected]>
| Newsgroups | gmane.comp.gnu.rcs |
|---|---|
| Message-ID | <[email protected]> |
On 04/21/06 02:27, Paul Eggert wrote: > Jonathan Noack <[email protected]> writes: >> It is highly improbable this sequence would randomly appear in a >> commit log. > > You might be surprised how many people feed the output of "rlog" into > "ci". So the probability is not as low as you might think. They would have to explicitly specify the proposed option when they shouldn't for this to happen, but the point is taken: the probability, however small, still exists. *grumble* Fine, make me do it the right way... ;) > Anyway, I'd rather not have a solution that merely lowers the > probability of an error. If we're going to make a change, we should > fix the problem in general, by coming up with a general quoting > scheme. One possibility would be a byte count in front of the string; > another would be a way to escape characters. The attached patch implements a "log byte count" option ('-c'). What do you think? Sample output below. By the way, thank you for your patience in dragging me out of Perl-hack-land! -Jonathan $ rlog -c -r1.342.2.13 /home/ncvs/src/UPDATING,v ... ---------------------------- revision 1.342.2.13 date: 2004/10/10 16:16:31; author: mtm; state: Exp; lines: +14 -5 branches: 1.342.2.13.2; log byte count: 534; RCS file: /home/ncvs/src/UPDATING,v ---------------------------- revision 1.372 date: 2004/10/07 14:51:23; author: mtm; state: Exp; lines: +0 -0 Make a note in UPDATING about the recent change regarding the FreeBSD keyword. ============================================================================= o Add additional information on how to cope with this change. o Fix the date for the previous libthr change to correctly reflect the date it was MFCed on. Approved by: re/assumed because of approval for the actual src change ---------------------------- ============================================================================= _______________________________________________ help-rcs mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-rcs
rlog-bytecount.diff
(text/x-patch, 1.1 KB)
Index: rlog.c
===================================================================
RCS file: /home/ncvs/src/gnu/usr.bin/rcs/rlog/rlog.c,v
retrieving revision 1.13
diff -u -r1.13 rlog.c
--- rlog.c 27 Aug 1999 23:36:59 -0000 1.13
+++ rlog.c 22 Apr 2006 03:46:16 -0000
@@ -209,6 +209,7 @@
static char const *insDelFormat;
static int branchflag; /*set on -b */
+static int bytecountflag;
static int exitstatus;
static int lockflag;
static struct Datepairs *datelist, *duelst;
@@ -325,6 +326,10 @@
vstring = a;
break;
+ case 'c':
+ bytecountflag = true;
+ break;
+
default:
unknown:
error("unknown option: %s%s", *argv, cmdusage);
@@ -580,6 +585,7 @@
struct buf branchnum;
char datebuf[datesize + zonelenmax];
int pre5 = RCSversion < VERSION(5);
+ int addnewline;
if (!node->selector)
return;
@@ -623,8 +629,11 @@
s = emptych;
n = sizeof(emptych)-1;
}
+ addnewline = (s[n-1] != '\n');
+ if (bytecountflag)
+ aprintf(out, "log byte count: %d;\n", n+addnewline);
awrite(s, n, out);
- if (s[n-1] != '\n')
+ if (addnewline)
afputc('\n', out);
}