Re: [PATCH] Support DOS line endings
From: Sam Ravnborg
Date: Thu Jul 13 2006 - 15:33:59 EST
On Thu, Jul 13, 2006 at 08:47:12PM +0200, Roman Zippel wrote:
> 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').
There is no semantic difference between decrementing a variable and a
negative index.
But I used this one anyway.
So now it look like this.
Sam
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index a69d8ac..b7e7281 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -195,6 +195,8 @@ load:
p2 = strchr(p, '\n');
if (p2)
*p2 = 0;
+ if (*--p2 == '\r')
+ *p2 = 0;
if (def == S_DEF_USER) {
sym = sym_find(line + 7);
if (!sym) {
@@ -266,6 +268,7 @@ load:
;
}
break;
+ case '\r':
case '\n':
break;
default:
-
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/