On Tue, 31 Aug 2010 14:40:28 +0200, Diego Biurrun <[email protected]> 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?
_______________________________________________
Mailing list: https://launchpad.net/~hipl-core
Post to : [email protected]
Unsubscribe : https://launchpad.net/~hipl-core
More help : https://help.launchpad.net/ListHelp