]> Savannah Git Hosting - gnulib.git/commitdiff
unistr/u8-uctomb: Fix warning.
authorBruno Haible <bruno@clisp.org>
Mon, 20 Jan 2020 17:40:59 +0000 (18:40 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 20 Jan 2020 17:40:59 +0000 (18:40 +0100)
Reported by Andreas Schwab <schwab@suse.de> in
<https://lists.gnu.org/archive/html/bug-gnulib/2020-01/msg00127.html>.

* lib/unistr/u8-uctomb.c (FALLTHROUGH): New macro.
(u8_uctomb): Add FALLTHROUGH markers.

ChangeLog
lib/unistr/u8-uctomb.c

index 8b6168164ab05c8d2dc41ec854a5a8bd0aafee16..29ee66869a32bc534b0b519269320382df428ebc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-01-20  Bruno Haible  <bruno@clisp.org>
+
+       unistr/u8-uctomb: Fix warning.
+       Reported by Andreas Schwab <schwab@suse.de> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2020-01/msg00127.html>.
+       * lib/unistr/u8-uctomb.c (FALLTHROUGH): New macro.
+       (u8_uctomb): Add FALLTHROUGH markers.
+
 2020-01-20  Bruno Haible  <bruno@clisp.org>
 
        lock: Fix test-once1 failure on FreeBSD 11 (regression from 2020-01-19).
index f093822134c7a07204efa697a5a3e4ca394b3f3f..d9980022c2bbbbd14f4ad5315d62cac1bfaeb500 100644 (file)
 /* Specification.  */
 #include "unistr.h"
 
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
 #if !HAVE_INLINE
 
 int
@@ -62,7 +70,9 @@ u8_uctomb (uint8_t *s, ucs4_t uc, int n)
           switch (count) /* note: code falls through cases! */
             {
             case 4: s[3] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x10000;
+              FALLTHROUGH;
             case 3: s[2] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0x800;
+              FALLTHROUGH;
             case 2: s[1] = 0x80 | (uc & 0x3f); uc = uc >> 6; uc |= 0xc0;
           /*case 1:*/ s[0] = uc;
             }