Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-2-0]: src/lib/libc/stdio Pull up revision 1.3 (requested by jmc i...
details: https://anonhg.NetBSD.org/src/rev/86839bcfa9db
branches: netbsd-2-0
changeset: 561501:86839bcfa9db
user: tron <tron%NetBSD.org@localhost>
date: Tue Jun 22 07:03:33 2004 +0000
description:
Pull up revision 1.3 (requested by jmc in ticket #527):
Add FLOCKFILE() locking - should be threadsafe now.
(Didn't test the !HAVE_FPARSELN && !_REENTRANT case -- this might be
hit in tools/compat on some host platforms.)
diffstat:
lib/libc/stdio/fparseln.c | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diffs (68 lines):
diff -r 2161350d5366 -r 86839bcfa9db lib/libc/stdio/fparseln.c
--- a/lib/libc/stdio/fparseln.c Mon Jun 21 17:27:18 2004 +0000
+++ b/lib/libc/stdio/fparseln.c Tue Jun 22 07:03:33 2004 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fparseln.c,v 1.2 2003/01/18 11:29:52 thorpej Exp $ */
+/* $NetBSD: fparseln.c,v 1.2.2.1 2004/06/22 07:03:33 tron Exp $ */
/*
* Copyright (c) 1997 Christos Zoulas. All rights reserved.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: fparseln.c,v 1.2 2003/01/18 11:29:52 thorpej Exp $");
+__RCSID("$NetBSD: fparseln.c,v 1.2.2.1 2004/06/22 07:03:33 tron Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -48,6 +48,15 @@
#if ! HAVE_FPARSELN
+#include "reentrant.h"
+#include "local.h"
+
+#ifdef _REENTRANT
+#define __fgetln(f, l) __fgetstr(f, l, '\n')
+#else
+#define __fgetln(f, l) fgetln(f, l)
+#endif
+
static int isescaped(const char *, const char *, int);
/* isescaped():
@@ -110,13 +119,15 @@
*/
nl = '\n';
+ FLOCKFILE(fp);
+
while (cnt) {
cnt = 0;
if (lineno)
(*lineno)++;
- if ((ptr = fgetln(fp, &s)) == NULL)
+ if ((ptr = __fgetln(fp, &s)) == NULL)
break;
if (s && com) { /* Check and eliminate comments */
@@ -148,6 +159,7 @@
continue;
if ((cp = realloc(buf, len + s + 1)) == NULL) {
+ FUNLOCKFILE(fp);
free(buf);
return NULL;
}
@@ -158,6 +170,8 @@
buf[len] = '\0';
}
+ FUNLOCKFILE(fp);
+
if ((flags & FPARSELN_UNESCALL) != 0 && esc && buf != NULL &&
strchr(buf, esc) != NULL) {
ptr = cp = buf;
Home |
Main Index |
Thread Index |
Old Index