Mir

Merge lp:~mterry/mir/fix-turkish into lp:mir

Proposed by Michael Terry
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 2121
Proposed branch: lp:~mterry/mir/fix-turkish
Merge into: lp:mir
Diff against target: 20 lines (+2/-1)
1 file modified
src/platform/options/program_option.cpp (+2/-1)
To merge this branch: bzr merge lp:~mterry/mir/fix-turkish
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Alberto Aguirre (community) Approve
Cemil Azizoglu (community) Approve
Kevin DuBois (community) Approve
Review via email: mp+243722@code.launchpad.net

Commit message

Fix parsing environment arguments in the Turkish locale by calling tolower() with the standard C locale. (LP: #1398984)

In the Turkish locale, tolower('I') gives you back 'I'. This is often unexpected and a common 'gotcha' when comparing the results to a hardcoded string. One easy fix is to use the C locale for case conversions when you are only really interested in the normal ASCII set.

Description of the change

Fix parsing environment arguments in the Turkish locale by calling tolower() with the standard C locale.

In the Turkish locale, tolower('I') gives you back 'I'. This is often unexpected and a common 'gotcha' when comparing the results to a hardcoded string. One easy fix is to use the C locale for case conversions when you are only really interested in the normal ASCII set.

== Checklist ==

Did you test your feature/code change/bug fix ? what device(s) ?
- No, I tested locally that it gave the correct results in Turkish, but am waiting for jenkins to build debs for me to test on my device.

Did you break mir server API or ABI and have the relevant bumps to .so and debian docs been made ?
- NA

Did you break mir client API or ABI and have you followed up with the known clients & announced on mir-devel mailing list ?
- NA

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

okay by me, although I don't know anything about Turkish... Cemil? :)

review: Approve
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

(As the resident Turkish expert) Yeap, looks good.

review: Approve
Revision history for this message
Alberto Aguirre (albaguirre) wrote :

Wow...always amazed how locale issues manage to screw things up one way or another :)

review: Approve
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Sounds reasonable. This would also be an easy target for a regression test :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platform/options/program_option.cpp'
2--- src/platform/options/program_option.cpp 2014-12-04 03:47:52 +0000
3+++ src/platform/options/program_option.cpp 2014-12-04 19:18:32 +0000
4@@ -22,6 +22,7 @@
5
6 #include <fstream>
7 #include <iostream>
8+#include <locale>
9
10 namespace mo = mir::options;
11 namespace po = boost::program_options;
12@@ -72,7 +73,7 @@
13 for(auto& ch : result)
14 {
15 if (ch == '_') ch = '-';
16- else ch = tolower(ch);
17+ else ch = std::tolower(ch, std::locale::classic()); // avoid current locale
18 }
19
20 return result;

Subscribers

People subscribed via source and target branches