Bug 155974

Summary: mc uses strange 'Other 8 bit' in the charset conversion
Product: [Fedora] Fedora Reporter: Andy Shevchenko <andy>
Component: mcAssignee: Jindrich Novy <jnovy>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 3CC: leonard-rh-bugzilla, pknirsch
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-05-18 10:39:46 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 154516    
Bug Blocks:    
Attachments:
Description Flags
Patch for using current charmap instead of 'Other 8 bit'
none
New version of patch none

Description Andy Shevchenko 2005-04-26 12:26:57 UTC
Description of problem:
mc uses strange item 'Other 8 bit' in charset chooser. I resolved the problem by 
changing that item to native current charmap (got by nl_langinfo(CODESET)).
In addition we do not need to choose charmap after first start of mc.

This bug is correlated with Andrew's patch from bug #154516.

Version-Release number of selected component (if applicable):
Last official FC3 update (and may be current)

Comment 1 Andy Shevchenko 2005-04-26 12:26:57 UTC
Created attachment 113664 [details]
Patch for using current charmap instead of 'Other 8 bit'

Comment 2 Jindrich Novy 2005-04-27 05:05:03 UTC
Hello Andy,

+static const char *
+get_current_charmap (void)
+{
+    int init = -1;
+    static char *charmap = NULL;
+
+    if (init == -1) {
+       char *lc_ctype = setlocale (LC_CTYPE, "");
+       charmap = nl_langinfo (CODESET);
+       setlocale (LC_CTYPE, lc_ctype);
+       init = 0;
+    }
+    return charmap;
+}

Doesn't the init variable miss the static storage class? The condition will be
executed every time when get_current_charmap() is called what is likely not
intended. Also #include <langinfo.h> seems to be missing.

Comment 3 Andy Shevchenko 2005-04-27 09:44:58 UTC
Hi, Jindrich.

1. Yes, I missed
2. Also, yes.

Thanks for reviewing code.

Comment 4 Andy Shevchenko 2005-04-27 09:46:19 UTC
2. Sorry, I am wrong. The langinfo.h already added.

Comment 5 Andy Shevchenko 2005-04-27 09:59:48 UTC
Created attachment 113710 [details]
New version of patch

Fix non-static class of init variable.
Also fix potential segfault in the strcasecmp().

Comment 6 Jindrich Novy 2005-04-28 08:02:20 UTC
Andy, the patch looks much better now but the only thing I'm afraid of is broken
translations of the "Current charmap" instead of "Other 8 bit". Maybe it's a
good thing if you send this patch to upstream so that people will take care
about translating the message when the patch is commmitted there.

Also it's not very usual that you put credits directly to the source code. If
you don't have any objections I credit authors of the patches in the spec file
instead of the source directly as I did in Andrew's case for instance.

Comment 7 Andy Shevchenko 2005-05-04 08:13:14 UTC
Ok, I try to some change patch (instead of -> with) and send to upstream it.
Yes, I agree with you. This patch injects minor function and no needs credit.


Comment 8 Jindrich Novy 2005-05-04 10:38:11 UTC
Andy, thanks for the patch anyway.

I'll close this bug UPSTREAM whenever I see mail from you on mc-devel.

Comment 9 Andy Shevchenko 2005-05-18 08:44:08 UTC
Hi, Jindrich!

I've put message to mc-devel@ list today.
You can close bug.

P.S> However, I should like to make this patch more convenient.

Comment 10 Jindrich Novy 2005-05-18 10:39:46 UTC
Hello Andy!

Thanks! I'll try to discuss it on upstream list when needed and keep track of it.