Merge lp:~aacid/gsettings-qt/use_qchar_upper_lower into lp:gsettings-qt

Proposed by Albert Astals Cid
Status: Merged
Approved by: Nick Dedekind
Approved revision: 81
Merged at revision: 80
Proposed branch: lp:~aacid/gsettings-qt/use_qchar_upper_lower
Merge into: lp:gsettings-qt
Diff against target: 25 lines (+4/-3)
1 file modified
src/util.cpp (+4/-3)
To merge this branch: bzr merge lp:~aacid/gsettings-qt/use_qchar_upper_lower
Reviewer Review Type Date Requested Status
Nick Dedekind (community) Approve
Michael Zanetti (community) Approve
Ubuntu Touch System Settings Pending
Review via email: mp+289620@code.launchpad.net

Commit message

Use QChar toUpper/toLower instead of C version

C version works according to the locale that is not what we want in here
since in some locales there's not capital versions for some of the latin1
characters (i.e. Turkish will return i for toupper('i')) so when we try to
go back to the dashed version it will fail

To post a comment you must log in.
Revision history for this message
Michael Zanetti (mzanetti) wrote :

lgtm

review: Approve
Revision history for this message
Nick Dedekind (nick-dedekind) :
review: Needs Fixing
81. By Albert Astals Cid

Use also the qchar isUpper for completeness

Revision history for this message
Nick Dedekind (nick-dedekind) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/util.cpp'
2--- src/util.cpp 2013-08-06 13:08:22 +0000
3+++ src/util.cpp 2016-03-21 10:03:13 +0000
4@@ -32,7 +32,7 @@
5 if (*name == '-') {
6 next_cap = true;
7 } else if (next_cap) {
8- result.append(toupper(*name));
9+ result.append(QChar(*name).toUpper().toLatin1());
10 next_cap = false;
11 } else {
12 result.append(*name);
13@@ -61,9 +61,10 @@
14 str = g_string_new (NULL);
15
16 for (p = bytes.constData(); *p; p++) {
17- if (isupper(*p)) {
18+ const QChar c(*p);
19+ if (c.isUpper()) {
20 g_string_append_c (str, '-');
21- g_string_append_c (str, tolower(*p));
22+ g_string_append_c (str, c.toLower().toLatin1());
23 }
24 else {
25 g_string_append_c (str, *p);

Subscribers

People subscribed via source and target branches