]> granicus.if.org Git - postgresql/blob - src/include/tsearch/ts_locale.h
pgindent run for 8.3.
[postgresql] / src / include / tsearch / ts_locale.h
1 /*-------------------------------------------------------------------------
2  *
3  * ts_locale.h
4  *              locale compatibility layer for tsearch
5  *
6  * Copyright (c) 1998-2007, PostgreSQL Global Development Group
7  *
8  * $PostgreSQL: pgsql/src/include/tsearch/ts_locale.h,v 1.4 2007/11/15 21:14:45 momjian Exp $
9  *
10  *-------------------------------------------------------------------------
11  */
12 #ifndef __TSLOCALE_H__
13 #define __TSLOCALE_H__
14
15 #include <ctype.h>
16 #include <limits.h>
17
18 #include "utils/pg_locale.h"
19 #include "mb/pg_wchar.h"
20
21 /*
22  * towlower() and friends should be in <wctype.h>, but some pre-C99 systems
23  * declare them in <wchar.h>.
24  */
25 #ifdef HAVE_WCHAR_H
26 #include <wchar.h>
27 #endif
28 #ifdef HAVE_WCTYPE_H
29 #include <wctype.h>
30 #endif
31
32 #if defined(HAVE_WCSTOMBS) && defined(HAVE_TOWLOWER)
33 #define TS_USE_WIDE
34 #endif
35
36 #define TOUCHAR(x)      (*((const unsigned char *) (x)))
37
38 #ifdef TS_USE_WIDE
39
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);
42
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);
47
48 /* The second argument of t_iseq() must be a plain ASCII character */
49 #define t_iseq(x,c)             (TOUCHAR(x) == (unsigned char) (c))
50
51 #define COPYCHAR(d,s)   memcpy(d, s, pg_mblen(s))
52 #else                                                   /* not TS_USE_WIDE */
53
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))
59
60 #define COPYCHAR(d,s)   (*((unsigned char *) (d)) = TOUCHAR(s))
61 #endif   /* TS_USE_WIDE */
62
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);
66
67 #endif   /* __TSLOCALE_H__ */