* feat: add fputc wrapper to IO
fputc is a low-level function that writes a single C character to a
file. We can use this as a basis for more elegant APIs.
The signature matches that of the C standard library function for
compatibility, which takes an Int instead of a char. However, the
documentation notes that the int argument is converted to an unsigned
char.
* doc: fix typos for fgetc and fputc docs
* feat: add feof and ferror
These are C stdio functions that enable programmers to determine if a
file read resulted in an error or EOF encounter.
We can use these to power a definition of IO.fgetc, which is currently
not defined.
* feat: implement missing IO.fgetc
IO defined a function, fgetc (distinct from IO.Raw.fgetc) which actually
produced invalid code, since the name was not overridden and C does not
define IO_fgetc.
There was also a TODO to handle EOF conditions; so, I've implemented the
function, checking for EOF and error conditions using the Raw stdio
wrappers. IO.fgetc returns a Char in Success on success and an error
string on failure.
* refactor: distinguish EOF from errors in IO.fgetc
We now report whether or not the error encountered in fgetc was EOF.
Note that we don't yet report on the contents of other errors.
* refactor: Move code out of Macros.carp into other files
* fix: Move back some macros needed in --no-core mode
* refactor: Remove weird 'evaluate' macros
* fix: Put back more macros
* fix: Remove transitive loading of Macros.carp
* refactor: Remove ArrayMacros.carp and put 'for' at top of Array.carp instead
* refactor: More splitting up
* refactor: Move back save-docs
* fix: Moved back some stuff
Co-authored-by: Erik Svedang <erik@Eriks-iMac.local>
`fopen` returns a nullable pointer, which doesn't fit very well with
Carp's notions of saftey and error handling. Instead, return a
`Result` type that forces the user to check if the operation was
successful.
+ Can't call the function fopen because we can't overload a C
function.
+ Leave `fopen` public in the IO module so extant code doesn't need to
be changed.