Bruno Haible <br...@clisp.org> writes: > Simon Josefsson wrote: >> Then I'm less sure that it makes sense for >> gnulib's limit.h to define HOST_NAME_MAX -- programs written against >> POSIX should not assume that symbol exists. > > On the other hand, the support of POSIX for unspecified maximum host > name lengths is weak: You see in [1] that > - when the host name is longer than namelen, the string is truncated, > possibly NUL terminated or not, > - when gethostname fails, it is unspecified whether it sets errno. > The reality (see lib/xgethostname.c) is even worse: > - when the host name is longer than namelen, then some platforms > return -1, others don't; some platforms even write past the specified > namelength bytes, > - the errnos appearing in this case are far from standard. > > I think it's a favour that gnulib can do to its users, to not force > developers to deal with these pitfalls. > > And don't tell me that host names longer than 256 bytes occur frequently :-)
Thanks, your arguments are compelling and useful to have archived in case some FreeBSD people thinks we are making things worse by re-introducing the HOST_NAME_MAX symbol that they appear to want to get rid of. I guess to really get rid of the symbol, improving the POSIX specification in this area would be useful -- however it may be hard since deployed implementations differ. >> Do sysconf work under mingw? Gnulib could provide a replacement if not. > > That would be some work, because of the many arguments that sysconf > should support. [2] It is a large number of symbols, but I wonder how many of them actually are difficult to quantify. /Simon