bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Keyword to stop keyword expansion?


From: Bob Bradley
Subject: Keyword to stop keyword expansion?
Date: Fri, 24 Jan 2003 06:21:53 -0800
User-agent: Microsoft-Entourage/10.1.0.2006

I often have the need to stop the expansion of CVS keywords after the
initial file header (which might use $Id$ or $Log$) is processed. For
example, scripts to process CVS log entries, which result in CVS keywords
appearing in the source code where expansion would cause problems, but I'd
still like keywords in the file header to be expanded for things like $Log$
(which would preclude using -ko).

It seems as though an $EndKeywords$ CVS keyword, which stopped keyword
expansion after it, might be a useful addition. It could be used as follows
in a file header for a script:

# $Id$
#
# My File Description
#
# $Log$
#
# $EndKeywords$
#
# $Log$ -- TEST - NOT EXPANDED

Does this seem like a reasonable addition? I checked out the CVS sources a
few minutes ago to experiment and it appeared relatively straightforward to
add support for this new keyword. The following patch is a quick hack for
it. It seemed to work in a few simple tests I did, but I am a total newbie
to the CVS sources so it likely overlooks something. Would it be possible
for something like this to be integrated into the CVS sources?

Index: rcs.c
===================================================================
RCS file: /cvs/ccvs/src/rcs.c,v
retrieving revision 1.262
diff -u -r1.262 rcs.c
--- rcs.c    3 Jan 2003 04:24:10 -0000    1.262
+++ rcs.c    24 Jan 2003 13:38:16 -0000
@@ -3470,6 +3470,7 @@
 {
     { KEYWORD_INIT ("Author") },
     { KEYWORD_INIT ("Date") },
+    { KEYWORD_INIT ("EndKeywords") },
     { KEYWORD_INIT ("Header") },
     { KEYWORD_INIT ("Id") },
     { KEYWORD_INIT ("Locker") },
@@ -3485,6 +3486,7 @@
 {
     KEYWORD_AUTHOR = 0,
     KEYWORD_DATE,
+    KEYWORD_END_KEYWORDS,
     KEYWORD_HEADER,
     KEYWORD_ID,
     KEYWORD_LOCKER,
@@ -3719,6 +3721,10 @@
         free_value = 1;
         break;
 
+        case KEYWORD_END_KEYWORDS:
+        expand = KFLAG_O;
+        break;
+
         case KEYWORD_HEADER:
         case KEYWORD_ID:
         {
@@ -3781,6 +3787,9 @@
         value = ver->state;
         break;
         }
+        
+        if (expand == KFLAG_O)
+            break;
     }
 
     sub = xmalloc (keyword->len





reply via email to

[Prev in Thread] Current Thread [Next in Thread]