From 7c35343da7560526167650c90fb58872d098e8ef Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 15 Dec 2013 21:27:25 +0000 Subject: [PATCH] [loc] add support for Locale registry setting * Closes #246 * Also bump version --- configure | 20 ++++++++++---------- configure.ac | 2 +- src/registry.h | 2 ++ src/rufus.c | 13 +++++++++++-- src/rufus.rc | 10 +++++----- 5 files changed, 29 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 616f166c..3e9c6ee7 100644 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for rufus 1.4.1. +# Generated by GNU Autoconf 2.68 for rufus 1.4.2. # # Report bugs to . # @@ -560,8 +560,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='rufus' PACKAGE_TARNAME='rufus' -PACKAGE_VERSION='1.4.1' -PACKAGE_STRING='rufus 1.4.1' +PACKAGE_VERSION='1.4.2' +PACKAGE_STRING='rufus 1.4.2' PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues' PACKAGE_URL='http://rufus.akeo.ie' @@ -1203,7 +1203,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures rufus 1.4.1 to adapt to many kinds of systems. +\`configure' configures rufus 1.4.2 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1269,7 +1269,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of rufus 1.4.1:";; + short | recursive ) echo "Configuration of rufus 1.4.2:";; esac cat <<\_ACEOF @@ -1357,7 +1357,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -rufus configure 1.4.1 +rufus configure 1.4.2 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1412,7 +1412,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by rufus $as_me 1.4.1, which was +It was created by rufus $as_me 1.4.2, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -2227,7 +2227,7 @@ fi # Define the identity of the package. PACKAGE='rufus' - VERSION='1.4.1' + VERSION='1.4.2' cat >>confdefs.h <<_ACEOF @@ -4140,7 +4140,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by rufus $as_me 1.4.1, which was +This file was extended by rufus $as_me 1.4.2, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4194,7 +4194,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -rufus config.status 1.4.1 +rufus config.status 1.4.2 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index 29d9b0c8..8811439e 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([rufus], [1.4.1], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie]) +AC_INIT([rufus], [1.4.2], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie]) AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies]) AC_CONFIG_SRCDIR([src/rufus.c]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/src/registry.h b/src/registry.h index c537dc24..d467eef9 100644 --- a/src/registry.h +++ b/src/registry.h @@ -38,6 +38,7 @@ extern "C" { #define REGKEY_UPDATE_INTERVAL "UpdateCheckInterval" #define REGKEY_INCLUDE_BETAS "CheckForBetas" #define REGKEY_COMM_CHECK "CommCheck" +#define REGKEY_LOCALE "Locale" /* Delete a registry key from \Software and all its values If the key has subkeys, this call will fail. */ @@ -168,6 +169,7 @@ static __inline BOOL WriteRegistryKey32(HKEY root, const char* key, int32_t val) // Use a static buffer - don't allocate static __inline char* ReadRegistryKeyStr(HKEY root, const char* key) { static char str[512]; + str[0] = 0; _GetRegistryKey(root, key, REG_SZ, (LPBYTE)str, (DWORD)sizeof(str)-1); return str; } diff --git a/src/rufus.c b/src/rufus.c index 4b841042..8f2503e5 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -2001,7 +2001,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine BOOL attached_console = FALSE, external_loc_file = FALSE; BYTE* loc_data; DWORD loc_size, Size; - char tmp_path[MAX_PATH], loc_file[MAX_PATH] = "", *locale_name = NULL; + char tmp_path[MAX_PATH], loc_file[MAX_PATH] = "", *tmp, *locale_name = NULL; char** argv = NULL; wchar_t **wenv, **wargv; PF_DECL(__wgetmainargs); @@ -2028,6 +2028,13 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine printf("\n"); } + // Use the Locale specified in the registry, if any + tmp = ReadRegistryKeyStr(REGKEY_HKCU, REGKEY_LOCALE); + if (tmp[0] != 0) { + locale_name = safe_strdup(tmp); + uprintf("found registry locale '%s'", locale_name); + } + // We have to process the arguments before we acquire the lock and process the locale PF_INIT(__wgetmainargs, msvcrt); if (pf__wgetmainargs != NULL) { @@ -2057,7 +2064,8 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine if (isdigitU(optarg[0])) { lcid = (int)strtol(optarg, NULL, 0); } else { - locale_name = optarg; + safe_free(locale_name); + locale_name =safe_strdup(optarg); } break; case 'w': @@ -2252,6 +2260,7 @@ out: DestroyAllTooltips(); exit_localization(); safe_free(iso_path); + safe_free(locale_name); safe_free(update.download_url); safe_free(update.release_notes); if (argv != NULL) { diff --git a/src/rufus.rc b/src/rufus.rc index 88cde682..18d59539 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 206, 329 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_APPWINDOW -CAPTION "Rufus v1.4.1.354" +CAPTION "Rufus v1.4.2.355" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Start",IDC_START,94,291,50,14 @@ -288,8 +288,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,4,1,354 - PRODUCTVERSION 1,4,1,354 + FILEVERSION 1,4,2,355 + PRODUCTVERSION 1,4,2,355 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -306,13 +306,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.4.1.354" + VALUE "FileVersion", "1.4.2.355" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2013 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "1.4.1.354" + VALUE "ProductVersion", "1.4.2.355" END END BLOCK "VarFileInfo"