]> git.saurik.com Git - apt.git/commitdiff
Introduce isspace_ascii() for use by parsers
authorJulian Andres Klode <jak@debian.org>
Sat, 26 Dec 2015 23:42:37 +0000 (00:42 +0100)
committerJulian Andres Klode <jak@debian.org>
Sat, 26 Dec 2015 23:42:37 +0000 (00:42 +0100)
This is like isspace(), but ignores the current locale.

apt-pkg/contrib/strutl.cc
apt-pkg/contrib/strutl.h

index 396cb7898c0e5dc26f31bbbbe030aa4c7cb90ca9..392412e52e2d8ca776b4d5c7fc0e35116bf5b69a 100644 (file)
@@ -1378,6 +1378,23 @@ int tolower_ascii(int const c)
 }
                                                                        /*}}}*/
 
+// isspace_ascii - isspace() function that ignores the locale          /*{{{*/
+// ---------------------------------------------------------------------
+/* This little function is one of the most called methods we have and tries
+   therefore to do the absolut minimum - and is notable faster than
+   standard isspace() and as a bonus avoids problems with different
+   locales - we only operate on ascii chars anyway. */
+int isspace_ascii(int const c)
+{
+   return (c == ' '
+           || c == '\f'
+           || c == '\n'
+           || c == '\r'
+           || c == '\t'
+           || c == '\v');
+}
+                                                                       /*}}}*/
+
 // CheckDomainList - See if Host is in a , separate list               /*{{{*/
 // ---------------------------------------------------------------------
 /* The domain list is a comma separate list of domains that are suffix
index 3e3c2cef6a4bb1ed57d163c6f585605696ed6508..6d1a1d7ee6e732f9f16d45a232476d2fe27fa6e0 100644 (file)
@@ -106,6 +106,8 @@ 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;
+
 std::string StripEpoch(const std::string &VerStr);
 
 #define APT_MKSTRCMP(name,func) \