summaryrefslogtreecommitdiff
path: root/lib/libc/gen/getttyent.c
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-02-12 19:32:52 +0000
committerEd Schouten <ed@FreeBSD.org>2009-02-12 19:32:52 +0000
commita73306e14e0a187e84ecdd6b14594894c4d4285e (patch)
treead48fd8d4d81bd558899c9dc222aca897f67c38d /lib/libc/gen/getttyent.c
parent5ebad6a76adaabbdb9391f494b7e215acd1fccb7 (diff)
Notes
Diffstat (limited to 'lib/libc/gen/getttyent.c')
-rw-r--r--lib/libc/gen/getttyent.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c
index efc4c9b84ecc..9152626213e8 100644
--- a/lib/libc/gen/getttyent.c
+++ b/lib/libc/gen/getttyent.c
@@ -43,9 +43,8 @@ __FBSDID("$FreeBSD$");
static char zapchar;
static FILE *tf;
-static int maxpts = 0;
+static int maxpts = -1;
static int curpts = 0;
-static int pts_valid = 0;
static size_t lbsize;
static char *line;
@@ -84,7 +83,7 @@ getttyent()
return (NULL);
for (;;) {
if (!fgets(p = line, lbsize, tf)) {
- if (pts_valid == 1 && curpts <= maxpts) {
+ if (curpts <= maxpts) {
sprintf(devpts_name, "pts/%d", curpts++);
tty.ty_name = devpts_name;
tty.ty_getty = tty.ty_type = NULL;
@@ -234,12 +233,12 @@ setttyent()
if (devpts_dir) {
struct dirent *dp;
+ maxpts = -1;
while ((dp = readdir(devpts_dir))) {
if (strcmp(dp->d_name, ".") != 0 &&
strcmp(dp->d_name, "..") != 0) {
if (atoi(dp->d_name) > maxpts) {
maxpts = atoi(dp->d_name);
- pts_valid = 1;
curpts = 0;
}
}
@@ -259,7 +258,7 @@ endttyent()
{
int rval;
- pts_valid = 0;
+ maxpts = -1;
/*
* NB: Don't free `line' because getttynam()
* may still be referencing it