Re: [PATCH] Support DOS line endings

From: Roman Zippel
Date: Thu Jul 13 2006 - 14:46:07 EST


Hi,

On Thu, 13 Jul 2006, Sam Ravnborg wrote:

> > if (p2[-1] == '\r')
> > p2[-1] = 0;
> Negative index'es always make me supsicious.

Opencoding of the strchr is not much better, you can change the above also
to (*--p2 == '\r').

> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index 2ee48c3..a30b1bb 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -192,9 +192,14 @@ load:
> if (!p)
> continue;
> *p++ = 0;
> - p2 = strchr(p, '\n');
> - if (p2)
> - *p2 = 0;
> + p2 = p;
> + while (*p2) {
> + if (*p2 == '\r' || *p2 == '\n') {
> + *p2 = 0;
> + break;
> + }
> + p2++;
> + }

IMO that's still too complicated, a '\n' is always the last character
(unless the line was too long), with an optional '\r' in front of it.

bye, Roman
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/