Browse Source

[trac838] Add more comments to skipSpaces() function and fix style problems.

Ocean Wang 14 years ago
parent
commit
e4543dee37
1 changed files with 9 additions and 5 deletions
  1. 9 5
      src/lib/util/encode/base_n.cc

+ 9 - 5
src/lib/util/encode/base_n.cc

@@ -174,11 +174,15 @@ public:
         return (*this);
     }
     void skipSpaces() {
-        // If *base_ < 0, on Windows platform with Visual Studio compiler
-        // it may trigger _ASSERTE((unsigned)(c + 1) <= 256);
-        // so make sure that the parameter of isspace() is larger than 0
-        while (base_ != base_end_ && ((*base_) >= 0) && isspace(*base_))
-        {
+        // If (char is signed and) *base_ < 0, on Windows platform with Visual
+        // Studio compiler it may trigger _ASSERTE((unsigned)(c + 1) <= 256);
+        // so make sure that the parameter of isspace() is larger than 0.
+        // We don't simply cast it to unsigned char to avoid confusing the
+        // isspace() implementation with a possible extension for values
+        // larger than 127.  Also note the check is not ">= 0"; for systems
+        // where char is unsigned that would always be true and would possibly
+        // trigger a compiler warning that could stop the build.
+        while (base_ != base_end_ && *base_ > 0 && isspace(*base_)) {
             ++base_;
         }
     }