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:
Corinna Vinschen 2018-03-13 22:09:30 +01:00
parent 5b97e36239
commit e186dc8661
1 changed files with 49 additions and 19 deletions

View File

@ -20,7 +20,7 @@ caseconv_table [] = {
/* auxiliary function for binary search in interval properties table */
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 mid;
@ -46,17 +46,32 @@ toulower (wint_t c)
const struct caseconv_entry * cce =
bisearch(c, caseconv_table,
sizeof(caseconv_table) / sizeof(*caseconv_table) - 1);
if (cce)
switch (cce->mode) {
case TOLO: return c + cce->delta;
case TOBOTH: 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;
switch (cce->mode)
{
case TOLO:
return c + cce->delta;
case TOBOTH:
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;
}
}
else
return c;
return c;
}
static wint_t
@ -65,17 +80,32 @@ touupper (wint_t c)
const struct caseconv_entry * cce =
bisearch(c, caseconv_table,
sizeof(caseconv_table) / sizeof(*caseconv_table) - 1);
if (cce)
switch (cce->mode) {
case TOUP: return c + cce->delta;
case TOBOTH: 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;
switch (cce->mode)
{
case TOUP:
return c + cce->delta;
case TOBOTH:
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;
}
}
else
return c;
return c;
}
wint_t