=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/rcs/rcsutil.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- src/usr.bin/rcs/rcsutil.c 2006/04/21 17:17:29 1.1 +++ src/usr.bin/rcs/rcsutil.c 2006/04/24 04:51:57 1.2 @@ -1,4 +1,4 @@ -/* $OpenBSD: rcsutil.c,v 1.1 2006/04/21 17:17:29 xsa Exp $ */ +/* $OpenBSD: rcsutil.c,v 1.2 2006/04/24 04:51:57 ray Exp $ */ /* * Copyright (c) 2005, 2006 Joris Vink * Copyright (c) 2006 Xavier Santolaria @@ -442,4 +442,36 @@ xfree(rnum.rn_id); return (nrev); +} + +/* + * 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. + */ +void +rcs_set_description(RCSFILE *file, const char *in) +{ + BUF *bp; + char *content; + const char *prompt = + "enter description, terminated with single '.' or end of file:\n" + "NOTE: This is NOT the log message!\n"; + + /* Description is in file . */ + if (in != NULL && *in != '-') { + bp = cvs_buf_load(in, BUF_AUTOEXT); + cvs_buf_putc(bp, '\0'); + content = cvs_buf_release(bp); + /* Description is in . */ + } else if (in != NULL) + /* Skip leading `-'. */ + content = xstrdup(in + 1); + /* Get description from stdin. */ + else + content = rcs_prompt(prompt); + + rcs_desc_set(file, content); + xfree(content); }