put local functions into unnamed namespaces

master
unK 18 years ago
parent d61cb54653
commit 9b65b39126
  1. 5
      src/help.cpp
  2. 11
      src/lyrics.cpp
  3. 1
      src/lyrics.h
  4. 55
      src/settings.cpp
  5. 6
      src/settings.h
  6. 17
      src/tag_editor.cpp
  7. 2
      src/tag_editor.h

@ -23,8 +23,10 @@
extern ncmpcpp_keys Key;
string DisplayKeys(int *key, int size = 2)
namespace
{
string DisplayKeys(int *key, int size = 2)
{
bool backspace = 1;
string result = "\t";
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++);
result += ": ";
return result;
}
}
string GetKeybindings()

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

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

@ -197,8 +197,30 @@ void DefaultConfiguration(ncmpcpp_config &conf)
conf.message_delay_time = 4;
}
void GetKeys(string line, int *key)
string GetLineValue(const string &line, char a, char b)
{
int i = 0;
int begin = -1, end = -1;
for (string::const_iterator it = line.begin(); it != line.end(); i++, it++)
{
if (*it == a || *it == b)
{
if (begin < 0)
begin = i+1;
else
end = i;
}
}
if (begin >= 0 && end >= 0)
return line.substr(begin, end-begin);
else
return "";
}
namespace
{
void GetKeys(string line, int *key)
{
int i = line.find("=")+1;
line = line.substr(i, line.length()-i);
i = 0;
@ -218,30 +240,10 @@ void GetKeys(string line, int *key)
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)
{
int i = 0;
int begin = -1, end = -1;
for (string::const_iterator it = line.begin(); it != line.end(); i++, it++)
{
if (*it == a || *it == b)
{
if (begin < 0)
begin = i+1;
else
end = i;
}
}
if (begin >= 0 && end >= 0)
return line.substr(begin, end-begin);
else
return "";
}
string IntoStr(Color color)
{
string IntoStr(Color color)
{
string result;
if (color == clDefault)
@ -264,10 +266,10 @@ string IntoStr(Color color)
result = "white";
return result;
}
}
Color IntoColor(const string &color)
{
Color IntoColor(const string &color)
{
Color result = clDefault;
if (color == "black")
@ -288,6 +290,7 @@ Color IntoColor(const string &color)
result = clWhite;
return result;
}
}
void ReadKeys(ncmpcpp_keys &keys)

@ -147,12 +147,10 @@ struct ncmpcpp_config
void DefaultKeys(ncmpcpp_keys &);
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 ReadConfiguration(ncmpcpp_config &);
string GetLineValue(const string &, char = '"', char = '"');
#endif

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

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

Loading…
Cancel
Save