From mboxrd@z Thu Jan 1 00:00:00 1970 To: 9fans@cse.psu.edu Date: Wed, 2 Jan 2008 11:00:26 +0000 From: "smahapatra_ct@yahoo.com" Message-ID: <16287bc4-e635-4d1d-9ede-2f3f02c8e8ae@f52g2000hsa.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [9fans] bungetc error Topicbox-Message-UUID: 24e2b4cc-ead3-11e9-9d60-3106f5b1d025 I think after bgetc returns Beof, bungetc should change the state, but not decrement bp->icount. The correct code should be: int Bungetc(Biobufhdr *bp) { if(bp->state != Bractive) { if (bp->state == Bracteof) bp->state = Bractive; return Beof; } bp->icount--; return 1; } instead of the current code: int Bungetc(Biobufhdr *bp) { if(bp->state == Bracteof) bp->state = Bractive; if(bp->state != Bractive) return Beof; bp->icount--; return 1; } Regards, Saroj Mahapatra