i18n fixes
authorMichael Poole <mdpoole@troilus.org>
Tue, 23 Mar 2004 00:12:53 +0000 (00:12 +0000)
committerMichael Poole <mdpoole@troilus.org>
Tue, 23 Mar 2004 00:12:53 +0000 (00:12 +0000)
* 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
src/gline.c
src/helpfile.c
src/helpfile.h
src/main.c
src/modcmd.c
src/nickserv.c
src/nickserv.help
src/proto-common.c

index 8ad057af26ba089d123e4f2c041adbf4321582b4..ed5a433b867517b679852fce0c6412be88b57ce8 100644 (file)
@@ -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)
index 318791991f63afd686ed8fa2d6d155957e9aeb91..ae8600c94c81587a901138b6eec745de3a35159c 100644 (file)
@@ -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;
index 092045c5951a146b432748ae837a2535d7b3c8c2..b04c7838b28f42355c064ca6aa590cac7e39ff6f 100644 (file)
@@ -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);
 }
index cf0ea6e267f7a719cc011e95c9cfef7c606e29a4..d7102ed4534730d92aa226ac7831cda7059a1e0e 100644 (file)
@@ -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);
index ec925665e956d64956f817d0e1ea9c59b46d7ea9..997c4786d0786c268f8a4cb73c96ce2a1031263f 100644 (file)
@@ -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(). */
index 27834d7d9edb91f38ac002971ee4abf050ed3d96..218c7c0f436d7d8af02f62edbde78c8ca439114e 100644 (file)
@@ -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." },
index bb445d739a7a70561f26b0837675e0ee3e8df232..a40f743b731d594ed2d304f2b2f0f5447b268c7c 100644 (file)
@@ -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");
index 7a08b33d39c6156c0b5540f0447961ea06e97fcb..b4b8a316717449183f5a24467224325c9aead1ea 100644 (file)
@@ -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"
         );
 };
index c558af1c2b2fb3ad29a1d3e121d0275422f0341a..3fcadd7b5c0b3f2fcd13ec3b26897e8f2e46f879 100644 (file)
@@ -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;