$NetBSD: patch-ab,v 1.4 2020/08/18 02:17:26 gutteridge Exp $ --- tcl/tclGlob.c.orig 1995-02-24 21:19:55.000000000 +0000 +++ tcl/tclGlob.c @@ -24,18 +24,26 @@ static char rcsid[] = "$Header: /home/ag #include #include #include -#include +#include #include #include +#define direct dirent + +#ifdef __sun +#define D_NAMLEN(d) (strlen((d)->d_name)) +#elif defined(__linux__) +#define D_NAMLEN(d) _D_EXACT_NAMLEN((d)) +#else +#define D_NAMLEN(d) ((d)->d_namlen) +#endif + /* * The structure below is used to keep track of a globbing result * being built up (i.e. a partial list of file names). The list * grows dynamically to be as big as needed. */ -extern int errno; - typedef struct { char *result; /* Pointer to result area. */ int totalSpace; /* Total number of characters allocated @@ -298,12 +306,12 @@ DoGlob(interp, dir, rem, resPtr) if (Tcl_StringMatch(entryPtr->d_name, pattern)) { if (*p == 0) { AppendResult(dir, entryPtr->d_name, - (int) entryPtr->d_namlen, resPtr); + (int) D_NAMLEN(entryPtr), resPtr); } else { - if ((l1+entryPtr->d_namlen+2) <= STATIC_SIZE) { + if ((l1+D_NAMLEN(entryPtr)+2) <= STATIC_SIZE) { newDir = static1; } else { - newDir = malloc((unsigned) (l1+entryPtr->d_namlen+2)); + newDir = malloc((unsigned) (l1+D_NAMLEN(entryPtr)+2)); } sprintf(newDir, "%s%s/", dir, entryPtr->d_name); result = DoGlob(interp, newDir, p+1, resPtr);