# HG changeset patch # User ali # Date 1382301111 -3600 # Node ID a4658f2df227532609f212d8b8aab6ca6cd72c9c # Parent 6ed7afd99ea9d8c2640f8703190b734793d84862 Bugs #13+14: charsets in configuration files diff -r 6ed7afd99ea9 -r a4658f2df227 bookloupe/bookloupe.c --- a/bookloupe/bookloupe.c Sun Oct 20 21:29:06 2013 +0100 +++ b/bookloupe/bookloupe.c Sun Oct 20 21:31:51 2013 +0100 @@ -268,11 +268,55 @@ UINT saved_cp; #endif +gboolean set_charset(const char *name,GError **err) +{ + /* The various UNICODE encodings all share the same character set. */ + const char *unicode_aliases[]={ "UCS-2", "UCS-2BE", "UCS-2LE", "UCS-4", + "UCS-4BE", "UCS-4LE", "UCS2", "UCS4", "UNICODE", "UNICODEBIG", + "UNICODELITTLE", "UTF-7", "UTF-8", "UTF-16", "UTF-16BE", "UTF-16LE", + "UTF-32", "UTF-32BE", "UTF-32LE", "UTF7", "UTF8", "UTF16", "UTF16BE", + "UTF16LE", "UTF32", "UTF32BE", "UTF32LE" }; + int i; + if (charset) + g_free(charset); + if (charset_validator!=(GIConv)-1) + g_iconv_close(charset_validator); + if (!name || !g_strcasecmp(name,"auto")) + { + charset=NULL; + charset_validator=(GIConv)-1; + return TRUE; + } + else + charset=g_strdup(name); + for(i=0;imessage); g_clear_error(&err); } - if (options[j].flags&G_OPTION_FLAG_REVERSE) - sw=!sw; - *(gboolean *)options[j].arg_data=sw; + else + { + if (options[j].flags&G_OPTION_FLAG_REVERSE) + sw=!sw; + *(gboolean *)options[j].arg_data=sw; + } + break; + } + else if (options[j].arg==G_OPTION_ARG_STRING) + { + s=g_key_file_get_string(config,"options",keys[i], + &err); + if (err) + { + g_printerr("Bookloupe: %s: options.%s: %s\n", + path,keys[i],err->message); + g_clear_error(&err); + } + else + { + g_free(*(gchar **)options[j].arg_data); + if (!g_strcmp0(s,"auto")) + { + *(gchar **)options[j].arg_data=NULL; + g_free(s); + } + else + *(gchar **)options[j].arg_data=s; + } break; } else @@ -429,49 +506,6 @@ g_free(path); } -gboolean set_charset(const char *name,GError **err) -{ - /* The various UNICODE encodings all share the same character set. */ - const char *unicode_aliases[]={ "UCS-2", "UCS-2BE", "UCS-2LE", "UCS-4", - "UCS-4BE", "UCS-4LE", "UCS2", "UCS4", "UNICODE", "UNICODEBIG", - "UNICODELITTLE", "UTF-7", "UTF-8", "UTF-16", "UTF-16BE", "UTF-16LE", - "UTF-32", "UTF-32BE", "UTF-32LE", "UTF7", "UTF8", "UTF16", "UTF16BE", - "UTF16LE", "UTF32", "UTF32BE", "UTF32LE" }; - int i; - if (charset) - g_free(charset); - if (charset_validator!=(GIConv)-1) - g_iconv_close(charset_validator); - if (!name || !g_strcasecmp(name,"auto")) - { - charset=NULL; - charset_validator=(GIConv)-1; - return TRUE; - } - else - charset=g_strdup(name); - for(i=0;i