From 1d3cda0e62bb6550f2a455855f8a970271d825f0 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Mon, 25 Dec 2023 17:17:46 +0100 Subject: Reformatted lines_file() --- FICS/utils.c | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/FICS/utils.c b/FICS/utils.c index f77841b..7b2b0bf 100644 --- a/FICS/utils.c +++ b/FICS/utils.c @@ -750,23 +750,27 @@ PUBLIC int truncate_file(char *file, int lines) return 0; } -/* Warning, if lines in the file are greater than 1024 bytes in length, this - won't work! */ -PUBLIC int lines_file(char *file) +/* + * XXX: If lines in the file are greater than 1024 bytes in length, + * this won't work! + */ +PUBLIC int +lines_file(char *file) { - FILE *fp; - int lcount = 0; - char tmp[MAX_LINE_SIZE]; + FILE *fp; + char tmp[MAX_LINE_SIZE]; + int lcount = 0; - fp = fopen(file, "r"); - if (!fp) - return 0; - while (!feof(fp)) { - if (fgets(tmp, MAX_LINE_SIZE, fp)) - lcount++; - } - fclose(fp); - return lcount; + if ((fp = fopen(file, "r")) == NULL) + return 0; + + while (!feof(fp)) { + if (fgets(tmp, MAX_LINE_SIZE, fp)) + lcount++; + } + + fclose(fp); + return lcount; } PUBLIC int -- cgit v1.2.3