diff options
author | Julian Andres Klode <jak@debian.org> | 2015-12-29 03:19:51 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-12-29 03:19:51 +0100 |
commit | 98eb4e9eec4e2e1fc62fe018d536b89f5524cd21 (patch) | |
tree | f65268d06ad96aa08a90a321475600c59a6bead3 /apt-pkg/contrib/strutl.h | |
parent | 0748f03aca4db260ad964b44519e0971647d1e9d (diff) |
Turn tolower_ascii() and isspace_ascii() into inline functions
To preserve compatibility, the new inline functions have _inline
as a suffix, and a macro defines the old names to refer to the
inline variants.
The old functions are still preserved for binary compatibility.
Also simplify the implementation of both functions.
Diffstat (limited to 'apt-pkg/contrib/strutl.h')
-rw-r--r-- | apt-pkg/contrib/strutl.h | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/apt-pkg/contrib/strutl.h b/apt-pkg/contrib/strutl.h index 6d1a1d7ee..a8bbc38af 100644 --- a/apt-pkg/contrib/strutl.h +++ b/apt-pkg/contrib/strutl.h @@ -105,8 +105,22 @@ void ioprintf(std::ostream &out,const char *format,...) APT_PRINTF(2); void strprintf(std::string &out,const char *format,...) APT_PRINTF(2); char *safe_snprintf(char *Buffer,char *End,const char *Format,...) APT_PRINTF(3); bool CheckDomainList(const std::string &Host, const std::string &List); -int tolower_ascii(int const c) APT_CONST APT_HOT; -int isspace_ascii(int const c) APT_CONST APT_HOT; + +/* Do some compat mumbo jumbo */ +#define tolower_ascii tolower_ascii_inline +#define isspace_ascii isspace_ascii_inline + +APT_CONST APT_HOT +static inline int tolower_ascii_inline(int const c) +{ + return (c >= 'A' && c <= 'Z') ? c + 32 : c; +} +APT_CONST APT_HOT +static inline int isspace_ascii_inline(int const c) +{ + // 9='\t',10='\n',11='\v',12='\f',13='\r',32=' ' + return (c >= 9 && c <= 13) || c == ' '; +} std::string StripEpoch(const std::string &VerStr); |