getc: make sure EOF is "sticky"
authorH. Peter Anvin <hpa@zytor.com>
Wed, 23 May 2007 05:46:25 +0000 (22:46 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 23 May 2007 05:46:25 +0000 (22:46 -0700)
Make sure to keep all the counters at zero if we hit EOF, so that
subsequent calls will also hit EOF (we rely on that in some places.)

getc.inc

index 2db6858..610d01b 100644 (file)
--- a/getc.inc
+++ b/getc.inc
@@ -148,6 +148,11 @@ getc:
                jmp .got_data
 
 .empty:
+               ; CX == 0 at this point; gc_bufbytes was clobbered
+               ; by the subtract; we need to restore it to zero so
+               ; we will continue to get EOF on any further attempts
+               ; to read the file.
+               mov [di+gc_bufbytes],cx
                popad
                stc
                jmp .ret