mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-11 11:39:02 -04:00
Merge pull request #1058 from SaberUK/insp20+nationalchars
[2.0] Fix various issues with the nationalchars module.
This commit is contained in:
commit
77b5bd0dbc
@ -1148,10 +1148,13 @@
|
|||||||
# 2) Allows using custom (national) casemapping over the network.
|
# 2) Allows using custom (national) casemapping over the network.
|
||||||
#<module name="m_nationalchars.so">
|
#<module name="m_nationalchars.so">
|
||||||
#
|
#
|
||||||
# file - filename of existing file in "locales" directory
|
# file - Location of the file which contains casemapping rules. If this
|
||||||
# casemapping - custom value for 005 numeric (if you want it to be
|
# is a relative path then it is relative to "<PWD>/../locales"
|
||||||
# different from the filename). Set this to the name of
|
# on UNIX and "<PWD>/locales" on Windows.
|
||||||
# the locale if you are specifying an absolute path.
|
# casemapping - The name of the casemapping sent to clients in the 005
|
||||||
|
# numeric. If this is not set then it defaults to the name
|
||||||
|
# of the casemapping file unless the file name contains a
|
||||||
|
# space in which case you will have to specify it manually.
|
||||||
#<nationalchars file="bynets/russian-w1251-charlink" casemapping="ru_RU.cp1251-charlink">
|
#<nationalchars file="bynets/russian-w1251-charlink" casemapping="ru_RU.cp1251-charlink">
|
||||||
|
|
||||||
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#
|
||||||
|
@ -284,11 +284,19 @@ class ModuleNationalChars : public Module
|
|||||||
{
|
{
|
||||||
ConfigTag* tag = ServerInstance->Config->ConfValue("nationalchars");
|
ConfigTag* tag = ServerInstance->Config->ConfValue("nationalchars");
|
||||||
charset = tag->getString("file");
|
charset = tag->getString("file");
|
||||||
casemapping = tag->getString("casemapping", charset);
|
casemapping = tag->getString("casemapping", ServerConfig::CleanFilename(charset.c_str()));
|
||||||
|
if (casemapping.find(' ') != std::string::npos)
|
||||||
|
throw ModuleException("<nationalchars:casemapping> must not contain any spaces!");
|
||||||
|
#if defined _WIN32
|
||||||
|
if (!ServerInstance->Config->StartsWithWindowsDriveLetter(charset))
|
||||||
|
charset.insert(0, "./locales/");
|
||||||
|
#else
|
||||||
if(charset[0] != '/')
|
if(charset[0] != '/')
|
||||||
charset.insert(0, "../locales/");
|
charset.insert(0, "../locales/");
|
||||||
|
#endif
|
||||||
unsigned char * tables[8] = { m_additional, m_additionalMB, m_additionalUp, m_lower, m_upper, m_additionalUtf8, m_additionalUtf8range, m_additionalUtf8interval };
|
unsigned char * tables[8] = { m_additional, m_additionalMB, m_additionalUp, m_lower, m_upper, m_additionalUtf8, m_additionalUtf8range, m_additionalUtf8interval };
|
||||||
loadtables(charset, tables, 8, 5);
|
if (!loadtables(charset, tables, 8, 5))
|
||||||
|
throw ModuleException("The locale file failed to load. Check your log file for more information.");
|
||||||
forcequit = tag->getBool("forcequit");
|
forcequit = tag->getBool("forcequit");
|
||||||
CheckForceQuit("National character set changed");
|
CheckForceQuit("National character set changed");
|
||||||
CheckRehash();
|
CheckRehash();
|
||||||
@ -330,13 +338,13 @@ class ModuleNationalChars : public Module
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*so Bynets Unreal distribution stuff*/
|
/*so Bynets Unreal distribution stuff*/
|
||||||
void loadtables(std::string filename, unsigned char ** tables, unsigned char cnt, char faillimit)
|
bool loadtables(std::string filename, unsigned char ** tables, unsigned char cnt, char faillimit)
|
||||||
{
|
{
|
||||||
std::ifstream ifs(filename.c_str());
|
std::ifstream ifs(filename.c_str());
|
||||||
if (ifs.fail())
|
if (ifs.fail())
|
||||||
{
|
{
|
||||||
ServerInstance->Logs->Log("m_nationalchars",DEFAULT,"loadtables() called for missing file: %s", filename.c_str());
|
ServerInstance->Logs->Log("m_nationalchars",DEFAULT,"loadtables() called for missing file: %s", filename.c_str());
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned char n=0; n< cnt; n++)
|
for (unsigned char n=0; n< cnt; n++)
|
||||||
@ -351,11 +359,12 @@ class ModuleNationalChars : public Module
|
|||||||
if (loadtable(ifs, tables[n], 255) && (n < faillimit))
|
if (loadtable(ifs, tables[n], 255) && (n < faillimit))
|
||||||
{
|
{
|
||||||
ServerInstance->Logs->Log("m_nationalchars",DEFAULT,"loadtables() called for illegal file: %s (line %d)", filename.c_str(), n+1);
|
ServerInstance->Logs->Log("m_nationalchars",DEFAULT,"loadtables() called for illegal file: %s (line %d)", filename.c_str(), n+1);
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
makereverse(m_additional, m_reverse_additional, sizeof(m_additional));
|
makereverse(m_additional, m_reverse_additional, sizeof(m_additional));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char symtoi(const char *t,unsigned char base)
|
unsigned char symtoi(const char *t,unsigned char base)
|
||||||
|
@ -74,6 +74,10 @@ install(FILES ${EXTRA_DLLS} DESTINATION .)
|
|||||||
file(GLOB_RECURSE EXAMPLE_CONFIGS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${INSPIRCD_BASE}/docs/conf/*.example")
|
file(GLOB_RECURSE EXAMPLE_CONFIGS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${INSPIRCD_BASE}/docs/conf/*.example")
|
||||||
install(FILES ${EXAMPLE_CONFIGS} DESTINATION conf)
|
install(FILES ${EXAMPLE_CONFIGS} DESTINATION conf)
|
||||||
|
|
||||||
|
# Install nationalchars files
|
||||||
|
file(GLOB_RECURSE EXAMPLE_LOCALES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${INSPIRCD_BASE}/locales/*")
|
||||||
|
install(FILES ${EXAMPLE_LOCALES} DESTINATION locales)
|
||||||
|
|
||||||
# Create an empty data and logs directory and install them
|
# Create an empty data and logs directory and install them
|
||||||
file(MAKE_DIRECTORY ${DATA_PATH})
|
file(MAKE_DIRECTORY ${DATA_PATH})
|
||||||
install(DIRECTORY ${DATA_PATH} DESTINATION .)
|
install(DIRECTORY ${DATA_PATH} DESTINATION .)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user