| Thread Previous • Date Previous • Date Next • Thread Next |
On Tue, 31 Aug 2010 14:40:28 +0200, Diego Biurrun <diego@xxxxxxxxxx> wrote:
+ /* terminate the line at comment sign */ + found = index(line, '#'); + if (found) { + *found = '\0'; + } + + /* remove trailing new line (there is at most one) */ + found = index(line, '\n'); + if (found) { + *found = '\0'; + }This looks like it can be merged.
You mean like this?
char *p;
...
/* terminate at comment sign or strip newline */
for (p = line; *p; ++p) {
if(*p == '#' || *p == '\n') {
*p = '\0';
break;
}
}
The "for (...) {...}" is shorter but some prefer "while (*p) { ...; ++p;
}". Is there a policy on this?
| Thread Previous • Date Previous • Date Next • Thread Next |