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:
@@ -48,8 +48,7 @@ read_words (const char *filename, char ***ret_w)
|
|||||||
err (1, "cannot open %s", filename);
|
err (1, "cannot open %s", filename);
|
||||||
alloc = n = 0;
|
alloc = n = 0;
|
||||||
while (fgets (buf, sizeof(buf), f) != NULL) {
|
while (fgets (buf, sizeof(buf), f) != NULL) {
|
||||||
if (buf[strlen (buf) - 1] == '\n')
|
buf[strcspn(buf, "\r\n")] = '\0';
|
||||||
buf[strlen (buf) - 1] = '\0';
|
|
||||||
if (n >= alloc) {
|
if (n >= alloc) {
|
||||||
alloc += 16;
|
alloc += 16;
|
||||||
w = erealloc (w, alloc * sizeof(char **));
|
w = erealloc (w, alloc * sizeof(char **));
|
||||||
|
@@ -58,8 +58,7 @@ read_words (const char *filename, char ***ret_w)
|
|||||||
err (1, "cannot open %s", filename);
|
err (1, "cannot open %s", filename);
|
||||||
alloc = n = 0;
|
alloc = n = 0;
|
||||||
while (fgets (buf, sizeof(buf), f) != NULL) {
|
while (fgets (buf, sizeof(buf), f) != NULL) {
|
||||||
if (buf[strlen (buf) - 1] == '\n')
|
buf[strcspn(buf, "\r\n")] = '\0';
|
||||||
buf[strlen (buf) - 1] = '\0';
|
|
||||||
if (n >= alloc) {
|
if (n >= alloc) {
|
||||||
alloc += 16;
|
alloc += 16;
|
||||||
w = erealloc (w, alloc * sizeof(char **));
|
w = erealloc (w, alloc * sizeof(char **));
|
||||||
|
@@ -127,8 +127,7 @@ check_acl (krb5_context context, const char *name)
|
|||||||
if (fp == NULL)
|
if (fp == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
while (fgets(buf, sizeof(buf), fp) != NULL) {
|
while (fgets(buf, sizeof(buf), fp) != NULL) {
|
||||||
if (buf[strlen(buf) - 1 ] == '\n')
|
buf[strcspn(buf, "\r\n")] = '\0';
|
||||||
buf[strlen(buf) - 1 ] = '\0';
|
|
||||||
if (strcmp (buf, name) == 0) {
|
if (strcmp (buf, name) == 0) {
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user