From 97553e635d2265ec4aad96b00b1fd72d98437f15 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 17 Jun 2019 18:28:52 +0200 Subject: RFC1123StrToTime: Accept const std::string& as first argument We are converting to std::string anyway by passing to istringstream, and this removes the need for .c_str() in callers. --- apt-pkg/contrib/macros.h | 7 +++++++ apt-pkg/contrib/strutl.cc | 4 ++++ apt-pkg/contrib/strutl.h | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h index df85b7856..4d9f780c7 100644 --- a/apt-pkg/contrib/macros.h +++ b/apt-pkg/contrib/macros.h @@ -150,4 +150,11 @@ #define APT_PKG_RELEASE 0 #define APT_PKG_ABI ((APT_PKG_MAJOR * 100) + APT_PKG_MINOR) + +#if APT_PKG_ABI > 590 +#define APT_PKG_590(msg) __attribute__((error(msg))) +#else +#define APT_PKG_590(msg) +#endif + #endif diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index c00bce5d5..e02067e13 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -994,6 +994,10 @@ static time_t timegm(struct tm *t) must be in UTC or parsing will fail. Previous implementations of this method used to ignore the timezone and assume always UTC. */ bool RFC1123StrToTime(const char* const str,time_t &time) +{ + return RFC1123StrToTime(std::string(str), time); +} +bool RFC1123StrToTime(std::string const &str,time_t &time) { unsigned short day = 0; signed int year = 0; // yes, Y23K problem – we going to worry then… diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 367b04ef6..fc02357a8 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -81,7 +81,8 @@ std::string TimeRFC1123(time_t Date, bool const NumericTimezone); * parsing is successful, undefined otherwise. * @return \b true if parsing was successful, otherwise \b false. */ -bool RFC1123StrToTime(const char* const str,time_t &time) APT_MUSTCHECK; +bool RFC1123StrToTime(const char* const str,time_t &time) APT_MUSTCHECK APT_PKG_590("Replaced by std::string variant"); +bool RFC1123StrToTime(const std::string &str,time_t &time) APT_MUSTCHECK; bool FTPMDTMStrToTime(const char* const str,time_t &time) APT_MUSTCHECK; std::string LookupTag(const std::string &Message,const char *Tag,const char *Default = 0); int StringToBool(const std::string &Text,int Default = -1); -- cgit v1.2.3-70-g09d2