bug-groff
[Top][All Lists]
Advanced

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

Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp


From: Steffen Nurpmeso
Subject: Re: [bug #55449] Use FILENAME_MAX in maxfilename.cpp
Date: Sat, 12 Jan 2019 01:23:34 +0100
User-agent: s-nail v14.9.11-134-gcc46cfe8

Eli Zaretskii wrote in <address@hidden>:
 |URL:
 |  <https://savannah.gnu.org/bugs/?55449>
 |
 |                 Summary: Use FILENAME_MAX in maxfilename.cpp
 |                 Project: GNU troff
 |            Submitted by: eliz
 |            Submitted on: Fri 11 Jan 2019 09:41:05 PM IST
 |                Category: Core
 |                Severity: 3 - Normal
 |              Item Group: Incorrect behaviour
 |                  Status: None
 |                 Privacy: Public
 |             Assigned to: None
 |             Open/Closed: Open
 |         Discussion Lock: Any
 |         Planned Release: None
 |
 |    _______________________________________________________
 |
 |Details:
 |
 |For platforms which don't have the Posix pathconf, maxfilename.cpp \
 |should try
 |harder, and look at (the ANSI-standard) FILENAME_MAX in addition to \
 |the other
 |varieties.  Right now, it decides that NAME_MAX is 14 on MS-Windows, \
 |which of
 |course makes no sense.  One adverse effect of this is that temporary file
 |names don't get the "groff" prefix, for no good reason.

Let me be plain one time.  The entire stuff that came in for
Windows polluted the code enormously.  That thing you say, and there is also
PATH_MAX, was one of the first things i have thrown away from my
port, which unfortunately stalls and lays around.  There is also
path_max for paths.  Note that even 

  /* POSIX 2008/Cor 1-2013 defines a minimum of 14 for _POSIX_NAME_MAX */
  #ifndef NAME_MAX
  # ifdef _POSIX_NAME_MAX
  #  define NAME_MAX _POSIX_NAME_MAX
  # else
  #  define NAME_MAX 14
  # endif
  #endif
  #if NAME_MAX + 0 < 8
  # error NAME_MAX is too small
  #endif
  
  /* POSIX 2008/Cor 1-2013 defines for
   * - _POSIX_PATH_MAX a minimum of 256
   * - _XOPEN_PATH_MAX a minimum of 1024
   * NFS RFC 1094 from March 1989 defines a MAXPATHLEN of 1024, so we really
   * should avoid anything smaller than that! */
  #ifndef PATH_MAX
  # ifdef MAXPATHLEN
  #  define PATH_MAX MAXPATHLEN
  # else
  #  define PATH_MAX 1024
  # endif
  #endif
  #if PATH_MAX + 0 < 1024
  # undef PATH_MAX
  # define PATH_MAX 1024
  #endif
  
  uz
  su_file_name_max(char const *dname){
     uz rv;
  #ifdef HAVE_PATHCONF
     long sr;
  #endif
     NYD_IN;
     UNUSED(dname);
     ASSERT_NYD_RET(dname != NIL, rv = NAME_MAX);
  
  #ifdef HAVE_PATHCONF
     if((sr = pathconf(dname, _PC_NAME_MAX)) != -1)
        rv = S(uz,sr);
     else
  #endif
        rv = NAME_MAX;
     NYD_OU;
     return rv;
  }
  
  uz
  su_path_name_max(char const *dname_or_nil){
     uz rv;
  #ifdef HAVE_PATHCONF
     long rv;
  #endif
     NYD_IN;
     UNUSED(dname_or_nil);
  
  #ifdef HAVE_PATHCONF
     if(dname_or_nil == NIL)
        dname_or_nil = "/"; /* TODO dirsep configurable */
  
     if((sr = pathconf(dname_or_nil, _PC_PATH_MAX)) != -1)
        rv = S(uz,sr);
     else
  #endif
        rv = PATH_MAX;
     NYD_OU;
     return rv;
  }

is still not right, since checks should be performed on open
directory file descriptors (on systems which do support this), but
that requires deeper changes on the code first.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



reply via email to

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