LCOV - code coverage report
Current view: top level - libs/libgroff - maxpathname.cpp (source / functions) Hit Total Coverage
Test: GNU roff Lines: 2 2 100.0 %
Date: 2026-01-16 17:51:41 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Copyright 2005-2024 Free Software Foundation, Inc.
       2             :      Written by Werner Lemberg (wl@gnu.org)
       3             : 
       4             : This file is part of groff, the GNU roff typesetting system.
       5             : 
       6             : groff is free software; you can redistribute it and/or modify it under
       7             : the terms of the GNU General Public License as published by the Free
       8             : Software Foundation, either version 3 of the License, or
       9             : (at your option) any later version.
      10             : 
      11             : groff is distributed in the hope that it will be useful, but WITHOUT ANY
      12             : WARRANTY; without even the implied warranty of MERCHANTABILITY or
      13             : FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
      14             : for more details.
      15             : 
      16             : You should have received a copy of the GNU General Public License
      17             : along with this program.  If not, see <http://www.gnu.org/licenses/>. */
      18             : 
      19             : #ifdef HAVE_CONFIG_H
      20             : #include <config.h>
      21             : #endif
      22             : 
      23             : #include "lib.h"
      24             : 
      25             : // needed for pathconf()
      26             : #include "posix.h"
      27             : #include "nonposix.h"
      28             : 
      29             : /* path_name_max(dir) does the same as pathconf(dir, _PC_PATH_MAX) */
      30             : 
      31             : #ifdef _POSIX_VERSION
      32             : 
      33          17 : size_t path_name_max()
      34             : {
      35          17 :   return pathconf("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf("/",_PC_PATH_MAX);
      36             : }
      37             : 
      38             : #else /* not _POSIX_VERSION */
      39             : 
      40             : #include <stdlib.h>
      41             : 
      42             : #ifdef HAVE_DIRENT_H
      43             : # include <dirent.h>
      44             : #else /* not HAVE_DIRENT_H */
      45             : # ifdef HAVE_SYS_DIR_H
      46             : #  include <sys/dir.h>
      47             : # endif /* HAVE_SYS_DIR_H */
      48             : #endif /* not HAVE_DIRENT_H */
      49             : 
      50             : #ifndef PATH_MAX
      51             : # ifdef MAXPATHLEN
      52             : #  define PATH_MAX MAXPATHLEN
      53             : # else /* !MAXPATHLEN */
      54             : #  ifdef MAX_PATH
      55             : #   define PATH_MAX MAX_PATH
      56             : #  else /* !MAX_PATH */
      57             : #   ifdef _MAX_PATH
      58             : #    define PATH_MAX _MAX_PATH
      59             : #   else /* !_MAX_PATH */
      60             : #    define PATH_MAX 255
      61             : #   endif /* !_MAX_PATH */
      62             : #  endif /* !MAX_PATH */
      63             : # endif /* !MAXPATHLEN */
      64             : #endif /* !PATH_MAX */
      65             : 
      66             : size_t path_name_max()
      67             : {
      68             :   return PATH_MAX;
      69             : }
      70             : 
      71             : #endif /* not _POSIX_VERSION */
      72             : 
      73             : // Local Variables:
      74             : // fill-column: 72
      75             : // mode: C++
      76             : // End:
      77             : // vim: set cindent noexpandtab shiftwidth=2 textwidth=72:

Generated by: LCOV version 1.14