public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] towctrans_l: Always return a value from helper functions
Date: Tue, 13 Mar 2018 21:09:00 -0000	[thread overview]
Message-ID: <20180313210943.100170.qmail@sourceware.org> (raw)

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


                 reply	other threads:[~2018-03-13 21:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180313210943.100170.qmail@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).