From 9d6a6d72ecb5624f28866a6aebb601097bf42643 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 22 Apr 1996 03:02:55 +0000 Subject: [PATCH] New version from gettext-0.10.12. --- lib/getline.c | 36 +++++++++++++++++++++++++++++++----- lib/getline.h | 33 ++++++++++++++++++++++++++------- 2 files changed, 57 insertions(+), 12 deletions(-) diff --git a/lib/getline.c b/lib/getline.c index c69946148f..e95aace343 100644 --- a/lib/getline.c +++ b/lib/getline.c @@ -14,21 +14,36 @@ General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software -Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Written by Jan Brittenson, bson@gnu.ai.mit.edu. */ #ifdef HAVE_CONFIG_H -#include +# include #endif -#include #include +#include + +#if defined __GNU_LIBRARY__ && defined HAVE_GETDELIM + +int +getline (lineptr, n, stream) + char **lineptr; + size_t *n; + FILE *stream; +{ + return getdelim (lineptr, n, '\n', stream); +} + + +#else /* ! have getdelim */ + #define NDEBUG #include #if STDC_HEADERS -#include +# include #else char *malloc (), *realloc (); #endif @@ -48,7 +63,7 @@ getstr (lineptr, n, stream, terminator, offset) size_t *n; FILE *stream; char terminator; - int offset; + size_t offset; { int nchars_avail; /* Allocated but unused chars in *LINEPTR. */ char *read_pos; /* Where we're reading into *LINEPTR. */ @@ -124,3 +139,14 @@ getline (lineptr, n, stream) { return getstr (lineptr, n, stream, '\n', 0); } + +int +getdelim (lineptr, n, delimiter, stream) + char **lineptr; + size_t *n; + int delimiter; + FILE *stream; +{ + return getstr (lineptr, n, stream, delimiter, 0); +} +#endif diff --git a/lib/getline.h b/lib/getline.h index e2c3574954..b22136d1e6 100644 --- a/lib/getline.h +++ b/lib/getline.h @@ -1,17 +1,36 @@ +/* Copyright (C) 1995 Free Software Foundation, Inc. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2, or (at your option) +any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + #ifndef _getline_h_ #define _getline_h_ 1 #include -#ifndef __P -# if defined (__GNUC__) || (defined (__STDC__) && __STDC__) -# define __P(args) args +#ifndef PARAMS +# if defined (__GNUC__) || __STDC__ +# define PARAMS(args) args # else -# define __P(args) () +# define PARAMS(args) () # endif /* GCC. */ -#endif /* Not __P. */ +#endif /* Not PARAMS. */ + +int +getline PARAMS ((char **_lineptr, size_t *_n, FILE *_stream)); int - getline __P ((char **_lineptr, size_t *_n, FILE *_stream)); +getdelim PARAMS ((char **_lineptr, size_t *_n, int _delimiter, FILE *_stream)); -#endif /* _getline_h_ */ +#endif -- 2.30.2