/src/postgres/src/include/tsearch/ts_locale.h
Line | Count | Source |
1 | | /*------------------------------------------------------------------------- |
2 | | * |
3 | | * ts_locale.h |
4 | | * locale compatibility layer for tsearch |
5 | | * |
6 | | * Copyright (c) 1998-2026, PostgreSQL Global Development Group |
7 | | * |
8 | | * src/include/tsearch/ts_locale.h |
9 | | * |
10 | | *------------------------------------------------------------------------- |
11 | | */ |
12 | | #ifndef __TSLOCALE_H__ |
13 | | #define __TSLOCALE_H__ |
14 | | |
15 | | #include <ctype.h> |
16 | | #include <limits.h> |
17 | | #include <wctype.h> |
18 | | |
19 | | #include "lib/stringinfo.h" |
20 | | #include "mb/pg_wchar.h" |
21 | | #include "utils/pg_locale.h" |
22 | | |
23 | | /* working state for tsearch_readline (should be a local var in caller) */ |
24 | | typedef struct |
25 | | { |
26 | | FILE *fp; |
27 | | const char *filename; |
28 | | int lineno; |
29 | | StringInfoData buf; /* current input line, in UTF-8 */ |
30 | | char *curline; /* current input line, in DB's encoding */ |
31 | | /* curline may be NULL, or equal to buf.data, or a palloc'd string */ |
32 | | ErrorContextCallback cb; |
33 | | } tsearch_readline_state; |
34 | | |
35 | 0 | #define TOUCHAR(x) (*((const unsigned char *) (x))) |
36 | | |
37 | | /* The second argument of t_iseq() must be a plain ASCII character */ |
38 | 0 | #define t_iseq(x,c) (TOUCHAR(x) == (unsigned char) (c)) |
39 | | |
40 | | /* Copy multibyte character of known byte length, return byte length. */ |
41 | | static inline int |
42 | | ts_copychar_with_len(void *dest, const void *src, int length) |
43 | 0 | { |
44 | 0 | memcpy(dest, src, length); |
45 | 0 | return length; |
46 | 0 | } Unexecuted instantiation: dict_synonym.c:ts_copychar_with_len Unexecuted instantiation: dict_thesaurus.c:ts_copychar_with_len Unexecuted instantiation: regis.c:ts_copychar_with_len Unexecuted instantiation: spell.c:ts_copychar_with_len Unexecuted instantiation: ts_locale.c:ts_copychar_with_len Unexecuted instantiation: ts_utils.c:ts_copychar_with_len Unexecuted instantiation: tsquery.c:ts_copychar_with_len Unexecuted instantiation: tsvector.c:ts_copychar_with_len Unexecuted instantiation: tsvector_parser.c:ts_copychar_with_len |
47 | | |
48 | | /* Copy multibyte character from null-terminated string, return byte length. */ |
49 | | static inline int |
50 | | ts_copychar_cstr(void *dest, const void *src) |
51 | 0 | { |
52 | 0 | return ts_copychar_with_len(dest, src, pg_mblen_cstr((const char *) src)); |
53 | 0 | } Unexecuted instantiation: dict_synonym.c:ts_copychar_cstr Unexecuted instantiation: dict_thesaurus.c:ts_copychar_cstr Unexecuted instantiation: regis.c:ts_copychar_cstr Unexecuted instantiation: spell.c:ts_copychar_cstr Unexecuted instantiation: ts_locale.c:ts_copychar_cstr Unexecuted instantiation: ts_utils.c:ts_copychar_cstr Unexecuted instantiation: tsquery.c:ts_copychar_cstr Unexecuted instantiation: tsvector.c:ts_copychar_cstr Unexecuted instantiation: tsvector_parser.c:ts_copychar_cstr |
54 | | |
55 | | /* Historical macro for the above. */ |
56 | | #define COPYCHAR ts_copychar_cstr |
57 | | |
58 | | #define GENERATE_T_ISCLASS_DECL(character_class) \ |
59 | | extern int t_is##character_class##_with_len(const char *ptr, int mblen); \ |
60 | | extern int t_is##character_class##_cstr(const char *ptr); \ |
61 | | extern int t_is##character_class##_unbounded(const char *ptr); \ |
62 | | \ |
63 | | /* deprecated */ \ |
64 | | extern int t_is##character_class(const char *ptr); |
65 | | |
66 | | GENERATE_T_ISCLASS_DECL(alnum); |
67 | | GENERATE_T_ISCLASS_DECL(alpha); |
68 | | |
69 | | extern bool tsearch_readline_begin(tsearch_readline_state *stp, |
70 | | const char *filename); |
71 | | extern char *tsearch_readline(tsearch_readline_state *stp); |
72 | | extern void tsearch_readline_end(tsearch_readline_state *stp); |
73 | | |
74 | | #endif /* __TSLOCALE_H__ */ |