/****************************************************************************
- * Copyright 2021,2023 Thomas E. Dickey *
+ * Copyright 2021-2023,2024 Thomas E. Dickey *
* *
* Permission is hereby granted, free of charge, to any person obtaining a *
* copy of this software and associated documentation files (the *
****************************************************************************/
/*
- * $Id: term.priv.h,v 1.8 2023/09/16 15:16:38 tom Exp $
+ * $Id: term.priv.h,v 1.12 2024/02/24 18:11:38 tom Exp $
*
* term.priv.h
*
#define NCURSES_INTERNALS 1
#define NCURSES_OPAQUE 0
-#include <limits.h> /* PATH_MAX */
+#if HAVE_LIMITS_H
+# include <limits.h> /* PATH_MAX, MB_LEN_MAX, etc */
+#elif HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
#include <signal.h> /* sig_atomic_t */
#include <time.h> /* time_t */
#include <term.h> /* time_t */
#endif
#endif
+/*
+ * If not properly configured to use the system's limits.h, we get gcc's
+ * fallback for limits.h which sets MB_LEN_MAX to 1, which is never correct.
+ */
+#if defined(MB_LEN_MAX) && (MB_LEN_MAX < 6)
+#undef MB_LEN_MAX
+#endif
+
+#ifndef MB_LEN_MAX
+#define MB_LEN_MAX 16 /* should be >= MB_CUR_MAX, but that may be a function */
+#endif
+
+#ifndef PATH_MAX
+# if defined(_POSIX_PATH_MAX)
+# define PATH_MAX _POSIX_PATH_MAX
+# elif defined(MAXPATHLEN)
+# define PATH_MAX MAXPATHLEN
+# else
+# define PATH_MAX 255 /* the Posix minimum path-size */
+# endif
+#endif
+
/*
* State of tparm().
*/
#ifdef TRACE
bool trace_opened;
- char trace_fname[PATH_MAX];
int trace_level;
FILE * trace_fp;
int trace_fd;