public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: CR/LF translation
@ 2000-10-04 11:26 Earnie Boyd
  0 siblings, 0 replies; 4+ messages in thread
From: Earnie Boyd @ 2000-10-04 11:26 UTC (permalink / raw)
  To: DJ Delorie, ryans; +Cc: cygwin

--- DJ Delorie <dj@delorie.com> wrote:
> 
> A text file created by Notepad will always have the CR at the end of
> the line.  This is the "normal" DOS text format.
> 
> Use "cat -v" to actually *see* the CRs as printable characters.  "od
> -c foo" will also show you exactly which characters are in your file
> (`foo' in the example).
> 
> MSVC will *always* treat a file as DOS text unless specified otherwise
> (so it eats CRs).  I'm not sure how to change stdin to binary with
> MSVC.  With Cygwin, you should be able to do setmode(0,O_BINARY).
> 

FWIR, that is the way you do it with MSVC.

Cheers,

=====
Earnie Boyd
mailto:earnie_boyd@yahoo.com

---         < http://earniesystems.safeshopper.com >         ---
--- Cygwin: POSIX on Windows < http://gw32.freeyellow.com/ > ---
---   Minimalist GNU for Windows < http://www.mingw.org/ >   ---

__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: CR/LF translation
@ 2000-10-04 11:24 Earnie Boyd
  0 siblings, 0 replies; 4+ messages in thread
From: Earnie Boyd @ 2000-10-04 11:24 UTC (permalink / raw)
  To: ryans, cygwin

--- Ryan Seghers <ryans@svisionllc.com> wrote:
>
> What's
> wrong with my setup?
>

Nothing, most likely.  The output of `cygcheck -s -r -v' pasted in a mail to
the list would help answer that question.

-8<- 
>
> Is my dump program build picking up a cygwin DLL or
> something?
> 

It's the "or something" and that something is your lack of understanding on
"text mode processing" vs "binary mode processing".  Check the archives, FAQ,
documentation and the Terms section on my webpage.

Cheers,

=====
Earnie Boyd
mailto:earnie_boyd@yahoo.com

---         < http://earniesystems.safeshopper.com >         ---
--- Cygwin: POSIX on Windows < http://gw32.freeyellow.com/ > ---
---   Minimalist GNU for Windows < http://www.mingw.org/ >   ---

__________________________________________________
Do You Yahoo!?
Yahoo! Photos - 35mm Quality Prints, Now Get 15 Free!
http://photos.yahoo.com/

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: CR/LF translation
  2000-10-04 11:06 Ryan Seghers
@ 2000-10-04 11:17 ` DJ Delorie
  0 siblings, 0 replies; 4+ messages in thread
From: DJ Delorie @ 2000-10-04 11:17 UTC (permalink / raw)
  To: ryans; +Cc: cygwin

A text file created by Notepad will always have the CR at the end of
the line.  This is the "normal" DOS text format.

Use "cat -v" to actually *see* the CRs as printable characters.  "od
-c foo" will also show you exactly which characters are in your file
(`foo' in the example).

MSVC will *always* treat a file as DOS text unless specified otherwise
(so it eats CRs).  I'm not sure how to change stdin to binary with
MSVC.  With Cygwin, you should be able to do setmode(0,O_BINARY).

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* CR/LF translation
@ 2000-10-04 11:06 Ryan Seghers
  2000-10-04 11:17 ` DJ Delorie
  0 siblings, 1 reply; 4+ messages in thread
From: Ryan Seghers @ 2000-10-04 11:06 UTC (permalink / raw)
  To: cygwin

Hi,

I have a problem with end-of-line characters in a bash script.  I'd
appreciate any suggestions or information you can provide.

In summary, I'm getting different behavior from this script based on whether
I process a NT text file or a Cygwin (vim) text file.  I read somewhere that
Cygwin did the end-of-line character translation automatically, but
apparently not.  I don't have CYGWIN=binmode set.  I saw an option in
Cygwin's setup.exe for default file type, DOS vs Unix.  I have installed
both ways and seen the same behavior. I uninstalled everything using
setup.exe between installs.

Here's the bash script:
	#!bash
	list=`cat $1`
	for word in $list;
		do
			echo List item is ${word}END-OF-LINE
	done

Here's the input file (indented) created by concatenating a file created in
notepad (3 lines) onto the end of a file created with vim (3 lines) using
cat:
	this
	is
	unix
	this
	is
	notepad

Here's the output on my test file (indented):
	List item is thisEND-OF-LINE
	List item is isEND-OF-LINE
	List item is unixEND-OF-LINE
	END-OF-LINEs this
	END-OF-LINEs is
	END-OF-LINEs notepad


So the last three lines are mangled, apparently by a carriage return
character.  It seems fairly clear that notepad put in a CR character which
is not being stripped by cat.  I can fix this with a dos2unix utility I
downloaded, but it would be more convenient not to have to do this.  What's
wrong with my setup?

Here are the relevant versions:
	bash 2.04-1
	cygwin 1.1.4

Thanks in advance,
Ryan Seghers


PS.  Here's a bonus question.  I tried to write my own dos2unix.  So I wrote
a dump program in Visual C++ without any special includes or links (not
linking any cygwin DLLs as far as I know).  I wanted to see what the codes
were for the end-of-line characters so I could strip them.  When I run my
dump from a NT Command Prompt on the text file, I see no difference between
the first three lines and the last three lines.  All the lines are
terminated by a single character, int 10!?  So my dump program isn't showing
the CR character.  Is my dump program build picking up a cygwin DLL or
something?

Here's the source:
	//
	// read the file
	//
	char c;
	while(!feof(fd))
	{
		c = getc(fd);
		if (c != -1)


			printf("c (int) = %d\n", c);
		}
	}







--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2000-10-04 11:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-04 11:26 CR/LF translation Earnie Boyd
  -- strict thread matches above, loose matches on Subject: below --
2000-10-04 11:24 Earnie Boyd
2000-10-04 11:06 Ryan Seghers
2000-10-04 11:17 ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).