DevSolar / pdclib

The Public Domain C Library
https://pdclib.rootdirectory.de
Creative Commons Zero v1.0 Universal
228 stars 41 forks source link

ungetc() not properly supported #16

Closed DevSolar closed 4 years ago

DevSolar commented 4 years ago

I just realized there is a major muckup surrounding that ugly red-headed stepchild of , ungetc(). (Which had been troubling me ever since I touched that header...)

As of now, ungetc() is not properly supported. As this is all kinds of "breaking", I will handle this issue with the utmost priority.

DevSolar commented 4 years ago

Somehow I have not yet been able to trigger the actual error I was sure had to be there when I looked at the code. Have I been imagining things, or did I somehow code around it and just forgot to document it for my later self? Will continue to investigate.

DevSolar commented 4 years ago

Unfortunately I did not imagine things. The last commit (both SVN and Git) triggers something. I assume that I have not handled the ungetc buffer correctly in all places. I am considering adding a non-locked fgetc() / fread() alike macro that all reading functions will have to go through, so I need to "do it right" in one place only.

I am about to spend a week of vacation with my SO. I cannot promise anything, but coding relaxes me, so I might get this nailed down in short order.

DevSolar commented 4 years ago

fread() has received a patch that helps the issue, if not the already poor performance of that function. There's still a bug in fsetpos() / fgetpos(). The scanf() familty of functions is going through the (correct) getc(), so all is good there.

Commiting this to SVN/Git as I don't know if I will get to the *pos() functions tomorrow and wanted the fix released, partial or not.

DevSolar commented 4 years ago

fgetpos() got patched as well, which should resolve the issue as far as I can tell.