Documentation.
This commit is contained in:
parent
23f3bdb722
commit
0e6f95203a
12
test/main.c
12
test/main.c
|
@ -16,11 +16,11 @@ struct num { size_t line; int num; };
|
|||
MIN_ARRAY(char, char)
|
||||
MIN_ARRAY(num, struct num)
|
||||
|
||||
/** Concatenates the contents after the file pointer of `fp` to `string`. Zeros
|
||||
are preserved, as well as appending a null-terminator. @return Success,
|
||||
otherwise `string` may have read a partial read and may not be terminated.
|
||||
@throws[fread, malloc] */
|
||||
static int cat_fp_to_str(FILE *const fp, struct char_array *const string) {
|
||||
/** Reads the contents of `fp` after the file pointer and copies them to
|
||||
`string`; adds a null-terminator.
|
||||
@return Success, otherwise `string` may have read a partial read and may not
|
||||
be terminated. @throws[fread, malloc] */
|
||||
static int fp_to_str(FILE *const fp, struct char_array *const string) {
|
||||
const size_t granularity = 1024;
|
||||
size_t nread;
|
||||
char *cursor;
|
||||
|
@ -44,7 +44,7 @@ int main(void) {
|
|||
char *a, *anum = 0;
|
||||
size_t i, line = 1 /* Unix: delimited by '\n'. */;
|
||||
errno = 0; /* In case we are running it as part of another editor. */
|
||||
if(!cat_fp_to_str(stdin, &str)) goto catch;
|
||||
if(!fp_to_str(stdin, &str)) goto catch;
|
||||
/* It would be conceivable use the length to continue past the first
|
||||
sentinel '\0', but not that complex. */
|
||||
fprintf(stderr, "Read:\n<<<%s>>>\n", str.data);
|
||||
|
|
Loading…
Reference in New Issue