Header And Logo

PostgreSQL
| The world's most advanced open source database.

ts_locale.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  * ts_locale.h
00004  *      locale compatibility layer for tsearch
00005  *
00006  * Copyright (c) 1998-2013, PostgreSQL Global Development Group
00007  *
00008  * src/include/tsearch/ts_locale.h
00009  *
00010  *-------------------------------------------------------------------------
00011  */
00012 #ifndef __TSLOCALE_H__
00013 #define __TSLOCALE_H__
00014 
00015 #include <ctype.h>
00016 #include <limits.h>
00017 
00018 #include "utils/pg_locale.h"
00019 #include "mb/pg_wchar.h"
00020 
00021 /*
00022  * towlower() and friends should be in <wctype.h>, but some pre-C99 systems
00023  * declare them in <wchar.h>.
00024  */
00025 #ifdef HAVE_WCHAR_H
00026 #include <wchar.h>
00027 #endif
00028 #ifdef HAVE_WCTYPE_H
00029 #include <wctype.h>
00030 #endif
00031 
00032 /* working state for tsearch_readline (should be a local var in caller) */
00033 typedef struct
00034 {
00035     FILE       *fp;
00036     const char *filename;
00037     int         lineno;
00038     char       *curline;
00039     ErrorContextCallback cb;
00040 } tsearch_readline_state;
00041 
00042 #define TOUCHAR(x)  (*((const unsigned char *) (x)))
00043 
00044 #ifdef USE_WIDE_UPPER_LOWER
00045 
00046 extern int  t_isdigit(const char *ptr);
00047 extern int  t_isspace(const char *ptr);
00048 extern int  t_isalpha(const char *ptr);
00049 extern int  t_isprint(const char *ptr);
00050 
00051 /* The second argument of t_iseq() must be a plain ASCII character */
00052 #define t_iseq(x,c)     (TOUCHAR(x) == (unsigned char) (c))
00053 
00054 #define COPYCHAR(d,s)   memcpy(d, s, pg_mblen(s))
00055 #else                           /* not USE_WIDE_UPPER_LOWER */
00056 
00057 #define t_isdigit(x)    isdigit(TOUCHAR(x))
00058 #define t_isspace(x)    isspace(TOUCHAR(x))
00059 #define t_isalpha(x)    isalpha(TOUCHAR(x))
00060 #define t_isprint(x)    isprint(TOUCHAR(x))
00061 #define t_iseq(x,c)     (TOUCHAR(x) == (unsigned char) (c))
00062 
00063 #define COPYCHAR(d,s)   (*((unsigned char *) (d)) = TOUCHAR(s))
00064 #endif   /* USE_WIDE_UPPER_LOWER */
00065 
00066 extern char *lowerstr(const char *str);
00067 extern char *lowerstr_with_len(const char *str, int len);
00068 
00069 extern bool tsearch_readline_begin(tsearch_readline_state *stp,
00070                        const char *filename);
00071 extern char *tsearch_readline(tsearch_readline_state *stp);
00072 extern void tsearch_readline_end(tsearch_readline_state *stp);
00073 
00074 extern char *t_readline(FILE *fp);
00075 
00076 #endif   /* __TSLOCALE_H__ */