Merge remote-tracking branch 'origin/master' into varargs-log-error-functions

This commit is contained in:
Richard Berger
2021-04-28 18:13:31 -04:00
28 changed files with 899 additions and 73 deletions

View File

@ -9,8 +9,8 @@ reading or writing to files with error checking or translation of
strings into specific types of numbers with checking for validity. This
reduces redundant implementations and encourages consistent behavior.
I/O with status check
^^^^^^^^^^^^^^^^^^^^^
I/O with status check and similar functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The the first two functions are wrappers around the corresponding C
library calls ``fgets()`` or ``fread()``. They will check if there
@ -19,6 +19,14 @@ In that case, the functions will stop with an error message, indicating
the name of the problematic file, if possible unless the *error* argument
is a NULL pointer.
The :cpp:func:`fgets_trunc` function will work similar for ``fgets()``
but it will read in a whole line (i.e. until the end of line or end
of file), but store only as many characters as will fit into the buffer
including a final newline character and the terminating NULL byte.
If the line in the file is longer it will thus be truncated in the buffer.
This function is used by :cpp:func:`read_lines_from_file` to read individual
lines but make certain they follow the size constraints.
The :cpp:func:`read_lines_from_file` function will read the requested
number of lines of a maximum length into a buffer and will return 0
if successful or 1 if not. It also guarantees that all lines are
@ -33,6 +41,9 @@ NULL character.
.. doxygenfunction:: sfread
:project: progguide
.. doxygenfunction:: fgets_trunc
:project: progguide
.. doxygenfunction:: read_lines_from_file
:project: progguide