mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-04 17:31:15 +00:00
Removed unsafe code from language.cpp.
This commit is contained in:
parent
94b7d3b867
commit
87b27facc0
@ -1008,6 +1008,29 @@ std::string get_binary_file_location(const std::string& type, const std::string&
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string get_binary_dir_location(const std::string &type, const std::string &filename)
|
||||
{
|
||||
LOG_FS << "Looking for '" << filename << "'.\n";
|
||||
|
||||
if (filename.empty()) {
|
||||
LOG_FS << " invalid filename (type: " << type <<")\n";
|
||||
return std::string();
|
||||
}
|
||||
|
||||
foreach (const std::string &path, get_binary_paths(type))
|
||||
{
|
||||
const std::string file = path + filename;
|
||||
DBG_FS << " checking '" << path << "'\n";
|
||||
if (is_directory(file)) {
|
||||
LOG_FS << " found at '" << file << "'\n";
|
||||
return file;
|
||||
}
|
||||
}
|
||||
|
||||
LOG_FS << " not found\n";
|
||||
return std::string();
|
||||
}
|
||||
|
||||
std::string get_wml_location(const std::string &filename, const std::string ¤t_dir)
|
||||
{
|
||||
LOG_FS << "Looking for '" << filename << "'.\n";
|
||||
|
@ -208,6 +208,12 @@ const std::vector<std::string>& get_binary_paths(const std::string& type);
|
||||
*/
|
||||
std::string get_binary_file_location(const std::string& type, const std::string& filename);
|
||||
|
||||
/**
|
||||
* Returns a complete path to the actual directory of a given @a type
|
||||
* or an empty string if the directory isn't present.
|
||||
*/
|
||||
std::string get_binary_dir_location(const std::string &type, const std::string &filename);
|
||||
|
||||
/**
|
||||
* Returns a complete path to the actual WML file or directory
|
||||
* or an empty string if the file isn't present.
|
||||
|
@ -395,26 +395,14 @@ void init_textdomains(const config& cfg)
|
||||
if(path.empty()) {
|
||||
t_string::add_textdomain(name, get_intl_dir());
|
||||
} else {
|
||||
//This is adapted version from a call to get_binary_file_location()
|
||||
DBG_FS << " Looking for textdomain path" << path << "\n";
|
||||
std::string location;
|
||||
|
||||
const std::vector<std::string>& paths = get_binary_paths(path);
|
||||
for(std::vector<std::string>::const_iterator i = paths.begin(); i != paths.end(); ++i) {
|
||||
const std::string loc = *i + "/" + path;
|
||||
DBG_FS << " Checking " << loc << "\n";
|
||||
if(is_directory(loc)) {
|
||||
location = loc;
|
||||
break;
|
||||
}
|
||||
}
|
||||
std::string location = get_binary_dir_location(path, path);
|
||||
|
||||
if (location.empty()) {
|
||||
//if location is empty, this causes a crash on Windows, so we
|
||||
//disallow adding empty domains
|
||||
std::cerr << "no location found for '" << path << "', not adding textdomain\n";
|
||||
LOG_STREAM(err, general) << "no location found for '" << path
|
||||
<< "', not adding textdomain\n";
|
||||
} else {
|
||||
DBG_FS << " Found at " << location << "\n";
|
||||
t_string::add_textdomain(name, location);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user