Nicholas Clark [mailto:[EMAIL PROTECTED]] asks: > Note that sv.c has this in sv__gets: > > #if defined(VMS) && defined(PERLIO_IS_STDIO) > /* An ungetc()d char is handled separately from the regular > * buffer, so we getc() it back out and stuff it in the buffer. > */ > i = PerlIO_getc(fp); > if (i == EOF) return 0; > *(--((*fp)->_ptr)) = (unsigned char) i; > (*fp)->_cnt++; > #endif > > How that code can know whether there is space at the start of > the buffer to do the stuffing, I don't know.
I wondered this too. I could only check our own implementation. We use the same trick of putting the ungetc's character right back into the input buffer. The reason it works is that (a) we only permit you to ungetc a single character, and (b) we never fill the buffer unless we are reading a byte out of it too. So we NEVER have a case where the ungetc function can be called with the ptr on the first byte of the buffer. PG
