orangeduck / BuildYourOwnLisp

Learn C and build your own programming language in under 1000 lines of code!
http://www.buildyourownlisp.com/
Other
2.9k stars 394 forks source link

Chapter 4: Cleanup _WIN32 readline() dummy function. #150

Closed peanutbutterandcrackers closed 3 years ago

peanutbutterandcrackers commented 3 years ago

According to GNU/Linux man pages, fgets stores a "... terminating null byte ('\0') ... after the last character in the buffer" and strcpy "copies the string ... including the terminating null byte ('\0')"

orangeduck commented 3 years ago

If I recall correctly, this is actually to remove the final newline character from fgets, not to add the null terminator.

peanutbutterandcrackers commented 3 years ago

I see. It could very well be. Well, I'm still learning, and thought this minor thing managed to slip through: hence the patch.

Anyways, closing this for now, then.

Also, thank you very much for the awesome book. I hope write some more books. You are a very engaging writer. And I'd love to read more books from you.