Commit 2771fcee authored by Michael Paquier's avatar Michael Paquier

Fix issue with --enable-coverage and the new unicode {de,re}composition code

genhtml has been generating the following warning with this new code:
WARNING: function data mismatch at /path/src/common/unicode_norm.c:102

HTML coverage reports care about the uniqueness of functions defined in
source files, ignoring any assumptions around CFLAGS.  783f0cc6
introduced a duplicated definition of get_code_entry(), leading to a
warning and potentially some incorrect data generated in the reports.
This refactors the code so as the code has only one function
declaration, fixing the warning.

Oversight in 783f0cc6.

Reported-by: Tom Lane
Author: Michael Paquier
Reviewed-by: Tom Lane
Discussion: https://postgr.es/m/207789.1603469272@sss.pgh.pa.us
parent 0b46e82c
...@@ -46,6 +46,21 @@ ...@@ -46,6 +46,21 @@
#define NCOUNT VCOUNT * TCOUNT #define NCOUNT VCOUNT * TCOUNT
#define SCOUNT LCOUNT * NCOUNT #define SCOUNT LCOUNT * NCOUNT
#ifdef FRONTEND
/* comparison routine for bsearch() of decomposition lookup table. */
static int
conv_compare(const void *p1, const void *p2)
{
uint32 v1,
v2;
v1 = *(const uint32 *) p1;
v2 = ((const pg_unicode_decomposition *) p2)->codepoint;
return (v1 > v2) ? 1 : ((v1 == v2) ? 0 : -1);
}
#endif
/* /*
* get_code_entry * get_code_entry
* *
...@@ -53,11 +68,10 @@ ...@@ -53,11 +68,10 @@
* The backend version of this code uses a perfect hash function for the * The backend version of this code uses a perfect hash function for the
* lookup, while the frontend version uses a binary search. * lookup, while the frontend version uses a binary search.
*/ */
#ifndef FRONTEND
static const pg_unicode_decomposition * static const pg_unicode_decomposition *
get_code_entry(pg_wchar code) get_code_entry(pg_wchar code)
{ {
#ifndef FRONTEND
int h; int h;
uint32 hashkey; uint32 hashkey;
pg_unicode_decompinfo decompinfo = UnicodeDecompInfo; pg_unicode_decompinfo decompinfo = UnicodeDecompInfo;
...@@ -82,33 +96,15 @@ get_code_entry(pg_wchar code) ...@@ -82,33 +96,15 @@ get_code_entry(pg_wchar code)
/* Success! */ /* Success! */
return &decompinfo.decomps[h]; return &decompinfo.decomps[h];
}
#else #else
/* comparison routine for bsearch() of decomposition lookup table. */
static int
conv_compare(const void *p1, const void *p2)
{
uint32 v1,
v2;
v1 = *(const uint32 *) p1;
v2 = ((const pg_unicode_decomposition *) p2)->codepoint;
return (v1 > v2) ? 1 : ((v1 == v2) ? 0 : -1);
}
static const pg_unicode_decomposition *
get_code_entry(pg_wchar code)
{
return bsearch(&(code), return bsearch(&(code),
UnicodeDecompMain, UnicodeDecompMain,
lengthof(UnicodeDecompMain), lengthof(UnicodeDecompMain),
sizeof(pg_unicode_decomposition), sizeof(pg_unicode_decomposition),
conv_compare); conv_compare);
#endif
} }
#endif /* !FRONTEND */
/* /*
* Given a decomposition entry looked up earlier, get the decomposed * Given a decomposition entry looked up earlier, get the decomposed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment