summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2009-02-11 23:47:06 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2009-02-11 23:47:06 +0000
commit13c5cb7845b957966b9ecb1a8c2e48afb8d69233 (patch)
treec1d207efdcce7ee310ef56c4e481f34156c72465
parent4ed72f3744b1f78251d66c9556695f6328a3bee0 (diff)
I really dont get the oddball count()? rewrite it
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11088 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--src/modules/extra/m_mssql.cpp8
-rw-r--r--src/modules/extra/m_mysql.cpp8
-rw-r--r--src/modules/extra/m_pgsql.cpp8
-rw-r--r--src/modules/extra/m_sqlite3.cpp8
4 files changed, 12 insertions, 20 deletions
diff --git a/src/modules/extra/m_mssql.cpp b/src/modules/extra/m_mssql.cpp
index 65f86e9ac..0b197efe5 100644
--- a/src/modules/extra/m_mssql.cpp
+++ b/src/modules/extra/m_mssql.cpp
@@ -37,12 +37,10 @@ typedef std::deque<MsSQLResult*> ResultQueue;
unsigned long count(const char * const str, char a)
{
unsigned long n = 0;
- const char *p = reinterpret_cast<const char *>(str);
-
- while ((p = strchr(p, a)) != NULL)
+ for (const char *p = reinterpret_cast<const char *>(str); *p; ++p)
{
- ++p;
- ++n;
+ if (*p == '?')
+ ++n;
}
return n;
}
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index 339f13309..a25234909 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -77,12 +77,10 @@ class DispatcherThread;
unsigned long count(const char * const str, char a)
{
unsigned long n = 0;
- const char *p = reinterpret_cast<const char *>(str);
-
- while ((p = strchr(p, a)) != NULL)
+ for (const char *p = reinterpret_cast<const char *>(str); *p; ++p)
{
- ++p;
- ++n;
+ if (*p == '?')
+ ++n;
}
return n;
}
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index 0484646df..526f1a51f 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -47,12 +47,10 @@ enum SQLstatus { CREAD, CWRITE, WREAD, WWRITE, RREAD, RWRITE };
unsigned long count(const char * const str, char a)
{
unsigned long n = 0;
- const char *p = reinterpret_cast<const char *>(str);
-
- while ((p = strchr(p, a)) != NULL)
+ for (const char *p = reinterpret_cast<const char *>(str); *p; ++p)
{
- ++p;
- ++n;
+ if (*p == '?')
+ ++n;
}
return n;
}
diff --git a/src/modules/extra/m_sqlite3.cpp b/src/modules/extra/m_sqlite3.cpp
index d174ce8aa..c4d1cc799 100644
--- a/src/modules/extra/m_sqlite3.cpp
+++ b/src/modules/extra/m_sqlite3.cpp
@@ -34,12 +34,10 @@ typedef std::deque<SQLite3Result*> ResultQueue;
unsigned long count(const char * const str, char a)
{
unsigned long n = 0;
- const char *p = reinterpret_cast<const char *>(str);
-
- while ((p = strchr(p, a)) != NULL)
+ for (const char *p = reinterpret_cast<const char *>(str); *p; ++p)
{
- ++p;
- ++n;
+ if (*p == '?')
+ ++n;
}
return n;
}