[comp.sys.next] Files created on IBM clones

ceblair@ux1.cso.uiuc.edu (Charles Blair) (03/11/91)

   I created a C program using the editor supplied by Turbo C 2.0 on
an IBM clone, copied this to a diskette, then read it into the NeXt.
Something went wrong somewhere along the way.  The file seemed to be
missing the last line and had what seemed to be invisible characters
which were also messing things up.  The file also looked a little 
different when I looked at it using (1) ed called from Terminal
(2) Write Now.

izumi@fugitive.berkeley.edu (Izumi Ohzawa) (03/12/91)

In article <1991Mar11.155026.3504@ux1.cso.uiuc.edu> ceblair@ux1.cso.uiuc.edu (Charles Blair) writes:
>
>   I created a C program using the editor supplied by Turbo C 2.0 on
>an IBM clone, copied this to a diskette, then read it into the NeXt.
>Something went wrong somewhere along the way.  The file seemed to be
>missing the last line and had what seemed to be invisible characters
>which were also messing things up.  The file also looked a little 
>different when I looked at it using (1) ed called from Terminal
>(2) Write Now.

You are looking at possibly two things.
One is a CR (0x0A) char at the end of each line, and the other
is a CTL-Z character at the end of the file.
Unix (NeXT) text files use LF (0x0D) as the end-of-line marker,
while MSDOS uses CR LF pair to indicate the same.
You will see CR char as "^M" in 'vi'.

CTL-Z is no longer needed for MSDOS, but a lot of editors still
put it in at the end of the file.
I know that cc on NeXT chokes on CTL-Z char, and may be other
things too.

Write a filter program which removes all control characters
with the exception of LF, TAB, FF.  It's a 5-line program.
And process all files imported from MS-DOS platforms.

Does /NextApps/Edit have an option of displaying control
characters in a text file?  That is sourly needed to see
this kind of problems with text files.

-- 
Izumi Ohzawa             [ $@Bg_78^=;(J ]
USMail: University of California, 360 Minor Hall, Berkeley, CA 94720
Telephone: (415) 642-6440             Fax:  (415) 642-3323
Internet: izumi@violet.berkeley.edu   NeXTmail: izumi@pinoko.berkeley.edu 

matthews@lewhoosh.umd.edu (Mike Matthews) (03/12/91)

In article <1991Mar11.155026.3504@ux1.cso.uiuc.edu> ceblair@ux1.cso.uiuc.edu (Charles Blair) writes:
>   I created a C program using the editor supplied by Turbo C 2.0 on
>an IBM clone, copied this to a diskette, then read it into the NeXt.
>Something went wrong somewhere along the way.  The file seemed to be
>missing the last line and had what seemed to be invisible characters
>which were also messing things up.  The file also looked a little 
>different when I looked at it using (1) ed called from Terminal
>(2) Write Now.

Does Turbo C's editor save it as straight text?

And are you aware that IBMs use CR/LF while Unix only uses one of them? (CR I
think).
------
Mike Matthews, matthews@lewhoosh.umd.edu (NeXT)/matthews@umdd (bitnet)
------
Those who believe that they believe in God, but without passion in their
hearts, without anguish in mind, without uncertainty, without doubt,
without an element of despair even in their consolation, believe only
in the God idea, not God Himself.
- Miguel de Unamuno, Spanish philosopher and writer

mdm@wdl50.wdl.loral.com (Mike D Marchionna) (03/12/91)

izumi@fugitive.berkeley.edu (Izumi Ohzawa) writes:

>In article <1991Mar11.155026.3504@ux1.cso.uiuc.edu> ceblair@ux1.cso.uiuc.edu (Charles Blair) writes:
>>
>>   I created a C program using the editor supplied by Turbo C 2.0 on
>>an IBM clone, copied this to a diskette, then read it into the NeXt.
>>Something went wrong somewhere along the way.  The file seemed to be
>>missing the last line and had what seemed to be invisible characters
>>which were also messing things up.  The file also looked a little 
>>different when I looked at it using (1) ed called from Terminal
>>(2) Write Now.

>You are looking at possibly two things.
>One is a CR (0x0A) char at the end of each line, and the other
>is a CTL-Z character at the end of the file.
>Unix (NeXT) text files use LF (0x0D) as the end-of-line marker,
>while MSDOS uses CR LF pair to indicate the same.
>You will see CR char as "^M" in 'vi'.

>CTL-Z is no longer needed for MSDOS, but a lot of editors still
>put it in at the end of the file.
>I know that cc on NeXT chokes on CTL-Z char, and may be other
>things too.

>Write a filter program which removes all control characters
>with the exception of LF, TAB, FF.  It's a 5-line program.
>And process all files imported from MS-DOS platforms.

>Does /NextApps/Edit have an option of displaying control
>characters in a text file?  That is sourly needed to see
>this kind of problems with text files.

Or you could use the program UNIX already provides for this sort of thing
called 'tr'.  What, you didn't intuitively know that tr stood for translate
characters.  Well neither did I.  This here little command will delete all
CR and CTRL-Z characters from "infile" and write the remaining characters to
"outfile".

tr -d '\015\032' < infile > outfile

-- 
+--------------||--##--%%--@@------+--------------------------------------+ 
|El-Rayo-X-----||--##--%%--@@----->| Brain and brain!  What is brain!     |
|El-Rayo-X-----||--##--%%--@@----->|       --Star Trek (Spock's Brain)    |
+--------------||--##--%%--@@------+--------------------------------------+

hardy@golem.ps.uci.edu (Meinhard E. Mayer (Hardy)) (03/12/91)

There is a simpler way to get rid of the blasted ^M and ^Z characters
imported from MS-DOS: Emacs will show them and you can  query-replace
them with spaces. It is faster than writing a script.

Hardy 
			  -------****-------
Meinhard E. Mayer (Prof.) Department of Physics, University of California
Irvine CA 92717;(714) 856 5543; hardy@golem.ps.uci.edu or MMAYER@UCI.BITNET

scott@texnext.gac.edu (Scott Hess) (03/13/91)

In article <HARDY.91Mar11234827@golem.ps.uci.edu> hardy@golem.ps.uci.edu (Meinhard E. Mayer (Hardy)) writes:
   There is a simpler way to get rid of the blasted ^M and ^Z characters
   imported from MS-DOS: Emacs will show them and you can  query-replace
   them with spaces. It is faster than writing a script.

That is, if you know emacs.  If you don't know emacs, you're not going to
have much luck finding out how to M-x to get to where you can run
query-replace, then escape control characters, then do all the other magic
needed, stuff which is obvious to those of us who use emacs, maybe not
so much to someone who's just come over from MSDOS, editting with
one of the gazillion PC editors out there.

[I don't mean this as an emacs flame - just pointing out that emacs
 certainly isn't what one would label user-friendly :-) ]

Later,
--
scott hess                      scott@gac.edu
Independent NeXT Developer	GAC Undergrad
<I still speak for nobody>
"Tried anarchy, once.  Found it had too many constraints . . ."
"I smoke the nose Lucifer . . . Banana, banana."

melling@cs.psu.edu (Michael D Mellinger) (03/13/91)

In article <SCOTT.91Mar12100159@texnext.gac.edu> scott@texnext.gac.edu (Scott Hess) writes:

   That is, if you know emacs.  If you don't know emacs, you're not going to
   have much luck finding out how to M-x to get to where you can run
   query-replace, then escape control characters, then do all the other magic
   needed, stuff which is obvious to those of us who use emacs, maybe not
   so much to someone who's just come over from MSDOS, editting with
   one of the gazillion PC editors out there.

Like JOVE, MicroEmacs, and Freemacs(my personal favorite).

   [I don't mean this as an emacs flame - just pointing out that emacs
    certainly isn't what one would label user-friendly :-) ]

Actually, Emacs is not too hard to learn if someone explains how to
use the help.  I hate to see someone use an "easier" editor because he
can master it in an hour.

-Mike

hardy@golem.ps.uci.edu (Meinhard E. Mayer (Hardy)) (03/14/91)

Except if ou also happen to have used emacs-epsilon-mg or whatever 
under MS-DOS. Let's face it, emacs is a way of life, not just an
editor!

Hardy 
			  -------****-------
Meinhard E. Mayer (Prof.) Department of Physics, University of California
Irvine CA 92717;(714) 856 5543; hardy@golem.ps.uci.edu or MMAYER@UCI.BITNET