rcskeys.c revision 1500
19Sjkh/* 29Sjkh * RCS keyword table and match operation 39Sjkh */ 49Sjkh 59Sjkh/* Copyright (C) 1982, 1988, 1989 Walter Tichy 69Sjkh Copyright 1990, 1991 by Paul Eggert 79Sjkh Distributed under license by the Free Software Foundation, Inc. 89Sjkh 99SjkhThis file is part of RCS. 109Sjkh 119SjkhRCS is free software; you can redistribute it and/or modify 129Sjkhit under the terms of the GNU General Public License as published by 139Sjkhthe Free Software Foundation; either version 2, or (at your option) 149Sjkhany later version. 159Sjkh 169SjkhRCS is distributed in the hope that it will be useful, 179Sjkhbut WITHOUT ANY WARRANTY; without even the implied warranty of 189SjkhMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 199SjkhGNU General Public License for more details. 209Sjkh 219SjkhYou should have received a copy of the GNU General Public License 229Sjkhalong with RCS; see the file COPYING. If not, write to 239Sjkhthe Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 249Sjkh 259SjkhReport problems and direct all questions to: 269Sjkh 279Sjkh rcs-bugs@cs.purdue.edu 289Sjkh 299Sjkh*/ 309Sjkh 319Sjkh 329Sjkh 339Sjkh/* $Log: rcskeys.c,v $ 341500Srgrimes * Revision 1.2 1994/05/14 07:00:23 rgrimes 351500Srgrimes * Add new option -K from David Dawes that allows you to turn on and off 361500Srgrimes * specific keyword substitution during a rcs co command. 371500Srgrimes * Add the new keyword FreeBSD that is IDENTICAL in operation to $Id$. 381500Srgrimes * 391494Srgrimes * Revision 1.1.1.1 1993/06/18 04:22:12 jkh 401494Srgrimes * Updated GNU utilities 411494Srgrimes * 429Sjkh * Revision 5.2 1991/08/19 03:13:55 eggert 439Sjkh * Say `T const' instead of `const T'; it's less confusing for pointer types. 449Sjkh * (This change was made in other source files too.) 459Sjkh * 469Sjkh * Revision 5.1 1991/04/21 11:58:25 eggert 479Sjkh * Don't put , just before } in initializer. 489Sjkh * 499Sjkh * Revision 5.0 1990/08/22 08:12:54 eggert 509Sjkh * Add -k. Ansify and Posixate. 519Sjkh * 529Sjkh * Revision 4.3 89/05/01 15:13:02 narten 539Sjkh * changed copyright header to reflect current distribution rules 549Sjkh * 559Sjkh * Revision 4.2 87/10/18 10:36:33 narten 569Sjkh * Updating version numbers. Changes relative to 1.1 actuallyt 579Sjkh * relative to 4.1 589Sjkh * 599Sjkh * Revision 1.2 87/09/24 14:00:10 narten 609Sjkh * Sources now pass through lint (if you ignore printf/sprintf/fprintf 619Sjkh * warnings) 629Sjkh * 639Sjkh * Revision 4.1 83/05/04 10:06:53 wft 649Sjkh * Initial revision. 659Sjkh * 669Sjkh */ 679Sjkh 689Sjkh 699Sjkh#include "rcsbase.h" 709Sjkh 711500SrgrimeslibId(keysId, "$Id: rcskeys.c,v 1.2 1994/05/14 07:00:23 rgrimes Exp $") 729Sjkh 739Sjkh 749Sjkhchar const *const Keyword[] = { 759Sjkh /* This must be in the same order as rcsbase.h's enum markers type. */ 769Sjkh nil, 779Sjkh AUTHOR, DATE, HEADER, IDH, 781500Srgrimes LOCKER, LOG, RCSFILE, REVISION, SOURCE, STATE, 791500Srgrimes FREEBSD 809Sjkh}; 819Sjkh 829Sjkh 831494Srgrimes/* Expand all keywords by default */ 849Sjkh 851494Srgrimesstatic int ExpandKeyword[] = { 861494Srgrimes nil, 871494Srgrimes true, true, true, true, 881500Srgrimes true, true, true, true, true, true, true, 891500Srgrimes false 901494Srgrimes}; 911494Srgrimes 929Sjkh enum markers 939Sjkhtrymatch(string) 949Sjkh char const *string; 959Sjkh/* function: Checks whether string starts with a keyword followed 969Sjkh * by a KDELIM or a VDELIM. 979Sjkh * If successful, returns the appropriate marker, otherwise Nomatch. 989Sjkh */ 999Sjkh{ 1009Sjkh register int j; 1019Sjkh register char const *p, *s; 1029Sjkh for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) { 1031494Srgrimes if (!ExpandKeyword[j]) 1041494Srgrimes continue; 1059Sjkh /* try next keyword */ 1069Sjkh p = Keyword[j]; 1079Sjkh s = string; 1089Sjkh while (*p++ == *s++) { 1099Sjkh if (!*p) 1109Sjkh switch (*s) { 1119Sjkh case KDELIM: 1129Sjkh case VDELIM: 1139Sjkh return (enum markers)j; 1149Sjkh default: 1159Sjkh return Nomatch; 1169Sjkh } 1179Sjkh } 1189Sjkh } 1199Sjkh return(Nomatch); 1209Sjkh} 1219Sjkh 1221494Srgrimes 1231494SrgrimessetIncExc(arg) 1241494Srgrimes char *arg; 1251494Srgrimes/* Sets up the ExpandKeyword table according to command-line flags */ 1261494Srgrimes{ 1271494Srgrimes char *key; 1281494Srgrimes int include = 0, j; 1291494Srgrimes 1301494Srgrimes arg += 2; 1311494Srgrimes switch (*arg++) { 1321494Srgrimes case 'e': 1331494Srgrimes include = false; 1341494Srgrimes break; 1351494Srgrimes case 'i': 1361494Srgrimes include = true; 1371494Srgrimes break; 1381494Srgrimes default: 1391494Srgrimes return(false); 1401494Srgrimes } 1411494Srgrimes if (include) 1421494Srgrimes for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) 1431494Srgrimes ExpandKeyword[j] = false; 1441494Srgrimes key = strtok(arg, ","); 1451494Srgrimes while (key) { 1461494Srgrimes for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) 1471494Srgrimes if (!strcmp(key, Keyword[j])) 1481494Srgrimes ExpandKeyword[j] = include; 1491494Srgrimes key = strtok(NULL, ","); 1501494Srgrimes } 1511494Srgrimes return(true); 1521494Srgrimes} 1531494Srgrimes 154