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

Go to the source code of this file.

Functions

const ScanKeywordScanCKeywordLookup (const char *text)
 

Variables

static const ScanKeyword ScanCKeywords []
 

Function Documentation

const ScanKeyword* ScanCKeywordLookup ( const char *  text)

Definition at line 64 of file c_keywords.c.

References difference(), lengthof, ScanKeyword::name, and NULL.

65 {
66  const ScanKeyword *low = &ScanCKeywords[0];
67  const ScanKeyword *high = &ScanCKeywords[lengthof(ScanCKeywords) - 1];
68 
69  while (low <= high)
70  {
71  const ScanKeyword *middle;
72  int difference;
73 
74  middle = low + (high - low) / 2;
75  difference = strcmp(middle->name, text);
76  if (difference == 0)
77  return middle;
78  else if (difference < 0)
79  low = middle + 1;
80  else
81  high = middle - 1;
82  }
83 
84  return NULL;
85 }
#define lengthof(array)
Definition: c.h:557
static const ScanKeyword ScanCKeywords[]
Definition: c_keywords.c:23
const char * name
Definition: keywords.h:26
Datum difference(PG_FUNCTION_ARGS)
#define NULL
Definition: c.h:226
Definition: c.h:434

Variable Documentation

const ScanKeyword ScanCKeywords[]
static

Definition at line 23 of file c_keywords.c.