bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] use unlocked io in getdelim


From: Bruno Haible
Subject: Re: [PATCH] use unlocked io in getdelim
Date: Sat, 6 Sep 2008 13:58:49 +0200
User-agent: KMail/1.5.4

Simon Josefsson wrote:
> I'd like to see getndelim2 solve this problem:
> 
> 1) LGPL license compatibility

Done.

> 2) Portability: getndelim2 uses freadptr and freedseek which appears
>    non-portable by design (or?) -- having a getline that can be compiled
>    on any C89/POSIX system can be useful

The same argument would hold for any program that uses freadptr and freadseek
(like, possibly in the future, 'm4'). Therefore I think such conditionals
belong into freadptr and freadseek proper. I'm applying the patch below.

> 3) Stack size usage, freadseek uses a 4kb large buffer

So what? Even in multithreaded situations, the minimum stack size usually
is at least 16 KB. Below the freadseek call, there's only stdio calls, which
will hardly need more than 2 KB of stack.

Bruno


2008-09-06  Bruno Haible  <address@hidden>

        * lib/freadahead.c (freadahead): Add conditional for SLOW_BUT_NO_HACKS.
        * lib/freadptr.c (freadptr): Likewise.
        * lib/freadseek.c (freadptrinc): Likewise.
        Reported by Simon Josefsson.

*** lib/freadahead.c.orig       2008-09-06 12:30:41.000000000 +0200
--- lib/freadahead.c    2008-09-06 12:25:19.000000000 +0200
***************
*** 19,24 ****
--- 19,25 ----
  /* Specification.  */
  #include "freadahead.h"
  
+ #include <stdlib.h>
  #include "stdio-impl.h"
  
  size_t
***************
*** 69,74 ****
--- 70,78 ----
         + (fp->_Mode & 0x4000 /* _MBYTE */
            ? (fp->_Back + sizeof (fp->_Back)) - fp->_Rback
            : 0);
+ #elif defined SLOW_BUT_NO_HACKS     /* users can define this */
+   abort ();
+   return 0;
  #else
   #error "Please port gnulib freadahead.c to your platform! Look at the 
definition of fflush, fread, ungetc on your system, then report this to 
bug-gnulib."
  #endif
*** lib/freadptr.c.orig 2008-09-06 12:30:41.000000000 +0200
--- lib/freadptr.c      2008-09-06 12:21:26.000000000 +0200
***************
*** 85,90 ****
--- 85,94 ----
      return NULL;
    *sizep = size;
    return (const char *) fp->_Next;
+ #elif defined SLOW_BUT_NO_HACKS     /* users can define this */
+   /* This implementation is correct on any ANSI C platform.  It is just
+      awfully slow.  */
+   return NULL;
  #else
   #error "Please port gnulib freadptr.c to your platform! Look at the 
definition of fflush, fread, getc, getc_unlocked on your system, then report 
this to bug-gnulib."
  #endif
*** lib/freadseek.c.orig        2008-09-06 12:30:41.000000000 +0200
--- lib/freadseek.c     2008-09-06 12:22:52.000000000 +0200
***************
*** 53,58 ****
--- 53,59 ----
  # endif
  #elif defined __QNX__               /* QNX */
    fp->_Next += increment;
+ #elif defined SLOW_BUT_NO_HACKS     /* users can define this */
  #else
   #error "Please port gnulib freadseek.c to your platform! Look at the 
definition of getc, getc_unlocked on your system, then report this to 
bug-gnulib."
  #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]