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