#include <stdlib.h> /* free() */
#include <string.h> /* memset(), strlen(), strcmp() */
#include "../common/err_try_fgets.h" /* reset_err_try_fgets_counter() */
-#include "../common/readwrite.h" /* try_fopen(),try_fclose(),textfile_sizes() */
+#include "../common/readwrite.h" /* try_fopen(),try_fclose(),textfile_width() */
#include "../common/rexit.h" /* exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
#include "misc.h" /* array_append() */
char * f_name = "init_command_db()";
char * context = "Failed reading command DB file. ";
FILE * file = try_fopen(world.path_commands, "r", f_name);
- uint32_t linemax = textfile_sizes(file, NULL);
+ uint32_t linemax = textfile_width(file);
char line[linemax + 1];
reset_err_try_fgets_counter();
uint8_t i = 0;
#include "../common/try_malloc.h" /* try_malloc() */
#include "../common/rexit.h" /* exit_trouble(), exit_err() */
#include "../common/readwrite.h" /* try_fopen(), try_fclose(), try_fgets(),
- * try_fgetc()
+ * try_fgetc(), textfile_width()
*/
#include "control.h" /* try_key() */
#include "map.h" /* map_center() */
{
return 0;
}
- uint32_t linemax = textfile_sizes(file, NULL);
+ uint32_t linemax = textfile_width(file);
char * read_buf = try_malloc(linemax + 1, f_name);
world.turn = read_value_from_line(read_buf, linemax, file);
world.player_score = read_value_from_line(read_buf, linemax, file);
#include "misc.h"
#include <ncurses.h> /* delwin() */
-#include <stddef.h> /* NULL */
#include <stdint.h> /* uint8_t, uint32_t */
#include <stdio.h> /* FILE, sprintf() */
#include <stdlib.h> /* free(), exit() */
#include <string.h> /* memcpy(), strlen() */
#include <unistd.h> /* global optarg, getopt() */
#include "../common/err_try_fgets.h" /* reset_err_try_fgets_counter() */
-#include "../common/readwrite.h" /* try_fopen(), try_fclose(), textfile_sizes(),
+#include "../common/readwrite.h" /* try_fopen(), try_fclose(), textfile_width(),
* try_fclose_unlink_rename(),
*/
#include "../common/rexit.h" /* exit_err() */
/* Read keybindings and WincConf DB from interface config file. */
reset_err_try_fgets_counter();
FILE * file = try_fopen(world.path_interface, "r", f_name);
- uint32_t linemax = textfile_sizes(file, NULL);
+ uint32_t linemax = textfile_width(file);
char line[linemax + 1];
read_keybindings_from_file(line, linemax, file, &world.kb_global);
read_keybindings_from_file(line, linemax, file, &world.kb_wingeom);
-extern uint32_t textfile_sizes(FILE * file, uint32_t * n_lines_p)
+extern uint32_t textfile_width(FILE * file)
{
- char * f_name = "textfile_sizes()";
+ char * f_name = "textfile_width()";
int c = 0;
uint32_t c_count = 0;
- uint32_t n_lines = 0;
uint32_t linemax = 0;
while (1)
{
linemax = c_count;
}
c_count = 0;
- if (n_lines_p)
- {
- n_lines++;
- }
}
}
if (0 == linemax && 0 < c_count) /* Handle files that consist of only one */
linemax = c_count;
}
exit_trouble(-1 == fseek(file, 0, SEEK_SET), f_name, "fseek()");
- if (n_lines_p)
- {
- * n_lines_p = n_lines;
- }
return linemax;
}
char * f);
/* Return largest line length from "file" the largest line length (including
- * newline chars) and write the number of newline chars in "file" to the memory
- * pointed to by "n_lines_p" if it is not passed as NULL.
+ * newline chars).
*/
-extern uint32_t textfile_sizes(FILE * file, uint32_t * n_lines_p);
+extern uint32_t textfile_width(FILE * file);
#include <string.h> /* atoi() */
#include <time.h> /* time() */
#include <unistd.h> /* optarg, getopt(), access(), unlink() */
-#include "../common/readwrite.h" /* try_fopen(), try_fclose(), textfile_sizes(),
+#include "../common/readwrite.h" /* try_fopen(), try_fclose(), textfile_width(),
* try_fgets()
*/
#include "../common/rexit.h" /* exit_err() */
if (!access(world.path_record, F_OK))
{
FILE * file = try_fopen(world.path_record, "r", f_name);
- uint32_t linemax = textfile_sizes(file, NULL);
+ uint32_t linemax = textfile_width(file);
char line[linemax + 1];
while ( (!world.replay || (world.turn < world.replay))
&& NULL != try_fgets(line, linemax + 1, file, f_name))
#include "../common/err_try_fgets.h" /* err_try_fgets(), err_line(),
* reset_err_try_fgets_counter()
*/
-#include "../common/readwrite.h" /* textfile_sizes(), try_fopen(), try_fclose(),
+#include "../common/readwrite.h" /* textfile_width(), try_fopen(), try_fclose(),
* try_fgetc()
*/
#include "../common/rexit.h" /* exit_err(), exit_trouble() */
{
char * f_name = "init_map_object_actions()";
FILE * file = try_fopen(world.path_map_obj_acts, "r", f_name);
- uint32_t linemax = textfile_sizes(file, NULL);
+ uint32_t linemax = textfile_width(file);
char line[linemax + 1];
struct MapObjAct ** moa_ptr_ptr = &world.map_obj_acts;
char * context = "Failed reading map object actions config file. ";
* reset_err_try_fgets_counter()
*/
#include "../common/readwrite.h" /* try_fopen(), try_fclose(), try_fgetc(),
- * textfile_sizes()
+ * textfile_width()
*/
#include "../common/rexit.h" /* exit_err(), exit_trouble() */
#include "../common/try_malloc.h" /* try_malloc() */
char * err_toolarge = "Value is too large.";
char * err_uniq = "Declaration of ID already used.";
FILE * file = try_fopen(world.path_map_obj_defs, "r", f_name);
- uint32_t linemax = textfile_sizes(file, NULL);
+ uint32_t linemax = textfile_width(file);
struct MapObjDef ** last_mod_ptr_ptr = &world.map_obj_defs;
char line[linemax + 1];
reset_err_try_fgets_counter();
#include <unistd.h> /* access() */
#include "../common/readwrite.h" /* try_fopen(), try_fcose(), try_fwrite(),
* try_fgets(), try_fclose_unlink_rename(),
- * textfile_sizes(), try_fputc()
+ * textfile_width(), try_fputc()
*/
#include "../common/rexit.h" /* exit_trouble() */
#include "ai.h" /* ai() */
if (!access(world.path_record, F_OK))
{
FILE * file_read = try_fopen(world.path_record, "r", f_name);
- uint32_t linemax = textfile_sizes(file_read, NULL);
+ uint32_t linemax = textfile_width(file_read);
char line[linemax + 1];
while (try_fgets(line, linemax + 1, file_read, f_name))
{