tools/qlocale_unix.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3struct QSystemLocaleData -
4{ -
5 QSystemLocaleData() -
6 : lc_numeric(QLocale::C) -
7 ,lc_time(QLocale::C) -
8 ,lc_monetary(QLocale::C) -
9 ,lc_messages(QLocale::C) -
10 { -
11 readEnvironment(); -
12 }
executed: }
Execution Count:45
45
13 -
14 void readEnvironment(); -
15 -
16 QReadWriteLock lock; -
17 -
18 QLocale lc_numeric; -
19 QLocale lc_time; -
20 QLocale lc_monetary; -
21 QLocale lc_messages; -
22 QByteArray lc_messages_var; -
23 QByteArray lc_measurement_var; -
24 QStringList uiLanguages; -
25}; -
26 -
27void QSystemLocaleData::readEnvironment() -
28{ -
29 QWriteLocker locker(&lock); -
30 -
31 QByteArray all = qgetenv("LC_ALL"); -
32 QByteArray numeric = all.isEmpty() ? qgetenv("LC_NUMERIC") : all;
partially evaluated: all.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
33 QByteArray time = all.isEmpty() ? qgetenv("LC_TIME") : all;
partially evaluated: all.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
34 QByteArray monetary = all.isEmpty() ? qgetenv("LC_MONETARY") : all;
partially evaluated: all.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
35 lc_messages_var = all.isEmpty() ? qgetenv("LC_MESSAGES") : all;
partially evaluated: all.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
36 lc_measurement_var = all.isEmpty() ? qgetenv("LC_MEASUREMENT") : all;
partially evaluated: all.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
37 QByteArray lang = qgetenv("LANG"); -
38 if (lang.isEmpty())
partially evaluated: lang.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:90
0-90
39 lang = QByteArray("C");
never executed: lang = QByteArray("C");
0
40 if (numeric.isEmpty())
partially evaluated: numeric.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
41 numeric = lang;
executed: numeric = lang;
Execution Count:90
90
42 if (time.isEmpty())
partially evaluated: time.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
43 time = lang;
executed: time = lang;
Execution Count:90
90
44 if (monetary.isEmpty())
partially evaluated: monetary.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
45 monetary = lang;
executed: monetary = lang;
Execution Count:90
90
46 if (lc_messages_var.isEmpty())
partially evaluated: lc_messages_var.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
47 lc_messages_var = lang;
executed: lc_messages_var = lang;
Execution Count:90
90
48 if (lc_measurement_var.isEmpty())
partially evaluated: lc_measurement_var.isEmpty()
TRUEFALSE
yes
Evaluation Count:90
no
Evaluation Count:0
0-90
49 lc_measurement_var = lang;
executed: lc_measurement_var = lang;
Execution Count:90
90
50 lc_numeric = QLocale(QString::fromLatin1(numeric)); -
51 lc_time = QLocale(QString::fromLatin1(time)); -
52 lc_monetary = QLocale(QString::fromLatin1(monetary)); -
53 lc_messages = QLocale(QString::fromLatin1(lc_messages_var)); -
54}
executed: }
Execution Count:90
90
55 -
56 -
57static QSystemLocaleData *qSystemLocaleData() { static QGlobalStatic<QSystemLocaleData > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QSystemLocaleData *x = new QSystemLocaleData; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QSystemLocaleData > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:45
executed: return thisGlobalStatic.pointer.load();
Execution Count:18114
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:18069
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-18114
58QLocale QSystemLocale::fallbackUiLocale() const -
59{ -
60 QByteArray lang = qgetenv("LC_ALL"); -
61 if (lang.isEmpty())
partially evaluated: lang.isEmpty()
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-45
62 lang = qgetenv("LC_MESSAGES");
executed: lang = qgetenv("LC_MESSAGES");
Execution Count:45
45
63 if (lang.isEmpty())
partially evaluated: lang.isEmpty()
TRUEFALSE
yes
Evaluation Count:45
no
Evaluation Count:0
0-45
64 lang = qgetenv("LANG");
executed: lang = qgetenv("LANG");
Execution Count:45
45
65 -
66 if (lang.isEmpty() || lang == QByteArray("C") || lang == QByteArray("POSIX"))
partially evaluated: lang.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:45
evaluated: lang == QByteArray("C")
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:44
partially evaluated: lang == QByteArray("POSIX")
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44
0-45
67 return QLocale(QString::fromLatin1(lang));
executed: return QLocale(QString::fromLatin1(lang));
Execution Count:1
1
68 -
69 -
70 -
71 QByteArray language = qgetenv("LANGUAGE"); -
72 if (!language.isEmpty()) {
partially evaluated: !language.isEmpty()
TRUEFALSE
yes
Evaluation Count:44
no
Evaluation Count:0
0-44
73 language = language.split(':').first(); -
74 if (!language.isEmpty())
partially evaluated: !language.isEmpty()
TRUEFALSE
yes
Evaluation Count:44
no
Evaluation Count:0
0-44
75 return QLocale(QString::fromLatin1(language));
executed: return QLocale(QString::fromLatin1(language));
Execution Count:44
44
76 }
never executed: }
0
77 -
78 return QLocale(QString::fromLatin1(lang));
never executed: return QLocale(QString::fromLatin1(lang));
0
79} -
80 -
81QVariant QSystemLocale::query(QueryType type, QVariant in) const -
82{ -
83 QSystemLocaleData *d = qSystemLocaleData(); -
84 -
85 -
86 -
87 -
88 if (type == LocaleChanged) {
evaluated: type == LocaleChanged
TRUEFALSE
yes
Evaluation Count:45
yes
Evaluation Count:18069
45-18069
89 d->readEnvironment(); -
90 return QVariant();
executed: return QVariant();
Execution Count:45
45
91 } -
92 -
93 QReadLocker locker(&d->lock); -
94 -
95 const QLocale &lc_numeric = d->lc_numeric; -
96 const QLocale &lc_time = d->lc_time; -
97 const QLocale &lc_monetary = d->lc_monetary; -
98 const QLocale &lc_messages = d->lc_messages; -
99 -
100 switch (type) { -
101 case DecimalPoint: -
102 return lc_numeric.decimalPoint();
executed: return lc_numeric.decimalPoint();
Execution Count:45
45
103 case GroupSeparator: -
104 return lc_numeric.groupSeparator();
executed: return lc_numeric.groupSeparator();
Execution Count:45
45
105 case ZeroDigit: -
106 return lc_numeric.zeroDigit();
executed: return lc_numeric.zeroDigit();
Execution Count:45
45
107 case NegativeSign: -
108 return lc_numeric.negativeSign();
executed: return lc_numeric.negativeSign();
Execution Count:45
45
109 case DateFormatLong: -
110 return lc_time.dateFormat(QLocale::LongFormat);
never executed: return lc_time.dateFormat(QLocale::LongFormat);
0
111 case DateFormatShort: -
112 return lc_time.dateFormat(QLocale::ShortFormat);
executed: return lc_time.dateFormat(QLocale::ShortFormat);
Execution Count:10
10
113 case TimeFormatLong: -
114 return lc_time.timeFormat(QLocale::LongFormat);
never executed: return lc_time.timeFormat(QLocale::LongFormat);
0
115 case TimeFormatShort: -
116 return lc_time.timeFormat(QLocale::ShortFormat);
executed: return lc_time.timeFormat(QLocale::ShortFormat);
Execution Count:10
10
117 case DayNameLong: -
118 return lc_time.dayName(in.toInt(), QLocale::LongFormat);
executed: return lc_time.dayName(in.toInt(), QLocale::LongFormat);
Execution Count:267
267
119 case DayNameShort: -
120 return lc_time.dayName(in.toInt(), QLocale::ShortFormat);
executed: return lc_time.dayName(in.toInt(), QLocale::ShortFormat);
Execution Count:582
582
121 case MonthNameLong: -
122 return lc_time.monthName(in.toInt(), QLocale::LongFormat);
executed: return lc_time.monthName(in.toInt(), QLocale::LongFormat);
Execution Count:4125
4125
123 case MonthNameShort: -
124 return lc_time.monthName(in.toInt(), QLocale::ShortFormat);
executed: return lc_time.monthName(in.toInt(), QLocale::ShortFormat);
Execution Count:8526
8526
125 case DateToStringLong: -
126 return lc_time.toString(in.toDate(), QLocale::LongFormat);
executed: return lc_time.toString(in.toDate(), QLocale::LongFormat);
Execution Count:1
1
127 case DateToStringShort: -
128 return lc_time.toString(in.toDate(), QLocale::ShortFormat);
executed: return lc_time.toString(in.toDate(), QLocale::ShortFormat);
Execution Count:1682
1682
129 case TimeToStringLong: -
130 return lc_time.toString(in.toTime(), QLocale::LongFormat);
executed: return lc_time.toString(in.toTime(), QLocale::LongFormat);
Execution Count:1
1
131 case TimeToStringShort: -
132 return lc_time.toString(in.toTime(), QLocale::ShortFormat);
executed: return lc_time.toString(in.toTime(), QLocale::ShortFormat);
Execution Count:1663
1663
133 case DateTimeFormatLong: -
134 return lc_time.dateTimeFormat(QLocale::LongFormat);
executed: return lc_time.dateTimeFormat(QLocale::LongFormat);
Execution Count:1
1
135 case DateTimeFormatShort: -
136 return lc_time.dateTimeFormat(QLocale::ShortFormat);
executed: return lc_time.dateTimeFormat(QLocale::ShortFormat);
Execution Count:12
12
137 case DateTimeToStringLong: -
138 return lc_time.toString(in.toDateTime(), QLocale::LongFormat);
never executed: return lc_time.toString(in.toDateTime(), QLocale::LongFormat);
0
139 case DateTimeToStringShort: -
140 return lc_time.toString(in.toDateTime(), QLocale::ShortFormat);
never executed: return lc_time.toString(in.toDateTime(), QLocale::ShortFormat);
0
141 case PositiveSign: -
142 return lc_numeric.positiveSign();
executed: return lc_numeric.positiveSign();
Execution Count:45
45
143 case AMText: -
144 return lc_time.amText();
executed: return lc_time.amText();
Execution Count:683
683
145 case PMText: -
146 return lc_time.pmText();
executed: return lc_time.pmText();
Execution Count:117
117
147 case FirstDayOfWeek: -
148 return lc_time.firstDayOfWeek();
executed: return lc_time.firstDayOfWeek();
Execution Count:22
22
149 case CurrencySymbol: -
150 return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
never executed: return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
0
151 case CurrencyToString: { -
152 switch (in.type()) { -
153 case QVariant::Int: -
154 return lc_monetary.toCurrencyString(in.toInt());
never executed: return lc_monetary.toCurrencyString(in.toInt());
0
155 case QVariant::UInt: -
156 return lc_monetary.toCurrencyString(in.toUInt());
never executed: return lc_monetary.toCurrencyString(in.toUInt());
0
157 case QVariant::Double: -
158 return lc_monetary.toCurrencyString(in.toDouble());
never executed: return lc_monetary.toCurrencyString(in.toDouble());
0
159 case QVariant::LongLong: -
160 return lc_monetary.toCurrencyString(in.toLongLong());
never executed: return lc_monetary.toCurrencyString(in.toLongLong());
0
161 case QVariant::ULongLong: -
162 return lc_monetary.toCurrencyString(in.toULongLong());
never executed: return lc_monetary.toCurrencyString(in.toULongLong());
0
163 default: -
164 break;
executed: break;
Execution Count:1
1
165 } -
166 return QString();
executed: return QString();
Execution Count:1
1
167 } -
168 case MeasurementSystem: { -
169 const QString meas_locale = QString::fromLatin1(d->lc_measurement_var.constData(), d->lc_measurement_var.size()); -
170 if (meas_locale.compare(QLatin1String("Metric"), Qt::CaseInsensitive) == 0)
never evaluated: meas_locale.compare(QLatin1String("Metric"), Qt::CaseInsensitive) == 0
0
171 return QLocale::MetricSystem;
never executed: return QLocale::MetricSystem;
0
172 if (meas_locale.compare(QLatin1String("Other"), Qt::CaseInsensitive) == 0)
never evaluated: meas_locale.compare(QLatin1String("Other"), Qt::CaseInsensitive) == 0
0
173 return QLocale::MetricSystem;
never executed: return QLocale::MetricSystem;
0
174 -
175 -
176 -
177 return QVariant((int)QLocale(meas_locale).measurementSystem());
never executed: return QVariant((int)QLocale(meas_locale).measurementSystem());
0
178 } -
179 case UILanguages: { -
180 if (!d->uiLanguages.isEmpty())
evaluated: !d->uiLanguages.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1
1-5
181 return d->uiLanguages;
executed: return d->uiLanguages;
Execution Count:5
5
182 QString languages = QString::fromLatin1(qgetenv("LANGUAGE")); -
183 QStringList lst; -
184 if (languages.isEmpty())
partially evaluated: languages.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
185 lst.append(QString::fromLatin1(d->lc_messages_var));
never executed: lst.append(QString::fromLatin1(d->lc_messages_var));
0
186 else -
187 lst = languages.split(QLatin1Char(':'));
executed: lst = languages.split(QLatin1Char(':'));
Execution Count:1
1
188 -
189 for (int i = 0; i < lst.size(); ++i) {
evaluated: i < lst.size()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
190 const QString &name = lst.at(i); -
191 QString lang, script, cntry; -
192 if (qt_splitLocaleName(name, lang, script, cntry)) {
partially evaluated: qt_splitLocaleName(name, lang, script, cntry)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
193 if (!cntry.length())
evaluated: !cntry.length()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
194 d->uiLanguages.append(lang);
executed: d->uiLanguages.append(lang);
Execution Count:1
1
195 else -
196 d->uiLanguages.append(lang % QLatin1Char('-') % cntry);
executed: d->uiLanguages.append(lang % QLatin1Char('-') % cntry);
Execution Count:1
1
197 } -
198 }
executed: }
Execution Count:2
2
199 return d->uiLanguages.isEmpty() ? QVariant() : QVariant(d->uiLanguages);
executed: return d->uiLanguages.isEmpty() ? QVariant() : QVariant(d->uiLanguages);
Execution Count:1
1
200 } -
201 case StringToStandardQuotation: -
202 return lc_messages.quoteString(in.value<QStringRef>());
never executed: return lc_messages.quoteString(in.value<QStringRef>());
0
203 case StringToAlternateQuotation: -
204 return lc_messages.quoteString(in.value<QStringRef>(), QLocale::AlternateQuotation);
never executed: return lc_messages.quoteString(in.value<QStringRef>(), QLocale::AlternateQuotation);
0
205 case ListToSeparatedString: -
206 return lc_messages.createSeparatedList(in.value<QStringList>());
never executed: return lc_messages.createSeparatedList(in.value<QStringList>());
0
207 case LocaleChanged: -
208 qt_noop(); -
209 default: -
210 break;
executed: break;
Execution Count:135
135
211 } -
212 return QVariant();
executed: return QVariant();
Execution Count:135
135
213} -
214 -
215 -
216 -
217 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial