Changed if/if/else/if/eleven chain to switch
Inlined isdigit in switch statement. Removed unused #includes. Documented unreachable segment with code (Q_ASSERT). Reviewed-by: Denis Dzyubenko (cherry picked from commit 3596db6c9bb8db42476d0c7b52fa2043dc67135b) Change-Id: I98c33801fd8794e95ba8fc0b5c4efe9b1910682b Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
This commit is contained in:
parent
74276637d9
commit
88316bf283
@ -53,10 +53,6 @@
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined(Q_OS_UNIX)
|
||||
# include "private/qcore_unix_p.h" // overrides QT_OPEN
|
||||
#endif
|
||||
@ -153,23 +149,34 @@ static int createFileFromTemplate(char *const path,
|
||||
for (char *iter = placeholderStart;;) {
|
||||
// Character progression: [0-9] => 'a' ... 'z' => 'A' .. 'Z'
|
||||
// String progression: "ZZaiC" => "aabiC"
|
||||
if (*iter == 'Z') {
|
||||
*iter++ = 'a';
|
||||
if (iter == placeholderEnd)
|
||||
return -1;
|
||||
} else {
|
||||
if (isdigit(*iter))
|
||||
switch (*iter) {
|
||||
case 'Z':
|
||||
// Rollover, advance next character
|
||||
*iter = 'a';
|
||||
else if (*iter == 'z') /* inc from z to A */
|
||||
if (++iter == placeholderEnd)
|
||||
return -1;
|
||||
|
||||
continue;
|
||||
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
*iter = 'a';
|
||||
break;
|
||||
|
||||
case 'z':
|
||||
// increment 'z' to 'A'
|
||||
*iter = 'A';
|
||||
else {
|
||||
break;
|
||||
|
||||
default:
|
||||
++*iter;
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
|
||||
Q_ASSERT(false);
|
||||
}
|
||||
|
||||
//************* QTemporaryFileEngine
|
||||
|
Loading…
Reference in New Issue
Block a user