Sometime on 4/5/2011, Ron Wilson wrote:
>Interestingly, Microsoft choose control-Z as end-of-file,
>rather than any of the other defined control values that might have
>been better. My guess is that that was because Z is the last 
>letter of
>the alphabet, and Z being closest to the lower left corner of the
>keyboard.

For some reason, that sets off an urge to reminisce about old 
computers...

Ctrl+Z was used as an end of file mark in CP/M-80, and DOS 1.0 
had a lot of CP/M heritage and inspiration. That is where drive 
letters and 8.3 file names come from, for instance.

Ctrl+Z (or some marker, at least) was needed because the CP/M 
file system stored files in whole disk blocks, and had no other 
way of marking the end of a file to single-byte accuracy. CP/M 
wasn't alone in this choice. Digital's RT-11 also stored files 
in whole block increments and used Ctrl+Z as EOF.

IIRC, very early versions of DOS followed the same conventions, 
and many old utilities would pad files out to block boundaries 
or at least insert a Ctrl+Z after the last byte written. To this 
day, files opened in Text on Windows will report EOF at the 
first Ctrl+Z encountered, although all versions of the FAT file 
system and its descendents know the file size in bytes.

As a further bit of trivia, PNG files include a Ctrl+Z in their 
header to explicitly catch the case that the file was opened 
with text-mode translations enabled. In that case, the file will 
appear to end after six bytes are read. The header is: 0x89 0x50 
0x4E 0x47 0x0d 0x0a 0x1a 0x0a. This sequence catches a bunch of 
incorrect ways to process the file including 7-bit only 
transmission, CRLF to NL, NL to CRLF, Ctrl+Z as EOF, and byte 
order. And if you use TYPE at the command prompt to display a 
PNG file, it will show the string PNG before stopping.

Incidentally, the use of Ctrl+D in Unix derivatives is a 
property of the tty driver and it does not get translated as EOF 
when read from files at all.

Ross Berteig                               r...@cheshireeng.com
Cheshire Engineering Corp.           http://www.CheshireEng.com/

_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to