summaryrefslogtreecommitdiff
path: root/pkgtools/libnbcompat
diff options
context:
space:
mode:
Diffstat (limited to 'pkgtools/libnbcompat')
-rw-r--r--pkgtools/libnbcompat/Makefile4
-rw-r--r--pkgtools/libnbcompat/buildlink3.mk3
-rw-r--r--pkgtools/libnbcompat/files/README12
-rw-r--r--pkgtools/libnbcompat/files/fgetln.c56
4 files changed, 40 insertions, 35 deletions
diff --git a/pkgtools/libnbcompat/Makefile b/pkgtools/libnbcompat/Makefile
index 6382ea1434d..ee0fbcf54ed 100644
--- a/pkgtools/libnbcompat/Makefile
+++ b/pkgtools/libnbcompat/Makefile
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.48 2007/05/07 16:38:47 joerg Exp $
+# $NetBSD: Makefile,v 1.49 2007/05/31 10:18:49 rillig Exp $
#
# NOTE: If you update this package, it is *mandatory* that you update
# pkgsrc/pkgtools/libnbcompat/files/README to reflect the actual
# list of tested and supported platforms.
#
-DISTNAME= libnbcompat-20070507
+DISTNAME= libnbcompat-20070531
CATEGORIES= pkgtools devel
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/pkgtools/libnbcompat/buildlink3.mk b/pkgtools/libnbcompat/buildlink3.mk
index e36e73b65f9..ea13c2be9f4 100644
--- a/pkgtools/libnbcompat/buildlink3.mk
+++ b/pkgtools/libnbcompat/buildlink3.mk
@@ -1,4 +1,4 @@
-# $NetBSD: buildlink3.mk,v 1.17 2006/07/08 23:11:05 jlam Exp $
+# $NetBSD: buildlink3.mk,v 1.18 2007/05/31 10:18:49 rillig Exp $
BUILDLINK_DEPTH:= ${BUILDLINK_DEPTH}+
LIBNBCOMPAT_BUILDLINK3_MK:= ${LIBNBCOMPAT_BUILDLINK3_MK}+
@@ -13,6 +13,7 @@ BUILDLINK_ORDER:= ${BUILDLINK_ORDER} ${BUILDLINK_DEPTH}libnbcompat
.if !empty(LIBNBCOMPAT_BUILDLINK3_MK:M+)
BUILDLINK_API_DEPENDS.libnbcompat+= libnbcompat>=20040911
+BUILDLINK_ABI_DEPENDS.libnbcompat+= libnbcompat>=20070531
BUILDLINK_PKGSRCDIR.libnbcompat?= ../../pkgtools/libnbcompat
BUILDLINK_DEPMETHOD.libnbcompat?= build
BUILDLINK_LDADD.libnbcompat= -lnbcompat
diff --git a/pkgtools/libnbcompat/files/README b/pkgtools/libnbcompat/files/README
index 0117f5b2734..e84a8dabb9d 100644
--- a/pkgtools/libnbcompat/files/README
+++ b/pkgtools/libnbcompat/files/README
@@ -1,4 +1,4 @@
-$NetBSD: README,v 1.15 2007/05/22 18:06:39 tnn Exp $
+$NetBSD: README,v 1.16 2007/05/31 10:18:49 rillig Exp $
0 Introduction
==============
@@ -66,9 +66,13 @@ libnbcompat-20070507 has been tested to build and install correctly
on the following operating systems:
DragonFly-1.8/i386 <joerg@NetBSD.org>
- HPUX-11.11/hppa <tnn@NetBSD.org>
- OSF1-5.1B/alpha <tnn@NetBSD.org>
- Solaris 10/sparc <tnn@NetBSD.org>
+
+libnbcompat-20070531 has been tested to build and install correctly
+on the following operating systems:
+
+ SunOS-5.10-sparc <rillig@NetBSD.org>
+ NetBSD-3.0-i386 <rillig@NetBSD.org>
+ IRIX-6.5-mips <rillig@NetBSD.org>
3 Usage
=======
diff --git a/pkgtools/libnbcompat/files/fgetln.c b/pkgtools/libnbcompat/files/fgetln.c
index d5a465f1208..4cd73892af7 100644
--- a/pkgtools/libnbcompat/files/fgetln.c
+++ b/pkgtools/libnbcompat/files/fgetln.c
@@ -1,4 +1,4 @@
-/* $NetBSD: fgetln.c,v 1.3 2004/09/11 19:01:40 jlam Exp $ */
+/* $NetBSD: fgetln.c,v 1.4 2007/05/31 10:18:49 rillig Exp $ */
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -40,6 +40,12 @@
#include <nbcompat/stdio.h>
#include <nbcompat/stdlib.h>
+/*
+ * XXX: This implementation doesn't quite conform to the specification
+ * in the man page, in that it only manages one buffer at all, not one
+ * per stdio stream. Since the previous implementation did the same,
+ * this won't break anything new.
+ */
char *
fgetln(fp, len)
FILE *fp;
@@ -47,7 +53,8 @@ fgetln(fp, len)
{
static char *buf = NULL;
static size_t bufsiz = 0;
- char *ptr;
+ static size_t buflen = 0;
+ int c;
if (buf == NULL) {
bufsiz = BUFSIZ;
@@ -55,34 +62,27 @@ fgetln(fp, len)
return NULL;
}
- if (fgets(buf, bufsiz, fp) == NULL)
- return NULL;
- *len = 0;
+ buflen = 0;
+ while ((c = fgetc(fp)) != EOF) {
+ if (buflen >= bufsiz) {
+ size_t nbufsiz = bufsiz + BUFSIZ;
+ char *nbuf = realloc(buf, nbufsiz);
- while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
- size_t nbufsiz = bufsiz + BUFSIZ;
- char *nbuf = realloc(buf, nbufsiz);
+ if (nbuf == NULL) {
+ int oerrno = errno;
+ free(buf);
+ errno = oerrno;
+ buf = NULL;
+ return NULL;
+ }
- if (nbuf == NULL) {
- int oerrno = errno;
- free(buf);
- errno = oerrno;
- buf = NULL;
- return NULL;
- } else
buf = nbuf;
-
- /*
- * We need to overwrite the '\0' written by the last call
- * to fgets().
- */
- *len = bufsiz - 1;
- if (fgets(&buf[bufsiz - 1], BUFSIZ + 1, fp) == NULL)
- return buf;
-
- bufsiz = nbufsiz;
+ bufsiz = nbufsiz;
+ }
+ buf[buflen++] = c;
+ if (c == '\n')
+ break;
}
-
- *len = (ptr - buf) + 1;
- return buf;
+ *len = buflen;
+ return buflen == 0 ? NULL : buf;
}