aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/DatabaseSave.cxx11
-rw-r--r--src/fs/Charset.cxx4
-rw-r--r--src/fs/Charset.hxx2
3 files changed, 8 insertions, 9 deletions
diff --git a/src/DatabaseSave.cxx b/src/DatabaseSave.cxx
index 67df236ef..b7077b413 100644
--- a/src/DatabaseSave.cxx
+++ b/src/DatabaseSave.cxx
@@ -56,8 +56,7 @@ db_save_internal(FILE *fp, const Directory *music_root)
fprintf(fp, "%s\n", DIRECTORY_INFO_BEGIN);
fprintf(fp, DB_FORMAT_PREFIX "%u\n", DB_FORMAT);
fprintf(fp, "%s%s\n", DIRECTORY_MPD_VERSION, VERSION);
- fprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET,
- GetFSCharset().c_str());
+ fprintf(fp, "%s%s\n", DIRECTORY_FS_CHARSET, GetFSCharset());
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
if (!ignore_tag_items[i])
@@ -110,14 +109,14 @@ db_load_internal(TextFile &file, Directory *music_root, Error &error)
found_charset = true;
new_charset = line + sizeof(DIRECTORY_FS_CHARSET) - 1;
- const std::string &old_charset = GetFSCharset();
- if (!old_charset.empty()
- && strcmp(new_charset, old_charset.c_str())) {
+ const char *const old_charset = GetFSCharset();
+ if (*old_charset != 0
+ && strcmp(new_charset, old_charset) != 0) {
error.Format(db_domain,
"Existing database has charset "
"\"%s\" instead of \"%s\"; "
"discarding database file",
- new_charset, old_charset.c_str());
+ new_charset, old_charset);
return false;
}
} else if (g_str_has_prefix(line, DB_TAG_PREFIX)) {
diff --git a/src/fs/Charset.cxx b/src/fs/Charset.cxx
index 3e324f470..39bb36e77 100644
--- a/src/fs/Charset.cxx
+++ b/src/fs/Charset.cxx
@@ -70,10 +70,10 @@ SetFSCharset(const char *charset)
"SetFSCharset: fs charset is: %s", fs_charset.c_str());
}
-const std::string &
+const char *
GetFSCharset()
{
- return fs_charset;
+ return fs_charset.empty() ? "utf-8" : fs_charset.c_str();
}
std::string
diff --git a/src/fs/Charset.hxx b/src/fs/Charset.hxx
index 19dabeb2b..a89cb0459 100644
--- a/src/fs/Charset.hxx
+++ b/src/fs/Charset.hxx
@@ -29,7 +29,7 @@
* Gets file system character set name.
*/
gcc_const
-const std::string &
+const char *
GetFSCharset();
void