]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove unused SBuf::Scanf method
authorAmos Jeffries <squid3@treenet.co.nz>
Mon, 3 Oct 2016 20:06:25 +0000 (09:06 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Mon, 3 Oct 2016 20:06:25 +0000 (09:06 +1300)
This method is unused and requires the risky c_str() API to operate.

Code wanting to parse an SBuf should use a Tokenizer or Parser instead.

src/sbuf/SBuf.cc
src/sbuf/SBuf.h
src/sbuf/Stats.cc
src/sbuf/Stats.h
src/tests/stub_SBuf.cc
src/tests/testSBuf.cc
src/tests/testSBuf.h

index 929dc157ba0cc8caab3b2305d76be4d9edd76e49..c981cdc71656807cc1026ef7ebff614e8c7d2ed3 100644 (file)
@@ -827,27 +827,6 @@ SBuf::findLastNotOf(const CharacterSet &set, size_type endPos) const
     return npos;
 }
 
-/*
- * TODO: borrow a sscanf implementation from Linux or similar?
- * we'd really need a vsnscanf(3)... ? As an alternative, a
- * light-regexp-like domain-specific syntax might be an idea.
- */
-int
-SBuf::scanf(const char *format, ...)
-{
-    // with the format or an arg might be a dangerous char*
-    // that gets invalidated by c_str()
-    const Locker blobKeeper(this, buf());
-
-    va_list arg;
-    int rv;
-    ++stats.scanf;
-    va_start(arg, format);
-    rv = vsscanf(c_str(), format, arg);
-    va_end(arg);
-    return rv;
-}
-
 void
 SBuf::toLower()
 {
index db64501c1b10f9d573abce9efedf3c0aa60be91b..4e2780fd269db069012b9daeacbe09d7adfa3a43 100644 (file)
@@ -583,14 +583,6 @@ public:
      */
     size_type findLastNotOf(const CharacterSet &set, size_type endPos = npos) const;
 
-    /** sscanf-alike
-     *
-     * sscanf re-implementation. Non-const, and not \0-clean.
-     * \return same as sscanf
-     * \see man sscanf(3)
-     */
-    int scanf(const char *format, ...);
-
     /// converts all characters to lower case; \see man tolower(3)
     void toLower();
 
index 67f7fac9cde7333685b353fa8e45dc02d3f81158..8b52a0fa3956b69b8a1c6ca8356cd8bf8d071238 100644 (file)
@@ -17,7 +17,7 @@ SBufStats::SBufStats()
     : alloc(0), allocCopy(0), allocFromCString(0),
       assignFast(0), clear(0), append(0), moves(0), toStream(0), setChar(0),
       getChar(0), compareSlow(0), compareFast(0), copyOut(0),
-      rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0), scanf(0),
+      rawAccess(0), nulTerminate(0), chop(0), trim(0), find(0),
       caseChange(0), cowFast(0), cowSlow(0), live(0)
 {}
 
@@ -42,7 +42,6 @@ SBufStats::operator +=(const SBufStats& ss)
     chop += ss.chop;
     trim += ss.trim;
     find += ss.find;
-    scanf += ss.scanf;
     caseChange += ss.caseChange;
     cowFast += ss.cowFast;
     cowSlow += ss.cowSlow;
@@ -75,7 +74,6 @@ SBufStats::dump(std::ostream& os) const
        "\nchop operations: " << chop <<
        "\ntrim operations: " << trim <<
        "\nfind: " << find <<
-       "\nscanf: " << scanf <<
        "\ncase-change ops: " << caseChange <<
        "\nCOW not actually requiring a copy: " << cowFast <<
        "\nCOW: " << cowSlow <<
index d70ff83dc9ee210288e6079f23e2a135002aeeef..2b9ad7a81e0d928689fac7e7b57b1b8e823dd3b4 100644 (file)
@@ -39,7 +39,6 @@ public:
     uint64_t chop;  ///<number of chop operations
     uint64_t trim;  ///<number of trim operations
     uint64_t find;  ///<number of find operations
-    uint64_t scanf;  ///<number of scanf operations
     uint64_t caseChange; ///<number of toUpper and toLower operations
     uint64_t cowFast; ///<number of cow operations not actually requiring a copy
     uint64_t cowSlow; ///<number of cow operations requiring a copy
index 1e7b6c7142d629d12c22326fb253e34cff481a83..d9517d0166bdd478a414ca4996278db9609acbeb 100644 (file)
@@ -63,7 +63,6 @@ SBuf::size_type SBuf::rfind(char c, size_type endPos) const STUB_RETVAL(SBuf::np
 SBuf::size_type SBuf::rfind(const SBuf &str, size_type endPos) const STUB_RETVAL(SBuf::npos)
 SBuf::size_type SBuf::findFirstOf(const CharacterSet &set, size_type startPos) const STUB_RETVAL(SBuf::npos)
 SBuf::size_type SBuf::findFirstNotOf(const CharacterSet &set, size_type startPos) const STUB_RETVAL(SBuf::npos)
-int SBuf::scanf(const char *format, ...) STUB_RETVAL(-1)
 void SBuf::toLower() STUB
 void SBuf::toUpper() STUB
 
index 948b065d27941a12afaba2ad13418378adf04631..5bd88235795439457c7b3d86057ad1801b233ec0 100644 (file)
@@ -753,22 +753,6 @@ testSBuf::testSBufLength()
     CPPUNIT_ASSERT_EQUAL(strlen(fox),(size_t)s.length());
 }
 
-void
-testSBuf::testScanf()
-{
-    SBuf s1;
-    char s[128];
-    int i;
-    float f;
-    int rv;
-    s1.assign("string , 123 , 123.50");
-    rv=s1.scanf("%s , %d , %f",s,&i,&f);
-    CPPUNIT_ASSERT_EQUAL(3,rv);
-    CPPUNIT_ASSERT_EQUAL(0,strcmp(s,"string"));
-    CPPUNIT_ASSERT_EQUAL(123,i);
-    CPPUNIT_ASSERT_EQUAL(static_cast<float>(123.5),f);
-}
-
 void
 testSBuf::testCopy()
 {
index fb54af4140d994aa91cad2ea13b9e50ded228146..e19f5eaab41077f047c60ae0639297fd7fe15a60 100644 (file)
@@ -45,7 +45,6 @@ class testSBuf : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST( testFindFirstOf );
     CPPUNIT_TEST( testFindFirstNotOf );
     CPPUNIT_TEST( testPrintf );
-    CPPUNIT_TEST( testScanf );
     CPPUNIT_TEST( testCopy );
     CPPUNIT_TEST( testStringOps );
     CPPUNIT_TEST( testGrow );
@@ -67,7 +66,6 @@ protected:
     void testAppendStdString();
     void testAppendf();
     void testPrintf();
-    void testScanf();
     void testSubscriptOp();
     void testSubscriptOpFail();
     void testDumpStats();