Optimized comment stripper code

This commit is contained in:
ProDrone 2015-05-14 00:11:31 +02:00
parent 1df9097e32
commit 0ee67a521b
1 changed files with 8 additions and 7 deletions

View File

@ -1712,19 +1712,20 @@ void cliProcess(void)
// Strip comment starting with # from line // Strip comment starting with # from line
char *p = cliBuffer; char *p = cliBuffer;
p = strchr(++p, '#'); p = strchr(p, '#');
if (NULL != p) { if (NULL != p) {
bufferIndex = (uint32_t)(p - cliBuffer); bufferIndex = (uint32_t)(p - cliBuffer);
} }
// Strip trailing whitespace // Process non-empty lines
while (bufferIndex > 0 && cliBuffer[bufferIndex - 1] == ' ') { if (bufferIndex > 0) {
bufferIndex--; // Strip trailing whitespace
} while (bufferIndex > 0 && cliBuffer[bufferIndex - 1] == ' ') {
bufferIndex--;
}
cliBuffer[bufferIndex] = 0; // null terminate cliBuffer[bufferIndex] = 0; // null terminate
if (cliBuffer[0] != '#') {
target.name = cliBuffer; target.name = cliBuffer;
target.param = NULL; target.param = NULL;