X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Freadwrite.c;h=e6660ae4238ef9ed16a0ad0dfc2634c9e865b5ce;hb=60a77cb1894c678fff62840dc6b24931d839f820;hp=78f1bffb73d4b4472c5daa699ba4220f6c797456;hpb=fdb7a8eb2bc58d180d53f4085085a62bc1f2e62b;p=plomrogue diff --git a/src/readwrite.c b/src/readwrite.c index 78f1bff..e6660ae 100644 --- a/src/readwrite.c +++ b/src/readwrite.c @@ -1,6 +1,7 @@ /* readwrite.c */ #include "readwrite.h" +#include /* for size_t */ #include /* for FILE typedef, fopen(), fgetc(), fputc(), fseek(), * sprintf(), fwrite(), ferror() */ @@ -8,7 +9,6 @@ #include /* for strlen() */ #include /* for unlink() */ #include "rexit.h" /* for exit_err(), exit_trouble() */ -#include "main.h" /* for world global */ @@ -105,17 +105,7 @@ extern void try_fclose_unlink_rename(FILE * file, char * p1, char * p2, -extern uint16_t get_linemax(FILE * file, char * f) -{ - uint16_t linemax; - exit_trouble(textfile_sizes(file, &linemax, NULL), f, "textfile_sizes()"); - return linemax; -} - - - -extern uint8_t textfile_sizes(FILE * file, uint16_t * linemax_p, - uint16_t * n_lines_p) +extern uint16_t textfile_sizes(FILE * file, uint16_t * n_lines_p) { char * f_name = "textfile_sizes()"; int c = 0; @@ -147,17 +137,12 @@ extern uint8_t textfile_sizes(FILE * file, uint16_t * linemax_p, { /* line / lack newline chars. */ linemax = c_count; } - - if (-1 == fseek(file, 0, SEEK_SET)) - { - return 1; - } - * linemax_p = linemax; + exit_trouble(-1 == fseek(file, 0, SEEK_SET), f_name, "fseek()"); if (n_lines_p) { * n_lines_p = n_lines; } - return 0; + return linemax; }