[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-gnulib] getline & getline_safe
From: |
Bruno Haible |
Subject: |
Re: [Bug-gnulib] getline & getline_safe |
Date: |
Fri, 18 Jul 2003 19:53:12 +0200 |
User-agent: |
KMail/1.5 |
OK, I've added the getndelim2 module, so that Jim might use it in the
coreutils.
2003-07-18 Bruno Haible <address@hidden>
* modules/getndelim2: New file.
* modules/getline: Share files with module getndelim2.
* modules/getnline: Depend on getndelim2 instead of sharing files with
it. Add getnline.c to lib_SOURCES.
* MODULES.html.sh (func_all_modules): Add getndelim2.
* lib/getndelim2.h: New file.
* lib/getndelim2.c: Make into a module of its own. Include config.h,
getndelim2.h.
(getndelim2): Make non-static. Change return type to ssize_t.
* lib/getline.h: Change argument names.
* lib/getline.c: Include getndelim2.h instead of getndelim2.c.
* lib/getnline.c: Include getndelim2.h.
* m4/getndelim2.m4: New file.
* m4/getline.m4 (AM_FUNC_GETLINE): Add AC_LIBOBJ of getndelim2.c and
invoke gl_PREREQ_GETNDELIM2.
(gl_PREREQ_GETLINE): Drop AC_HEADER_STDC, now done by
gl_PREREQ_GETNDELIM2.
* m4/getnline.m4 (gl_GETNLINE): Drop AC_HEADER_STDC, now done by
gl_GETNDELIM2.
Derek Robert Price wrote:
> +ssize_t
> +getndelim2 (char **lineptr, size_t *linesize, size_t offset, int limit,
> + int delim1, int delim2, FILE *stream)
What's the purpose of having the offset as 3rd argument when historically
(and in the coreutils) it comes last?
> +# define GETNDELIM_NO_LIMIT (ssize_t)-1
Totally confusing types: the limit is an upper bound for the size of an
array or count, so it should be 'size_t'. The getndelim2() argument called
limit is of type 'int'. And this macro is of type 'ssize_t'. Better let
the caller use 'size_t' everywhere.
> --- modules/getnline 17 Jul 2003 16:23:52 -0000 1.1
> +++ modules/getnline 17 Jul 2003 19:09:58 -0000
> @@ -1,10 +1,12 @@
> Description:
> -Read a line from a stream, with bounded memory allocation.
> +Read a line of n characters or less from a stream.
>
> Files:
> +lib/getndelim2.h
> +lib/getndelim2.c
> lib/getnline.h
> lib/getnline.c
> -lib/getndelim2.c
> +m4/getndelim2.m4
> m4/getnline.m4
> m4/ssize_t.m4
>
> @@ -15,8 +17,7 @@
> gl_GETNLINE
>
> Makefile.am:
> -lib_SOURCES += getnline.h
> -EXTRA_DIST += getndelim2.c
> +lib_SOURCES += getnline.h getndelim2.h
>
> Include:
> "getnline.h"
It's simpler to make the module 'getnline' depend on the module 'getndelim2'.
Bruno
- 01-getnline.diff (was Re: [Bug-gnulib] getline & getline_safe), (continued)
- [Bug-gnulib] Re: 01-getnline.diff, Jim Meyering, 2003/07/17
- Re: [Bug-gnulib] getline & getline_safe, Bruno Haible, 2003/07/17
- Re: [Bug-gnulib] getline & getline_safe, Bruno Haible, 2003/07/17
- Re: [Bug-gnulib] getline & getline_safe, Derek Robert Price, 2003/07/17
- Re: [Bug-gnulib] getline & getline_safe, Derek Robert Price, 2003/07/17
- Re: [Bug-gnulib] getline & getline_safe, Bruno Haible, 2003/07/18
- Re: [Bug-gnulib] getline & getline_safe, Derek Robert Price, 2003/07/18
- Re: [Bug-gnulib] getline & getline_safe,
Bruno Haible <=
- Re: [Bug-gnulib] getline & getline_safe, Derek Robert Price, 2003/07/18
- Re: [Bug-gnulib] getline & getline_safe, Bruno Haible, 2003/07/24
- Re: [Bug-gnulib] getline & getline_safe, Derek Robert Price, 2003/07/24
- Re: [Bug-gnulib] getline & getline_safe, Bruno Haible, 2003/07/24
- Re: [Bug-gnulib] getline & getline_safe, Derek Robert Price, 2003/07/25
- Re: [Bug-gnulib] getline & getline_safe, Bruno Haible, 2003/07/28
- Re: [Bug-gnulib] getline & getline_safe, Jim Meyering, 2003/07/28
- Re: [Bug-gnulib] getline & getline_safe, Derek Robert Price, 2003/07/31
- Re: [Bug-gnulib] getline & getline_safe, Bruno Haible, 2003/07/31
- Re: [Bug-gnulib] getline & getline_safe, Derek Robert Price, 2003/07/31