Remove ICU includes from pg_locale.h, and instead include them in the
few C files that need ICU. Clean up a few other includes in passing.
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/
48911db71d953edec66df0d2ce303563d631fbe0.camel@j-davis.com
*/
#include "postgres.h"
+#ifdef USE_ICU
+#include <unicode/uloc.h>
+#endif
+
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"
#include <math.h>
#include <float.h>
#include <limits.h>
-#include <wctype.h>
-#ifdef USE_ICU
-#include <unicode/ustring.h>
-#endif
-
-#include "catalog/pg_collation.h"
#include "catalog/pg_type.h"
#include "common/int.h"
-#include "common/unicode_case.h"
-#include "common/unicode_category.h"
#include "mb/pg_wchar.h"
#include "nodes/miscnodes.h"
#include "parser/scansup.h"
#include "postgres.h"
#include <time.h>
+#ifdef USE_ICU
+#include <unicode/ucol.h>
+#endif
#include "access/htup_details.h"
#include "catalog/pg_collation.h"
return locale->ctype->wc_tolower(wc, locale);
}
+/* version of Unicode used by ICU */
+const char *
+pg_icu_unicode_version()
+{
+#ifdef USE_ICU
+ return U_UNICODE_VERSION;
+#else
+ return NULL;
+#endif
+}
+
/*
* Return required encoding ID for the given locale, or -1 if any encoding is
* valid for the locale.
#include "postgres.h"
#ifdef USE_ICU
+#include <unicode/ucasemap.h>
#include <unicode/ucnv.h>
+#include <unicode/ucol.h>
#include <unicode/ustring.h>
/*
Datum
icu_unicode_version(PG_FUNCTION_ARGS)
{
-#ifdef USE_ICU
- PG_RETURN_TEXT_P(cstring_to_text(U_UNICODE_VERSION));
-#else
- PG_RETURN_NULL();
-#endif
+ const char *version = pg_icu_unicode_version();
+
+ if (version)
+ PG_RETURN_TEXT_P(cstring_to_text(version));
+ else
+ PG_RETURN_NULL();
}
/*
#include "mb/pg_wchar.h"
-#ifdef USE_ICU
-/* only include the C APIs, to avoid errors in cpluspluscheck */
-#undef U_SHOW_CPLUSPLUS_API
-#define U_SHOW_CPLUSPLUS_API 0
-#undef U_SHOW_CPLUSPLUS_HEADER_API
-#define U_SHOW_CPLUSPLUS_HEADER_API 0
-#include <unicode/ucol.h>
-#include <unicode/ucasemap.h>
-#endif
-
/* use for libc locale names */
#define LOCALE_NAME_BUFLEN 128
struct
{
const char *locale;
- UCollator *ucol;
+ struct UCollator *ucol;
+ struct UCaseMap *ucasemap;
locale_t lt;
- UCaseMap *ucasemap;
} icu;
#endif
};
extern pg_wchar pg_towupper(pg_wchar wc, pg_locale_t locale);
extern pg_wchar pg_towlower(pg_wchar wc, pg_locale_t locale);
+extern const char *pg_icu_unicode_version(void);
+
extern int builtin_locale_encoding(const char *locale);
extern const char *builtin_validate_locale(int encoding, const char *locale);
extern void icu_validate_locale(const char *loc_str);