[Lldb-commits] [lldb] r169417 - in /lldb/trunk: include/lldb/Interpreter/Options.h source/Interpreter/Args.cpp source/Interpreter/Options.cpp

Daniel Malea daniel.malea at intel.com
Wed Dec 5 12:24:57 PST 2012


Author: dmalea
Date: Wed Dec  5 14:24:57 2012
New Revision: 169417

URL: http://llvm.org/viewvc/llvm-project?rev=169417&view=rev
Log:
Define isprint8() wrapper around isprint() in order to avoid crashes on Linux


Modified:
    lldb/trunk/include/lldb/Interpreter/Options.h
    lldb/trunk/source/Interpreter/Args.cpp
    lldb/trunk/source/Interpreter/Options.cpp

Modified: lldb/trunk/include/lldb/Interpreter/Options.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/Options.h?rev=169417&r1=169416&r2=169417&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Interpreter/Options.h (original)
+++ lldb/trunk/include/lldb/Interpreter/Options.h Wed Dec  5 14:24:57 2012
@@ -23,6 +23,18 @@
 #include "lldb/lldb-defines.h"
 #include "lldb/Interpreter/Args.h"
 
+namespace {
+
+  static inline bool
+  isprint8 (int ch)
+  {
+      if (ch & 0xffffff00u)
+          return false;
+      return isprint(ch);
+  }
+
+}
+
 namespace lldb_private {
 
 //----------------------------------------------------------------------

Modified: lldb/trunk/source/Interpreter/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=169417&r1=169416&r2=169417&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Args.cpp (original)
+++ lldb/trunk/source/Interpreter/Args.cpp Wed Dec  5 14:24:57 2012
@@ -627,7 +627,7 @@
     {
         if (long_options[i].flag == NULL)
         {
-            if (isprint(long_options[i].val))
+            if (isprint8(long_options[i].val))
             {
                 sstr << (char)long_options[i].val;
                 switch (long_options[i].has_arg)
@@ -1628,7 +1628,7 @@
     {
         for (const char *p = src; *p != '\0'; ++p)
         {
-            if (isprint(*p))
+            if (isprint8(*p))
                 dst.append(1, *p);
             else
             {

Modified: lldb/trunk/source/Interpreter/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Options.cpp?rev=169417&r1=169416&r2=169417&view=diff
==============================================================================
--- lldb/trunk/source/Interpreter/Options.cpp (original)
+++ lldb/trunk/source/Interpreter/Options.cpp Wed Dec  5 14:24:57 2012
@@ -291,7 +291,7 @@
                 m_getopt_table[i].val = 0;
                 std::map<int, uint32_t>::const_iterator pos = option_seen.find(short_opt);
                 StreamString strm;
-                if (isprint(short_opt))
+                if (isprint8(short_opt))
                     Host::SystemLog (Host::eSystemLogError, "option[%u] --%s has a short option -%c that conflicts with option[%u] --%s, short option won't be used for --%s\n",
                                 i,
                                 opt_defs[i].long_option,
@@ -427,7 +427,7 @@
              bool show_optional,
              Stream &strm)
 {
-    const bool has_short_option = isprint(opt_def.short_option) != 0;
+    const bool has_short_option = isprint8(opt_def.short_option) != 0;
 
     if (display_type == eDisplayShortOption && !has_short_option)
         return false;
@@ -525,7 +525,7 @@
         bool first;
         for (i = 0, first = true; i < num_options; ++i)
         {
-            if (opt_defs[i].usage_mask & opt_set_mask && isprint(opt_defs[i].short_option))
+            if (opt_defs[i].usage_mask & opt_set_mask && isprint8(opt_defs[i].short_option))
             {
                 // Add current option to the end of out_stream.
 
@@ -556,7 +556,7 @@
 
         for (i = 0, options.clear(); i < num_options; ++i)
         {
-            if (opt_defs[i].usage_mask & opt_set_mask && isprint(opt_defs[i].short_option))
+            if (opt_defs[i].usage_mask & opt_set_mask && isprint8(opt_defs[i].short_option))
             {
                 // Add current option to the end of out_stream.
 
@@ -590,7 +590,7 @@
         
         for (i = 0; i < num_options; ++i)
         {
-            if (opt_defs[i].usage_mask & opt_set_mask && isprint(opt_defs[i].short_option))
+            if (opt_defs[i].usage_mask & opt_set_mask && isprint8(opt_defs[i].short_option))
             {
                 if (opt_defs[i].required && opt_defs[i].option_has_arg != no_argument)
                     PrintOption (opt_defs[i], eDisplayBestOption, " ", NULL, true, strm);
@@ -668,7 +668,7 @@
         arg_name_str.Printf ("<%s>", CommandObject::GetArgumentName (arg_type));
 
         strm.Indent ();
-        if (opt_defs[i].short_option && isprint(opt_defs[i].short_option))
+        if (opt_defs[i].short_option && isprint8(opt_defs[i].short_option))
         {
             PrintOption (opt_defs[i], eDisplayShortOption, NULL, NULL, false, strm);
             PrintOption (opt_defs[i], eDisplayLongOption, " ( ", " )", false, strm);





More information about the lldb-commits mailing list