PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
c_keywords.c File Reference
#include "postgres_fe.h"
#include "c_kwlist_d.h"
#include "preproc_extern.h"
#include "preproc.h"
#include "c_kwlist.h"
Include dependency graph for c_keywords.c:

Go to the source code of this file.

Macros

#define PG_KEYWORD(kwname, value)   value,
 

Functions

int ScanCKeywordLookup (const char *text)
 

Variables

static const uint16 ScanCKeywordTokens []
 

Macro Definition Documentation

◆ PG_KEYWORD

#define PG_KEYWORD (   kwname,
  value 
)    value,

Definition at line 18 of file c_keywords.c.

Function Documentation

◆ ScanCKeywordLookup()

int ScanCKeywordLookup ( const char *  text)

Definition at line 36 of file c_keywords.c.

37 {
38  size_t len;
39  int h;
40  const char *kw;
41 
42  /*
43  * Reject immediately if too long to be any keyword. This saves useless
44  * hashing work on long strings.
45  */
46  len = strlen(text);
47  if (len > ScanCKeywords.max_kw_len)
48  return -1;
49 
50  /*
51  * Compute the hash function. Since it's a perfect hash, we need only
52  * match to the specific keyword it identifies.
53  */
54  h = ScanCKeywords_hash_func(text, len);
55 
56  /* An out-of-range result implies no match */
57  if (h < 0 || h >= ScanCKeywords.num_keywords)
58  return -1;
59 
60  kw = GetScanKeyword(h, &ScanCKeywords);
61 
62  if (strcmp(kw, text) == 0)
63  return ScanCKeywordTokens[h];
64 
65  return -1;
66 }
static const uint16 ScanCKeywordTokens[]
Definition: c_keywords.c:20
static const char * GetScanKeyword(int n, const ScanKeywordList *keywords)
Definition: kwlookup.h:39
const void size_t len
Definition: c.h:666

References GetScanKeyword(), len, and ScanCKeywordTokens.

Variable Documentation

◆ ScanCKeywordTokens

const uint16 ScanCKeywordTokens[]
static
Initial value:
= {
}

Definition at line 20 of file c_keywords.c.

Referenced by ScanCKeywordLookup().