Fix indentation in i18n.cpp, remove unused havePendingTitle, output when writing to pipe fails

This commit is contained in:
KockaAdmiralac 2018-06-16 09:21:53 +02:00
parent 3a6e61604b
commit 8060adceee
No known key found for this signature in database
GPG key ID: A6007A5107D8CFBD
4 changed files with 63 additions and 62 deletions

View file

@ -48,13 +48,19 @@ int server_thread(void *data)
}
CloseHandle(pipe);
#else
if (FILE *file = fopen(PIPE_PATH, "r")) {
if (FILE *file = fopen(PIPE_PATH, "r"))
{
fclose(file);
out_pipe = open(PIPE_PATH, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
SDL_LockMutex(mutex);
active = true;
if (message_len > 0)
write(out_pipe, (char*)message_buffer, message_len);
{
if (write(out_pipe, (char*)message_buffer, message_len) == -1)
{
Debug() << "Failure writing to journal's pipe!";
}
}
SDL_UnlockMutex(mutex);
}
return 0;

View file

@ -48,7 +48,7 @@ unix {
}
!macx: {
QMAKE_CXXFLAGS += -g
PKGCONFIG += giomm-2.4 gtk+-3.0 gdk-3.0 libxfconf-0
PKGCONFIG += gtk+-3.0 gdk-3.0 libxfconf-0
INCLUDEPATH += /usr/include/AL /usr/local/include/AL
LIBS += -lX11
}

View file

@ -166,7 +166,6 @@ void EventThread::process(RGSSThreadData &rtData)
char buffer[128];
char pendingTitle[128];
bool havePendingTitle = false;
bool resetting = false;
@ -330,8 +329,6 @@ void EventThread::process(RGSSThreadData &rtData)
/* Prevent fullscreen flicker */
strncpy(pendingTitle, rtData.config.windowTitle.c_str(),
sizeof(pendingTitle));
havePendingTitle = true;
break;
}
@ -510,8 +507,6 @@ void EventThread::process(RGSSThreadData &rtData)
if (fullscreen)
{
strncpy(pendingTitle, buffer, sizeof(pendingTitle));
havePendingTitle = true;
break;
}

View file

@ -1,5 +1,5 @@
/*
Really hacked-together naiive implementation of gettext
Really hacked-together naiive implementation of gettext
*/
#include "i18n.h"
#include "debugwriter.h"
@ -15,72 +15,72 @@ unsigned int nStr = 0;
int family = LOCALE_FAMILY_LATIN;
int getLocaleFamily() {
Debug() << "Get family:" << family;
return family;
Debug() << "Get family:" << family;
return family;
}
const char* findtext(unsigned int msgid, const char* fallback) {
Debug() << "Looking for msg" << msgid << fallback;
if (msgid >= nStr) {
return fallback;
} else {
Debug() << "found" << strdict[msgid];
return strdict[msgid];
}
Debug() << "Looking for msg" << msgid << fallback;
if (msgid >= nStr) {
return fallback;
} else {
Debug() << "found" << strdict[msgid];
return strdict[msgid];
}
}
void unloadLocale() {
for (unsigned int i = 0; i < nStr; i++) {
free(strdict[i]);
}
free(strdict);
strdict = 0;
nStr = 0;
for (unsigned int i = 0; i < nStr; i++) {
free(strdict[i]);
}
free(strdict);
strdict = 0;
nStr = 0;
}
void _setLocaleFamily(const char* locale) {
if (!strcmp(locale, "ja")
|| !strcmp(locale, "ko")
|| !strcmp(locale, "zh_CN")) {
family = LOCALE_FAMILY_ASIAN;
} else {
family = LOCALE_FAMILY_LATIN;
}
if (!strcmp(locale, "ja")
|| !strcmp(locale, "ko")
|| !strcmp(locale, "zh_CN")) {
family = LOCALE_FAMILY_ASIAN;
} else {
family = LOCALE_FAMILY_LATIN;
}
}
void loadLocale(const char* locale) {
Debug() << "Load locale:" << locale;
char pathbuf[100];
FILE* locfile;
char header[8];
unsigned int i;
int strSize = 0;
Debug() << "Load locale:" << locale;
char pathbuf[100];
FILE* locfile;
char header[8];
unsigned int i;
int strSize = 0;
unloadLocale();
unloadLocale();
_setLocaleFamily(locale);
_setLocaleFamily(locale);
sprintf(pathbuf, "Languages/internal/%s.loc", locale);
locfile = fopen(pathbuf, "rb");
if (locfile) {
fread(header, 1, 8, locfile);
if (!strcmp(header, LOC_HEADER)) {
//read number of strs in this file
fread(&nStr, 4, 1, locfile);
strdict = (char**)malloc(sizeof(char*) * nStr);
for (i = 0; i < nStr; i++) {
//read the size of the next string
fread(&strSize, 4, 1, locfile);
strdict[i] = (char*)malloc(strSize+1);
if (strSize > 0) {
//read the contents of the next string
fread(strdict[i], 1, strSize, locfile);
strdict[i][strSize] = 0;
Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize;
}
strdict[i][strSize] = 0;
}
}
fclose(locfile);
}
sprintf(pathbuf, "Languages/internal/%s.loc", locale);
locfile = fopen(pathbuf, "rb");
if (locfile) {
fread(header, 1, 8, locfile);
if (!strcmp(header, LOC_HEADER)) {
//read number of strs in this file
fread(&nStr, 4, 1, locfile);
strdict = (char**)malloc(sizeof(char*) * nStr);
for (i = 0; i < nStr; i++) {
//read the size of the next string
fread(&strSize, 4, 1, locfile);
strdict[i] = (char*)malloc(strSize+1);
if (strSize > 0) {
//read the contents of the next string
fread(strdict[i], 1, strSize, locfile);
strdict[i][strSize] = 0;
Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize;
}
strdict[i][strSize] = 0;
}
}
fclose(locfile);
}
}