(__getmntent_r): Don't return with locked stream.
[kopensolaris-gnu/glibc.git] / misc / getttyent.c
index 777108f..e886e58 100644 (file)
@@ -57,7 +57,8 @@ getttynam(tty)
        return (t);
 }
 
-static char *skip __P((char *)), *value __P((char *));
+static char *skip __P((char *)) internal_function;
+static char *value __P((char *)) internal_function;
 
 struct ttyent *
 getttyent()
@@ -70,12 +71,15 @@ getttyent()
 
        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;
                }
@@ -84,6 +88,7 @@ getttyent()
                if (*p && *p != '#')
                        break;
        }
+       funlockfile(tf);
 
        zapchar = 0;
        tty.ty_name = p;
@@ -133,6 +138,7 @@ getttyent()
  * the next field.
  */
 static char *
+internal_function
 skip(p)
        register char *p;
 {
@@ -167,6 +173,7 @@ skip(p)
 }
 
 static char *
+internal_function
 value(p)
        register char *p;
 {