handle zero-size attribute list.
1.1 --- a/src/core/attribute-list.cc Tue Mar 03 16:06:20 2009 +0100
1.2 +++ b/src/core/attribute-list.cc Tue Mar 03 16:07:16 2009 +0100
1.3 @@ -208,50 +208,51 @@
1.4
1.5 std::string::size_type cur;
1.6 cur = 0;
1.7 - do {
1.8 - std::string::size_type equal = str.find ("=", cur);
1.9 - if (equal == std::string::npos)
1.10 - {
1.11 - NS_FATAL_ERROR ("Error while parsing serialized attribute: \"" << str << "\"");
1.12 - break;
1.13 - }
1.14 - else
1.15 - {
1.16 - std::string name = str.substr (cur, equal-cur);
1.17 - struct TypeId::AttributeInfo info;
1.18 - if (!TypeId::LookupAttributeByFullName (name, &info))
1.19 - {
1.20 - NS_FATAL_ERROR ("Error while parsing serialized attribute: name does not exist: \"" << name << "\"");
1.21 - break;
1.22 - }
1.23 - else
1.24 - {
1.25 - std::string::size_type next = str.find ("|", cur);
1.26 - std::string value;
1.27 - if (next == std::string::npos)
1.28 - {
1.29 - value = str.substr (equal+1, str.size () - (equal+1));
1.30 - cur = str.size ();
1.31 - }
1.32 - else
1.33 - {
1.34 - value = str.substr (equal+1, next - (equal+1));
1.35 - cur++;
1.36 - }
1.37 - Ptr<AttributeValue> val = info.checker->Create ();
1.38 - bool ok = val->DeserializeFromString (value, info.checker);
1.39 - if (!ok)
1.40 - {
1.41 - NS_FATAL_ERROR ("Error while parsing serialized attribute: value invalid: \"" << value << "\"");
1.42 - break;
1.43 - }
1.44 - else
1.45 - {
1.46 - DoSetOne (info.checker, *val);
1.47 - }
1.48 - }
1.49 - }
1.50 - } while (cur != str.size ());
1.51 + while (cur != str.size ())
1.52 + {
1.53 + std::string::size_type equal = str.find ("=", cur);
1.54 + if (equal == std::string::npos)
1.55 + {
1.56 + NS_FATAL_ERROR ("Error while parsing serialized attribute: \"" << str << "\"");
1.57 + break;
1.58 + }
1.59 + else
1.60 + {
1.61 + std::string name = str.substr (cur, equal-cur);
1.62 + struct TypeId::AttributeInfo info;
1.63 + if (!TypeId::LookupAttributeByFullName (name, &info))
1.64 + {
1.65 + NS_FATAL_ERROR ("Error while parsing serialized attribute: name does not exist: \"" << name << "\"");
1.66 + break;
1.67 + }
1.68 + else
1.69 + {
1.70 + std::string::size_type next = str.find ("|", cur);
1.71 + std::string value;
1.72 + if (next == std::string::npos)
1.73 + {
1.74 + value = str.substr (equal+1, str.size () - (equal+1));
1.75 + cur = str.size ();
1.76 + }
1.77 + else
1.78 + {
1.79 + value = str.substr (equal+1, next - (equal+1));
1.80 + cur++;
1.81 + }
1.82 + Ptr<AttributeValue> val = info.checker->Create ();
1.83 + bool ok = val->DeserializeFromString (value, info.checker);
1.84 + if (!ok)
1.85 + {
1.86 + NS_FATAL_ERROR ("Error while parsing serialized attribute: value invalid: \"" << value << "\"");
1.87 + break;
1.88 + }
1.89 + else
1.90 + {
1.91 + DoSetOne (info.checker, *val);
1.92 + }
1.93 + }
1.94 + }
1.95 + }
1.96
1.97 return true;
1.98 }