diff --git a/ChangeLog b/ChangeLog index 41dc9d63..e65af62f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2008-05-26 Nicolas François + + * libmisc/ttytype.c: Avoid implicit conversion of pointers / + integers to booleans. + * libmisc/ttytype.c: Avoid assignments in comparisons. + * libmisc/ttytype.c: Add brackets and parenthesis. + * libmisc/ttytype.c: The return values of fclose is not checked on + purpose. + 2008-05-26 Nicolas François * libmisc/mail.c: Avoid implicit conversion of pointers to diff --git a/libmisc/ttytype.c b/libmisc/ttytype.c index b50a770f..5c52c735 100644 --- a/libmisc/ttytype.c +++ b/libmisc/ttytype.c @@ -53,26 +53,33 @@ void ttytype (const char *line) return; if ((typefile = getdef_str ("TTYTYPE_FILE")) == NULL) return; - if (access (typefile, F_OK)) + if (access (typefile, F_OK) != 0) return; - if (!(fp = fopen (typefile, "r"))) { + fp = fopen (typefile, "r"); + if (NULL == fp) { perror (typefile); return; } - while (fgets (buf, sizeof buf, fp)) { - if (buf[0] == '#') + while (fgets (buf, sizeof buf, fp) == buf) { + if (buf[0] == '#') { continue; + } - if ((cp = strchr (buf, '\n'))) + cp = strchr (buf, '\n'); + if (NULL != cp) { *cp = '\0'; + } - if (sscanf (buf, "%s %s", type, port) == 2 && - strcmp (line, port) == 0) + if ((sscanf (buf, "%s %s", type, port) == 2) && + (strcmp (line, port) == 0)) { break; + } } - if (!feof (fp) && !ferror (fp)) + if ((feof (fp) == 0) && (ferror (fp) == 0)) { addenv ("TERM", type); + } - fclose (fp); + (void) fclose (fp); } +