Made const char[] static

pull/2/head
Tatsuhiro Tsujikawa 2011-11-11 23:00:41 +09:00
parent d17ea2837b
commit 226480ad60
11 changed files with 41 additions and 41 deletions

View File

@ -83,12 +83,12 @@ HttpConnection::~HttpConnection() {}
std::string HttpConnection::eraseConfidentialInfo(const std::string& request)
{
static const char A2_AUTH_HEADER[] = "Authorization: Basic";
static const char A2_PROXY_AUTH_HEADER[] = "Proxy-Authorization: Basic";
std::istringstream istr(request);
std::string result;
std::string line;
while(getline(istr, line)) {
const char A2_AUTH_HEADER[] = "Authorization: Basic";
const char A2_PROXY_AUTH_HEADER[] = "Proxy-Authorization: Basic";
if(util::startsWith(line.begin(), line.end(),
A2_AUTH_HEADER, vend(A2_AUTH_HEADER)-1)) {
result += "Authorization: Basic ********\n";

View File

@ -441,8 +441,8 @@ bool HttpRequest::conditionalRequest() const
if(!ifModSinceHeader_.empty()) {
return true;
}
const char A2_IF_MOD_SINCE[] = "if-modified-since";
const char A2_IF_NONE_MATCH[] = "if-none-match";
static const char A2_IF_MOD_SINCE[] = "if-modified-since";
static const char A2_IF_NONE_MATCH[] = "if-none-match";
for(std::vector<std::string>::const_iterator i = headers_.begin(),
eoi = headers_.end(); i != eoi; ++i) {
std::string hd = util::toLower(*i);

View File

@ -221,7 +221,7 @@ bool HttpServer::authenticate()
}
std::pair<Scip, Scip> p;
util::divide(p, authHeader.begin(), authHeader.end(), ' ');
const char A2_AUTHMETHOD[] = "Basic";
static const char A2_AUTHMETHOD[] = "Basic";
if(!util::streq(p.first.first, p.first.second,
A2_AUTHMETHOD, vend(A2_AUTHMETHOD)-1)) {
return false;

View File

@ -154,15 +154,15 @@ void Netrc::parse(const std::string& path)
continue;
}
std::vector<Scip> tokens;
const char A2_DELIMS[] = " \t";
static const char A2_DELIMS[] = " \t";
util::splitIterM(&buf[0], &buf[len], std::back_inserter(tokens),
A2_DELIMS, vend(A2_DELIMS)-1, true);
const char A2_MACHINE[] = "machine";
const char A2_DEFAULT[] = "default";
const char A2_LOGIN[] = "login";
const char A2_PASSWORD[] = "password";
const char A2_ACCOUNT[] = "account";
const char A2_MACDEF[] = "macdef";
static const char A2_MACHINE[] = "machine";
static const char A2_DEFAULT[] = "default";
static const char A2_LOGIN[] = "login";
static const char A2_PASSWORD[] = "password";
static const char A2_ACCOUNT[] = "account";
static const char A2_MACDEF[] = "macdef";
for(std::vector<Scip>::const_iterator iter = tokens.begin(),
eoi = tokens.end(); iter != eoi; ++iter) {
if(state == GET_TOKEN) {

View File

@ -87,7 +87,7 @@ bool parseNsCookie
// aria2 treats expiryTime == 0 means session cookie.
cookie.setPersistent(expiryTime != 0);
cookie.setDomain(vs[0].first, vs[0].second);
const char C_TRUE[] = "TRUE";
static const char C_TRUE[] = "TRUE";
cookie.setHostOnly(util::isNumericHost(cookie.getDomain()) ||
!util::streq(vs[1].first, vs[1].second,
C_TRUE, vend(C_TRUE)-1));

View File

@ -521,7 +521,7 @@ HttpProxyUserOptionHandler::HttpProxyUserOptionHandler
void HttpProxyUserOptionHandler::parseArg
(Option& option, const std::string& optarg)
{
const char A2_USER[] = "-user";
static const char A2_USER[] = "-user";
size_t kLen = strlen(pref_->k);
if(util::endsWith(pref_->k, pref_->k+kLen, A2_USER, vend(A2_USER)-1)) {
const Pref* proxyPref = option::k2p(std::string(pref_->k, kLen-5));
@ -565,7 +565,7 @@ HttpProxyPasswdOptionHandler::HttpProxyPasswdOptionHandler
void HttpProxyPasswdOptionHandler::parseArg
(Option& option, const std::string& optarg)
{
const char A2_PASSWD[] = "-passwd";
static const char A2_PASSWD[] = "-passwd";
size_t kLen = strlen(pref_->k);
if(util::endsWith(pref_->k, pref_->k+kLen, A2_PASSWD, vend(A2_PASSWD)-1)) {
const Pref* proxyPref = option::k2p(std::string(pref_->k, kLen-7));
@ -617,9 +617,9 @@ void HttpProxyOptionHandler::parseArg(Option& option, const std::string& optarg)
} else {
Request req;
std::string uri;
const char A2_HTTP[] = "http://";
const char A2_HTTPS[] = "https://";
const char A2_FTP[] = "ftp://";
static const char A2_HTTP[] = "http://";
static const char A2_HTTPS[] = "https://";
static const char A2_FTP[] = "ftp://";
if(util::startsWith(optarg.begin(), optarg.end(),
A2_HTTP, vend(A2_HTTP)-1) ||
util::startsWith(optarg.begin(), optarg.end(),

View File

@ -875,7 +875,7 @@ SharedHandle<TorrentAttribute> parseMagnet(const std::string& magnet)
}
SharedHandle<TorrentAttribute> attrs(new TorrentAttribute());
std::string infoHash;
const char A2_URN_BTIH[] = "urn:btih:";
static const char A2_URN_BTIH[] = "urn:btih:";
for(List::ValueType::const_iterator xtiter = xts->begin(),
eoi = xts->end(); xtiter != eoi && infoHash.empty(); ++xtiter) {
const String* xt = downcast<String>(*xtiter);

View File

@ -545,10 +545,10 @@ decodeGetParams(const std::string& query)
std::vector<Scip> getParams;
util::splitIter(query.begin()+1, query.end(), std::back_inserter(getParams),
'&');
const char A2_METHOD[] = "method=";
const char A2_ID[] = "id=";
const char A2_PARAMS[] = "params=";
const char A2_JSONCB[] = "jsoncallback=";
static const char A2_METHOD[] = "method=";
static const char A2_ID[] = "id=";
static const char A2_PARAMS[] = "params=";
static const char A2_JSONCB[] = "jsoncallback=";
for(std::vector<Scip>::const_iterator i =
getParams.begin(), eoi = getParams.end(); i != eoi; ++i) {
if(util::startsWith((*i).first, (*i).second,

View File

@ -43,7 +43,7 @@ namespace magnet {
SharedHandle<Dict> parse(const std::string& magnet)
{
SharedHandle<Dict> dict;
const char A2_MSGNET[] = "magnet:?";
static const char A2_MSGNET[] = "magnet:?";
if(!util::startsWith(magnet.begin(), magnet.end(),
A2_MSGNET, vend(A2_MSGNET)-1)) {
return dict;

View File

@ -115,7 +115,7 @@ void option_processing(Option& op, std::vector<std::string>& uris,
keyword = TAG_BASIC;
} else {
keyword = op.get(PREF_HELP);
const char A2_HH[] = "--";
static const char A2_HH[] = "--";
if(util::startsWith(keyword.begin(), keyword.end(),
A2_HH, vend(A2_HH)-1)) {
keyword.erase(keyword.begin(), keyword.begin()+2);

View File

@ -638,10 +638,10 @@ void parsePrioritizePieceRange
{
std::vector<size_t> indexes;
std::vector<Scip> parts;
const char A2_HEAD[] = "head";
const char A2_HEADEQ[] = "head=";
const char A2_TAIL[] = "tail";
const char A2_TAILEQ[] = "tail=";
static const char A2_HEAD[] = "head";
static const char A2_HEADEQ[] = "head=";
static const char A2_TAIL[] = "tail";
static const char A2_TAILEQ[] = "tail=";
splitIter(src.begin(), src.end(), std::back_inserter(parts), ',', true);
for(std::vector<Scip>::const_iterator i = parts.begin(),
eoi = parts.end(); i != eoi; ++i) {
@ -736,7 +736,7 @@ void parseParam(OutputIterator out, const std::string& header)
std::string getContentDispositionFilename(const std::string& header)
{
const char A2_KEYNAME[] = "filename";
static const char A2_KEYNAME[] = "filename";
std::string filename;
std::vector<std::string> params;
parseParam(std::back_inserter(params), header);
@ -801,7 +801,7 @@ std::string getContentDispositionFilename(const std::string& header)
}
std::string value =
percentDecode(extValues[2].first, extValues[2].second);
const char A2_ISO88591[] = "iso-8859-1";
static const char A2_ISO88591[] = "iso-8859-1";
if(util::strieq(extValues[0].first, extValues[0].second,
A2_ISO88591, vend(A2_ISO88591)-1)) {
value = iso8859ToUtf8(value);
@ -1282,8 +1282,8 @@ void generateRandomKey(unsigned char* key)
// 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
bool inPrivateAddress(const std::string& ipv4addr)
{
const char A2_IP10[] = "10.";
const char A2_IP192[] = "192.168.";
static const char A2_IP10[] = "10.";
static const char A2_IP192[] = "192.168.";
if(util::startsWith(ipv4addr.begin(), ipv4addr.end(),
A2_IP10, vend(A2_IP10)-1) ||
util::startsWith(ipv4addr.begin(), ipv4addr.end(),
@ -1318,13 +1318,13 @@ bool detectDirTraversal(const std::string& s)
}
}
const char A2_DS[] = "./";
const char A2_DDS[] = "../";
const char A2_SD[] = "/.";
const char A2_SDD[] = "/..";
const char A2_SDDS[] = "/../";
const char A2_SDS[] = "/./";
const char A2_DD[] = "..";
static const char A2_DS[] = "./";
static const char A2_DDS[] = "../";
static const char A2_SD[] = "/.";
static const char A2_SDD[] = "/..";
static const char A2_SDDS[] = "/../";
static const char A2_SDS[] = "/./";
static const char A2_DD[] = "..";
return s == A2STR::DOT_C ||
s == A2_DD ||
@ -1439,7 +1439,7 @@ void executeHook
memset(&pi, 0, sizeof (pi));
const char A2_BAT[] = ".bat";
static const char A2_BAT[] = ".bat";
bool batch = util::iendsWith(command.begin(), command.end(),
A2_BAT, vend(A2_BAT)-1);
std::string cmdline;