towctrans_l: Always return a value from helper functions
touupper and toulower didn't return a value in all cases. Worse, this only broke Cygwin when building without optimization for debug purposes. Why GCC neglects to notice this is a mystery. While at it, fix formatting. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
5b97e36239
commit
e186dc8661
|
@ -20,7 +20,7 @@ caseconv_table [] = {
|
||||||
|
|
||||||
/* auxiliary function for binary search in interval properties table */
|
/* auxiliary function for binary search in interval properties table */
|
||||||
static const struct caseconv_entry *
|
static const struct caseconv_entry *
|
||||||
bisearch(wint_t ucs, const struct caseconv_entry *table, int max)
|
bisearch (wint_t ucs, const struct caseconv_entry *table, int max)
|
||||||
{
|
{
|
||||||
int min = 0;
|
int min = 0;
|
||||||
int mid;
|
int mid;
|
||||||
|
@ -46,17 +46,32 @@ toulower (wint_t c)
|
||||||
const struct caseconv_entry * cce =
|
const struct caseconv_entry * cce =
|
||||||
bisearch(c, caseconv_table,
|
bisearch(c, caseconv_table,
|
||||||
sizeof(caseconv_table) / sizeof(*caseconv_table) - 1);
|
sizeof(caseconv_table) / sizeof(*caseconv_table) - 1);
|
||||||
|
|
||||||
if (cce)
|
if (cce)
|
||||||
switch (cce->mode) {
|
switch (cce->mode)
|
||||||
case TOLO: return c + cce->delta;
|
{
|
||||||
case TOBOTH: return c + 1;
|
case TOLO:
|
||||||
case TO1: switch (cce->delta) {
|
return c + cce->delta;
|
||||||
case EVENCAP: if (!(c & 1)) return c + 1; break;
|
case TOBOTH:
|
||||||
case ODDCAP: if (c & 1) return c + 1; break;
|
return c + 1;
|
||||||
|
case TO1:
|
||||||
|
switch (cce->delta)
|
||||||
|
{
|
||||||
|
case EVENCAP:
|
||||||
|
if (!(c & 1))
|
||||||
|
return c + 1;
|
||||||
|
break;
|
||||||
|
case ODDCAP:
|
||||||
|
if (c & 1)
|
||||||
|
return c + 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
return c;
|
||||||
else
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static wint_t
|
static wint_t
|
||||||
|
@ -65,17 +80,32 @@ touupper (wint_t c)
|
||||||
const struct caseconv_entry * cce =
|
const struct caseconv_entry * cce =
|
||||||
bisearch(c, caseconv_table,
|
bisearch(c, caseconv_table,
|
||||||
sizeof(caseconv_table) / sizeof(*caseconv_table) - 1);
|
sizeof(caseconv_table) / sizeof(*caseconv_table) - 1);
|
||||||
|
|
||||||
if (cce)
|
if (cce)
|
||||||
switch (cce->mode) {
|
switch (cce->mode)
|
||||||
case TOUP: return c + cce->delta;
|
{
|
||||||
case TOBOTH: return c - 1;
|
case TOUP:
|
||||||
case TO1: switch (cce->delta) {
|
return c + cce->delta;
|
||||||
case EVENCAP: if (c & 1) return c - 1; break;
|
case TOBOTH:
|
||||||
case ODDCAP: if (!(c & 1)) return c - 1; break;
|
return c - 1;
|
||||||
|
case TO1:
|
||||||
|
switch (cce->delta)
|
||||||
|
{
|
||||||
|
case EVENCAP:
|
||||||
|
if (c & 1)
|
||||||
|
return c - 1;
|
||||||
|
break;
|
||||||
|
case ODDCAP:
|
||||||
|
if (!(c & 1))
|
||||||
|
return c - 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
return c;
|
||||||
else
|
|
||||||
return c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wint_t
|
wint_t
|
||||||
|
|
Loading…
Reference in New Issue