public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] towctrans_l: Always return a value from helper functions
@ 2018-03-13 21:09 Corinna Vinschen
0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2018-03-13 21:09 UTC (permalink / raw)
To: newlib-cvs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e186dc86615039fe6a2d8db514d792a3375b367d
commit e186dc86615039fe6a2d8db514d792a3375b367d
Author: Corinna Vinschen <corinna@vinschen.de>
Date: Tue Mar 13 22:09:30 2018 +0100
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>
Diff:
---
newlib/libc/ctype/towctrans_l.c | 68 +++++++++++++++++++++++++++++------------
1 file changed, 49 insertions(+), 19 deletions(-)
diff --git a/newlib/libc/ctype/towctrans_l.c b/newlib/libc/ctype/towctrans_l.c
index 8da372f..eaabd8c 100644
--- a/newlib/libc/ctype/towctrans_l.c
+++ b/newlib/libc/ctype/towctrans_l.c
@@ -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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2018-03-13 21:09 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-13 21:09 [newlib-cygwin] towctrans_l: Always return a value from helper functions Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).