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
char *p = cliBuffer;
p = strchr(++p, '#');
p = strchr(p, '#');
if (NULL != p) {
bufferIndex = (uint32_t)(p - cliBuffer);
}
// Strip trailing whitespace
while (bufferIndex > 0 && cliBuffer[bufferIndex - 1] == ' ') {
bufferIndex--;
}
// Process non-empty lines
if (bufferIndex > 0) {
// 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.param = NULL;