From 13c5cb7845b957966b9ecb1a8c2e48afb8d69233 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 11 Feb 2009 23:47:06 +0000 Subject: 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 --- src/modules/extra/m_mssql.cpp | 8 +++----- src/modules/extra/m_mysql.cpp | 8 +++----- src/modules/extra/m_pgsql.cpp | 8 +++----- src/modules/extra/m_sqlite3.cpp | 8 +++----- 4 files changed, 12 insertions(+), 20 deletions(-) (limited to 'src') 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 ResultQueue; unsigned long count(const char * const str, char a) { unsigned long n = 0; - const char *p = reinterpret_cast(str); - - while ((p = strchr(p, a)) != NULL) + for (const char *p = reinterpret_cast(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(str); - - while ((p = strchr(p, a)) != NULL) + for (const char *p = reinterpret_cast(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(str); - - while ((p = strchr(p, a)) != NULL) + for (const char *p = reinterpret_cast(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 ResultQueue; unsigned long count(const char * const str, char a) { unsigned long n = 0; - const char *p = reinterpret_cast(str); - - while ((p = strchr(p, a)) != NULL) + for (const char *p = reinterpret_cast(str); *p; ++p) { - ++p; - ++n; + if (*p == '?') + ++n; } return n; } -- cgit v1.2.3