Here's the updated module. Note the slight documentation change since
my e-mail to Bruno.
Index: lib/read-file.c
===
RCS file: lib/read-file.c
diff -N lib/read-file.c
--- /dev/null 1 Jan 1970 00:00:00 -
+++ lib/read-file.c
Bruno Haible <[EMAIL PROTECTED]> writes:
> Simon Josefsson wrote:
>> Here's the module. Only lighted tested, mostly to get feedback on the
>> approach, but if you agree with it, detailed review would be useful.
>
> Looks already quite good. Only minor nits:
>
>> +/* Read a STREAM and return a new
Simon Josefsson wrote:
> Here's the module. Only lighted tested, mostly to get feedback on the
> approach, but if you agree with it, detailed review would be useful.
Looks already quite good. Only minor nits:
> +/* Read a STREAM and return a newly allocated string with the content,
> + and set
Ralf Wildenhues <[EMAIL PROTECTED]> writes:
> * Paul Eggert wrote on Thu, Jun 01, 2006 at 10:20:58AM CEST:
>> Simon Josefsson <[EMAIL PROTECTED]> writes:
>>
>> > What about realloc (NULL, ...)?
>>
>> In practice that is as portable as free (NULL). They were
>> standardized at the same time.
>
>
* Paul Eggert wrote on Thu, Jun 01, 2006 at 10:20:58AM CEST:
> Simon Josefsson <[EMAIL PROTECTED]> writes:
>
> > What about realloc (NULL, ...)?
>
> In practice that is as portable as free (NULL). They were
> standardized at the same time.
Well, with the difference being here that realloc, simi
Simon Josefsson <[EMAIL PROTECTED]> writes:
> What about realloc (NULL, ...)?
In practice that is as portable as free (NULL). They were
standardized at the same time.
Paul Eggert <[EMAIL PROTECTED]> writes:
> Simon Josefsson <[EMAIL PROTECTED]> writes:
>
>> I think we should be able to assume free (NULL) works though
>
> Yes. To my knowledge the last major system for which the 'free'
> module was needed was SunOS 4.1.4 aka Solaris 1.1.2. Sun stopped
> patchin
Simon Josefsson <[EMAIL PROTECTED]> writes:
> I think we should be able to assume free (NULL) works though
Yes. To my knowledge the last major system for which the 'free'
module was needed was SunOS 4.1.4 aka Solaris 1.1.2. Sun stopped
patching SunOS 4.1.4 in 2000 and stopped supporting it in 2
Paul Eggert <[EMAIL PROTECTED]> writes:
> Looks nice. A couple of comments:
>
>> + count = fread (buf + size, 1, BUFSIZ, stream);
>
> BUFSIZ is too small on many systems, for backward compatibility reasons.
> Why not change that "BUFSIZ" to "alloc - size - 1"?
Done.
> Also, for the common
Looks nice. A couple of comments:
> + count = fread (buf + size, 1, BUFSIZ, stream);
BUFSIZ is too small on many systems, for backward compatibility reasons.
Why not change that "BUFSIZ" to "alloc - size - 1"?
Also, for the common case of regular files that you have opened,
you can use fst
Simon Josefsson <[EMAIL PROTECTED]> writes:
> Hmmm. I've made the same mistake before. I'll see how hard it would
> be to write a tool that will "prepare" additions of a gnulib module,
> for one it should run indent on the files, and then run 'cvs
> --new-file diff' on the modules file, and the
Simon Josefsson <[EMAIL PROTECTED]> writes:
> I like this, and I also like your fread_file function. I will create
> a module read-file with two functions fread_file and read_file.
Here's the module. Only lighted tested, mostly to get feedback on the
approach, but if you agree with it, detailed
Bruno Haible <[EMAIL PROTECTED]> wrote:
> /* Read the contents of an input stream, and return it, terminated with a NUL
>byte. */
> char* fread_file (FILE* stream)
> {
How about an interface that provides a length as well as a malloc'd
buffer, so that it works also when the file contains NUL b
Bruno Haible <[EMAIL PROTECTED]> writes:
>> Index: modules/strfile
>
> I would call the module 'read-file' and the function 'read_file'. So that it's
> possible to add a module 'write_file' if needed, and for consistency with the
> 'copy-file' module.
I like this, and I also like your fread_file
On 5/30/06, Bruno Haible <[EMAIL PROTECTED]> wrote:
> +tmp = realloc (out, pos + BUFSIZ);
Quadratic runtime behaviour: if you don't have particular luck with the
realloc()
implementation, for large files, this loop will spend most of its time in
realloc(), copying memory around.
Since I w
Simon Josefsson wrote:
> This is used in GnuTLS, and I need it in Shishi now, so I thought that
> it should be a module. What do you think?
I agree it's common enough that we can use it in gnulib.
> Possibly, there should be a xstrfile too, that uses xrealloc...
Yes.
> Index: modules/strfile
Ralf Wildenhues <[EMAIL PROTECTED]> writes:
> * Simon Josefsson wrote on Sat, May 27, 2006 at 12:35:21PM CEST:
>>
>> I hadn't actually even compiled the module..
>
> Let's put it this way: Using a mailing list to fix trivial
> compile warnings doesn't encourage further code reviews.
Right, sorry
Bruce Korb <[EMAIL PROTECTED]> writes:
> It might also be useful to use mmap to load the text, too.
We use mmap GnuTLS's strfile now, but it has had its portability
problems, and I'd like to move to something simpler since this isn't
performance critical. It is also possible that sometimes the f
OK. I can be an idiot, too. It has to be compiled with -DHAVE_MMAP
(so I had an empty compile) and it needs a couple more headers:
sys/stat.h, errno.h and fcntl.h.
Ralf Wildenhues wrote:
* Simon Josefsson wrote on Sat, May 27, 2006 at 12:35:21PM CEST:
I hadn't actually even compiled the module..
Let's put it this way: Using a mailing list to fix trivial
compile warnings doesn't encourage further code reviews.
It might also be useful to use mmap to loa
* Simon Josefsson wrote on Sat, May 27, 2006 at 12:35:21PM CEST:
>
> I hadn't actually even compiled the module..
Let's put it this way: Using a mailing list to fix trivial
compile warnings doesn't encourage further code reviews.
* Simon Josefsson wrote on Sat, May 27, 2006 at 12:40:37PM CEST:
>
Ralf Wildenhues <[EMAIL PROTECTED]> writes:
> * Ralf Wildenhues wrote on Sat, May 27, 2006 at 12:22:35PM CEST:
>> * Simon Josefsson wrote on Sat, May 27, 2006 at 12:12:59PM CEST:
>> > + int save_errno = errno;
>>
>> You are using errno but not including .
>
> ...and realloc but not including .
>
Ralf Wildenhues <[EMAIL PROTECTED]> writes:
> Hi Simon,
>
> * Simon Josefsson wrote on Sat, May 27, 2006 at 12:12:59PM CEST:
>> +int save_errno = errno;
>
> You are using errno but not including .
Hi Ralf! Thanks. I hadn't actually even compiled the module..
Improved patch below.
Index: mo
* Ralf Wildenhues wrote on Sat, May 27, 2006 at 12:22:35PM CEST:
> * Simon Josefsson wrote on Sat, May 27, 2006 at 12:12:59PM CEST:
> > + int save_errno = errno;
>
> You are using errno but not including .
...and realloc but not including .
Please compile your code with lots of warnings enabled
Hi Simon,
* Simon Josefsson wrote on Sat, May 27, 2006 at 12:12:59PM CEST:
> + int save_errno = errno;
You are using errno but not including .
Cheers,
Ralf
This is used in GnuTLS, and I need it in Shishi now, so I thought that
it should be a module. What do you think?
Possibly, there should be a xstrfile too, that uses xrealloc...
Thanks!
Index: modules/strfile
===
RCS file: modules/s
26 matches
Mail list logo