X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;ds=sidebyside;f=src%2Fclient%2Fparse.c;h=5bf2bd71a957d95900c13076101ee5afc0eca415;hb=5d5d1a77736d23d3282055a5f96354c1ff09bf48;hp=2767c46b55e8d9d5b0856cfd5c320731a0e63128;hpb=891ba8fbca53d920f6b3704827fa6b8aee737de4;p=plomrogue
diff --git a/src/client/parse.c b/src/client/parse.c
index 2767c46..5bf2bd7 100644
--- a/src/client/parse.c
+++ b/src/client/parse.c
@@ -1,6 +1,11 @@
-/* src/client/parse.c */
-
-#define _POSIX_C_SOURCE 200809L /* strdup() */
+/* src/client/parse.c
+ *
+ * This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
+ * or any later version. For details on its copyright, license, and warranties,
+ * see the file NOTICE in the root directory of the PlomRogue source package.
+ */
+
+#define _POSIX_C_SOURCE 200809L /* strdup(), snprintf() */
#include "parse.h"
#include /* size_t, NULL */
#include /* FILE, snprintf() */
@@ -19,27 +24,25 @@
extern void parse_file(char * path, void (* token_to_entry) (char *, char *))
{
- char * f_name = "read_new_config_file()";
char * prefix = "Failed reading config file: \"";
char * affix = "\". ";
size_t size = strlen(prefix) + strlen(path) + strlen(affix) + 1;
- char * errline_intro = try_malloc(size, f_name);
+ char * errline_intro = try_malloc(size, __func__);
int test = snprintf(errline_intro, size, "%s%s%s", prefix, path, affix);
- exit_trouble(test < 0, f_name, "snprintf()");
+ exit_trouble(test < 0, __func__, "snprintf");
exit_err(access(path, F_OK), errline_intro);
- FILE * file = try_fopen(path, "r", f_name);
+ FILE * file = try_fopen(path, "r", __func__);
uint32_t linemax = textfile_width(file);
- char * errline_line = try_malloc(linemax + 1, f_name);
+ char * errline_line = try_malloc(linemax + 1, __func__);
set_err_line_options(errline_intro, errline_line, 1);
err_line_zero();
- err_line(0 == linemax, "File is empty.");
+ err_line(!linemax, "File is empty.");
char * token0 = NULL; /* For final token_to_entry() if while() stagnates. */
char * token1 = NULL;
char * err_val = "No value given.";
- while (try_fgets(errline_line, linemax + 1, file, f_name))
+ while (try_fgets(errline_line, linemax + 1, file, __func__))
{
err_line_inc();
- // err_line(UINT32_MAX == err_line_count, "Line reaches max lines limit.");
char * line_copy = strdup(errline_line);
token0 = token_from_line(line_copy);
if (token0)
@@ -51,7 +54,7 @@ extern void parse_file(char * path, void (* token_to_entry) (char *, char *))
free(line_copy);
}
token_to_entry(token0, token1);
- try_fclose(file, f_name);
+ try_fclose(file, __func__);
free(errline_line);
free(errline_intro);
}
@@ -67,7 +70,7 @@ extern void parsetest_defcontext(uint8_t flags)
extern void parsetest_too_many_values()
{
- err_line(NULL != token_from_line(NULL), "Too many values.");
+ err_line(!(!token_from_line(NULL)), "Too many values.");
}
@@ -88,9 +91,8 @@ extern void parse_unknown_arg()
extern char * parse_init_entry(uint8_t * flags, size_t size)
{
- char * f_name = "parse_init_entry()";
*flags = EDIT_STARTED;
- char * p = try_malloc(size, f_name);
+ char * p = try_malloc(size, __func__);
memset(p, 0, size);
return p;
}