[nemiver/asm-support] Validate decimal and hexa numbers



commit c7482e8623a68307086b2beb484623d7f4e77e7b
Author: Dodji Seketeli <dodji gnome org>
Date:   Tue Apr 27 15:35:31 2010 +0200

    Validate decimal and hexa numbers
    
    	* src/common/nmv-str-utils.h (string_is_decimal_number): Declare
    	new fn.
    	* src/common/nmv-str-utils.cc (string_is_decimal_number): Define
    	new fn.
    	(string_is_number): Validate decimal and hexa numbers using
    	string_is_decimal_number and string_is_hexa_number.
    	* src/dbgengine/nmv-gdbmi-parser.cc
    	(GDBMIParser::analyse_mixed_asm_instrs): Adjust. Use
    	str_utils::string_is_decimal_number to validate decimal numbers,
    	instead of the former string_is_number that now validate decimal
    	and hexa numbers.

 src/common/nmv-str-utils.cc       |    7 +++++++
 src/common/nmv-str-utils.h        |    1 +
 src/dbgengine/nmv-gdbmi-parser.cc |    2 +-
 3 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/common/nmv-str-utils.cc b/src/common/nmv-str-utils.cc
index 645090e..97c0f58 100644
--- a/src/common/nmv-str-utils.cc
+++ b/src/common/nmv-str-utils.cc
@@ -103,6 +103,13 @@ int_to_string (size_t an_int)
 bool
 string_is_number (const string &a_str)
 {
+    return (string_is_hexa_number (a_str)
+            || string_is_decimal_number (a_str));
+}
+
+bool
+string_is_decimal_number (const string &a_str)
+{
     for (unsigned i = 0; i < a_str.size (); ++i)
         if (!isdigit (a_str[i]))
             return false;
diff --git a/src/common/nmv-str-utils.h b/src/common/nmv-str-utils.h
index afed527..76490cd 100644
--- a/src/common/nmv-str-utils.h
+++ b/src/common/nmv-str-utils.h
@@ -38,6 +38,7 @@ extract_path_and_line_num_from_location (const std::string &a_location,
 size_t hexa_to_int (const string &a_hexa_str);
 std::string int_to_string (size_t an_int);
 bool string_is_number (const string&);
+bool string_is_decimal_number (const string&);
 bool string_is_hexa_number (const string &a_str);
 vector<UString> split (const UString &a_string, const UString &a_delim);
 vector<UString> split_set (const UString &a_string, const UString &a_delim_set);
diff --git a/src/dbgengine/nmv-gdbmi-parser.cc b/src/dbgengine/nmv-gdbmi-parser.cc
index 6abbe3b..150770e 100644
--- a/src/dbgengine/nmv-gdbmi-parser.cc
+++ b/src/dbgengine/nmv-gdbmi-parser.cc
@@ -4103,7 +4103,7 @@ GDBMIParser::analyse_mixed_asm_instrs (GDBMIListSafePtr a_gdbmi_list,
             if ((*inner_it)->variable () == "line"
                 && inner_result_type == GDBMIValue::STRING_TYPE) {
                 string line_str = val->get_string_content ().raw ();
-                if (!str_utils::string_is_number (line_str)) {
+                if (!str_utils::string_is_decimal_number (line_str)) {
                     stringstream s;
                     s << "The value of the 'line' RESULT should be "
                          "a number. Instead it was: "



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]