diff --git a/src/A2STR.cc b/src/A2STR.cc index bcd6d76f..790a5329 100644 --- a/src/A2STR.cc +++ b/src/A2STR.cc @@ -36,30 +36,10 @@ namespace aria2 { -const std::string A2STR::NIL(""); +namespace A2STR { -const std::string A2STR::SHARP_C("#"); +const std::string NIL(""); -const std::string A2STR::CR_C("\r"); - -const std::string A2STR::LF_C("\n"); - -const std::string A2STR::CRLF("\r\n"); - -const std::string A2STR::SLASH_C("/"); - -const std::string A2STR::DOT_C("."); - -const std::string A2STR::COLON_C(":"); - -const std::string A2STR::SEMICOLON_C(";"); - -const std::string A2STR::EQUAL_C("="); - -const std::string A2STR::UNDERSCORE_C("_"); - -const std::string A2STR::BACK_SLASH_C("\\"); - -const std::string A2STR::COMMA_C(","); +} // namespace A2STR } // namespace aria2 diff --git a/src/A2STR.h b/src/A2STR.h index bddb8808..445c946d 100644 --- a/src/A2STR.h +++ b/src/A2STR.h @@ -39,36 +39,12 @@ namespace aria2 { -class A2STR { -private: - A2STR(); -public: - static const std::string NIL; +namespace A2STR { - static const std::string SHARP_C; +extern const std::string NIL; - static const std::string CR_C; +} // namespace A2STR - static const std::string LF_C; - - static const std::string CRLF; - - static const std::string SLASH_C; - - static const std::string DOT_C; - - static const std::string COLON_C; - - static const std::string SEMICOLON_C; - - static const std::string EQUAL_C; - - static const std::string UNDERSCORE_C; - - static const std::string BACK_SLASH_C; - - static const std::string COMMA_C; -}; } // namespace aria2 #endif // D_A2_STR_H diff --git a/src/Cookie.cc b/src/Cookie.cc index 5dc8db54..0628bc27 100644 --- a/src/Cookie.cc +++ b/src/Cookie.cc @@ -147,7 +147,7 @@ std::string Cookie::toNsCookieFormat() const { std::stringstream ss; if(!hostOnly_) { - ss << A2STR::DOT_C; + ss << "."; } ss << domain_ << "\t"; if(hostOnly_) { diff --git a/src/File.cc b/src/File.cc index dab20cbb..4bef6712 100644 --- a/src/File.cc +++ b/src/File.cc @@ -216,10 +216,10 @@ std::string File::getDirname() const if(name_.empty()) { return A2STR::NIL; } else { - return A2STR::DOT_C; + return "."; } } else if(lastSlashIndex == 0) { - return A2STR::SLASH_C; + return "/"; } else { return name_.substr(0, lastSlashIndex); } @@ -281,7 +281,7 @@ std::string File::getCurrentDir() if(_wgetcwd(buf, buflen)) { return wCharToUtf8(buf); } else { - return A2STR::DOT_C; + return "."; } #else // !__MINGW32__ const size_t buflen = 2048; @@ -289,7 +289,7 @@ std::string File::getCurrentDir() if(getcwd(buf, buflen)) { return std::string(buf); } else { - return A2STR::DOT_C; + return "."; } #endif // !__MINGW32__ } diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc index 30196f50..60b5e6c6 100644 --- a/src/FtpConnection.cc +++ b/src/FtpConnection.cc @@ -314,7 +314,7 @@ FtpConnection::findEndOfResponse if(p == std::string::npos) { return std::string::npos; } - p = buf.find(A2STR::CRLF, p+6); + p = buf.find("\r\n", p+6); if(p == std::string::npos) { return std::string::npos; } else { @@ -322,7 +322,7 @@ FtpConnection::findEndOfResponse } } else { // single line response - std::string::size_type p = buf.find(A2STR::CRLF); + std::string::size_type p = buf.find("\r\n"); if(p == std::string::npos) { return std::string::npos; } else { diff --git a/src/util.cc b/src/util.cc index ea1b75c7..68bc7390 100644 --- a/src/util.cc +++ b/src/util.cc @@ -1371,7 +1371,7 @@ std::string applyDir(const std::string& dir, const std::string& relPath) std::string fixTaintedBasename(const std::string& src) { static std::string SLASH_REP = "%2F"; - return escapePath(replace(src, A2STR::SLASH_C, SLASH_REP)); + return escapePath(replace(src, "/", SLASH_REP)); } void generateRandomKey(unsigned char* key) diff --git a/test/ExceptionTest.cc b/test/ExceptionTest.cc index fe1697f6..1a7c1065 100644 --- a/test/ExceptionTest.cc +++ b/test/ExceptionTest.cc @@ -38,7 +38,7 @@ void ExceptionTest::testStackTrace() ("Exception: [ExceptionTest.cc:34] errorCode=2 exception thrown\n" " -> [ExceptionTest.cc:32] errorCode=2 cause2\n" " -> [ExceptionTest.cc:31] errorCode=2 cause1\n"), - util::replace(e.stackTrace(), A2_TEST_DIR+A2STR::SLASH_C, "")); + util::replace(e.stackTrace(), std::string(A2_TEST_DIR)+"/", "")); } } // namespace aria2