hipl-core team mailing list archive
-
hipl-core team
-
Mailing list archive
-
Message #00133
Re: Patch: Allow empty lines in hipfw config. Clean up config reader.
On Tue, Aug 31, 2010 at 11:10:45PM +0200, Christof Mroz wrote:
> 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;
> }
> }
This does more than just merge the above redundant statements, but yes,
I had something like this in mind. If you have tested the code and it
works, I guess it is fine to commit.
> The "for (...) {...}" is shorter but some prefer "while (*p) { ...; ++p;
> }". Is there a policy on this?
Not that I know of. Go for whatever floats your boat.
Diego
References