rcskeys.c revision 9
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 $ 349Sjkh * Revision 5.2 1991/08/19 03:13:55 eggert 359Sjkh * Say `T const' instead of `const T'; it's less confusing for pointer types. 369Sjkh * (This change was made in other source files too.) 379Sjkh * 389Sjkh * Revision 5.1 1991/04/21 11:58:25 eggert 399Sjkh * Don't put , just before } in initializer. 409Sjkh * 419Sjkh * Revision 5.0 1990/08/22 08:12:54 eggert 429Sjkh * Add -k. Ansify and Posixate. 439Sjkh * 449Sjkh * Revision 4.3 89/05/01 15:13:02 narten 459Sjkh * changed copyright header to reflect current distribution rules 469Sjkh * 479Sjkh * Revision 4.2 87/10/18 10:36:33 narten 489Sjkh * Updating version numbers. Changes relative to 1.1 actuallyt 499Sjkh * relative to 4.1 509Sjkh * 519Sjkh * Revision 1.2 87/09/24 14:00:10 narten 529Sjkh * Sources now pass through lint (if you ignore printf/sprintf/fprintf 539Sjkh * warnings) 549Sjkh * 559Sjkh * Revision 4.1 83/05/04 10:06:53 wft 569Sjkh * Initial revision. 579Sjkh * 589Sjkh */ 599Sjkh 609Sjkh 619Sjkh#include "rcsbase.h" 629Sjkh 639SjkhlibId(keysId, "$Id: rcskeys.c,v 5.2 1991/08/19 03:13:55 eggert Exp $") 649Sjkh 659Sjkh 669Sjkhchar const *const Keyword[] = { 679Sjkh /* This must be in the same order as rcsbase.h's enum markers type. */ 689Sjkh nil, 699Sjkh AUTHOR, DATE, HEADER, IDH, 709Sjkh LOCKER, LOG, RCSFILE, REVISION, SOURCE, STATE 719Sjkh}; 729Sjkh 739Sjkh 749Sjkh 759Sjkh enum markers 769Sjkhtrymatch(string) 779Sjkh char const *string; 789Sjkh/* function: Checks whether string starts with a keyword followed 799Sjkh * by a KDELIM or a VDELIM. 809Sjkh * If successful, returns the appropriate marker, otherwise Nomatch. 819Sjkh */ 829Sjkh{ 839Sjkh register int j; 849Sjkh register char const *p, *s; 859Sjkh for (j = sizeof(Keyword)/sizeof(*Keyword); (--j); ) { 869Sjkh /* try next keyword */ 879Sjkh p = Keyword[j]; 889Sjkh s = string; 899Sjkh while (*p++ == *s++) { 909Sjkh if (!*p) 919Sjkh switch (*s) { 929Sjkh case KDELIM: 939Sjkh case VDELIM: 949Sjkh return (enum markers)j; 959Sjkh default: 969Sjkh return Nomatch; 979Sjkh } 989Sjkh } 999Sjkh } 1009Sjkh return(Nomatch); 1019Sjkh} 1029Sjkh 103