lkml.org 
[lkml]   [2006]   [Jul]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Support DOS line endings
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-07-13 20:51    [W:0.039 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site