Add replacement fgetln(3) (from lukemftp/libukem), as fparseln(3) uses it
This commit is contained in:
parent
cd2127f548
commit
07fae6dedd
|
@ -1,8 +1,8 @@
|
|||
# $NetBSD: Makefile,v 1.1 2001/12/11 21:17:57 tv Exp $
|
||||
# $NetBSD: Makefile,v 1.2 2002/01/04 14:39:06 lukem Exp $
|
||||
|
||||
HOSTLIB= nbcompat
|
||||
|
||||
SRCS= err.c fparseln.c setprogname.c
|
||||
SRCS= err.c fgetln.c fparseln.c setprogname.c
|
||||
HOST_CPPFLAGS+= -I. -DHAVE_CONFIG_H
|
||||
|
||||
DPSRCS= config.h
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: config.h.in,v 1.1 2001/12/11 21:17:58 tv Exp $ */
|
||||
/* $NetBSD: config.h.in,v 1.2 2002/01/04 14:39:07 lukem Exp $ */
|
||||
|
||||
#ifndef __NETBSD_COMPAT_CONFIG_H__
|
||||
#define __NETBSD_COMPAT_CONFIG_H__
|
||||
|
@ -9,6 +9,7 @@
|
|||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
#undef HAVE_ERRX
|
||||
#undef HAVE_FGETLN
|
||||
#undef HAVE_FPARSELN
|
||||
#undef HAVE_SETPROGNAME
|
||||
|
||||
|
@ -31,6 +32,10 @@ void warn(const char *, ...);
|
|||
void warnx(const char *, ...);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FGETLN
|
||||
char *fgetln(FILE *, size_t *);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FPARSELN
|
||||
char *fparseln(FILE *, size_t *, size_t *, const char [3], int);
|
||||
#endif
|
||||
|
|
|
@ -2173,7 +2173,7 @@ fi
|
|||
echo "$as_me:2173: result: $ac_cv_header_sys_types_h" >&5
|
||||
echo "${ECHO_T}$ac_cv_header_sys_types_h" >&6
|
||||
|
||||
for ac_func in errx
|
||||
for ac_func in errx fgetln setprogname
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
echo "$as_me:2179: checking for $ac_func" >&5
|
||||
|
@ -2341,75 +2341,6 @@ EOF
|
|||
|
||||
fi
|
||||
|
||||
for ac_func in setprogname
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
echo "$as_me:2347: checking for $ac_func" >&5
|
||||
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
|
||||
if eval "test \"\${$as_ac_var+set}\" = set"; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
#line 2353 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func (); below. */
|
||||
#include <assert.h>
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
builtin and then its argument prototype would still apply. */
|
||||
char $ac_func ();
|
||||
char (*f) ();
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
/* The GNU C library defines this for functions which it implements
|
||||
to always fail with ENOSYS. Some functions are actually named
|
||||
something starting with __ and the normal name is an alias. */
|
||||
#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
|
||||
choke me
|
||||
#else
|
||||
f = $ac_func;
|
||||
#endif
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (eval echo "$as_me:2384: \"$ac_link\"") >&5
|
||||
(eval $ac_link) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:2387: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (eval echo "$as_me:2390: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:2393: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
eval "$as_ac_var=yes"
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
cat conftest.$ac_ext >&5
|
||||
eval "$as_ac_var=no"
|
||||
fi
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
|
||||
fi
|
||||
echo "$as_me:2403: result: `eval echo '${'$as_ac_var'}'`" >&5
|
||||
echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
|
||||
if test `eval echo '${'$as_ac_var'}'` = yes; then
|
||||
cat >>confdefs.h <<EOF
|
||||
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||
EOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
cat >confcache <<\_ACEOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
# tests run on this system so they can be shared between configure
|
||||
|
@ -2489,7 +2420,7 @@ DEFS=-DHAVE_CONFIG_H
|
|||
: ${CONFIG_STATUS=./config.status}
|
||||
ac_clean_files_save=$ac_clean_files
|
||||
ac_clean_files="$ac_clean_files $CONFIG_STATUS"
|
||||
{ echo "$as_me:2492: creating $CONFIG_STATUS" >&5
|
||||
{ echo "$as_me:2423: creating $CONFIG_STATUS" >&5
|
||||
echo "$as_me: creating $CONFIG_STATUS" >&6;}
|
||||
cat >$CONFIG_STATUS <<_ACEOF
|
||||
#! $SHELL
|
||||
|
@ -2661,7 +2592,7 @@ cat >>$CONFIG_STATUS <<\EOF
|
|||
echo "$ac_cs_version"; exit 0 ;;
|
||||
--he | --h)
|
||||
# Conflict between --help and --header
|
||||
{ { echo "$as_me:2664: error: ambiguous option: $1
|
||||
{ { echo "$as_me:2595: error: ambiguous option: $1
|
||||
Try \`$0 --help' for more information." >&5
|
||||
echo "$as_me: error: ambiguous option: $1
|
||||
Try \`$0 --help' for more information." >&2;}
|
||||
|
@ -2680,7 +2611,7 @@ Try \`$0 --help' for more information." >&2;}
|
|||
ac_need_defaults=false;;
|
||||
|
||||
# This is an error.
|
||||
-*) { { echo "$as_me:2683: error: unrecognized option: $1
|
||||
-*) { { echo "$as_me:2614: error: unrecognized option: $1
|
||||
Try \`$0 --help' for more information." >&5
|
||||
echo "$as_me: error: unrecognized option: $1
|
||||
Try \`$0 --help' for more information." >&2;}
|
||||
|
@ -2717,7 +2648,7 @@ do
|
|||
# Handling of arguments.
|
||||
"defs.mk" ) CONFIG_FILES="$CONFIG_FILES defs.mk" ;;
|
||||
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
|
||||
*) { { echo "$as_me:2720: error: invalid argument: $ac_config_target" >&5
|
||||
*) { { echo "$as_me:2651: error: invalid argument: $ac_config_target" >&5
|
||||
echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
|
||||
{ (exit 1); exit 1; }; };;
|
||||
esac
|
||||
|
@ -2915,7 +2846,7 @@ done; }
|
|||
esac
|
||||
|
||||
if test x"$ac_file" != x-; then
|
||||
{ echo "$as_me:2918: creating $ac_file" >&5
|
||||
{ echo "$as_me:2849: creating $ac_file" >&5
|
||||
echo "$as_me: creating $ac_file" >&6;}
|
||||
rm -f "$ac_file"
|
||||
fi
|
||||
|
@ -2933,7 +2864,7 @@ echo "$as_me: creating $ac_file" >&6;}
|
|||
-) echo $tmp/stdin ;;
|
||||
[\\/$]*)
|
||||
# Absolute (can't be DOS-style, as IFS=:)
|
||||
test -f "$f" || { { echo "$as_me:2936: error: cannot find input file: $f" >&5
|
||||
test -f "$f" || { { echo "$as_me:2867: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
echo $f;;
|
||||
|
@ -2946,7 +2877,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
|
|||
echo $srcdir/$f
|
||||
else
|
||||
# /dev/null tree
|
||||
{ { echo "$as_me:2949: error: cannot find input file: $f" >&5
|
||||
{ { echo "$as_me:2880: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi;;
|
||||
|
@ -3006,7 +2937,7 @@ for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
|
|||
* ) ac_file_in=$ac_file.in ;;
|
||||
esac
|
||||
|
||||
test x"$ac_file" != x- && { echo "$as_me:3009: creating $ac_file" >&5
|
||||
test x"$ac_file" != x- && { echo "$as_me:2940: creating $ac_file" >&5
|
||||
echo "$as_me: creating $ac_file" >&6;}
|
||||
|
||||
# First look for the input files in the build tree, otherwise in the
|
||||
|
@ -3017,7 +2948,7 @@ echo "$as_me: creating $ac_file" >&6;}
|
|||
-) echo $tmp/stdin ;;
|
||||
[\\/$]*)
|
||||
# Absolute (can't be DOS-style, as IFS=:)
|
||||
test -f "$f" || { { echo "$as_me:3020: error: cannot find input file: $f" >&5
|
||||
test -f "$f" || { { echo "$as_me:2951: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
echo $f;;
|
||||
|
@ -3030,7 +2961,7 @@ echo "$as_me: error: cannot find input file: $f" >&2;}
|
|||
echo $srcdir/$f
|
||||
else
|
||||
# /dev/null tree
|
||||
{ { echo "$as_me:3033: error: cannot find input file: $f" >&5
|
||||
{ { echo "$as_me:2964: error: cannot find input file: $f" >&5
|
||||
echo "$as_me: error: cannot find input file: $f" >&2;}
|
||||
{ (exit 1); exit 1; }; }
|
||||
fi;;
|
||||
|
@ -3147,7 +3078,7 @@ cat >>$CONFIG_STATUS <<\EOF
|
|||
rm -f $tmp/in
|
||||
if test x"$ac_file" != x-; then
|
||||
if cmp -s $ac_file $tmp/config.h 2>/dev/null; then
|
||||
{ echo "$as_me:3150: $ac_file is unchanged" >&5
|
||||
{ echo "$as_me:3081: $ac_file is unchanged" >&5
|
||||
echo "$as_me: $ac_file is unchanged" >&6;}
|
||||
else
|
||||
ac_dir=`$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: configure.ac,v 1.1 2001/12/11 21:17:58 tv Exp $
|
||||
# $NetBSD: configure.ac,v 1.2 2002/01/04 14:39:07 lukem Exp $
|
||||
#
|
||||
# Autoconf definition file for libnbcompat.
|
||||
#
|
||||
|
@ -12,8 +12,7 @@ AC_TYPE_SIZE_T
|
|||
AC_CHECK_HEADER(stddef.h)
|
||||
AC_CHECK_HEADER(sys/types.h)
|
||||
|
||||
AC_CHECK_FUNCS(errx)
|
||||
AC_CHECK_FUNCS(errx fgetln setprogname)
|
||||
AC_SEARCH_LIBS(fparseln, util, AC_DEFINE(HAVE_FPARSELN))
|
||||
AC_CHECK_FUNCS(setprogname)
|
||||
|
||||
AC_OUTPUT
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/* $NetBSD: fgetln.c,v 1.1 2002/01/04 14:39:07 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1999 Luke Mewburn <lukem@netbsd.org>.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_FGETLN
|
||||
|
||||
#define BUFCHUNKS BUFSIZ
|
||||
|
||||
char *
|
||||
fgetln(FILE *fp, size_t *len)
|
||||
{
|
||||
static char *buf;
|
||||
static size_t bufsize;
|
||||
size_t buflen;
|
||||
char curbuf[BUFCHUNKS];
|
||||
char *p;
|
||||
|
||||
if (buf == NULL) {
|
||||
bufsize = BUFCHUNKS;
|
||||
buf = (char *)malloc(bufsize);
|
||||
if (buf == NULL)
|
||||
err(1, "Unable to allocate buffer for fgetln()");
|
||||
}
|
||||
|
||||
*buf = '\0';
|
||||
buflen = 0;
|
||||
while ((p = fgets(curbuf, sizeof(curbuf), fp)) != NULL) {
|
||||
size_t l;
|
||||
|
||||
l = strlen(p);
|
||||
if (bufsize < buflen + l) {
|
||||
bufsize += BUFCHUNKS;
|
||||
if ((buf = (char *)realloc(buf, bufsize)) == NULL)
|
||||
err(1, "Unable to allocate %ld bytes of memory",
|
||||
(long)bufsize);
|
||||
}
|
||||
strcpy(buf + buflen, p);
|
||||
buflen += l;
|
||||
if (p[l - 1] == '\n')
|
||||
break;
|
||||
}
|
||||
if (p == NULL && *buf == '\0')
|
||||
return (NULL);
|
||||
*len = strlen(buf);
|
||||
return (buf);
|
||||
}
|
||||
#endif /* HAVE_FGETLN */
|
Loading…
Reference in New Issue