hirc

IRC client
Log | Files | Refs

commit a611ee4557078dada54f3bdb77ccf431c92a5b8e
parent a9e8d13cfc199a7681672cdf0e0918e8b6309ebd
Author: hhvn <dev@hhvn.uk>
Date:   Thu, 21 Apr 2022 20:52:50 +0100

Remove read_line (fgets is fine)

Diffstat:
Msrc/config.c | 4+++-
Msrc/hirc.h | 1-
Msrc/main.c | 15---------------
3 files changed, 3 insertions(+), 17 deletions(-)

diff --git a/src/config.c b/src/config.c @@ -281,9 +281,11 @@ config_read(char *filename) { save = nouich; nouich = 1; - while (read_line(fileno(file), buf, sizeof(buf))) + while (fgets(buf, sizeof(buf), file)) { + buf[strlen(buf) - 1] = '\0'; /* remove \n */ if (*buf == '/') command_eval(NULL, buf); + } fclose(file); nouich = save; diff --git a/src/hirc.h b/src/hirc.h @@ -42,7 +42,6 @@ size_t wcslcpy(wchar_t *, const wchar_t *, size_t); /* main.c */ void cleanup(char *quitmsg); -int read_line(int fd, char *buf, size_t buf_len); int ircgets(struct Server *server, char *buf, size_t buf_len); int ircprintf(struct Server *server, char *format, ...); diff --git a/src/main.c b/src/main.c @@ -49,21 +49,6 @@ cleanup(char *quitmsg) { ui_deinit(); } -int -read_line(int fd, char *buf, size_t buf_len) { - size_t i = 0; - char c = 0; - - do { - if (read(fd, &c, sizeof(char)) != sizeof(char)) - return 0; - if (c != '\r') - buf[i++] = c; - } while (c != '\n' && i < buf_len); - buf[i - 1] = '\0'; - return 1; -} - void ircread(struct Server *sp) { char *line, *end;