Ver Fonte

Merge pull request #598 from Dmitry-Me/fallThroughComments

Annotate fall throughs with comments
Lee Thomason há 8 anos atrás
pai
commit
68edbcee49
1 ficheiros alterados com 5 adições e 1 exclusões
  1. 5 1
      tinyxml2.cpp

+ 5 - 1
tinyxml2.cpp

@@ -424,20 +424,24 @@ void XMLUtil::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length
 
 
     output += *length;
     output += *length;
 
 
-    // Scary scary fall throughs.
+    // Scary scary fall throughs are annotated with carefully designed comments
+    // to suppress compiler warnings such as -Wimplicit-fallthrough in gcc
     switch (*length) {
     switch (*length) {
         case 4:
         case 4:
             --output;
             --output;
             *output = (char)((input | BYTE_MARK) & BYTE_MASK);
             *output = (char)((input | BYTE_MARK) & BYTE_MASK);
             input >>= 6;
             input >>= 6;
+            //fall through
         case 3:
         case 3:
             --output;
             --output;
             *output = (char)((input | BYTE_MARK) & BYTE_MASK);
             *output = (char)((input | BYTE_MARK) & BYTE_MASK);
             input >>= 6;
             input >>= 6;
+            //fall through
         case 2:
         case 2:
             --output;
             --output;
             *output = (char)((input | BYTE_MARK) & BYTE_MASK);
             *output = (char)((input | BYTE_MARK) & BYTE_MASK);
             input >>= 6;
             input >>= 6;
+            //fall through
         case 1:
         case 1:
             --output;
             --output;
             *output = (char)(input | FIRST_BYTE_MARK[*length]);
             *output = (char)(input | FIRST_BYTE_MARK[*length]);