From: Amos Jeffries Date: Mon, 3 Oct 2016 20:06:25 +0000 (+1300) Subject: Remove unused SBuf::Scanf method X-Git-Tag: SQUID_4_0_15~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5bf2c0cbe1480933ad0df5cc8c751ed04905fba1;p=thirdparty%2Fsquid.git Remove unused SBuf::Scanf method 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. --- diff --git a/src/sbuf/SBuf.cc b/src/sbuf/SBuf.cc index 929dc157ba..c981cdc716 100644 --- a/src/sbuf/SBuf.cc +++ b/src/sbuf/SBuf.cc @@ -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() { diff --git a/src/sbuf/SBuf.h b/src/sbuf/SBuf.h index db64501c1b..4e2780fd26 100644 --- a/src/sbuf/SBuf.h +++ b/src/sbuf/SBuf.h @@ -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(); diff --git a/src/sbuf/Stats.cc b/src/sbuf/Stats.cc index 67f7fac9cd..8b52a0fa39 100644 --- a/src/sbuf/Stats.cc +++ b/src/sbuf/Stats.cc @@ -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 << diff --git a/src/sbuf/Stats.h b/src/sbuf/Stats.h index d70ff83dc9..2b9ad7a81e 100644 --- a/src/sbuf/Stats.h +++ b/src/sbuf/Stats.h @@ -39,7 +39,6 @@ public: uint64_t chop; ///(123.5),f); -} - void testSBuf::testCopy() { diff --git a/src/tests/testSBuf.h b/src/tests/testSBuf.h index fb54af4140..e19f5eaab4 100644 --- a/src/tests/testSBuf.h +++ b/src/tests/testSBuf.h @@ -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();