[PATCH] Allow double quote to be defined in font file
Hi, so far, it doesn't seem to be possible to define the double quote character in the font.fnt file. The patch enables this now. Ingo
Hi, 2nd attempt. Ingo
Sorry, last message has wrong subject. It's the "Allow gmplayer the use of non-UTF-8 filename encoding" 2nd attempt patch.
On Sun, Dec 19, 2010 at 09:12:26PM +0100, Ingo Brueckl wrote:
+ locale = setlocale(LC_ALL, ""); + filename = g_filename_to_utf8(fname, -1, NULL, NULL, NULL); + setlocale(LC_ALL, locale);
You could extract that into a wrapper function, that's duplicated a lot of time. Also, does restoring the old locale this way actually work? LC_ALL modifies multiple locale settings, do they all get restored correctly (e.g. if you have if LC_CTYPE="tr" and LC_NUMERIC="en" at the start, would they again have different locale settings at the end?).
+ char *locale;
const char * would be more appropriate.
- str[1] = fname; + str[1] = filename; pos = gtk_clist_append(GTK_CLIST(list), str); gtk_clist_set_pixmap(GTK_CLIST(list), pos, 0, pixmap, mask); + g_free(filename);
+ text[0][0]=name; + text[0][1]=path; gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); + g_free(path); + g_free(name);
+ text[0][0]=itext[0][0]; text[0][1]=cpath; gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); + g_free(cpath);
Are you sure that gtk_clist_append makes a copy if the string? The documentation I could find for it is unfortunately useless.
+ if (name) g_free(name);
No need for the if btw.
Reimar Döffinger wrote on Sun, 19 Dec 2010 21:49:48 +0100:
Also, does restoring the old locale this way actually work? LC_ALL modifies multiple locale settings, do they all get restored correctly
Didn't you tell me that allowing gtk to call setlocale(LC_ALL, "") "breaks MPLayer left and right"? So the locale during runtime should be "C" anyway. (Perhaps setlocale(LC_ALL, "C") should be used to restore to make it clear?)
Are you sure that gtk_clist_append makes a copy if the string?
I didn't change the use of the string for gtk_clist_append. It does with the string what it did prior to the patch.
On Sun, Dec 19, 2010 at 10:30:09PM +0100, Ingo Brueckl wrote:
Reimar Döffinger wrote on Sun, 19 Dec 2010 21:49:48 +0100:
Also, does restoring the old locale this way actually work? LC_ALL modifies multiple locale settings, do they all get restored correctly
Didn't you tell me that allowing gtk to call setlocale(LC_ALL, "") "breaks MPLayer left and right"? So the locale during runtime should be "C" anyway. (Perhaps setlocale(LC_ALL, "C") should be used to restore to make it clear?)
Well, I see two options, and I do not mind which: 1) properly restore the locale, but we should be confident that actually works for all cases 2) Just use setlocale(LC_ALL, "C"), then at least it looks like the hack it is. I do wonder a bit what that function actually uses and if you really have to change all LC_*...
Are you sure that gtk_clist_append makes a copy if the string?
I didn't change the use of the string for gtk_clist_append. It does with the string what it did prior to the patch.
You now pass a string to gtk_clist_append that you free _directly_ afterwards, that wasn't the case before.
Reimar Döffinger wrote on Sun, 19 Dec 2010 21:49:48 and 23:37:58 +0100:
Also, does restoring the old locale this way actually work?
In principle yes, but there was a bug.
LC_ALL modifies multiple locale settings, do they all get restored correctly
Apparently. Please see the output of a test program: Starting with no locale set: LC_ALL = C LC_CTYPE = C LC_NUMERIC = C Setting LC_CTYPE=tr: LC_ALL = LC_CTYPE=tr;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C LC_CTYPE = tr LC_NUMERIC = C Setting LC_NUMERIC=en: LC_ALL = LC_CTYPE=tr;LC_NUMERIC=en;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C LC_CTYPE = tr LC_NUMERIC = en Saving locale. Setting LC_ALL=de: LC_ALL = de LC_CTYPE = de LC_NUMERIC = de Restoring locale: LC_ALL = LC_CTYPE=tr;LC_NUMERIC=en;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C LC_CTYPE = tr LC_NUMERIC = en As there is no setlocale allowed in MPlayer so far, its locale during runtime is C anyway. So, for the moment, it would be ok to reset it to C, but it is safer to restore, just in case.
I do wonder a bit what that function actually uses and if you really have to change all LC_*...
Glib's _g_locale_charset_raw() reads LC_CYTPE, but only on modern systems providing nl_langinfo(). It reads LC_ALL, LC_CTYPE, LANG (in that order) else, so it is safest to set LC_ALL to work on all systems.
Are you sure that gtk_clist_append makes a copy if the string?
Now I am. Gtk's set_cell_contents() which does the work for gtk_clist_append() makes a g_strdup(text); Attached is 3rd attempt. Ingo
Hi, On Mon, Dec 20, 2010 at 11:05:57AM +0100, Ingo Brueckl wrote:
Reimar Döffinger wrote on Sun, 19 Dec 2010 21:49:48 and 23:37:58 +0100:
Also, does restoring the old locale this way actually work?
In principle yes, but there was a bug.
LC_ALL modifies multiple locale settings, do they all get restored correctly
I dunno if mplayer has threads or not. But just in case, becareful that setlocale is not thread safe. -- fenrir
On Mon, Dec 20, 2010 at 01:11:59PM +0100, Laurent Aimar wrote:
I dunno if mplayer has threads or not.
It has in some cases, at least (think multithreaded Win32 codecs). /* Steinar */ -- Homepage: http://www.sesse.net/
Laurent Aimar wrote on Mon, 20 Dec 2010 13:11:59 +0100:
I dunno if mplayer has threads or not. But just in case, becareful that setlocale is not thread safe.
Ok then, let's get rid of setlocale and let the user explicitly set G_FILENAME_ENCODING to the character set used. Final (hopefully) patch attached. Ingo
participants (4)
-
Ingo Brueckl -
Laurent Aimar -
Reimar Döffinger -
Steinar H. Gunderson