Re: [PATCH] Support DOS line endings

From: Sam Ravnborg
Date: Thu Jul 13 2006 - 14:17:00 EST


On Sat, Jul 08, 2006 at 05:23:17AM +0200, Roman Zippel wrote:
> Hi,
>
> On Fri, 7 Jul 2006, Matthew Wilcox wrote:
>
> > Kconfig doesn't currently handle config files with DOS line endings.
> > While these are, of course, an abomination, etc, etc, it can be handy
> > to not have to convert them first. It's also a tiny patch and even adds
> > support for lines ending in just \r or even \n\r.
>
> Did you try the latter? Unless you told fgets() about it I don't see how
> it should work.
>
> > if (p2)
> > *p2 = 0;
> > + p2 = strchr(p, '\r');
> > + if (p2)
> > + *p2 = 0;
>
> I think something like this would be simpler:
>
> if (p2[-1] == '\r')
> p2[-1] = 0;
Negative index'es always make me supsicious.
I've applied followign patch.
The fgets thing I have not looked at.

Sam

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++;
+ }
if (def == S_DEF_USER) {
sym = sym_find(line + 7);
if (!sym) {
-
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/