The fparseln() function had the NetBSD uppercase macros stubbed out,
so replace them with the actual stdio ones. The fgetln() function was
missing any locking at all.
struct filebuf *fb;
ssize_t nread;
+ flockfile(stream);
+
/* Try to diminish the possibility of several fgetln() calls being
* used on different streams, by using a pool of buffers per file. */
fb = &fb_pool[fb_pool_cur];
fb->fp = stream;
nread = getline(&fb->buf, &fb->len, stream);
+
+ funlockfile(stream);
+
/* Note: the getdelim/getline API ensures nread != 0. */
if (nread == -1) {
*len = 0;
#include <string.h>
#include <stdlib.h>
-#define FLOCKFILE(fp)
-#define FUNLOCKFILE(fp)
#define _DIAGASSERT(t)
static int isescaped(const char *, const char *, int);
*/
nl = '\n';
- FLOCKFILE(fp);
+ flockfile(fp);
while (cnt) {
cnt = 0;
}
if ((cp = realloc(buf, len + s + 1)) == NULL) {
- FUNLOCKFILE(fp);
+ funlockfile(fp);
free(buf);
free(ptr);
return NULL;
buf[len] = '\0';
}
- FUNLOCKFILE(fp);
+ funlockfile(fp);
free(ptr);
if ((flags & FPARSELN_UNESCALL) != 0 && esc && buf != NULL &&