From 702b1e55f4814ffbe8285ee2336bc3c74c429767 Mon Sep 17 00:00:00 2001 From: Ray Lai Date: Mon, 27 Mar 2006 08:21:02 +0000 Subject: Fix and clean up -t flag: - Add comments. - Support -t-inline-comments-like-man-page-says. - -tfilename still works. - When using -t (read description from stdin) don't end when first character is `.'. Instead, end if whole line consists of one `.'. - Add regression test. I also changed the regression Makefile to have a trailing slash on the final element. As long as we have a blank line it will be fine, plus it will save us some trouble when adding new tests. After adding line breaks, ``rest looks fine.'' xsa@ --- usr.bin/rcs/rcsprog.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'usr.bin/rcs') diff --git a/usr.bin/rcs/rcsprog.c b/usr.bin/rcs/rcsprog.c index 10c5cf11322..60cb97d9f4e 100644 --- a/usr.bin/rcs/rcsprog.c +++ b/usr.bin/rcs/rcsprog.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsprog.c,v 1.87 2006/03/27 07:38:24 ray Exp $ */ +/* $OpenBSD: rcsprog.c,v 1.88 2006/03/27 08:21:01 ray Exp $ */ /* * Copyright (c) 2005 Jean-Francois Brousseau * All rights reserved. @@ -718,6 +718,12 @@ rcs_attach_symbol(RCSFILE *file, const char *symname) } } +/* + * Load description from to . + * If starts with a `-', is taken as the description. + * Otherwise is the name of the file containing the description. + * If is NULL, the description is read from stdin. + */ static void rcs_set_description(RCSFILE *file, const char *in) { @@ -725,15 +731,31 @@ rcs_set_description(RCSFILE *file, const char *in) char *content, buf[128]; content = NULL; - if (in != NULL) { + /* Description is in file . */ + if (in != NULL && *in != '-') bp = cvs_buf_load(in, BUF_AUTOEXT); + /* Description is in . */ + else if (in != NULL) { + size_t len; + const char *desc; + + /* Skip leading `-'. */ + desc = in + 1; + len = strlen(desc); + + bp = cvs_buf_alloc(len + 1, BUF_AUTOEXT); + cvs_buf_append(bp, desc, len); + /* Get description from stdin. */ } else { bp = cvs_buf_alloc(64, BUF_AUTOEXT); printf(DESC_PROMPT); for (;;) { + /* XXX - fgetln() may be more elegant. */ fgets(buf, sizeof(buf), stdin); - if (feof(stdin) || ferror(stdin) || buf[0] == '.') + if (feof(stdin) || ferror(stdin) || + strcmp(buf, ".\n") == 0 || + strcmp(buf, ".") == 0) break; cvs_buf_append(bp, buf, strlen(buf)); printf(">> "); -- cgit v1.2.3