From: JINMEI Tatuya Date: Tue, 31 Jan 2012 18:11:39 +0000 (-0800) Subject: [1574b] used ::toupper instead of a helper functor object with transform(). X-Git-Tag: trac2351_base~268^2~5^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=13ef8a1a140dd572deeb4f971109e2fe4a8363ac;p=thirdparty%2Fkea.git [1574b] used ::toupper instead of a helper functor object with transform(). g++ somehow seems to require it to compile with toupper. updated comments about it. --- diff --git a/src/lib/datasrc/memory_datasrc.cc b/src/lib/datasrc/memory_datasrc.cc index 2a37bddb2f..0a3280be4a 100644 --- a/src/lib/datasrc/memory_datasrc.cc +++ b/src/lib/datasrc/memory_datasrc.cc @@ -298,15 +298,6 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl { } } - // A helper functor to convert the 1st NSEC3 label to all upper-cased - // characters. Note: technically there's a subtle issue when char - // is signed, but in practice the label should consist of all positive - // character values for a valid NSEC3 hash name (if it's invalid the - // resulting zone doesn't work correctly anyway). - struct ToUpper { - char operator()(char ch) { return (toupper(ch)); } - }; - result::Result addRRsig(const ConstRRsetPtr sig_rrset, ZoneData& zone_data) { // Check consistency of the type covered. @@ -341,10 +332,17 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl { // In case of NSEC3 if something is found it must be NSEC3 RRset // under the assumption of our current implementation. if (zone_data.nsec3_data_) { - string fst_label = sig_rrset->getName().split(0, 1). - toText(true); + // Convert the first label to upper-cased text. Note that + // for a valid NSEC3 RR the label should only consist of + // positive 8-bit char values, so using toupper(int) should be + // safe (if it's a bogus label for NSEC3 the zone won't work + // anyway). Also note the '::' below: g++'s STL implementation + // seems to require it to toupper to make this compile. + string fst_label = + sig_rrset->getName().split(0, 1).toText(true); transform(fst_label.begin(), fst_label.end(), - fst_label.begin(), ToUpper()); + fst_label.begin(), ::toupper); + NSEC3Map::const_iterator found = zone_data.nsec3_data_->map_.find(fst_label); if (found != zone_data.nsec3_data_->map_.end()) { @@ -397,7 +395,7 @@ struct InMemoryZoneFinder::InMemoryZoneFinderImpl { string fst_label = rrset->getName().split(0, 1).toText(true); transform(fst_label.begin(), fst_label.end(), fst_label.begin(), - ToUpper()); + ::toupper); // Our current implementation doesn't allow an existing NSEC3 to be // updated/overridden.