put local functions into unnamed namespaces

This commit is contained in:
unK
2008-09-27 20:54:32 +02:00
parent d61cb54653
commit 9b65b39126
7 changed files with 229 additions and 222 deletions

View File

@@ -23,8 +23,10 @@
extern ncmpcpp_keys Key; extern ncmpcpp_keys Key;
string DisplayKeys(int *key, int size = 2) namespace
{ {
string DisplayKeys(int *key, int size = 2)
{
bool backspace = 1; bool backspace = 1;
string result = "\t"; string result = "\t";
for (int i = 0; i < size; i++) for (int i = 0; i < size; i++)
@@ -79,6 +81,7 @@ string DisplayKeys(int *key, int size = 2)
for (int i = result.length(); i <= 12; result += " ", i++); for (int i = result.length(); i <= 12; result += " ", i++);
result += ": "; result += ": ";
return result; return result;
}
} }
string GetKeybindings() string GetKeybindings()

View File

@@ -32,8 +32,10 @@ pthread_mutex_t curl = PTHREAD_MUTEX_INITIALIZER;
bool data_ready = 0; bool data_ready = 0;
#endif #endif
size_t write_data(char *buffer, size_t size, size_t nmemb, string data) namespace
{ {
size_t write_data(char *buffer, size_t size, size_t nmemb, string data)
{
int result = 0; int result = 0;
if (buffer) if (buffer)
{ {
@@ -41,10 +43,10 @@ size_t write_data(char *buffer, size_t size, size_t nmemb, string data)
result = size*nmemb; result = size*nmemb;
} }
return result; return result;
} }
void EscapeHtml(string &str) void EscapeHtml(string &str)
{ {
for (int i = str.find("<"); i != string::npos; i = str.find("<")) for (int i = str.find("<"); i != string::npos; i = str.find("<"))
{ {
int j = str.find(">")+1; int j = str.find(">")+1;
@@ -56,6 +58,7 @@ void EscapeHtml(string &str)
str.replace(i, 6, "\""); str.replace(i, 6, "\"");
for (int i = str.find("&amp;"); i != string::npos; i = str.find("&amp;")) for (int i = str.find("&amp;"); i != string::npos; i = str.find("&amp;"))
str.replace(i, 5, "&"); str.replace(i, 5, "&");
}
} }
#ifdef HAVE_CURL_CURL_H #ifdef HAVE_CURL_CURL_H

View File

@@ -30,7 +30,6 @@
void * GetArtistInfo(void *); void * GetArtistInfo(void *);
#endif #endif
void EscapeHtml(string &);
void * GetLyrics(void *); void * GetLyrics(void *);
#endif #endif

View File

@@ -197,29 +197,6 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.message_delay_time = 4; conf.message_delay_time = 4;
} }
void GetKeys(string line, int *key)
{
int i = line.find("=")+1;
line = line.substr(i, line.length()-i);
i = 0;
if (line[i] == ' ')
while (line[++i] == ' ');
line = line.substr(i, line.length()-i);
i = line.find(" ");
string one;
string two;
if (i != string::npos)
{
one = line.substr(0, i);
i++;
two = line.substr(i, line.length()-i);
}
else
one = line;
key[0] = !one.empty() && one[0] == '\'' ? one[1] : (atoi(one.c_str()) == 0 ? null_key : atoi(one.c_str()));
key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str()));
}
string GetLineValue(const string &line, char a, char b) string GetLineValue(const string &line, char a, char b)
{ {
int i = 0; int i = 0;
@@ -240,8 +217,33 @@ string GetLineValue(const string &line, char a, char b)
return ""; return "";
} }
string IntoStr(Color color) namespace
{ {
void GetKeys(string line, int *key)
{
int i = line.find("=")+1;
line = line.substr(i, line.length()-i);
i = 0;
if (line[i] == ' ')
while (line[++i] == ' ');
line = line.substr(i, line.length()-i);
i = line.find(" ");
string one;
string two;
if (i != string::npos)
{
one = line.substr(0, i);
i++;
two = line.substr(i, line.length()-i);
}
else
one = line;
key[0] = !one.empty() && one[0] == '\'' ? one[1] : (atoi(one.c_str()) == 0 ? null_key : atoi(one.c_str()));
key[1] = !two.empty() && two[0] == '\'' ? two[1] : (atoi(two.c_str()) == 0 ? null_key : atoi(two.c_str()));
}
string IntoStr(Color color)
{
string result; string result;
if (color == clDefault) if (color == clDefault)
@@ -264,10 +266,10 @@ string IntoStr(Color color)
result = "white"; result = "white";
return result; return result;
} }
Color IntoColor(const string &color) Color IntoColor(const string &color)
{ {
Color result = clDefault; Color result = clDefault;
if (color == "black") if (color == "black")
@@ -288,6 +290,7 @@ Color IntoColor(const string &color)
result = clWhite; result = clWhite;
return result; return result;
}
} }
void ReadKeys(ncmpcpp_keys &keys) void ReadKeys(ncmpcpp_keys &keys)

View File

@@ -147,12 +147,10 @@ struct ncmpcpp_config
void DefaultKeys(ncmpcpp_keys &); void DefaultKeys(ncmpcpp_keys &);
void DefaultConfiguration(ncmpcpp_config &); void DefaultConfiguration(ncmpcpp_config &);
void GetKeys(string, int *);
string GetLineValue(const string &, char = '"', char = '"');
string IntoStr(Color);
Color IntoColor(const string &);
void ReadKeys(ncmpcpp_keys &); void ReadKeys(ncmpcpp_keys &);
void ReadConfiguration(ncmpcpp_config &); void ReadConfiguration(ncmpcpp_config &);
string GetLineValue(const string &, char = '"', char = '"');
#endif #endif

View File

@@ -189,8 +189,10 @@ bool WriteTags(Song &s)
return false; return false;
} }
SongSetFunction IntoSetFunction(char c) namespace
{ {
SongSetFunction IntoSetFunction(char c)
{
switch (c) switch (c)
{ {
case 'a': case 'a':
@@ -216,10 +218,10 @@ SongSetFunction IntoSetFunction(char c)
default: default:
return NULL; return NULL;
} }
} }
string GenerateFilename(const Song &s, string &pattern) string GenerateFilename(const Song &s, string &pattern)
{ {
const string unallowed_chars = "\"*/:<>?\\|"; const string unallowed_chars = "\"*/:<>?\\|";
string result = Window::OmitBBCodes(DisplaySong(s, &pattern)); string result = Window::OmitBBCodes(DisplaySong(s, &pattern));
for (string::const_iterator it = unallowed_chars.begin(); it != unallowed_chars.end(); it++) for (string::const_iterator it = unallowed_chars.begin(); it != unallowed_chars.end(); it++)
@@ -231,10 +233,10 @@ string GenerateFilename(const Song &s, string &pattern)
} }
} }
return result; return result;
} }
string ParseFilename(Song &s, string mask, bool preview) string ParseFilename(Song &s, string mask, bool preview)
{ {
std::stringstream result; std::stringstream result;
vector<string> separators; vector<string> separators;
vector< std::pair<char, string> > tags; vector< std::pair<char, string> > tags;
@@ -281,6 +283,7 @@ string ParseFilename(Song &s, string mask, bool preview)
result << "%" << it->first << ": " << it->second << "\n"; result << "%" << it->first << ": " << it->second << "\n";
} }
return result.str(); return result.str();
}
} }
void __deal_with_filenames(SongList &v) void __deal_with_filenames(SongList &v)

View File

@@ -41,8 +41,6 @@ string DisplayTag(const Song &, void *, const Menu<Song> *);
bool GetSongTags(Song &); bool GetSongTags(Song &);
bool WriteTags(Song &); bool WriteTags(Song &);
string GenerateFilename(const Song &, string &);
string ParseFilename(Song &, string, bool);
void __deal_with_filenames(SongList &); void __deal_with_filenames(SongList &);
#endif #endif