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
@@ -2031,7 +2035,7 @@ pg_strcoll(const char *arg1, const char *arg2, pg_locale_t locale)
2031
2035
#endif
2032
2036
else
2033
2037
/* shouldn't happen */
2034
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2038
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2035
2039
2036
2040
return result ;
2037
2041
}
@@ -2067,7 +2071,7 @@ pg_strncoll(const char *arg1, size_t len1, const char *arg2, size_t len2,
2067
2071
#endif
2068
2072
else
2069
2073
/* shouldn't happen */
2070
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2074
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2071
2075
2072
2076
return result ;
2073
2077
}
@@ -2086,7 +2090,7 @@ pg_strxfrm_libc(char *dest, const char *src, size_t destsize,
2086
2090
return strxfrm (dest , src , destsize );
2087
2091
#else
2088
2092
/* shouldn't happen */
2089
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2093
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2090
2094
return 0 ; /* keep compiler quiet */
2091
2095
#endif
2092
2096
}
@@ -2282,7 +2286,7 @@ pg_strxfrm_enabled(pg_locale_t locale)
2282
2286
return true ;
2283
2287
else
2284
2288
/* shouldn't happen */
2285
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2289
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2286
2290
2287
2291
return false; /* keep compiler quiet */
2288
2292
}
@@ -2314,7 +2318,7 @@ pg_strxfrm(char *dest, const char *src, size_t destsize, pg_locale_t locale)
2314
2318
#endif
2315
2319
else
2316
2320
/* shouldn't happen */
2317
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2321
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2318
2322
2319
2323
return result ;
2320
2324
}
@@ -2351,7 +2355,7 @@ pg_strnxfrm(char *dest, size_t destsize, const char *src, size_t srclen,
2351
2355
#endif
2352
2356
else
2353
2357
/* shouldn't happen */
2354
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2358
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2355
2359
2356
2360
return result ;
2357
2361
}
@@ -2369,7 +2373,7 @@ pg_strxfrm_prefix_enabled(pg_locale_t locale)
2369
2373
return true;
2370
2374
else
2371
2375
/* shouldn't happen */
2372
- elog ( ERROR , "unsupported collprovider: %c" , locale -> provider );
2376
+ PGLOCALE_SUPPORT_ERROR ( locale -> provider );
2373
2377
2374
2378
return false; /* keep compiler quiet */
2375
2379
}
@@ -2393,16 +2397,14 @@ pg_strxfrm_prefix(char *dest, const char *src, size_t destsize,
2393
2397
{
2394
2398
size_t result = 0 ; /* keep compiler quiet */
2395
2399
2396
- if (!locale || locale -> provider == COLLPROVIDER_LIBC )
2397
- elog (ERROR , "collprovider '%c' does not support pg_strxfrm_prefix()" ,
2398
- locale -> provider );
2400
+ if (!locale )
2401
+ PGLOCALE_SUPPORT_ERROR (COLLPROVIDER_LIBC );
2399
2402
#ifdef USE_ICU
2400
2403
else if (locale -> provider == COLLPROVIDER_ICU )
2401
2404
result = pg_strnxfrm_prefix_icu (dest , src , -1 , destsize , locale );
2402
2405
#endif
2403
2406
else
2404
- /* shouldn't happen */
2405
- elog (ERROR , "unsupported collprovider: %c" , locale -> provider );
2407
+ PGLOCALE_SUPPORT_ERROR (locale -> provider );
2406
2408
2407
2409
return result ;
2408
2410
}
@@ -2430,16 +2432,14 @@ pg_strnxfrm_prefix(char *dest, size_t destsize, const char *src,
2430
2432
{
2431
2433
size_t result = 0 ; /* keep compiler quiet */
2432
2434
2433
- if (!locale || locale -> provider == COLLPROVIDER_LIBC )
2434
- elog (ERROR , "collprovider '%c' does not support pg_strnxfrm_prefix()" ,
2435
- locale -> provider );
2435
+ if (!locale )
2436
+ PGLOCALE_SUPPORT_ERROR (COLLPROVIDER_LIBC );
2436
2437
#ifdef USE_ICU
2437
2438
else if (locale -> provider == COLLPROVIDER_ICU )
2438
2439
result = pg_strnxfrm_prefix_icu (dest , src , -1 , destsize , locale );
2439
2440
#endif
2440
2441
else
2441
- /* shouldn't happen */
2442
- elog (ERROR , "unsupported collprovider: %c" , locale -> provider );
2442
+ PGLOCALE_SUPPORT_ERROR (locale -> provider );
2443
2443
2444
2444
return result ;
2445
2445
}
0 commit comments