From 90b0c84bcf83e234c447eb1d13a65918939b3c26 Mon Sep 17 00:00:00 2001 From: Daniel Malea Date: Wed, 5 Dec 2012 20:24:57 +0000 Subject: [PATCH] Define isprint8() wrapper around isprint() in order to avoid crashes on Linux llvm-svn: 169417 --- lldb/include/lldb/Interpreter/Options.h | 12 ++++++++++++ lldb/source/Interpreter/Args.cpp | 4 ++-- lldb/source/Interpreter/Options.cpp | 12 ++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/lldb/include/lldb/Interpreter/Options.h b/lldb/include/lldb/Interpreter/Options.h index e131445..2a9be0b 100644 --- a/lldb/include/lldb/Interpreter/Options.h +++ b/lldb/include/lldb/Interpreter/Options.h @@ -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 { //---------------------------------------------------------------------- diff --git a/lldb/source/Interpreter/Args.cpp b/lldb/source/Interpreter/Args.cpp index 5086c28..65c3153 100644 --- a/lldb/source/Interpreter/Args.cpp +++ b/lldb/source/Interpreter/Args.cpp @@ -627,7 +627,7 @@ Args::ParseOptions (Options &options) { 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 @@ Args::ExpandEscapedCharacters (const char *src, std::string &dst) { for (const char *p = src; *p != '\0'; ++p) { - if (isprint(*p)) + if (isprint8(*p)) dst.append(1, *p); else { diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index 91424ba..95b7078 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -291,7 +291,7 @@ Options::GetLongOptions () m_getopt_table[i].val = 0; std::map::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 @@ PrintOption (const OptionDefinition &opt_def, 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 @@ Options::GenerateOptionUsage 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 @@ Options::GenerateOptionUsage 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 @@ Options::GenerateOptionUsage 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 @@ Options::GenerateOptionUsage 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); -- 2.7.4