aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-31 22:33:46 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-31 22:33:46 +0100
commit8bcfa8db8a604ed9d0cde07bb20bf8089362c3e9 (patch)
treee9061381cbc32c717d08790ffa4a18d4e12d995e
parent28946e4d1748ddd47d685dc1a1ac679b49e71fc2 (diff)
Trim the newline using strcspn()
-rw-r--r--FICS/playerdb.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/FICS/playerdb.c b/FICS/playerdb.c
index 904ceb5..065d1d2 100644
--- a/FICS/playerdb.c
+++ b/FICS/playerdb.c
@@ -356,9 +356,9 @@ ReadV1PlayerFmt(int p, player *pp, FILE *fp, char *file, int version)
/*
* Name
*/
- fgets(tmp2, sizeof tmp2, fp);
+ (void)fgets(tmp2, sizeof tmp2, fp);
if (strcmp(tmp2, "NONE\n")) {
- tmp2[strlen(tmp2) - 1] = '\0';
+ tmp2[strcspn(tmp2, "\n")] = '\0';
pp->name = xstrdup(tmp2);
} else {
pp->name = NULL;
@@ -367,9 +367,9 @@ ReadV1PlayerFmt(int p, player *pp, FILE *fp, char *file, int version)
/*
* Full name
*/
- fgets(tmp2, sizeof tmp2, fp);
+ (void)fgets(tmp2, sizeof tmp2, fp);
if (strcmp(tmp2, "NONE\n")) {
- tmp2[strlen(tmp2) - 1] = '\0';
+ tmp2[strcspn(tmp2, "\n")] = '\0';
pp->fullName = xstrdup(tmp2);
} else {
pp->fullName = NULL;
@@ -378,9 +378,9 @@ ReadV1PlayerFmt(int p, player *pp, FILE *fp, char *file, int version)
/*
* Password
*/
- fgets(tmp2, sizeof tmp2, fp);
+ (void)fgets(tmp2, sizeof tmp2, fp);
if (strcmp(tmp2, "NONE\n")) {
- tmp2[strlen(tmp2) - 1] = '\0';
+ tmp2[strcspn(tmp2, "\n")] = '\0';
pp->passwd = xstrdup(tmp2);
} else {
pp->passwd = NULL;
@@ -389,9 +389,9 @@ ReadV1PlayerFmt(int p, player *pp, FILE *fp, char *file, int version)
/*
* Email
*/
- fgets(tmp2, sizeof tmp2, fp);
+ (void)fgets(tmp2, sizeof tmp2, fp);
if (strcmp(tmp2, "NONE\n")) {
- tmp2[strlen(tmp2) - 1] = '\0';
+ tmp2[strcspn(tmp2, "\n")] = '\0';
pp->emailAddress = xstrdup(tmp2);
} else {
pp->emailAddress = NULL;