From: Christian Heller Date: Wed, 5 Feb 2014 15:23:01 +0000 (+0100) Subject: Removed unused textfile_sizes() functionality, appropriately renamed it. X-Git-Tag: tce~843 X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7Byoutube_prefix%7D%7D%7B%7Bvideo_data.id_%7D%7D?a=commitdiff_plain;h=0cc6c4ad7e0b01e2a89ced908f410eadf3f22b1f;p=plomrogue Removed unused textfile_sizes() functionality, appropriately renamed it. --- diff --git a/src/client/command_db.c b/src/client/command_db.c index aed92c9..3837d2a 100644 --- a/src/client/command_db.c +++ b/src/client/command_db.c @@ -7,7 +7,7 @@ #include /* free() */ #include /* 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() */ @@ -50,7 +50,7 @@ extern void init_command_db() 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; diff --git a/src/client/io.c b/src/client/io.c index 2b1c165..43a695a 100644 --- a/src/client/io.c +++ b/src/client/io.c @@ -15,7 +15,7 @@ #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() */ @@ -193,7 +193,7 @@ static uint8_t read_world() { 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); diff --git a/src/client/misc.c b/src/client/misc.c index 09268b5..fcb53ec 100644 --- a/src/client/misc.c +++ b/src/client/misc.c @@ -2,14 +2,13 @@ #include "misc.h" #include /* delwin() */ -#include /* NULL */ #include /* uint8_t, uint32_t */ #include /* FILE, sprintf() */ #include /* free(), exit() */ #include /* memcpy(), strlen() */ #include /* 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() */ @@ -73,7 +72,7 @@ extern void load_interface_conf() /* 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); diff --git a/src/common/readwrite.c b/src/common/readwrite.c index 026c9ad..a0ab3f7 100644 --- a/src/common/readwrite.c +++ b/src/common/readwrite.c @@ -95,12 +95,11 @@ extern void try_fclose_unlink_rename(FILE * file, char * p1, char * p2, -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) { @@ -117,10 +116,6 @@ extern uint32_t textfile_sizes(FILE * file, uint32_t * n_lines_p) 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 */ @@ -128,9 +123,5 @@ extern uint32_t textfile_sizes(FILE * file, uint32_t * n_lines_p) 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; } diff --git a/src/common/readwrite.h b/src/common/readwrite.h index 9c1358a..9affeb8 100644 --- a/src/common/readwrite.h +++ b/src/common/readwrite.h @@ -35,10 +35,9 @@ extern void try_fclose_unlink_rename(FILE * file, char * p1, char * p2, 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); diff --git a/src/server/init.c b/src/server/init.c index b63fbf9..4e885fe 100644 --- a/src/server/init.c +++ b/src/server/init.c @@ -7,7 +7,7 @@ #include /* atoi() */ #include /* time() */ #include /* 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() */ @@ -80,7 +80,7 @@ extern void run_game() 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)) diff --git a/src/server/map_object_actions.c b/src/server/map_object_actions.c index 6f94ce1..a30809b 100644 --- a/src/server/map_object_actions.c +++ b/src/server/map_object_actions.c @@ -9,7 +9,7 @@ #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() */ @@ -232,7 +232,7 @@ extern void init_map_object_actions() { 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. "; diff --git a/src/server/map_objects.c b/src/server/map_objects.c index 696db04..97fbc32 100644 --- a/src/server/map_objects.c +++ b/src/server/map_objects.c @@ -10,7 +10,7 @@ * 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() */ @@ -108,7 +108,7 @@ extern void init_map_object_defs() 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(); diff --git a/src/server/run.c b/src/server/run.c index 83bb724..82e0aae 100644 --- a/src/server/run.c +++ b/src/server/run.c @@ -9,7 +9,7 @@ #include /* 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() */ @@ -158,7 +158,7 @@ extern void obey_msg(char * msg, uint8_t do_record) 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)) {