[Scummvm-cvs-logs] SF.net SVN: scummvm:[52285] scummvm/trunk/tools/create_translations

criezy at users.sourceforge.net criezy at users.sourceforge.net
Sun Aug 22 21:47:07 CEST 2010


Revision: 52285
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52285&view=rev
Author:   criezy
Date:     2010-08-22 19:47:07 +0000 (Sun, 22 Aug 2010)

Log Message:
-----------
i18n: Formatting fixes.

Modified Paths:
--------------
    scummvm/trunk/tools/create_translations/create_translations.cpp
    scummvm/trunk/tools/create_translations/po_parser.cpp
    scummvm/trunk/tools/create_translations/po_parser.h

Modified: scummvm/trunk/tools/create_translations/create_translations.cpp
===================================================================
--- scummvm/trunk/tools/create_translations/create_translations.cpp	2010-08-22 18:49:19 UTC (rev 52284)
+++ scummvm/trunk/tools/create_translations/create_translations.cpp	2010-08-22 19:47:07 UTC (rev 52285)
@@ -84,7 +84,7 @@
 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 @@
 			++numLangs;
 	}
 	
-	FILE* outFile;
+	FILE *outFile;
 	int i, lang;
 	int len;
 
@@ -137,7 +137,7 @@
 	// 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 @@
 	// 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 @@
 	
 	// 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 @@
 	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 @@
 	fclose(outFile);
 	
 	// Clean the memory
-	for (i = 0 ; i < numLangs ; ++i)
+	for (i = 0; i < numLangs; ++i)
 		delete translations[i];
 	delete [] translations;
 

Modified: scummvm/trunk/tools/create_translations/po_parser.cpp
===================================================================
--- scummvm/trunk/tools/create_translations/po_parser.cpp	2010-08-22 18:49:19 UTC (rev 52284)
+++ scummvm/trunk/tools/create_translations/po_parser.cpp	2010-08-22 19:47:07 UTC (rev 52285)
@@ -33,7 +33,7 @@
 }
 
 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 @@
 	// 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 @@
 	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 @@
 	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 @@
 	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 @@
 	// 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 @@
 	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 @@
 	
 	// 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 @@
 	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 @@
 	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 @@
 	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;

Modified: scummvm/trunk/tools/create_translations/po_parser.h
===================================================================
--- scummvm/trunk/tools/create_translations/po_parser.h	2010-08-22 18:49:19 UTC (rev 52284)
+++ scummvm/trunk/tools/create_translations/po_parser.h	2010-08-22 19:47:07 UTC (rev 52285)
@@ -36,10 +36,10 @@
 	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 @@
  * 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 @@
 
 	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 */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list