josef@nixpbe.UUCP (Moellers) (09/21/90)
Hi, Can somebody tell me how "hard" the CR/LF sequence is built into CP/M? I'm asking this as I want to read a text-file line by line and need a definite place to terminate the line. UNIX uses a single \n, but with a two character sequence, I'm not sure if LF is always the last character and the second last character is always a CR which I can discard. Regards, -- | Josef Moellers | c/o Nixdorf Computer AG | | USA: mollers.pad@nixdorf.com | Abt. PXD-S14 | | !USA: mollers.pad@nixdorf.de | Heinz-Nixdorf-Ring | | Phone: (+49) 5251 104662 | D-4790 Paderborn |
mwilson@crash.cts.com (Marc Wilson) (09/22/90)
In article <josef.653915275@peun11> josef@nixpbe.UUCP (Moellers) writes: >Hi, >Can somebody tell me how "hard" the CR/LF sequence is built into CP/M? >I'm asking this as I want to read a text-file line by line and need a >definite place to terminate the line. It's not built into CP/M at all. It's just that most terminals and hardcopy drvices of the time required both the CR and the LF to get to the first position on the next line. >UNIX uses a single \n, but with a two character sequence, I'm not sure >if LF is always the last character and the second last character is >always a CR which I can discard. Why don't you just scan for the CR? If you find one, then look at the next character. If it's a LF, then throw it away. If it's not, you've got a weird file. You could always therminate the line at 80 characters or CR, whichever comes first. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Marc Wilson ARPA: ...!crash!mwilson@nosc.mil ...!crash!pnet01!pro-sol!mwilson@nosc.mil UUCP: [ cbosgd | hp-sdd!hplabs | sdcsvax | nosc ]!crash!mwilson INET: mwilson@crash.CTS.COM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Marc Wilson ARPA: ...!crash!mwilson@nosc.mil ...!crash!pnet01!pro-sol!mwilson@nosc.mil UUCP: [ cbosgd | hp-sdd!hplabs | sdcsvax | nosc ]!crash!mwilson INET: mwilson@crash.CTS.COM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ewen@actrix.co.nz (Ewen McNeill) (09/23/90)
In article <4584@crash.cts.com> mwilson@crash.cts.com (Marc Wilson) writes: > Why don't you just scan for the CR? If you find one, then look > at the next character. If it's a LF, then throw it away. If it's > not, you've got a weird file. IMHO, the best idea is to scan for a LF. If you find a CR, then ignore it. This means that you can read in text files that were produced on Unix/Amiga/whatever which only have LFs, directly. If more CP/M utilities did this (UNARC does when typing a file from an archive), then life would be much nicer, and I could throw away my unix2cpm program. --- Ewen McNeill. Email: ewen@actrix.co.nz
darcy@druid.uucp (D'Arcy J.M. Cain) (09/24/90)
In article <josef.653915275@peun11> josef@nixpbe.UUCP (Moellers) writes: >Hi, >Can somebody tell me how "hard" the CR/LF sequence is built into CP/M? >I'm asking this as I want to read a text-file line by line and need a >definite place to terminate the line. >UNIX uses a single \n, but with a two character sequence, I'm not sure >if LF is always the last character and the second last character is >always a CR which I can discard. > A quick and dirty method that I have used successfully in both DOS and CP/M is to simply ignore CRs and use \n as the line terminator. This will work most of the time. It even ports to Unix unchanged although it is a little wasteful of the CPU checking for non-existent CRs. -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | MS-DOS: The Andrew Dice Clay West Hill, Ontario, Canada | of operating systems. + 416 281 6094 |
rickc@pogo.WV.TEK.COM (Rick Clements) (10/02/90)
In article <1990Sep23.092141.1446@actrix.co.nz> ewen@actrix.co.nz (Ewen McNeill) writes: >In article <4584@crash.cts.com> mwilson@crash.cts.com (Marc Wilson) writes: >> Why don't you just scan for the CR? If you find one, then look >> at the next character. If it's a LF, then throw it away. If it's >> not, you've got a weird file. >IMHO, the best idea is to scan for a LF. If you find a CR, then >ignore it. This means that you can read in text files that were >produced on Unix/Amiga/whatever which only have LFs, directly. The only problem is some system use only CR. (The Macintosh is the one I use most often.) I mentioned to someone else that I like PostScript's mothod the best. It takes CR, LF or CR LF as a single new line character. All three are seen by the program as a single new line. On output new line is converted to CR LF. This works reasonably well on all systems. (There may be extra characters on some systems but no files come in as a single line.) -- Rick Clements (RickC@pogo.WV.TEK.COM)