]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/strutl.h
document --no- as --show-upgraded is the default
[apt.git] / apt-pkg / contrib / strutl.h
index 6d1a1d7ee6e732f9f16d45a232476d2fe27fa6e0..ef117267814d7ef4bcbc54e500a4b3bcc8e5174d 100644 (file)
@@ -22,6 +22,9 @@
 #include <cstring>
 #include <vector>
 #include <iostream>
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+#include <apt-pkg/string_view.h>
+#endif
 #include <time.h>
 #include <stddef.h>
 
@@ -75,7 +78,9 @@ bool StrToNum(const char *Str,unsigned long long &Res,unsigned Len,unsigned Base
 bool Base256ToNum(const char *Str,unsigned long &Res,unsigned int Len);
 bool Base256ToNum(const char *Str,unsigned long long &Res,unsigned int Len);
 bool Hex2Num(const std::string &Str,unsigned char *Num,unsigned int Length);
-
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+APT_HIDDEN bool Hex2Num(const APT::StringView Str,unsigned char *Num,unsigned int Length);
+#endif
 // input changing string split
 bool TokSplitString(char Tok,char *Input,char **List,
                    unsigned long ListMax);
@@ -88,7 +93,7 @@ std::vector<std::string> VectorizeString(std::string const &haystack, char const
  *
  * \param input The input string.
  *
- * \param sep The seperator to use.
+ * \param sep The separator to use.
  *
  * \param maxsplit (optional) The maximum amount of splitting that
  * should be done .
@@ -105,8 +110,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);