xref: /netbsd-src/external/bsd/mdocml/dist/test-PATH_MAX.c (revision 9508192e445c6bc8463a56d16765781892ab889e)
1*9508192eSchristos /*
2*9508192eSchristos  * POSIX allows PATH_MAX to not be defined, see
3*9508192eSchristos  * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sysconf.html;
4*9508192eSchristos  * the GNU Hurd is an example of a system not having it.
5*9508192eSchristos  *
6*9508192eSchristos  * Arguably, it would be better to test sysconf(_SC_PATH_MAX),
7*9508192eSchristos  * but since the individual *.c files include "config.h" before
8*9508192eSchristos  * <limits.h>, overriding an excessive value of PATH_MAX from
9*9508192eSchristos  * "config.h" is impossible anyway, so for now, the simplest
10*9508192eSchristos  * fix is to provide a value only on systems not having any.
11*9508192eSchristos  * So far, we encountered no system defining PATH_MAX to an
12*9508192eSchristos  * impractically large value, even though POSIX explicitly
13*9508192eSchristos  * allows that.
14*9508192eSchristos  *
15*9508192eSchristos  * The real fix would be to replace all static buffers of size
16*9508192eSchristos  * PATH_MAX by dynamically allocated buffers.  But that is
17*9508192eSchristos  * somewhat intrusive because it touches several files and
18*9508192eSchristos  * because it requires changing struct mlink in mandocdb.c.
19*9508192eSchristos  * So i'm postponing that for now.
20*9508192eSchristos  */
21*9508192eSchristos 
22*9508192eSchristos #include <limits.h>
23*9508192eSchristos #include <stdio.h>
24*9508192eSchristos 
25*9508192eSchristos int
main(void)26*9508192eSchristos main(void)
27*9508192eSchristos {
28*9508192eSchristos 	printf("PATH_MAX is defined to be %ld\n", (long)PATH_MAX);
29*9508192eSchristos 	return 0;
30*9508192eSchristos }
31