Portable implementations of POSIX getdelim
and getline
functions for
non-POSIX systems, along with some other line-reading utilities.
Provides reimplementations of Chuck Falconer's ggets
and fggets
functions, versions of gets
and fgets
that automatically
allocate a buffer of the necessary size and that always strip any trailing
newline. These have friendlier syntax than getline
.
(Note that because they always strip a trailing newline, callers will not be able to distinguish a final line that contains a newline from a final line that does not. Some consider this to be a bug; others consider this to be a feature.)
Additionally provides getline_univ
and fggets_univ
, versions that recognize
any of CR
, LF
, or CR-LF
as line endings, regardless of the platform and
of whether the stream has been opened in text or binary modes. These provide
behavior similar to universal newline support in Python.
To try to maximize portability, code is written in C89. (Some exotic systems
might need to explicitly add definitions for ssize_t
and SIZE_MAX
.)
Optionally provides wchar_t
versions for systems that do not support UTF-8.
Note that wchar_t
versions require wchar.h
, which is not available in C89.
Questions? Comments? Bugs? I welcome feedback. Contact me.
Copyright © 2020 James D. Lin