guile-devel
[Top][All Lists]
Advanced

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

Re: gethostname max len


From: Wolfgang Jaehrling
Subject: Re: gethostname max len
Date: Mon, 22 Mar 2004 02:34:14 +0100
User-agent: Mutt/1.3.28i

On Mon, Mar 22, 2004 at 11:02:55AM +1000, Kevin Ryde wrote:
> Wolfgang Jaehrling <address@hidden> writes:
> > Which is what Guile probably also should do, otherwise it won't work
> > correctly on the GNU system, which has no limit on the length of host
> > names;
> 
> Oh, is that how the -1 is to be understood?  Nosing around the glibc
> sources it looked only like it didn't have an implementation for
> HOST_NAME_MAX yet.

The GNU system deliberately defines no such limits, following the
spirit of the GNU coding standards, which say (node "Semantics"):

  "Avoid arbitrary limits on the length of _any_ data structure,
  including file names, lines, files, and symbols, by allocating all
  data structures dynamically.  In most Unix utilities, "long lines
  are silently truncated."  This is not acceptable in a GNU utility."

I'm personally quite happy if programs at least try to use constants
like PATH_MAX, so that we can find these places and fix them.  I
really don't want to know how many programs just use arrays of size
1024 for file names.  There are even manual pages out there (like
realpath(3) on my GNU/Linux system) that contain examples like:

  #ifdef PATH_MAX
    path_max = PATH_MAX;
  #else
    path_max = pathconf (path, _PC_PATH_MAX);
    if (path_max <= 0)
      path_max = 4096;
  #endif

which tries to do the right thing, but ends up doing nonsense on the
GNU system (as pathconf() behaves like sysconf(), returning -1 to
indicate the absence of any limit).  Though I have to admit that doing
the right thing in a portable way is probably more work than it should
be.  But that's what you get for using C instead of Scheme. :-)

Cheers,
Wolfgang

-- 
Repeating false statements makes them true.
Repeating false statements makes them true.
Repeating false statements makes them true.




reply via email to

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