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); CloseHandle(pipe);
#else #else
if (FILE *file = fopen(PIPE_PATH, "r")) { if (FILE *file = fopen(PIPE_PATH, "r"))
{
fclose(file); 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); 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); SDL_LockMutex(mutex);
active = true; active = true;
if (message_len > 0) 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); SDL_UnlockMutex(mutex);
} }
return 0; return 0;

View file

@ -48,7 +48,7 @@ unix {
} }
!macx: { !macx: {
QMAKE_CXXFLAGS += -g 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 INCLUDEPATH += /usr/include/AL /usr/local/include/AL
LIBS += -lX11 LIBS += -lX11
} }

View file

@ -166,7 +166,6 @@ void EventThread::process(RGSSThreadData &rtData)
char buffer[128]; char buffer[128];
char pendingTitle[128]; char pendingTitle[128];
bool havePendingTitle = false;
bool resetting = false; bool resetting = false;
@ -330,8 +329,6 @@ void EventThread::process(RGSSThreadData &rtData)
/* Prevent fullscreen flicker */ /* Prevent fullscreen flicker */
strncpy(pendingTitle, rtData.config.windowTitle.c_str(), strncpy(pendingTitle, rtData.config.windowTitle.c_str(),
sizeof(pendingTitle)); sizeof(pendingTitle));
havePendingTitle = true;
break; break;
} }
@ -510,8 +507,6 @@ void EventThread::process(RGSSThreadData &rtData)
if (fullscreen) if (fullscreen)
{ {
strncpy(pendingTitle, buffer, sizeof(pendingTitle)); strncpy(pendingTitle, buffer, sizeof(pendingTitle));
havePendingTitle = true;
break; 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 "i18n.h"
#include "debugwriter.h" #include "debugwriter.h"
@ -15,72 +15,72 @@ unsigned int nStr = 0;
int family = LOCALE_FAMILY_LATIN; int family = LOCALE_FAMILY_LATIN;
int getLocaleFamily() { int getLocaleFamily() {
Debug() << "Get family:" << family; Debug() << "Get family:" << family;
return family; return family;
} }
const char* findtext(unsigned int msgid, const char* fallback) { const char* findtext(unsigned int msgid, const char* fallback) {
Debug() << "Looking for msg" << msgid << fallback; Debug() << "Looking for msg" << msgid << fallback;
if (msgid >= nStr) { if (msgid >= nStr) {
return fallback; return fallback;
} else { } else {
Debug() << "found" << strdict[msgid]; Debug() << "found" << strdict[msgid];
return strdict[msgid]; return strdict[msgid];
} }
} }
void unloadLocale() { void unloadLocale() {
for (unsigned int i = 0; i < nStr; i++) { for (unsigned int i = 0; i < nStr; i++) {
free(strdict[i]); free(strdict[i]);
} }
free(strdict); free(strdict);
strdict = 0; strdict = 0;
nStr = 0; nStr = 0;
} }
void _setLocaleFamily(const char* locale) { void _setLocaleFamily(const char* locale) {
if (!strcmp(locale, "ja") if (!strcmp(locale, "ja")
|| !strcmp(locale, "ko") || !strcmp(locale, "ko")
|| !strcmp(locale, "zh_CN")) { || !strcmp(locale, "zh_CN")) {
family = LOCALE_FAMILY_ASIAN; family = LOCALE_FAMILY_ASIAN;
} else { } else {
family = LOCALE_FAMILY_LATIN; family = LOCALE_FAMILY_LATIN;
} }
} }
void loadLocale(const char* locale) { void loadLocale(const char* locale) {
Debug() << "Load locale:" << locale; Debug() << "Load locale:" << locale;
char pathbuf[100]; char pathbuf[100];
FILE* locfile; FILE* locfile;
char header[8]; char header[8];
unsigned int i; unsigned int i;
int strSize = 0; int strSize = 0;
unloadLocale(); unloadLocale();
_setLocaleFamily(locale); _setLocaleFamily(locale);
sprintf(pathbuf, "Languages/internal/%s.loc", locale); sprintf(pathbuf, "Languages/internal/%s.loc", locale);
locfile = fopen(pathbuf, "rb"); locfile = fopen(pathbuf, "rb");
if (locfile) { if (locfile) {
fread(header, 1, 8, locfile); fread(header, 1, 8, locfile);
if (!strcmp(header, LOC_HEADER)) { if (!strcmp(header, LOC_HEADER)) {
//read number of strs in this file //read number of strs in this file
fread(&nStr, 4, 1, locfile); fread(&nStr, 4, 1, locfile);
strdict = (char**)malloc(sizeof(char*) * nStr); strdict = (char**)malloc(sizeof(char*) * nStr);
for (i = 0; i < nStr; i++) { for (i = 0; i < nStr; i++) {
//read the size of the next string //read the size of the next string
fread(&strSize, 4, 1, locfile); fread(&strSize, 4, 1, locfile);
strdict[i] = (char*)malloc(strSize+1); strdict[i] = (char*)malloc(strSize+1);
if (strSize > 0) { if (strSize > 0) {
//read the contents of the next string //read the contents of the next string
fread(strdict[i], 1, strSize, locfile); fread(strdict[i], 1, strSize, locfile);
strdict[i][strSize] = 0; strdict[i][strSize] = 0;
Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize; Debug() << "localization #" << i << " : " << strdict[i] << "|" << strSize;
} }
strdict[i][strSize] = 0; strdict[i][strSize] = 0;
} }
} }
fclose(locfile); fclose(locfile);
} }
} }