1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-29 05:12:41 +00:00

Shrink code by using more c++ in main()

This commit is contained in:
Nikolas Garofil 2010-02-24 22:06:06 +01:00
parent e7ed9a5060
commit 6c25f335c4

View File

@ -33,6 +33,8 @@
#include "conky.h" #include "conky.h"
#include "common.h" #include "common.h"
#include "timed-thread.h" #include "timed-thread.h"
#include <algorithm>
#include <string>
#include <stdarg.h> #include <stdarg.h>
#include <cmath> #include <cmath>
#include <ctime> #include <ctime>
@ -4196,8 +4198,7 @@ void initialisation(int argc, char **argv) {
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
#ifdef BUILD_X11 #ifdef BUILD_X11
char *s, *temp; char *s;
unsigned int x;
#endif #endif
argc_copy = argc; argc_copy = argc;
@ -4218,19 +4219,11 @@ int main(int argc, char **argv)
#ifdef BUILD_X11 #ifdef BUILD_X11
if (((s = getenv("LC_ALL")) && *s) || ((s = getenv("LC_CTYPE")) && *s) if (((s = getenv("LC_ALL")) && *s) || ((s = getenv("LC_CTYPE")) && *s)
|| ((s = getenv("LANG")) && *s)) { || ((s = getenv("LANG")) && *s)) {
temp = (char *) malloc((strlen(s) + 1) * sizeof(char)); std::string temp = s;
if (temp == NULL) { std::transform(temp.begin(), temp.end(), temp.begin(), ::tolower);
NORM_ERR("malloc failed"); if( (temp.find("utf-8") != std::string::npos) || (temp.find("utf8") != std::string::npos) ) {
}
for (x = 0; x < strlen(s); x++) {
temp[x] = tolower(s[x]);
}
temp[x] = 0;
if (strstr(temp, "utf-8") || strstr(temp, "utf8")) {
utf8_mode = 1; utf8_mode = 1;
} }
free(temp);
} }
if (!setlocale(LC_CTYPE, "")) { if (!setlocale(LC_CTYPE, "")) {
NORM_ERR("Can't set the specified locale!\nCheck LANG, LC_CTYPE, LC_ALL."); NORM_ERR("Can't set the specified locale!\nCheck LANG, LC_CTYPE, LC_ALL.");