MCPcopy Index your code
hub / github.com/IBM/Project_CodeNet / is_keyword

Function is_keyword

tools/tokenizer/token_common.c:54–66  ·  view source on GitHub ↗

Generic binary search lookup in some keyword table. `word' to be searched must be NUL-terminated C string. `table' is array of const char * of `size' sorted alphabetically. Returns word found (i.e., pointer value in table) or 0. */

Source from the content-addressed store, hash-verified

52 Returns word found (i.e., pointer value in table) or 0.
53*/
54const char *is_keyword(const char *word,
55 const char *table[], unsigned size)
56{
57 int i = 0, j = size;
58 while (i < j) {
59 int k = (i + j) >> 1 /* / 2 */;
60 int cmp = strcmp(word, table[k]);
61 if (!cmp)
62 return table[k];
63 if (cmp < 0) j = k; else i = k + 1;
64 }
65 return 0;
66}
67
68/* Must be called right after a file is opened as stdin.
69 Will attempt to remove any UTF-8 unicode signature (byte-order mark, BOM)

Callers 3

tokenizeFunction · 0.85
C_tokenize_intFunction · 0.85
tokenizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected