From 82a1d5c34e951687d67a6313fb42d9e75768adbc Mon Sep 17 00:00:00 2001 From: Jelte Jansen Date: Thu, 10 Jan 2013 09:56:52 +0100 Subject: [2498] move out some common charstrings functions And add a number of tests --- src/lib/dns/rdata/generic/naptr_35.cc | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/lib/dns/rdata/generic/naptr_35.cc') diff --git a/src/lib/dns/rdata/generic/naptr_35.cc b/src/lib/dns/rdata/generic/naptr_35.cc index 611fc5b16d..4d891e6a6c 100644 --- a/src/lib/dns/rdata/generic/naptr_35.cc +++ b/src/lib/dns/rdata/generic/naptr_35.cc @@ -45,9 +45,9 @@ public: preference = buffer.readUint16(); rdata_len -= 4; - rdata_len -= readTextField(flags, buffer, rdata_len); - rdata_len -= readTextField(services, buffer, rdata_len); - rdata_len -= readTextField(regexp, buffer, rdata_len); + rdata_len -= detail::bufferToCharString(buffer, rdata_len, flags); + rdata_len -= detail::bufferToCharString(buffer, rdata_len, services); + rdata_len -= detail::bufferToCharString(buffer, rdata_len, regexp); replacement = Name(buffer); if (rdata_len < 1) { isc_throw(isc::dns::DNSMessageFORMERR, "Error in parsing " @@ -192,22 +192,22 @@ NAPTR::compare(const Rdata& other) const { return (1); } - if (impl_->flags < other_naptr.impl_->flags) { - return (-1); - } else if (impl_->flags > other_naptr.impl_->flags) { - return (1); + const int fcmp = detail::compareCharStrings(impl_->flags, + other_naptr.impl_->flags); + if (fcmp != 0) { + return (fcmp); } - if (impl_->services < other_naptr.impl_->services) { - return (-1); - } else if (impl_->services > other_naptr.impl_->services) { - return (1); + const int scmp = detail::compareCharStrings(impl_->services, + other_naptr.impl_->services); + if (scmp != 0) { + return (scmp); } - if (impl_->regexp < other_naptr.impl_->regexp) { - return (-1); - } else if (impl_->regexp > other_naptr.impl_->regexp) { - return (1); + const int rcmp = detail::compareCharStrings(impl_->regexp, + other_naptr.impl_->regexp); + if (rcmp != 0) { + return (rcmp); } return (compareNames(impl_->replacement, other_naptr.impl_->replacement)); -- cgit v1.2.3