This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [PATCH] Handle > 2GB objects in strings, speed it up


On Fri, Oct 26, 2001 at 10:11:01AM +0100, Nick Clifton wrote:
> Hi Jakub,
> 
> > I've fixed my strings patch I posted recently and made it portable
> > (I didn't want to use largefile.m4 because I don't think any program in
> > binutils but strings need to be LFS in the near future).
> > Ok to commit?
> 
> The patch looks good to me.  So yes, please do commit it.  There are a
> couple of comments I would like to make, however:
> 
> > -      stream = fopen (file, "rb");
> > +      stream = file_open (file, "rb");
> >        /* Not all systems permit "rb", so try "r" if it failed.  */
> >        if (stream == NULL)
> > -	stream = fopen (file, "r");
> > +	stream = file_open (file, "r");
> 
> Wouldn't it be a good idea to make use of the FOPEN_RB and FOPEN_RT
> macros here ?

Changed to stream = file_open (file, FOPEN_RB); instead of 2 file_open
calls.
On David Brien's request I've also changed typedef file_ptr file_off; to
typedef off_t file_off; since *BSD have off_t 64bit and fopen handles LFS
files, plus configure defines off_t if it was not defined in sys/types.h.

> > +#if __STDC_VERSION__ >= 199901L || (defined(__GNUC__) && __GNUC__ >= 2)
> > +	    if (sizeof (start) > sizeof (long))
> > +	      printf ("%7Lo ", (unsigned long long) start);
> > +	    else
> > +#else
> > +# if !BFD_HOST_64BIT_LONG
> > +	    if (start != (unsigned long) start)
> > +	      printf ("++%7lo ", (unsigned long) start);
> > +	    else
> > +# endif
> > +#endif
> 
> Since this section of code is used in several places, wouldn't it be a
> good idea to replace it with a macro ?  [Well there are slight
> variations, but these could be handled by the macro].

With string concatenation, yes (though it would be a little bit ugly, since
the hex non-gcc !BFD_HOST_64BIT_LONG line is different). But don't binutils
need to support K&R compilers?

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]