summaryrefslogtreecommitdiff
path: root/libc/misc/ttyent
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2004-05-07 10:22:52 +0000
committerManuel Novoa III <mjn3@codepoet.org>2004-05-07 10:22:52 +0000
commitb3ae173353762576f231204787f668e6bc1aa2a2 (patch)
treead891df090d2dcfca2597d27281ec67e8c4253ef /libc/misc/ttyent
parent3a03e34abc79cbba30795256375c4f44621159ab (diff)
"Fix" this so that at least things will link when threading is disabled.
Also fix the sizeof() issue since the change to a dynamicly allocated buf. Note! This is still broken wrt threading, but so is the glibc version. I'm just commiting this for new until I can test my rewrite.
Diffstat (limited to 'libc/misc/ttyent')
-rw-r--r--libc/misc/ttyent/getttyent.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libc/misc/ttyent/getttyent.c b/libc/misc/ttyent/getttyent.c
index 0b2c9a3cc..6e2fbd2f4 100644
--- a/libc/misc/ttyent/getttyent.c
+++ b/libc/misc/ttyent/getttyent.c
@@ -34,6 +34,10 @@
#include <stdio_ext.h>
#include <ctype.h>
#include <string.h>
+#include <stdlib.h>
+#ifdef __UCLIBC_HAS_THREADS__
+#include <pthread.h>
+#endif
static char zapchar;
static FILE *tf;
@@ -110,11 +114,11 @@ struct ttyent * getttyent(void)
abort();
}
- flockfile (tf);
+ __STDIO_ALWAYS_THREADLOCK(tf);
for (;;) {
- if (!fgets_unlocked(p = line, sizeof(line), tf)) {
- funlockfile (tf);
+ if (!fgets_unlocked(p = line, BUFSIZ, tf)) {
+ __STDIO_ALWAYS_THREADUNLOCK(tf);
return (NULL);
}
/* skip lines that are too big */
@@ -159,7 +163,7 @@ struct ttyent * getttyent(void)
break;
}
/* We can release the lock only here since `zapchar' is global. */
- funlockfile(tf);
+ __STDIO_ALWAYS_THREADUNLOCK(tf);
if (zapchar == '#' || *p == '#')
while ((c = *++p) == ' ' || c == '\t')