(__getmntent_r): Don't return with locked stream.
[kopensolaris-gnu/glibc.git] / misc / getttyent.c
index f9b1e0d..e886e58 100644 (file)
@@ -57,6 +57,9 @@ getttynam(tty)
        return (t);
 }
 
+static char *skip __P((char *)) internal_function;
+static char *value __P((char *)) internal_function;
+
 struct ttyent *
 getttyent()
 {
@@ -65,16 +68,18 @@ getttyent()
        register char *p;
 #define        MAXLINELENGTH   100
        static char line[MAXLINELENGTH];
-       static char *skip(), *value();
 
        if (!tf && !setttyent())
                return (NULL);
+       flockfile (tf);
        for (;;) {
-               if (!fgets(p = line, sizeof(line), tf))
+               if (!fgets_unlocked(p = line, sizeof(line), tf)) {
+                       funlockfile (tf);
                        return (NULL);
+               }
                /* skip lines that are too big */
                if (!index(p, '\n')) {
-                       while ((c = getc(tf)) != '\n' && c != EOF)
+                       while ((c = getc_unlocked(tf)) != '\n' && c != EOF)
                                ;
                        continue;
                }
@@ -83,6 +88,7 @@ getttyent()
                if (*p && *p != '#')
                        break;
        }
+       funlockfile(tf);
 
        zapchar = 0;
        tty.ty_name = p;
@@ -132,6 +138,7 @@ getttyent()
  * the next field.
  */
 static char *
+internal_function
 skip(p)
        register char *p;
 {
@@ -166,6 +173,7 @@ skip(p)
 }
 
 static char *
+internal_function
 value(p)
        register char *p;
 {