Use strcspn to remove \n from string returned by fgets.
From Björn Sandell git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@19233 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -58,8 +58,7 @@ read_words (const char *filename, char ***ret_w)
|
||||
err (1, "cannot open %s", filename);
|
||||
alloc = n = 0;
|
||||
while (fgets (buf, sizeof(buf), f) != NULL) {
|
||||
if (buf[strlen (buf) - 1] == '\n')
|
||||
buf[strlen (buf) - 1] = '\0';
|
||||
buf[strcspn(buf, "\r\n")] = '\0';
|
||||
if (n >= alloc) {
|
||||
alloc += 16;
|
||||
w = erealloc (w, alloc * sizeof(char **));
|
||||
|
Reference in New Issue
Block a user