81
81
#include <shlwapi.h>
82
82
#endif
83
83
84
+ /* Error triggered for locale-sensitive subroutines */
85
+ #define PGLOCALE_SUPPORT_ERROR (provider ) \
86
+ elog(ERROR, "unsupported collprovider for %s: %c", __func__, provider)
87
+
84
88
/*
85
89
* This should be large enough that most strings will fit, but small enough
86
90
* that we feel comfortable putting it on the stack
@@ -2016,7 +2020,7 @@ pg_strcoll(const char *arg1, const char *arg2, pg_locale_t locale)
2016
2020
#endif
2017
2021
else
2018
2022
/* shouldn't happen */
2019
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2023
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2020
2024
2021
2025
return result ;
2022
2026
}
@@ -2052,7 +2056,7 @@ pg_strncoll(const char *arg1, size_t len1, const char *arg2, size_t len2,
2052
2056
#endif
2053
2057
else
2054
2058
/* shouldn't happen */
2055
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2059
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2056
2060
2057
2061
return result ;
2058
2062
}
@@ -2073,7 +2077,7 @@ pg_strxfrm_libc(char *dest, const char *src, size_t destsize,
2073
2077
return strxfrm (dest , src , destsize );
2074
2078
#else
2075
2079
/* shouldn't happen */
2076
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2080
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2077
2081
return 0 ; /* keep compiler quiet */
2078
2082
#endif
2079
2083
}
@@ -2269,7 +2273,7 @@ pg_strxfrm_enabled(pg_locale_t locale)
2269
2273
return true ;
2270
2274
else
2271
2275
/* shouldn't happen */
2272
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2276
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2273
2277
2274
2278
return false; /* keep compiler quiet */
2275
2279
}
@@ -2301,7 +2305,7 @@ pg_strxfrm(char *dest, const char *src, size_t destsize, pg_locale_t locale)
2301
2305
#endif
2302
2306
else
2303
2307
/* shouldn't happen */
2304
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2308
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2305
2309
2306
2310
return result ;
2307
2311
}
@@ -2338,7 +2342,7 @@ pg_strnxfrm(char *dest, size_t destsize, const char *src, size_t srclen,
2338
2342
#endif
2339
2343
else
2340
2344
/* shouldn't happen */
2341
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2345
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2342
2346
2343
2347
return result ;
2344
2348
}
@@ -2356,7 +2360,7 @@ pg_strxfrm_prefix_enabled(pg_locale_t locale)
2356
2360
return true;
2357
2361
else
2358
2362
/* shouldn't happen */
2359
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2363
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2360
2364
2361
2365
return false; /* keep compiler quiet */
2362
2366
}
@@ -2380,16 +2384,14 @@ pg_strxfrm_prefix(char *dest, const char *src, size_t destsize,
2380
2384
{
2381
2385
size_t result = 0 ; /* keep compiler quiet */
2382
2386
2383
- if (!locale || locale -> provider == COLLPROVIDER_LIBC )
2384
- elog (ERROR , "collprovider '%c' does not support pg_strxfrm_prefix()" ,
2385
- locale -> provider );
2387
+ if (!locale )
2388
+ PGLOCALE_SUPPORT_ERROR (COLLPROVIDER_LIBC );
2386
2389
#ifdef USE_ICU
2387
2390
else if (locale -> provider == COLLPROVIDER_ICU )
2388
2391
result = pg_strnxfrm_prefix_icu (dest , src , -1 , destsize , locale );
2389
2392
#endif
2390
2393
else
2391
- /* shouldn't happen */
2392
- elog (ERROR , "unsupported collprovider: %c" , locale -> provider );
2394
+ PGLOCALE_SUPPORT_ERROR (locale -> provider );
2393
2395
2394
2396
return result ;
2395
2397
}
@@ -2417,16 +2419,14 @@ pg_strnxfrm_prefix(char *dest, size_t destsize, const char *src,
2417
2419
{
2418
2420
size_t result = 0 ; /* keep compiler quiet */
2419
2421
2420
- if (!locale || locale -> provider == COLLPROVIDER_LIBC )
2421
- elog (ERROR , "collprovider '%c' does not support pg_strnxfrm_prefix()" ,
2422
- locale -> provider );
2422
+ if (!locale )
2423
+ PGLOCALE_SUPPORT_ERROR (COLLPROVIDER_LIBC );
2423
2424
#ifdef USE_ICU
2424
2425
else if (locale -> provider == COLLPROVIDER_ICU )
2425
2426
result = pg_strnxfrm_prefix_icu (dest , src , -1 , destsize , locale );
2426
2427
#endif
2427
2428
else
2428
- /* shouldn't happen */
2429
- elog (ERROR , "unsupported collprovider: %c" , locale -> provider );
2429
+ PGLOCALE_SUPPORT_ERROR (locale -> provider );
2430
2430
2431
2431
return result ;
2432
2432
}
0 commit comments