in reply to Best way to implement ungetstring?

I have never understood why unget was used except for networking code where you want to peak at some data to see where you want to send it to, maybe I am missing something but what are you doing where you want to reinsert chars into the buffer?

-Waswas

Replies are listed 'Best First'.
Re: Re: Best way to implement ungetstring?
by Anonymous Monk on Aug 19, 2003 at 23:37 UTC
    Simple--first, test whether a stream is binary. You can't use -B on a stream because it consumes the bytes. If it is binary, see if it is a known compressed file type. Then redirect the stream to an appropriate decompressor program.

    Yes, I *could* store the bytes I've read, but things would be much simpler if I could unget them. I could also write an external file, but I don't want to risk a security flaw. (This is for email.)