[Top][All Lists]

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

Re: [Bug-gnulib] why no strchr or strrchr?

From: Oskar Liljeblad
Subject: Re: [Bug-gnulib] why no strchr or strrchr?
Date: Mon, 23 Aug 2004 15:57:51 +0200
User-agent: Mutt/1.5.6+20040523i

On Mon, Aug 23, 2004 at 01:39:41PM +0200, Jim Meyering wrote:
> > Is there any particular reason strchr and strrchr are not implemented
> > in gnulib? autoconf suggests using these tests for strchr and strrchr:
> Probably because every useful system has working versions already.
> > header file:
> >           #if STDC_HEADERS
> >           # include <string.h>
> >           #else
> >           # if !HAVE_STRCHR
> >           #  define strchr index
> >           #  define strrchr rindex
> >           # endif
> >           char *strchr (), *strrchr ();
> >           #endif
> IMHO, those examples are no longer useful for more than historical
> reference.  I seem to have removed all rindex/index/bcmp/bcopy/bzero
> references from the fileutils in 1995.  I haven't looked back since.

My first experience coding on *nix was with linux 2.0. I have also
been coding on SunOS 5.5+ and FreeBSD but nothing beyond that. I
have very little knowledge of porting to old *nix other than what
the GNU libc, autoconf, and automake documentation has told me. I
want to make portable code but this situation is very perplexing!

Why does gnulib implement memcpy but not strchr? Why is autoscan
telling me I should check for strchr before using it? It
would be extremely useful if there was a consensus between the
autoconf/automake and gnulib crew on what standard to support. Is
autoconf out of date? It would also be useful to know what
gnulib modules are unnecessary (i.e. already implemented in C89
C libraries, and there's no known systems implementing it

Also, it would be a pain to add 9-16 lines of code to each file
needing some function, type definition or macro. That's what
autoconf recommends doing right now (see AC_HEADER_DIRENT for
instance). Maybe all these could be added to gnulib, so that
I can replace

          #if HAVE_DIRENT_H
          # include <dirent.h>
          # define NAMLEN(dirent) strlen((dirent)->d_name)
          # define dirent direct
          # define NAMLEN(dirent) (dirent)->d_namlen
          # if HAVE_SYS_NDIR_H
          #  include <sys/ndir.h>
          # endif
          # if HAVE_SYS_DIR_H
          #  include <sys/dir.h>
          # endif
          # if HAVE_NDIR_H
          #  include <ndir.h>
          # endif


        #include "dirent.h"

or something...


Oskar Liljeblad (address@hidden)

reply via email to

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