From 45494b4d0a3301afc3d334fccb7f0d1d875db1bb Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 17 May 2011 17:27:16 -0700 Subject: [PATCH] crushtool: strip leading spaces from identifiers No idea where these are coming from! Weird. Signed-off-by: Sage Weil --- src/crushtool.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/crushtool.cc b/src/crushtool.cc index e60b623532cb6..86199e7833d04 100644 --- a/src/crushtool.cc +++ b/src/crushtool.cc @@ -56,7 +56,11 @@ map rule_id; string string_node(node_t &node) { - return string(node.value.begin(), node.value.end()); + string s = string(node.value.begin(), node.value.end()); + while (s.length() > 0 && + s[0] == ' ') + s = string(s.begin() + 1, s.end()); + return s; } int int_node(node_t &node) @@ -84,7 +88,7 @@ void parse_device(iter_t const& i, CrushWrapper &crush) item_id[name] = id; id_item[id] = name; - if (verbose) cout << "device " << id << " " << name << std::endl; + if (verbose) cout << "device " << id << " '" << name << "'" << std::endl; if (id >= crush.get_max_devices()) crush.set_max_devices(id+1); @@ -94,7 +98,7 @@ void parse_bucket_type(iter_t const& i, CrushWrapper &crush) { int id = int_node(i->children[1]); string name = string_node(i->children[2]); - if (verbose) cout << "type " << id << " " << name << std::endl; + if (verbose) cout << "type " << id << " '" << name << "'" << std::endl; type_id[name] = id; crush.set_type_name(id, name.c_str()); } -- 2.39.5