changeset 10330:4f5a7ddd3161

[gaim-migrate @ 11537] Get rid of 3 goto's. Can someone please let me know if this doesn't compile? Herman, I hope this changes are ok with you... if not, feel free to revert it. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 09 Dec 2004 00:24:30 +0000
parents 0ad82da3ffcf
children 20df7dd1c57c
files src/win_gaim.c
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/win_gaim.c	Thu Dec 09 00:04:39 2004 +0000
+++ b/src/win_gaim.c	Thu Dec 09 00:24:30 2004 +0000
@@ -216,29 +216,33 @@
    - Check NSIS Installer Language reg value
    - Use default user locale
 */
-static void wgaim_set_locale() {
+static const char* wgaim_get_locale() {
+        const char* locale=NULL;
         char data[10];
         DWORD datalen = 10;
-        char* locale=NULL;
-        char envstr[25];
         LCID lcid;
 
         /* Check if user set GAIMLANG env var */
-        if((locale = (char*)getenv("GAIMLANG")))
-                goto finish;
+        if((locale = getenv("GAIMLANG")))
+                return locale;
 
         if(read_reg_string(HKEY_CURRENT_USER, "SOFTWARE\\gaim", "Installer Language", (LPBYTE)&data, &datalen)) {
                 if((locale = wgaim_lcid_to_posix(atoi(data))))
-                        goto finish;
+                        return locale;
         }
 
         lcid = GetUserDefaultLCID();
         if((locale = wgaim_lcid_to_posix(lcid)))
-                goto finish;
+                return locale;
+
+		return "en";
+}
 
-        finish:
-        if(!locale)
-                locale = "en";
+static void wgaim_set_locale() {
+        const char* locale=NULL;
+        char envstr[25];
+
+        locale = wgaim_get_locale();
 
         snprintf(envstr, 25, "LANG=%s", locale);
         printf("Setting locale: %s\n", envstr);