]> git.saurik.com Git - apple/security.git/blob - SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd2.c
Security-54.1.3.tar.gz
[apple/security.git] / SecuritySNACCRuntime / compiler / back-ends / c-gen / kwd2.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/src/live/Security/SecuritySNACCRuntime/compiler/back-ends/c-gen/kwd2.c,v 1.1.1.1 2001/05/18 23:14:09 mb Exp $
35 * $Log: kwd2.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.1.1 1999/03/16 18:06:43 aram
43 * Originals from SMIME Free Library.
44 *
45 * Revision 1.4 1995/07/25 18:45:38 rj
46 * file name has been shortened for redundant part: c-gen/c-kwd -> c-gen/kwd.
47 *
48 * Revision 1.3 1994/10/08 03:48:06 rj
49 * 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.
50 *
51 * Revision 1.2 1994/09/01 00:20:28 rj
52 * snacc_config.h removed; more portable .h file inclusion.
53 *
54 * Revision 1.1 1994/08/28 09:48:13 rj
55 * first check-in. for a list of changes to the snacc-1.1 distribution please refer to the ChangeLog.
56 *
57 */
58
59 #include "snacc.h"
60
61 #if STDC_HEADERS || HAVE_STRING_H
62 #include <string.h>
63 #else
64 #include <strings.h>
65 #endif
66
67 #include "kwd.h"
68
69 /*
70 * last elmt must be NULL.
71 * key words grabbed from K&R 2nd Ed
72 */
73 static char *cKWdG[] =
74 {
75 "auto", "break", "case", "char", "const", "continue",
76 "default", "do", "double", "else", "enum", "extern",
77 "float", "for", "goto", "if", "int", "long", "register",
78 "return", "short", "signed", "sizeof", "static", "struct",
79 "switch", "typedef", "union", "unsigned", "void", "volatile",
80 "while", NULL
81 };
82
83
84 /*
85 * returns non-zero if the given str is a C key word
86 */
87 int
88 IsCKeyWord PARAMS ((str),
89 char *str)
90 {
91 int i;
92
93 for (i=0; (cKWdG[i] != NULL) && (strcmp (cKWdG[i],str) != 0); i++)
94 ;
95
96 return cKWdG[i] != NULL;
97 }