]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.c
4c6777b2e44d38c84be3060938a6f2cf9408c711
[apple/security.git] / SecuritySNACCRuntime / compiler / back-ends / c-gen / kwd.c
1 /*
2 * Copyright (c) 2000-2001 Apple Computer, Inc. All Rights Reserved.
3 *
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
8 * using this file.
9 *
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
16 */
17
18
19 /*
20 * compiler/back-ends/c-gen/kwd.c - routines for determining whether a given str is a C keyword
21 *
22 * NOTE: this was hacked up really quickly. It uses a slow linear
23 * search. A much better approach is to use a hash tbl.
24 *
25 * MS 92
26 * Copyright (C) 1991, 1992 Michael Sample
27 * and the University of British Columbia
28 *
29 * This program is free software; you can redistribute it and/or modify
30 * it under the terms of the GNU General Public License as published by
31 * the Free Software Foundation; either version 2 of the License, or
32 * (at your option) any later version.
33 *
34 * $Header: /cvs/Darwin/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $
35 * $Log: kwd.c,v $
36 * Revision 1.1.1.1 2001/05/18 23:14:09 mb
37 * Move from private repository to open source repository
38 *
39 * Revision 1.2 2001/05/05 00:59:28 rmurphy
40 * Adding darwin license headers
41 *
42 * Revision 1.1 2000/05/10 21:35:02 rmurphy
43 * Adding back in base code files which had been moved to "2" versions.
44 *
45 * Revision 1.1.1.1 1999/03/16 18:06:43 aram
46 * Originals from SMIME Free Library.
47 *
48 * Revision 1.4 1995/07/25 18:45:38 rj
49 * file name has been shortened for redundant part: c-gen/c-kwd -> c-gen/kwd.
50 *
51 * Revision 1.3 1994/10/08 03:48:06 rj
52 * since i was still irritated by cpp standing for c++ and not the C preprocessor, i renamed them to cxx (which is one known suffix for C++ source files). since the standard #define is __cplusplus, cplusplus would have been the more obvious choice, but it is a little too long.
53 *
54 * Revision 1.2 1994/09/01 00:20:28 rj
55 * snacc_config.h removed; more portable .h file inclusion.
56 *
57 * Revision 1.1 1994/08/28 09:48:13 rj
58 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
59 *
60 */
61
62 #include "snacc.h"
63
64 #if STDC_HEADERS || HAVE_STRING_H
65 #include <string.h>
66 #else
67 #include <strings.h>
68 #endif
69
70 #include "kwd.h"
71
72 /*
73 * last elmt must be NULL.
74 * key words grabbed from K&R 2nd Ed
75 */
76 static char *cKWdG[] =
77 {
78 "auto", "break", "case", "char", "const", "continue",
79 "default", "do", "double", "else", "enum", "extern",
80 "float", "for", "goto", "if", "int", "long", "register",
81 "return", "short", "signed", "sizeof", "static", "struct",
82 "switch", "typedef", "union", "unsigned", "void", "volatile",
83 "while", NULL
84 };
85
86
87 /*
88 * returns non-zero if the given str is a C key word
89 */
90 int
91 IsCKeyWord PARAMS ((str),
92 char *str)
93 {
94 int i;
95
96 for (i=0; (cKWdG[i] != NULL) && (strcmp (cKWdG[i],str) != 0); i++)
97 ;
98
99 return cKWdG[i] != NULL;
100 }