pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/pkgtools/libnbcompat Updated libnbcompat to 20070531.



details:   https://anonhg.NetBSD.org/pkgsrc/rev/0542d6e34cbc
branches:  trunk
changeset: 529324:0542d6e34cbc
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Thu May 31 10:18:49 2007 +0000

description:
Updated libnbcompat to 20070531.

Changes since 20070507:

Completely rewrote the fgetln implementation, since the previous version
couldn't handle files that don't end with a '\n' character. Tested on IRIX,
NetBSD and Solaris.

diffstat:

 pkgtools/libnbcompat/Makefile       |   4 +-
 pkgtools/libnbcompat/buildlink3.mk  |   3 +-
 pkgtools/libnbcompat/files/README   |  12 +++++--
 pkgtools/libnbcompat/files/fgetln.c |  58 ++++++++++++++++++------------------
 4 files changed, 41 insertions(+), 36 deletions(-)

diffs (147 lines):

diff -r 918aec72fffc -r 0542d6e34cbc pkgtools/libnbcompat/Makefile
--- a/pkgtools/libnbcompat/Makefile     Thu May 31 08:34:52 2007 +0000
+++ b/pkgtools/libnbcompat/Makefile     Thu May 31 10:18:49 2007 +0000
@@ -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 -r 918aec72fffc -r 0542d6e34cbc pkgtools/libnbcompat/buildlink3.mk
--- a/pkgtools/libnbcompat/buildlink3.mk        Thu May 31 08:34:52 2007 +0000
+++ b/pkgtools/libnbcompat/buildlink3.mk        Thu May 31 10:18:49 2007 +0000
@@ -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 @@
 
 .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 -r 918aec72fffc -r 0542d6e34cbc pkgtools/libnbcompat/files/README
--- a/pkgtools/libnbcompat/files/README Thu May 31 08:34:52 2007 +0000
+++ b/pkgtools/libnbcompat/files/README Thu May 31 10:18:49 2007 +0000
@@ -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 @@
 on the following operating systems:
 
        DragonFly-1.8/i386              <joerg%NetBSD.org@localhost>
-       HPUX-11.11/hppa                 <tnn%NetBSD.org@localhost>
-       OSF1-5.1B/alpha                 <tnn%NetBSD.org@localhost>
-       Solaris 10/sparc                <tnn%NetBSD.org@localhost>
+
+libnbcompat-20070531 has been tested to build and install correctly
+on the following operating systems:
+
+       SunOS-5.10-sparc                <rillig%NetBSD.org@localhost>
+       NetBSD-3.0-i386                 <rillig%NetBSD.org@localhost>
+       IRIX-6.5-mips                   <rillig%NetBSD.org@localhost>
 
  3 Usage
  =======
diff -r 918aec72fffc -r 0542d6e34cbc pkgtools/libnbcompat/files/fgetln.c
--- a/pkgtools/libnbcompat/files/fgetln.c       Thu May 31 08:34:52 2007 +0000
+++ b/pkgtools/libnbcompat/files/fgetln.c       Thu May 31 10:18:49 2007 +0000
@@ -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 @@
 {
        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 @@
                        return NULL;
        }
 
-       if (fgets(buf, bufsiz, fp) == NULL)
-               return NULL;
-       *len = 0;
-
-       while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
-               size_t nbufsiz = bufsiz + BUFSIZ;
-               char *nbuf = realloc(buf, nbufsiz);
+       buflen = 0;
+       while ((c = fgetc(fp)) != EOF) {
+               if (buflen >= bufsiz) {
+                       size_t nbufsiz = bufsiz + BUFSIZ;
+                       char *nbuf = realloc(buf, nbufsiz);
 
-               if (nbuf == NULL) {
-                       int oerrno = errno;
-                       free(buf);
-                       errno = oerrno;
-                       buf = NULL;
-                       return NULL;
-               } else
+                       if (nbuf == NULL) {
+                               int oerrno = errno;
+                               free(buf);
+                               errno = oerrno;
+                               buf = NULL;
+                               return NULL;
+                       }
+
                        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;
 }



Home | Main Index | Thread Index | Old Index