[8094] in Athena Bugs

home help back first fref pref prev next nref lref last post

decmips 7.3M: dosread

daemon@ATHENA.MIT.EDU (Shamu the Chiller Whale)
Tue Sep 3 20:26:33 1991

To: bugs@ATHENA.MIT.EDU, cfyi@ATHENA.MIT.EDU
Date: Tue, 03 Sep 91 20:26:44 EDT
From: Shamu the Chiller Whale <krishna@ATHENA.MIT.EDU>

System name:		hydrox-cookie
Type and version:	KN01 7.3M (1 update(s) to same version)
Display type:		PMAX-MFB

What were you trying to do?

Dosread in a file with the -a (ascii read) option.

What's wrong:

This section of code in /source/bsd-4.3/common/ibm/dosread.c needs to be
changed, reflecting what I believe to be a change in IBM PC DOS, or at least
the way files are stored these days.  Now instead of a ^Z for eof, there's a ^D
at the beginning and end of a file, I think.  Anyone want to verify this?

{
    static          next = 0;
    register char  *end;
    register char  *p = buff;
    register int    c;

    if (!aflg)
	return (read(fileno(file), buff, length));
    for (end = buff + length; p < end;)
    {
	if (c = next)
	{
	    *p++ = c;
	    next = 0;
	    continue;
	}			/* handle worst case */
	c = getc(file);
	if (c == EOF)
	{
	    if (p != buff)
		*p++ = CTL_Z;	/* not quite correct but close */
	    break;
	}
	if (c == NL)
	{
	    next = c;
	    c = CR;
	}
	*p++ = c;
    }
    return (p - buff);
}


What should have happened:

	It should have removed any non-supposed-to-be-there ascii characters.
	It missed the beginning and trailing ^D.

Please describe any relevant documentation references:
	

home help back first fref pref prev next nref lref last post