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