aboutsummaryrefslogtreecommitdiff
path: root/devtools/create_translations
diff options
context:
space:
mode:
authorChristoph Mallon2012-03-17 18:46:19 +0100
committerChristoph Mallon2012-03-17 23:00:57 +0100
commitb520b5db6900c7fa23d5b4b2160643984bba5f49 (patch)
treec8672d70ad6fece6534ef9112becf23aee57761f /devtools/create_translations
parent55c3350e38f1e74b478657624368169556845ad2 (diff)
downloadscummvm-rg350-b520b5db6900c7fa23d5b4b2160643984bba5f49.tar.gz
scummvm-rg350-b520b5db6900c7fa23d5b4b2160643984bba5f49.tar.bz2
scummvm-rg350-b520b5db6900c7fa23d5b4b2160643984bba5f49.zip
JANITORIAL: Simplify stripLine().
Simply use pointers to the source and destination chars instead of multiple indices.
Diffstat (limited to 'devtools/create_translations')
-rw-r--r--devtools/create_translations/po_parser.cpp47
1 files changed, 17 insertions, 30 deletions
diff --git a/devtools/create_translations/po_parser.cpp b/devtools/create_translations/po_parser.cpp
index bc49da40d4..cba0557752 100644
--- a/devtools/create_translations/po_parser.cpp
+++ b/devtools/create_translations/po_parser.cpp
@@ -337,47 +337,34 @@ PoMessageEntryList *parsePoFile(const char *file, PoMessageList& messages) {
return list;
}
-char *stripLine(char *line) {
+char *stripLine(char *const line) {
// This function modifies line in place and return it.
// Keep only the text between the first two unprotected quotes.
// It also look for literal special characters (e.g. preceded by '\n', '\\', '\"', '\'', '\t')
// and replace them by the special character so that strcmp() can match them at run time.
// Look for the first quote
- int start = 0;
- int len = strlen(line);
- while (start < len && line[start++] != '"') {}
+ char const *src = line;
+ while (*src != '\0' && *src++ != '"') {}
// shift characters until we reach the end of the string or an unprotected quote
- int i = 0, j = 0;
- while (start + i + j < len && line[start + i + j] != '"') {
- if (line[start + i + j] == '\\') {
- switch (line[start + i + j + 1]) {
- case 'n':
- line[i++] = '\n';
- break;
- case 't':
- line[i++] = '\t';
- break;
- case '\"':
- line[i++] = '\"';
- break;
- case '\'':
- line[i++] = '\'';
- break;
- case '\\':
- line[i++] = '\\';
- break;
+ char *dst = line;
+ while (*src != '\0' && *src != '"') {
+ char c = *src++;
+ if (c == '\\') {
+ switch (c = *src++) {
+ case 'n': c = '\n'; break;
+ case 't': c = '\t'; break;
+ case '\"': c = '\"'; break;
+ case '\'': c = '\''; break;
+ case '\\': c = '\\'; break;
default:
// Just skip
- fprintf(stdout, "Unsupported special character \"%c%c\" in string. Please contact ScummVM developers.\n", line[start + i + j], line[start + i + j + 1]);
- ++j;
+ fprintf(stdout, "Unsupported special character \"\\%c\" in string. Please contact ScummVM developers.\n", c);
+ continue;
}
- ++j;
- } else {
- line[i] = line[start + i + j];
- ++i;
}
+ *dst++ = c;
}
- line[i] = '\0';
+ *dst = '\0';
return line;
}