J3/01-215 To: J3 From: Malcolm Cohen Subject: Unresolved issues 127 and 128 Date: 21st May 2001 1. Introduction Issue 128 says "The words ... imply to me that a nonadvancing formatted stream output statement that writes a linefeed as the last character in a stream file will cause there to be an empty and incomplete record at the end of the file." This idea directly contradicts the definition of record structure for a stream file ([168:31-34]); this definition implies that writing an empty incomplete record at the end of file will have no effect on the contents of the file (viewed as file storage units) and thus no effect on what happens on reading the file in again. But if it makes the editor happy, I'll try to spell it out as a separate rule saying that writing an empty ... has no effect. (It would be possible instead to describe new record creation for stream files as occurring when the first datum [or record marker] is written; this however strikes me as being a much messier description.) Issue 127 says "I'm not convinced that end-of-file conditions are fully covered for formatted streams. Note that there is no endfile record in a formatted stream (and I doubt we want there to be one). A strict reading of the 2nd sentence of 9.2.3.2 would tell me that it didn't apply because the endfile ^^^^^^^ actually 9.2.3.3 wasn't as a result of reading an endfile record, but that's subtle. I'd suggest explicitly adding something about sequential; didn't do that myself ^^^^^^^^^^ presumably streams in case someone thinks that this should apply." OK, I'll add something about formatted stream input. It further asks: "What happens when reading a partial record at the end of a file? We say that there may be partial records, but I don't see where we ever say what the effects of such a thing are. If there is a partial record at the end of a file, is it possible to position after it so that it is the previous record?" No. The file ends with the last data character, not with a record marker. "Should, perhaps, reading past the end of a partial record be an error instead of an eor or eof condition?" IMO it should be an eof condition, though it could be made to work if we simultaneously raised eor and eof! Just raising eor is no good, as it prevents the program from discovering the important fact that the last record is incomplete. Raising error is no good either, as it makes it impossible to distinguish between an incomplete final record and a true i/o error. We really do want to be able to read this things accurately, so that we can handle C files properly (both binary and text). "Does padding apply to partial records?" Yes, but the end-of-file condition should be raised, not end-of-record. "Some of these questions are probably best answered elsewhere than in 9.2.3.2, but I'll lump them all into one J3 note." ^^^^^^^ Again, 9.2.3.3. 2. Edits to 01-007r1 [168:35+] Insert new list item "(2a) Writing an empty record with no record marker to the file has no effect. Note 9.7a: Note that because the record structure is determined from the record markers that are stored in the file itself, an incomplete record at the end of the file is necessarily not empty." {Explain some of the consequences of item (1) in the list.} [170:18+] Insert new paragraph "For formatted stream input, if an end-of-file condition occurred, the file position is not changed." {On eof, leave the file positioned after the last character in it. This might be after a record marker, it might not.} [170:26-39] Delete J3 note 127. [186:41] Before "." insert ", unless the file is a stream file and the current record is an incomplete record at the end of the file (the end-of-file condition occurs instead)." {Fix the description of when end-of-record occurs. Unfortunately, this is not the only place it is described!} [191:28] Change "." to ", and the record is not incomplete (9.2.2.3). If the record is incomplete, an end-of-file condition occurs instead of an end-of-record condition." {Raise EOF for running off an incomplete record with PAD='NO'.} [191:29-30] Delete "an end-of-record condition occurs and". {For PAD='YES', start by just specifying the padding.} [191:31] After "." insert "If the record is incomplete, an end-of-file condition occurs; otherwise, an end-of-record condition occurs." {Specify which condition occurs.} [221:14-23] Delete J3 note 128. ===END