diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/tsearch/ts_locale.h | 63 | ||||
-rw-r--r-- | src/include/tsearch/ts_public.h | 4 |
2 files changed, 24 insertions, 43 deletions
diff --git a/src/include/tsearch/ts_locale.h b/src/include/tsearch/ts_locale.h index dcae2af93a4..cea3830a0f1 100644 --- a/src/include/tsearch/ts_locale.h +++ b/src/include/tsearch/ts_locale.h @@ -1,15 +1,14 @@ /*------------------------------------------------------------------------- * * ts_locale.h - * helper utilities for tsearch + * locale compatibility layer for tsearch * * Copyright (c) 1998-2007, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/tsearch/ts_locale.h,v 1.2 2007/08/25 00:03:59 tgl Exp $ + * $PostgreSQL: pgsql/src/include/tsearch/ts_locale.h,v 1.3 2007/11/09 22:37:35 tgl Exp $ * *------------------------------------------------------------------------- */ - #ifndef __TSLOCALE_H__ #define __TSLOCALE_H__ @@ -34,55 +33,37 @@ #define TS_USE_WIDE #endif -#define TOUCHAR(x) (*((unsigned char*)(x))) +#define TOUCHAR(x) (*((const unsigned char *) (x))) #ifdef TS_USE_WIDE -extern size_t char2wchar(wchar_t *to, const char *from, size_t len); - -#ifdef WIN32 - -extern size_t wchar2char(char *to, const wchar_t *from, size_t len); -#else /* WIN32 */ - -/* correct wcstombs */ -#define wchar2char wcstombs +extern size_t wchar2char(char *to, const wchar_t *from, size_t tolen); +extern size_t char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen); -#endif /* WIN32 */ +extern int t_isdigit(const char *ptr); +extern int t_isspace(const char *ptr); +extern int t_isalpha(const char *ptr); +extern int t_isprint(const char *ptr); -#define t_isdigit(x) ( pg_mblen(x)==1 && isdigit( TOUCHAR(x) ) ) -#define t_isspace(x) ( pg_mblen(x)==1 && isspace( TOUCHAR(x) ) ) -extern int _t_isalpha(const char *ptr); +/* The second argument of t_iseq() must be a plain ASCII character */ +#define t_iseq(x,c) (TOUCHAR(x) == (unsigned char) (c)) -#define t_isalpha(x) ( (pg_mblen(x)==1) ? isalpha( TOUCHAR(x) ) : _t_isalpha(x) ) -extern int _t_isprint(const char *ptr); +#define COPYCHAR(d,s) memcpy(d, s, pg_mblen(s)) -#define t_isprint(x) ( (pg_mblen(x)==1) ? isprint( TOUCHAR(x) ) : _t_isprint(x) ) -/* - * t_iseq() should be called only for ASCII symbols - */ -#define t_iseq(x,c) ( (pg_mblen(x)==1) ? ( TOUCHAR(x) == ((unsigned char)(c)) ) : false ) +#else /* not TS_USE_WIDE */ -#define COPYCHAR(d,s) do { \ - int lll = pg_mblen( s ); \ - \ - while( lll-- ) \ - TOUCHAR((d)+lll) = TOUCHAR((s)+lll); \ -} while(0) +#define t_isdigit(x) isdigit(TOUCHAR(x)) +#define t_isspace(x) isspace(TOUCHAR(x)) +#define t_isalpha(x) isalpha(TOUCHAR(x)) +#define t_isprint(x) isprint(TOUCHAR(x)) +#define t_iseq(x,c) (TOUCHAR(x) == (unsigned char) (c)) -#else /* not def TS_USE_WIDE */ +#define COPYCHAR(d,s) (*((unsigned char *) (d)) = TOUCHAR(s)) -#define t_isdigit(x) isdigit( TOUCHAR(x) ) -#define t_isspace(x) isspace( TOUCHAR(x) ) -#define t_isalpha(x) isalpha( TOUCHAR(x) ) -#define t_isprint(x) isprint( TOUCHAR(x) ) -#define t_iseq(x,c) ( TOUCHAR(x) == ((unsigned char)(c)) ) - -#define COPYCHAR(d,s) TOUCHAR(d) = TOUCHAR(s) -#endif +#endif /* TS_USE_WIDE */ -extern char *lowerstr(char *str); -extern char *lowerstr_with_len(char *str, int len); +extern char *lowerstr(const char *str); +extern char *lowerstr_with_len(const char *str, int len); extern char *t_readline(FILE *fp); #endif /* __TSLOCALE_H__ */ diff --git a/src/include/tsearch/ts_public.h b/src/include/tsearch/ts_public.h index ab19de7924f..92736c4e1bc 100644 --- a/src/include/tsearch/ts_public.h +++ b/src/include/tsearch/ts_public.h @@ -6,7 +6,7 @@ * * Copyright (c) 1998-2007, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/tsearch/ts_public.h,v 1.4 2007/09/07 15:09:56 teodor Exp $ + * $PostgreSQL: pgsql/src/include/tsearch/ts_public.h,v 1.5 2007/11/09 22:37:35 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -74,7 +74,7 @@ typedef struct } StopList; extern void readstoplist(const char *fname, StopList *s, - char *(*wordop) (char *)); + char *(*wordop) (const char *)); extern bool searchstoplist(StopList *s, char *key); /* |