info-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: Spaces added ... and line endings in general


From: James Lyon
Subject: Re[2]: Spaces added ... and line endings in general
Date: Wed, 24 Jan 2001 09:38:12 +0000

ES> How should a *single* CVS executable "accept/deal with" all of
ES> the following, which it *must* do if it's to defend itself
ES> against the kinds of abuse you want to throw at it?
ES>   - Unix format: <LF>
ES>   - DOS format:  <CR><LF>
ES>   - Mac format:  <CR>
ES>   - Files in which some lines use one of the above conventions,
ES>     and some use another (because you edited a DOS-format file in
ES>     vi on a Unix box, and didn't religiously type the ^v^m's)
ES>   - Unix-format files that contain <CR>s as actual formatting
ES>     characters -- perhaps even at the ends of lines, for doing
ES>     overstriking, so looking specifically for <CR><LF> is unsafe
ES>   - Record-oriented formats which use length words and have no
ES>     terminator at all.  This is old mainframe stuff -- dying, but
ES>     alas not dead yet.  (For an example, see below.)

The request was to handle only the line-terminated approach, and not
the record-orientated approach.

You just treat *any* <LF> *or* <CR> as a line terminitor with the
single *exception* that any <LF> that is found immediately following a
<CR> is skipped without treating it as a line terminator.

This simple algorithm is *very* effective except when a "formatting"
<CR> is used with something following it other than an <LF>. But
that's logically ambiguous anyway and so you have to tell "it" what to
do with such situations.

Having said all that, the real answer is to use utilities like
unix2dos and dos2unix to make sure your files are fixed before using
them in the particular environment... so the problem is evaded in the
first place.

Cheers,
James.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]