From b22604e348aad340152b2370ed7ded405d89aa25 Mon Sep 17 00:00:00 2001 From: Michael Poole Date: Tue, 23 Mar 2004 00:12:53 +0000 Subject: [PATCH] i18n fixes * Fix typos in several message strings, and clarify others. * Typecast first argument of gethostbyaddr() to quash warnings. * Load languages in finalization, not initialization, and do not crash when running off the end of a localized strings.db file. * Show the LANGUAGE option in NickServ SET response. * Remove mention of GHOST command when !enable_ghost. * Only initialize alloc_argc when !defined(NDEBUG) git-archimport-id: srvx@srvx.net--2004-srvx/srvx--devo--1.3--patch-31 --- src/chanserv.c | 16 +++++++++++----- src/gline.c | 2 +- src/helpfile.c | 39 +++++++++++++++++++++++++++------------ src/helpfile.h | 1 + src/main.c | 2 +- src/modcmd.c | 2 +- src/nickserv.c | 4 ++-- src/nickserv.help | 1 - src/proto-common.c | 2 ++ 9 files changed, 46 insertions(+), 23 deletions(-) diff --git a/src/chanserv.c b/src/chanserv.c index 8ad057a..ed5a433 100644 --- a/src/chanserv.c +++ b/src/chanserv.c @@ -236,7 +236,7 @@ static const struct message_entry msgtab[] = { { "CSMSG_MODE_LOCKED", "Modes conflicting with $b%s$b are not allowed in %s." }, { "CSMSG_CANNOT_SET", "That setting is above your current level, so you cannot change it." }, { "CSMSG_OWNER_DEFAULTS", "You must have access 500 in %s to reset it to the default options." }, - { "CSMSG_CONFIRM_DEFAULTS", "To reset %s's settings to the defaults, you muse use 'set defaults %s'." }, + { "CSMSG_CONFIRM_DEFAULTS", "To reset %s's settings to the defaults, you must use 'set defaults %s'." }, { "CSMSG_SETTINGS_DEFAULTED", "All settings for %s have been reset to default values." }, { "CSMSG_BAD_SETLEVEL", "You cannot change any setting to above your level." }, { "CSMSG_BAD_GIVEVOICE", "You cannot change GiveVoice to above GiveOps (%d)." }, @@ -296,8 +296,9 @@ static const struct message_entry msgtab[] = { { "CSMSG_CTCPREACTION_LONGBAN", "Long timed ban on disallowed CTCPs" }, { "CSMSG_INVITED_USER", "Invited $b%s$b to join %s." }, - { "CSMSG_INVITING_YOU", "$b%s$b invites you to join %s%s%s" }, - { "CSMSG_ALREADY_PRESENT", "%s is $balready in %s$b." }, + { "CSMSG_INVITING_YOU_REASON", "$b%s$b invites you to join %s: %s" }, + { "CSMSG_INVITING_YOU", "$b%s$b invites you to join %s." }, + { "CSMSG_ALREADY_PRESENT", "%s is already in $b%s$b." }, { "CSMSG_YOU_ALREADY_PRESENT", "You are already in $b%s$b." }, { "CSMSG_LOW_CHANNEL_ACCESS", "You lack sufficient access in %s to use this command." }, @@ -3743,8 +3744,13 @@ static CHANSERV_FUNC(cmd_invite) if(user != invite) { - char *reason = (argc > 2) ? unsplit_string(argv + 2, argc - 2, NULL) : ""; - send_message(invite, chanserv, "CSMSG_INVITING_YOU", user->nick, channel->name, (argc > 2) ? ": " : ".", reason); + if(argc > 2) + { + char *reason = unsplit_string(argv + 2, argc - 2, NULL); + send_message(invite, chanserv, "CSMSG_INVITING_YOU_REASON", user->nick, channel->name, reason); + } + else + send_message(invite, chanserv, "CSMSG_INVITING_YOU", user->nick, channel->name); } irc_invite(chanserv, invite, channel); if(argc > 1) diff --git a/src/gline.c b/src/gline.c index 3187919..ae8600c 100644 --- a/src/gline.c +++ b/src/gline.c @@ -184,7 +184,7 @@ gline_alternate_target(const char *target) struct in_addr in; struct hostent *he; if (inet_aton(hostname+1, &in) - && (he = gethostbyaddr(&in, sizeof(in), AF_INET))) { + && (he = gethostbyaddr((char*)&in, sizeof(in), AF_INET))) { res = malloc((hostname - target) + 2 + strlen(he->h_name)); sprintf(res, "%.*s@%s", hostname - target, target, he->h_name); return res; diff --git a/src/helpfile.c b/src/helpfile.c index 092045c..b04c783 100644 --- a/src/helpfile.c +++ b/src/helpfile.c @@ -64,6 +64,7 @@ static struct language *language_alloc(const char *name) { struct language *lang = calloc(1, sizeof(*lang)); lang->name = strdup(name); + lang->parent = language_find("C"); if (!languages) { languages = dict_new(); dict_set_free_data(languages, language_free); @@ -108,19 +109,13 @@ static void language_set_messages(struct language *lang, dict_t dict) { dict_iterator_t it, it2; struct record_data *rd; - const char *msgid; char *msg; - int diff, extra, missing; + int extra, missing; extra = missing = 0; - for (it = dict_first(dict), it2 = dict_first(lang_C->messages); it || it2; ) { - msgid = iter_key(it); - if (it && it2) - diff = irccasecmp(msgid, iter_key(it2)); - else if (it) - diff = -1; - else - diff = 1; + for (it = dict_first(dict), it2 = dict_first(lang_C->messages); it; ) { + const char *msgid = iter_key(it); + int diff = it2 ? irccasecmp(msgid, iter_key(it2)) : -1; if (diff < 0) { extra++; it = iter_next(it); @@ -130,7 +125,6 @@ static void language_set_messages(struct language *lang, dict_t dict) it2 = iter_next(it2); continue; } - msgid = iter_key(it); rd = iter_data(it); switch (rd->type) { case RECDB_QSTRING: @@ -142,10 +136,14 @@ static void language_set_messages(struct language *lang, dict_t dict) log_module(MAIN_LOG, LOG_WARNING, "Unsupported record type for message %s in language %s", msgid, lang->name); continue; } - dict_insert(lang->messages, iter_key(it2), msg); + dict_insert(lang->messages, msgid, msg); it = iter_next(it); it2 = iter_next(it2); } + while (it2) { + missing++; + it2 = iter_next(it2); + } log_module(MAIN_LOG, LOG_WARNING, "In language %s, %d extra and %d missing messages", lang->name, extra, missing); } @@ -213,6 +211,18 @@ static struct language *language_read(const char *name) return lang; } +static void language_read_list(void) +{ + struct dirent *dirent; + DIR *dir; + + if (!(dir = opendir("languages"))) + return; + while ((dirent = readdir(dir))) + language_alloc(dirent->d_name); + closedir(dir); +} + static void language_read_all(void) { struct string_list *slist; @@ -994,6 +1004,11 @@ void message_register_table(const struct message_entry *table) void helpfile_init(void) { message_register_table(msgtab); + language_read_list(); +} + +void helpfile_finalize(void) +{ language_read_all(); reg_exit_func(language_cleanup); } diff --git a/src/helpfile.h b/src/helpfile.h index cf0ea6e..d7102ed 100644 --- a/src/helpfile.h +++ b/src/helpfile.h @@ -95,6 +95,7 @@ const char *language_find_message(struct language *lang, const char *msgid); #define handle_find_message(HANDLE, MSGID) language_find_message((HANDLE) ? (HANDLE)->language : lang_C, (MSGID)) #define user_find_message(USER, MSGID) language_find_message((USER)->handle_info ? (USER)->handle_info->language : lang_C, (MSGID)) void helpfile_init(void); +void helpfile_finalize(void); struct helpfile *open_helpfile(const char *fname, expand_func_t expand); void close_helpfile(struct helpfile *hf); diff --git a/src/main.c b/src/main.c index ec92566..997c478 100644 --- a/src/main.c +++ b/src/main.c @@ -84,7 +84,6 @@ static const struct message_entry msgtab[] = { { "MSG_COMMAND_PRIVILEGED", "$b%s$b is a privileged command." }, { "MSG_COMMAND_DISABLED", "$b%s$b is a disabled command." }, { "MSG_SETTING_PRIVILEGED", "$b%s$b is a privileged setting." }, - { "MSG_REGISTER_HANDLE", "You must first register a account with $b$N$b." }, { "MSG_AUTHENTICATE", "You must first authenticate with $b$N$b." }, { "MSG_USER_AUTHENTICATE", "%s must first authenticate with $b$N$b." }, { "MSG_SET_EMAIL_ADDR", "You must first set your account's email address. (Contact network staff if you cannot auth to your account.)" }, @@ -829,6 +828,7 @@ int main(int argc, char *argv[]) message_register_table(msgtab); modcmd_finalize(); saxdb_finalize(); + helpfile_finalize(); modules_finalize(); /* The first exit func to be called *should* be saxdb_write_all(). */ diff --git a/src/modcmd.c b/src/modcmd.c index 27834d7..218c7c0 100644 --- a/src/modcmd.c +++ b/src/modcmd.c @@ -37,7 +37,7 @@ static struct module *modcmd_module; static struct modcmd *bind_command, *help_command, *version_command; static const struct message_entry msgtab[] = { { "MCMSG_VERSION", "$b"PACKAGE_STRING"$b ("CODENAME"), Built: " __DATE__ ", " __TIME__"." }, - { "MCMSG_BARE_FLAG", "Flag %.*s must be preceeded by a + or -." }, + { "MCMSG_BARE_FLAG", "Flag %.*s must be preceded by a + or -." }, { "MCMSG_UNKNOWN_FLAG", "Unknown module flag %.*s." }, { "MCMSG_BAD_OPSERV_LEVEL", "Invalid $O access level %s." }, { "MCMSG_BAD_CHANSERV_LEVEL", "Invalid $C access level %s." }, diff --git a/src/nickserv.c b/src/nickserv.c index bb445d7..a40f743 100644 --- a/src/nickserv.c +++ b/src/nickserv.c @@ -285,7 +285,7 @@ static const struct message_entry msgtab[] = { { "NSEMAIL_EMAIL_CHANGE_BODY_NEW", "This email has been sent to verify that your email address belongs to the same person as account %5$s on %1$s. The SECOND HALF of your cookie is %2$.*6$s.\nTo verify your address as associated with this account, log on to %1$s and type the following command:\n /msg %3$s@%4$s COOKIE %5$s ?????%2$.*6$s\n(Replace the ????? with the FIRST HALF of the cookie, as sent to your OLD email address.)\nIf you did NOT request this email address to be associated with this account, you do not need to do anything. Please contact the %1$s staff if you have questions." }, { "NSEMAIL_EMAIL_CHANGE_BODY_OLD", "This email has been sent to verify that you want to change your email for account %5$s on %1$s from this address to %7$s. The FIRST HALF of your cookie is %2$.*6$s\nTo verify your new address as associated with this account, log on to %1$s and type the following command:\n /msg %3$s@%4$s COOKIE %5$s %2$.*6$s?????\n(Replace the ????? with the SECOND HALF of the cookie, as sent to your NEW email address.)\nIf you did NOT request this change of email address, you do not need to do anything. Please contact the %1$s staff if you have questions." }, { "NSEMAIL_EMAIL_VERIFY_SUBJECT", "Email address verification for %s" }, - { "NSEMAIL_EMAIL_VERIFY_BODY", "This email has been sent to verify that this address belongs to the same person as %5$s on %1$s. Your cookie is %2$s.\nTo verify your address as associated with this account, log on to %1$s and type the following command:\n /msg %3$s@%4$s COOKIE %5$s %1$s\nIf you did NOT request this email address to be associated with this account, you do not need to do anything. Please contact the %1$s staff if you have questions." }, + { "NSEMAIL_EMAIL_VERIFY_BODY", "This email has been sent to verify that this address belongs to the same person as %5$s on %1$s. Your cookie is %2$s.\nTo verify your address as associated with this account, log on to %1$s and type the following command:\n /msg %3$s@%4$s COOKIE %5$s %2$s\nIf you did NOT request this email address to be associated with this account, you do not need to do anything. Please contact the %1$s staff if you have questions." }, { "NSEMAIL_ALLOWAUTH_SUBJECT", "Authentication allowed for %s" }, { "NSEMAIL_ALLOWAUTH_BODY", "This email has been sent to let you authenticate (auth) to account %5$s on %1$s. Your cookie is %2$s.\nTo auth to that account, log on to %1$s and type the following command:\n /msg %3$s@%4$s COOKIE %5$s %1$s\nIf you did NOT request this authorization, you do not need to do anything. Please contact the %1$s staff if you have questions." }, { "CHECKPASS_YES", "Yes." }, @@ -2019,7 +2019,7 @@ set_list(struct userNode *user, struct handle_info *hi, int override) unsigned int i; char *set_display[] = { "INFO", "WIDTH", "TABLEWIDTH", "COLOR", "PRIVMSG", "STYLE", - "EMAIL", "ANNOUNCEMENTS", "MAXLOGINS" + "EMAIL", "ANNOUNCEMENTS", "MAXLOGINS", "LANGUAGE" }; send_message(user, nickserv, "NSMSG_SETTING_LIST"); diff --git a/src/nickserv.help b/src/nickserv.help index 7a08b33..b4b8a31 100644 --- a/src/nickserv.help +++ b/src/nickserv.help @@ -71,7 +71,6 @@ " SET Set per-account options.", " UNREGISTER Unregister an account.", " RENAME Renames an account", - " GHOST Disconnects your old clients", " ACCOUNT FLAGS Definition for each account flag" ); }; diff --git a/src/proto-common.c b/src/proto-common.c index c558af1..3fcadd7 100644 --- a/src/proto-common.c +++ b/src/proto-common.c @@ -522,7 +522,9 @@ mod_chanmode_alloc(unsigned int argc) else res = calloc(1, sizeof(*res)); if (res) { +#if !defined(NDEBUG) res->alloc_argc = argc; +#endif res->argc = argc; } return res; -- 2.20.1