From a88d97174e9967a6fc606df56fc230ef954a0f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Wed, 18 Dec 2013 13:47:44 +0100 Subject: Do not close string data by a double null terminator. There is no point in saving \0 twice. Any code that could relay on it is broken anyway, because moc saves \0\0 for an empty string. Change-Id: I28fa4f78aae8c883c088df43ec89d608a99b3bdd Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/tools/moc/generator.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/tools/moc') diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index 3546d2e395..8653e25738 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -244,7 +244,7 @@ void Generator::generateCode() int len = 0; for (int i = 0; i < strings.size(); ++i) len += strings.at(i).length() + 1; - fprintf(out, " char stringdata[%d];\n", len + 1); + fprintf(out, " char stringdata[%d];\n", len); } fprintf(out, "};\n"); @@ -316,7 +316,8 @@ void Generator::generateCode() col += spanLen; } - fputs("\\0", out); + if (i != strings.size() - 1) // skip the last \0 the c++ will add it for us + fputs("\\0", out); col += len + 2; } -- cgit v1.2.3