aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Crozat2010-08-22 19:47:07 +0000
committerThierry Crozat2010-08-22 19:47:07 +0000
commit083faee7c1d4b3cfc82bd271a96827f9102c913a (patch)
tree1338a40e768999201b5c76bc770fb3f8884e8385
parentc89462c2a63f1419f389190c058c0d18a2d09118 (diff)
downloadscummvm-rg350-083faee7c1d4b3cfc82bd271a96827f9102c913a.tar.gz
scummvm-rg350-083faee7c1d4b3cfc82bd271a96827f9102c913a.tar.bz2
scummvm-rg350-083faee7c1d4b3cfc82bd271a96827f9102c913a.zip
i18n: Formatting fixes.
svn-id: r52285
-rw-r--r--tools/create_translations/create_translations.cpp14
-rw-r--r--tools/create_translations/po_parser.cpp62
-rw-r--r--tools/create_translations/po_parser.h38
3 files changed, 57 insertions, 57 deletions
diff --git a/tools/create_translations/create_translations.cpp b/tools/create_translations/create_translations.cpp
index 1a9de96464..af7dd02f82 100644
--- a/tools/create_translations/create_translations.cpp
+++ b/tools/create_translations/create_translations.cpp
@@ -84,7 +84,7 @@ void writeString(FILE *fp, const char* string) {
int main(int argc, char *argv[]) {
// Build the translation list
PoMessageList messageIds;
- PoMessageEntryList** translations = new PoMessageEntryList*[argc - 1];
+ PoMessageEntryList **translations = new PoMessageEntryList*[argc - 1];
int numLangs = 0;
for (int i = 1 ; i < argc ; ++i) {
translations[numLangs] = parsePoFile(argv[i], messageIds);
@@ -92,7 +92,7 @@ int main(int argc, char *argv[]) {
++numLangs;
}
- FILE* outFile;
+ FILE *outFile;
int i, lang;
int len;
@@ -137,7 +137,7 @@ int main(int argc, char *argv[]) {
// It starts with the number of strings coded on 2 bytes followed by each
// string (two bytes for the number of chars and the string itself).
len = 2;
- for (i = 0; i < messageIds.size() ; ++i)
+ for (i = 0; i < messageIds.size(); ++i)
len += stringSize(messageIds[i]);
writeUint16BE(outFile, len);
@@ -147,7 +147,7 @@ int main(int argc, char *argv[]) {
// the string size (two bytes for the number of chars and the string itself).
for (lang = 0; lang < numLangs; lang++) {
len = 2 + stringSize(translations[lang]->charset());
- for (i = 0; i < translations[lang]->size() ; ++i)
+ for (i = 0; i < translations[lang]->size(); ++i)
len += 2 + stringSize(translations[lang]->entry(i)->msgstr);
writeUint16BE(outFile, len);
}
@@ -160,7 +160,7 @@ int main(int argc, char *argv[]) {
// Write original messages
writeUint16BE(outFile, messageIds.size());
- for (i = 0; i < messageIds.size() ; ++i) {
+ for (i = 0; i < messageIds.size(); ++i) {
writeString(outFile, messageIds[i]);
}
@@ -168,7 +168,7 @@ int main(int argc, char *argv[]) {
for (lang = 0; lang < numLangs; lang++) {
writeUint16BE(outFile, translations[lang]->size());
writeString(outFile, translations[lang]->charset());
- for (i = 0; i < translations[lang]->size() ; ++i) {
+ for (i = 0; i < translations[lang]->size(); ++i) {
writeUint16BE(outFile, messageIds.findIndex(translations[lang]->entry(i)->msgid));
writeString(outFile, translations[lang]->entry(i)->msgstr);
}
@@ -177,7 +177,7 @@ int main(int argc, char *argv[]) {
fclose(outFile);
// Clean the memory
- for (i = 0 ; i < numLangs ; ++i)
+ for (i = 0; i < numLangs; ++i)
delete translations[i];
delete [] translations;
diff --git a/tools/create_translations/po_parser.cpp b/tools/create_translations/po_parser.cpp
index 1d0045e8d5..f2cd5a5859 100644
--- a/tools/create_translations/po_parser.cpp
+++ b/tools/create_translations/po_parser.cpp
@@ -33,7 +33,7 @@ PoMessageList::PoMessageList() : _messages(NULL), _size(0), _allocated(0) {
}
PoMessageList::~PoMessageList() {
- for (int i = 0 ; i < _size ; ++i)
+ for (int i = 0; i < _size; ++i)
delete [] _messages[i];
delete [] _messages;
}
@@ -59,18 +59,18 @@ void PoMessageList::insert(const char *msg) {
// between the two (i.a. at leftIndex).
if (_size + 1 > _allocated) {
_allocated += 100;
- char** newMessages = new char*[_allocated];
- for (int i = 0 ; i < leftIndex ; ++i)
+ char **newMessages = new char*[_allocated];
+ for (int i = 0; i < leftIndex; ++i)
newMessages[i] = _messages[i];
- for (int i = leftIndex ; i < _size ; ++i)
- newMessages[i+1] = _messages[i];
+ for (int i = leftIndex; i < _size; ++i)
+ newMessages[i + 1] = _messages[i];
delete [] _messages;
_messages = newMessages;
} else {
- for (int i = _size - 1 ; i >= leftIndex ; --i)
- _messages[i+1] = _messages[i];
+ for (int i = _size - 1; i >= leftIndex; --i)
+ _messages[i + 1] = _messages[i];
}
- _messages[leftIndex] = new char[1+strlen(msg)];
+ _messages[leftIndex] = new char[1 + strlen(msg)];
strcpy(_messages[leftIndex], msg);
++_size;
}
@@ -101,13 +101,13 @@ int PoMessageList::size() const {
return _size;
}
-const char* PoMessageList::operator[](int index) const {
+const char *PoMessageList::operator[](int index) const {
if (index < 0 || index >= _size)
return NULL;
return _messages[index];
}
-PoMessageEntryList::PoMessageEntryList(const char* lang) :
+PoMessageEntryList::PoMessageEntryList(const char *lang) :
_lang(NULL), _charset(NULL), _langName(NULL),
_list(NULL), _size(0), _allocated(0)
{
@@ -125,7 +125,7 @@ PoMessageEntryList::~PoMessageEntryList() {
delete [] _lang;
delete [] _charset;
delete [] _langName;
- for (int i = 0 ; i < _size ; ++i)
+ for (int i = 0; i < _size; ++i)
delete _list[i];
delete [] _list;
}
@@ -134,7 +134,7 @@ void PoMessageEntryList::addMessageEntry(const char *translation, const char *me
if (*message == '\0') {
// This is the header.
// We get the charset and the language name from the translation string
- char* str = parseLine(translation, "Language:");
+ char *str = parseLine(translation, "Language:");
if (str != NULL) {
delete [] _langName;
_langName = str;
@@ -177,30 +177,30 @@ void PoMessageEntryList::addMessageEntry(const char *translation, const char *me
// between the two (i.a. at leftIndex).
if (_size + 1 > _allocated) {
_allocated += 100;
- PoMessageEntry** newList = new PoMessageEntry*[_allocated];
- for (int i = 0 ; i < leftIndex ; ++i)
+ PoMessageEntry **newList = new PoMessageEntry*[_allocated];
+ for (int i = 0; i < leftIndex; ++i)
newList[i] = _list[i];
- for (int i = leftIndex ; i < _size ; ++i)
- newList[i+1] = _list[i];
+ for (int i = leftIndex; i < _size; ++i)
+ newList[i + 1] = _list[i];
delete [] _list;
_list = newList;
} else {
- for (int i = _size - 1 ; i >= leftIndex ; --i)
- _list[i+1] = _list[i];
+ for (int i = _size - 1; i >= leftIndex; --i)
+ _list[i + 1] = _list[i];
}
_list[leftIndex] = new PoMessageEntry(translation, message, context);
++_size;
}
-const char* PoMessageEntryList::language() const {
+const char *PoMessageEntryList::language() const {
return _lang;
}
-const char* PoMessageEntryList::languageName() const {
+const char *PoMessageEntryList::languageName() const {
return _langName;
}
-const char* PoMessageEntryList::charset() const {
+const char *PoMessageEntryList::charset() const {
return _charset;
}
@@ -208,15 +208,15 @@ int PoMessageEntryList::size() const {
return _size;
}
-const PoMessageEntry* PoMessageEntryList::entry(int index) const {
+const PoMessageEntry *PoMessageEntryList::entry(int index) const {
if (index < 0 || index >= _size)
return NULL;
return _list[index];
}
-PoMessageEntryList* parsePoFile(const char* file, PoMessageList& messages) {
- FILE* inFile = fopen(file, "r");
+PoMessageEntryList *parsePoFile(const char *file, PoMessageList& messages) {
+ FILE *inFile = fopen(file, "r");
if (!inFile)
return NULL;
@@ -225,11 +225,11 @@ PoMessageEntryList* parsePoFile(const char* file, PoMessageList& messages) {
// Get language from file name and create PoMessageEntryList
int index = 0, start_index = strlen(file) - 1;
- while (start_index > 0 && file[start_index-1] != '/' && file[start_index-1] != '\\') {
+ while (start_index > 0 && file[start_index - 1] != '/' && file[start_index - 1] != '\\') {
--start_index;
}
- while (file[start_index+index] != '.' && file[start_index+index] != '\0') {
- msgidBuf[index] = file[start_index+index];
+ while (file[start_index + index] != '.' && file[start_index + index] != '\0') {
+ msgidBuf[index] = file[start_index + index];
++index;
}
msgidBuf[index] = '\0';
@@ -279,7 +279,7 @@ PoMessageEntryList* parsePoFile(const char* file, PoMessageList& messages) {
return list;
}
-char* stripLine(char* line) {
+char *stripLine(char *line) {
// This function modifies line in place and return it.
// Keep only the text between the first two unprotected quotes.
// Look for the first quote
@@ -296,12 +296,12 @@ char* stripLine(char* line) {
return line;
}
-char* parseLine(const char* line, const char* field) {
+char *parseLine(const char *line, const char *field) {
// This function allocate and return a new char*.
// It will return a NULL pointer if the field is not found.
// It is used to parse the header of the po files to find the language name
// and the charset.
- char* str = strstr(line, field);
+ char *str = strstr(line, field);
if (str == NULL)
return NULL;
str += strlen(field);
@@ -318,7 +318,7 @@ char* parseLine(const char* line, const char* field) {
if (len == 0)
return NULL;
// Create result string
- char* result = new char[len+1];
+ char *result = new char[len + 1];
strncpy(result, str, len);
result[len] = '\0';
return result;
diff --git a/tools/create_translations/po_parser.h b/tools/create_translations/po_parser.h
index 7464c37601..ac54a7fdae 100644
--- a/tools/create_translations/po_parser.h
+++ b/tools/create_translations/po_parser.h
@@ -36,10 +36,10 @@ public:
int findIndex(const char *msg);
int size() const;
- const char* operator[](int) const;
+ const char *operator[](int) const;
private:
- char** _messages;
+ char **_messages;
int _size;
int _allocated;
};
@@ -48,23 +48,23 @@ private:
* Describes a translation entry.
*/
struct PoMessageEntry {
- char* msgstr;
- char* msgid;
- char* msgctxt;
+ char *msgstr;
+ char *msgid;
+ char *msgctxt;
PoMessageEntry(const char *translation, const char *message, const char *context = NULL) :
msgstr(NULL), msgid(NULL), msgctxt(NULL)
{
if (translation != NULL && *translation != '\0') {
- msgstr = new char[1+strlen(translation)];
+ msgstr = new char[1 + strlen(translation)];
strcpy(msgstr, translation);
}
if (message != NULL && *message != '\0') {
- msgid = new char[1+strlen(message)];
+ msgid = new char[1 + strlen(message)];
strcpy(msgid, message);
}
if (context != NULL && *context != '\0') {
- msgctxt = new char[1+strlen(context)];
+ msgctxt = new char[1 + strlen(context)];
strcpy(msgctxt, context);
}
}
@@ -85,26 +85,26 @@ public:
void addMessageEntry(const char *translation, const char *message, const char *context = NULL);
- const char* language() const;
- const char* languageName() const;
- const char* charset() const;
+ const char *language() const;
+ const char *languageName() const;
+ const char *charset() const;
int size() const;
- const PoMessageEntry* entry(int) const;
+ const PoMessageEntry *entry(int) const;
private:
- char* _lang;
- char* _charset;
- char* _langName;
+ char *_lang;
+ char *_charset;
+ char *_langName;
- PoMessageEntry** _list;
+ PoMessageEntry **_list;
int _size;
int _allocated;
};
-PoMessageEntryList* parsePoFile(const char* file, PoMessageList&);
-char* stripLine(char*);
-char* parseLine(const char* line, const char* field);
+PoMessageEntryList *parsePoFile(const char *file, PoMessageList &);
+char *stripLine(char *);
+char *parseLine(const char *line, const char *field);
#endif /* PO_PARSER_H */