1 /*-------------------------------------------------------------------------
4 * locale compatibility layer for tsearch
6 * Copyright (c) 1998-2007, PostgreSQL Global Development Group
8 * $PostgreSQL: pgsql/src/include/tsearch/ts_locale.h,v 1.4 2007/11/15 21:14:45 momjian Exp $
10 *-------------------------------------------------------------------------
12 #ifndef __TSLOCALE_H__
13 #define __TSLOCALE_H__
18 #include "utils/pg_locale.h"
19 #include "mb/pg_wchar.h"
22 * towlower() and friends should be in <wctype.h>, but some pre-C99 systems
23 * declare them in <wchar.h>.
32 #if defined(HAVE_WCSTOMBS) && defined(HAVE_TOWLOWER)
36 #define TOUCHAR(x) (*((const unsigned char *) (x)))
40 extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen);
41 extern size_t char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen);
43 extern int t_isdigit(const char *ptr);
44 extern int t_isspace(const char *ptr);
45 extern int t_isalpha(const char *ptr);
46 extern int t_isprint(const char *ptr);
48 /* The second argument of t_iseq() must be a plain ASCII character */
49 #define t_iseq(x,c) (TOUCHAR(x) == (unsigned char) (c))
51 #define COPYCHAR(d,s) memcpy(d, s, pg_mblen(s))
52 #else /* not TS_USE_WIDE */
54 #define t_isdigit(x) isdigit(TOUCHAR(x))
55 #define t_isspace(x) isspace(TOUCHAR(x))
56 #define t_isalpha(x) isalpha(TOUCHAR(x))
57 #define t_isprint(x) isprint(TOUCHAR(x))
58 #define t_iseq(x,c) (TOUCHAR(x) == (unsigned char) (c))
60 #define COPYCHAR(d,s) (*((unsigned char *) (d)) = TOUCHAR(s))
61 #endif /* TS_USE_WIDE */
63 extern char *lowerstr(const char *str);
64 extern char *lowerstr_with_len(const char *str, int len);
65 extern char *t_readline(FILE *fp);
67 #endif /* __TSLOCALE_H__ */