Trust libnbcompat to know if we need a getline(3) replacement or not.
Avoids us having to encode a list of all such platforms here.
This commit is contained in:
parent
3cfbbfbd64
commit
afb657e78b
6 changed files with 8 additions and 68 deletions
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.9 2015/03/18 15:05:35 jperkin Exp $
|
||||
# $NetBSD: Makefile,v 1.10 2015/04/19 13:30:35 tnn Exp $
|
||||
|
||||
PKGNAME= cwrappers-20150318
|
||||
CATEGORIES= pkgtools sysutils
|
||||
|
@ -21,9 +21,6 @@ CHECK_PERMS= no
|
|||
.if ${OPSYS} != "NetBSD" || !empty(MACHINE_PLATFORM:MNetBSD-[0-5].*)
|
||||
MAKE_ENV+= NEED_MI_VECTOR_HASH=1
|
||||
.endif
|
||||
.if !empty(MACHINE_PLATFORM:MDarwin-9.*) || !empty(MACHINE_PLATFORM:MDarwin-10.*)
|
||||
MAKE_ENV+= NEED_GETLINE=1
|
||||
.endif
|
||||
|
||||
CFLAGS.FreeBSD+= -D_WITH_GETLINE
|
||||
CFLAGS.Linux+= -D_GNU_SOURCE=1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.2 2014/09/18 19:31:47 joerg Exp $
|
||||
# $NetBSD: Makefile,v 1.3 2015/04/19 13:30:35 tnn Exp $
|
||||
#
|
||||
PROGS= as-wrapper cc-wrapper c++-wrapper cpp-wrapper f77-wrapper \
|
||||
imake-wrapper ld-wrapper libtool-wrapper shlibtool-wrapper
|
||||
|
@ -11,10 +11,6 @@ LIB_SRCS= alloc.c cleanup-cc.c common.c reorder-cc.c
|
|||
LIB_SRCS+= mi_vector_hash.c
|
||||
CPPFLAGS+= -DNEED_MI_VECTOR_HASH
|
||||
.endif
|
||||
.ifdef NEED_GETLINE
|
||||
LIB_SRCS+= getline.c
|
||||
CPPFLAGS+= -DNEED_GETLINE
|
||||
.endif
|
||||
|
||||
LDADD+= -lnbcompat
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: common.c,v 1.3 2014/11/29 22:19:55 joerg Exp $ */
|
||||
/* $NetBSD: common.c,v 1.4 2015/04/19 13:30:35 tnn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 Joerg Sonnenberger <joerg@NetBSD.org>.
|
||||
|
@ -32,6 +32,7 @@
|
|||
#include <nbcompat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <nbcompat/err.h>
|
||||
#include <nbcompat/stdio.h>
|
||||
#include <nbcompat/stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: common.h,v 1.3 2015/02/13 22:18:38 jperkin Exp $ */
|
||||
/* $NetBSD: common.h,v 1.4 2015/04/19 13:30:35 tnn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 Joerg Sonnenberger <joerg@NetBSD.org>.
|
||||
|
@ -104,8 +104,5 @@ void fixup_libtool(struct arglist *);
|
|||
#ifdef NEED_MI_VECTOR_HASH
|
||||
void mi_vector_hash(const void *, size_t, uint32_t, uint32_t[3]);
|
||||
#endif
|
||||
#ifdef NEED_GETLINE
|
||||
ssize_t getline(char **, size_t *, FILE *);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: fixup-libtool.c,v 1.5 2015/03/18 15:05:36 jperkin Exp $ */
|
||||
/* $NetBSD: fixup-libtool.c,v 1.6 2015/04/19 13:30:35 tnn Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2009 Joerg Sonnenberger <joerg@NetBSD.org>.
|
||||
|
@ -29,10 +29,11 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <nbcompat.h>
|
||||
#include <nbcompat/stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <err.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "common.h"
|
||||
|
||||
ssize_t
|
||||
getline(char **lineptr, size_t *len, FILE *fp)
|
||||
{
|
||||
char *iter, *eos;
|
||||
int ch;
|
||||
|
||||
if (*len == 1) {
|
||||
free(*lineptr);
|
||||
*len = 0;
|
||||
}
|
||||
if (*len == 0) {
|
||||
*lineptr = malloc(128);
|
||||
if (*lineptr == NULL)
|
||||
return -1;
|
||||
*len = 128;
|
||||
}
|
||||
|
||||
iter = *lineptr;
|
||||
for (;;) {
|
||||
eos = *lineptr + *len - 1;
|
||||
|
||||
while (iter < eos) {
|
||||
ch = getc_unlocked(fp);
|
||||
if (ch == -1)
|
||||
break;
|
||||
*iter++ = ch;
|
||||
if (ch == '\n') {
|
||||
*iter = '\0';
|
||||
return iter - *lineptr;
|
||||
}
|
||||
}
|
||||
if (iter == *lineptr)
|
||||
return -1;
|
||||
if (iter < eos) {
|
||||
*iter = '\0';
|
||||
return iter - *lineptr;
|
||||
}
|
||||
|
||||
iter = realloc(*lineptr, *len * 2);
|
||||
if (iter == NULL)
|
||||
return -1;
|
||||
*lineptr = iter;
|
||||
iter += *len - 1;
|
||||
*len *= 2;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue