Skip to content

Commit

Permalink
Docs generated from: feat: add IO.fgetc (#1405)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
carp-lang committed Mar 28, 2022
1 parent bcb0dd7 commit 19b2d63
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 5 deletions.
38 changes: 38 additions & 0 deletions core/IO.Raw.html
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,44 @@ <h3 id="fclose!">

</p>
</div>
<div class="binder">
<a class="anchor" href="#feof">
<h3 id="feof">
feof
</h3>
</a>
<div class="description">
external
</div>
<p class="sig">
(Fn [(Ptr FILE)] Bool)
</p>
<span>

</span>
<p class="doc">

</p>
</div>
<div class="binder">
<a class="anchor" href="#ferror">
<h3 id="ferror">
ferror
</h3>
</a>
<div class="description">
external
</div>
<p class="sig">
(Fn [(Ptr FILE)] Bool)
</p>
<span>

</span>
<p class="doc">

</p>
</div>
<div class="binder">
<a class="anchor" href="#fflush">
<h3 id="fflush">
Expand Down
10 changes: 5 additions & 5 deletions core/IO.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,14 +406,14 @@ <h3 id="fgetc">
</h3>
</a>
<div class="description">
external
defn
</div>
<p class="sig">
(Fn [(Ptr FILE)] Char)
(Fn [(Ptr FILE)] (Result Char String))
</p>
<span>

</span>
<pre class="args">
(fgetc file)
</pre>
<p class="doc">
<p>gets a character from a file pointer (thin wrapper for the C standard library).</p>

Expand Down

0 comments on commit 19b2d63

Please sign in to comment.