2016-12-24  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* scripts/cfg_defs.sh: Use temporary files instead of pipe.

	* scripts/cfg_path.sh: Use temporary files instead of pipe.

	* src/GridText.c (ALLOC_IN_POOL): Pacify compiler.

	* src/LYMain.c [__DJGPP__]: Define shell variable that has been declared
	as extern in LYGlobalDefs.h.

	* src/LYrcFile.c [USE_PERSISTENT_COOKIES]: If HAVE_LFN_SUPPORT defined
	use .lynx_cookies else cookies as file name.

	* src/LYUtils.c (Home_Dir) [__DJGPP__]: For DJGPP, if HOME is not defined
	assume that the current directory can be used as writable directory.

	* userdefs.h [FNAMES_8_3]:  For DJGPP define HAVE_LFN_SUPPORT to detect
	at runtime if LFN support is available or not.  Select the file names
	and extensions accordingly.  For all othe plain DOS compilers, the macro
	HAVE_LFN_SUPPORT defaults to false.
	For plain DOS default to cp850 as character set instead of using the
	posix default iso-8859-1 character set.

	* WWW/Library/Implementation/HTDOS.c [DJGPP_KEYHANDLER || USE_SLANG]:
	Define getxkey function only if either DJGPP_KEYHANDLER or USE_SLANG is
	defined.







diff -aprNU5 lynx2.8.9dev.11.orig/scripts/cfg_defs.sh lynx2.8.9dev.11/scripts/cfg_defs.sh
--- lynx2.8.9dev.11.orig/scripts/cfg_defs.sh	2006-01-23 01:25:56 +0000
+++ lynx2.8.9dev.11/scripts/cfg_defs.sh	2016-12-24 12:50:36 +0000
@@ -21,11 +21,13 @@ EOF
 sed \
 	-e '/^#/d'     \
 	-e 's/^.[^=]*_cv_//' \
 	-e 's/=\${.*=/=/'  \
 	-e 's/}$//'          \
-	config.cache | $SHELL $TOP/scripts/cfg_edit.sh >>$OUT
+	config.cache > ./pipe.tmp
+$SHELL $TOP/scripts/cfg_edit.sh < ./pipe.tmp >>$OUT
+rm -f ./pipe.tmp
 
 cat >>$OUT <<EOF
 };
 
 static const struct {
diff -aprNU5 lynx2.8.9dev.11.orig/scripts/cfg_path.sh lynx2.8.9dev.11/scripts/cfg_path.sh
--- lynx2.8.9dev.11.orig/scripts/cfg_path.sh	2006-05-29 23:09:22 +0000
+++ lynx2.8.9dev.11/scripts/cfg_path.sh	2016-12-24 12:50:36 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh
 # Use this script for substituting the configured path into lynx.cfg -
 # not all paths begin with a slash.
 SECOND=`echo "$2" | sed -e 's,^/,,'`
-sed -e "/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]*:file:/s,/PATH_TO/$1,/$SECOND,"
+sed -e "/^[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]*:file:/s,/PATH_TO/$1,/$SECOND," $3
diff -aprNU5 lynx2.8.9dev.11.orig/src/GridText.c lynx2.8.9dev.11/src/GridText.c
--- lynx2.8.9dev.11.orig/src/GridText.c	2015-12-16 01:19:56 +0000
+++ lynx2.8.9dev.11/src/GridText.c	2016-12-24 12:50:36 +0000
@@ -238,11 +238,11 @@ There are 3 functions - POOL_NEW, POOL_F
  * Updates 'poolptr' if necessary.
  */
 static void *ALLOC_IN_POOL(HTPool ** ppoolptr, unsigned request)
 {
     HTPool *pool = *ppoolptr;
-    pool_data *ptr;
+    pool_data *ptr = NULL;
     unsigned n;
     unsigned j;
 
     if (!pool) {
 	outofmem(__FILE__, "ALLOC_IN_POOL");
diff -aprNU5 lynx2.8.9dev.11.orig/src/LYMain.c lynx2.8.9dev.11/src/LYMain.c
--- lynx2.8.9dev.11.orig/src/LYMain.c	2015-12-18 00:34:40 +0000
+++ lynx2.8.9dev.11/src/LYMain.c	2016-12-24 12:50:36 +0000
@@ -333,10 +333,11 @@ BOOLEAN LYforce_HTML_mode = FALSE;
 BOOLEAN LYfind_leaks = TRUE;
 
 #ifdef __DJGPP__
 BOOLEAN watt_debug = FALSE;	/* WATT-32 debugging */
 BOOLEAN dj_is_bash = FALSE;	/* Check for bash shell under DJGPP */
+char *shell = NULL;
 #endif /* __DJGPP__ */
 
 #ifdef WIN_EX
 BOOLEAN focus_window = FALSE;	/* 1998/10/05 (Mon) 17:18:42 */
 char windows_drive[4];		/* 1998/01/13 (Tue) 21:13:24 */
diff -aprNU5 lynx2.8.9dev.11.orig/src/LYrcFile.c lynx2.8.9dev.11/src/LYrcFile.c
--- lynx2.8.9dev.11.orig/src/LYrcFile.c	2015-12-18 01:57:40 +0000
+++ lynx2.8.9dev.11/src/LYrcFile.c	2016-12-24 12:50:36 +0000
@@ -386,10 +386,16 @@ lists of domains from which Lynx should
 all cookies.  If a domain is specified in both options, rejection will\n\
 take precedence.  The accept_all_cookies parameter will override any\n\
 settings made here.\n\
 ")),
 #ifdef USE_PERSISTENT_COOKIES
+#undef FNAME_LYNX_COOKIES
+#if defined(FNAMES_8_3) && !defined(HAVE_LFN_SUPPORT)
+#define FNAME_LYNX_COOKIES "cookies"
+#else
+#define FNAME_LYNX_COOKIES ".lynx_cookies"
+#endif /* FNAMES_8_3 */
     PARSE_STR(RC_COOKIE_FILE,	        LYCookieFile, N_("\
 cookie_file specifies the file from which to read persistent cookies.\n\
 The default is ~/" FNAME_LYNX_COOKIES ".\n\
 ")),
 #endif
diff -aprNU5 lynx2.8.9dev.11.orig/src/LYUtils.c lynx2.8.9dev.11/src/LYUtils.c
--- lynx2.8.9dev.11.orig/src/LYUtils.c	2016-11-15 09:34:26 +0000
+++ lynx2.8.9dev.11/src/LYUtils.c	2016-12-24 12:50:38 +0000
@@ -5265,10 +5265,16 @@ const char *Home_Dir(void)
 		 * Use /tmp; it should be writable.
 		 */
 		StrAllocCopy(HomeDir, "/tmp");
 	    }
 #endif
+#ifdef __DJGPP__
+	/*
+	 * DOS/DJGPP specific: try the current directory.
+	 */
+	StrAllocCopy(HomeDir, ".");
+#endif /* __DJGPP__ */
 #endif /* VMS */
 	} else {
 	    StrAllocCopy(HomeDir, cp);
 	}
 	homedir = (const char *) HomeDir;
diff -aprNU5 lynx2.8.9dev.11.orig/userdefs.h lynx2.8.9dev.11/userdefs.h
--- lynx2.8.9dev.11.orig/userdefs.h	2016-11-15 09:04:20 +0000
+++ lynx2.8.9dev.11/userdefs.h	2016-12-24 12:50:38 +0000
@@ -1475,35 +1475,61 @@
 /* Win32 may support more, but old win16 helper apps may not. */
 #if defined(__DJGPP__) || defined(_WINDOWS)
 #define FNAMES_8_3
 #endif
 
+#if defined(FNAMES_8_3)
+/*  DJGPP supports long file names if the undelying OS does.  */
+#if defined(__DJGPP__)
+#include <unistd.h>
+#define HAVE_LFN_SUPPORT(name)  (pathconf((name), _PC_NAME_MAX) > 12)
+#else
+#define HAVE_LFN_SUPPORT(name)  (0)
+#endif
+
+/*  On plain DOS, a DOS code page is the better choice.  */
+#ifdef DOSPATH
+#undef  CHARACTER_SET
+#define CHARACTER_SET "cp850"
+#endif
+#endif
+
 #ifdef FNAMES_8_3
-#define HTML_SUFFIX ".htm"
+#define HTML_SUFFIX (HAVE_LFN_SUPPORT("./") ? ".html" : ".htm")
 #else
 #define HTML_SUFFIX ".html"
 #endif
 
+#ifdef FNAMES_8_3
+#undef  PERSONAL_EXTENSION_MAP
+#define PERSONAL_EXTENSION_MAP (HAVE_LFN_SUPPORT("./") ? "~/.mime.types" : "~/mime.types")
+#undef  PERSONAL_MAILCAP
+#define PERSONAL_MAILCAP (HAVE_LFN_SUPPORT("./") ? "~/.mailcap" : "~/mailcap")
+#undef  LYNX_SIG_FILE
+#define LYNX_SIG_FILE (HAVE_LFN_SUPPORT("./") ? "~/.lynxsig" : "~/lynxsig")
+#endif
+
+
 #ifndef FNAME_LYNXRC
 #ifdef FNAMES_8_3
-#define FNAME_LYNXRC "lynx.rc"
+#define FNAME_LYNXRC (HAVE_LFN_SUPPORT("./") ? ".lynxrc" : "lynx.rc")
 #else
 #define FNAME_LYNXRC ".lynxrc"
 #endif /* FNAMES_8_3 */
 #endif
 
 #ifndef FNAME_LYNX_COOKIES
 #ifdef FNAMES_8_3
-#define FNAME_LYNX_COOKIES "cookies"
+#define FNAME_LYNX_COOKIES (HAVE_LFN_SUPPORT("./") ? ".lynx_cookies" : "cookies")
 #else
 #define FNAME_LYNX_COOKIES ".lynx_cookies"
 #endif /* FNAMES_8_3 */
 #endif
 
 #ifndef FNAME_LYNX_TRACE
 #ifdef FNAMES_8_3
-#define FNAME_LYNX_TRACE "LY-TRACE.LOG"
+#define FNAME_LYNX_TRACE (HAVE_LFN_SUPPORT("./") ? "Lynx.trace" : "LY-TRACE.LOG")
 #else
 #define FNAME_LYNX_TRACE "Lynx.trace"
 #endif /* FNAMES_8_3 */
 #endif
 
diff -aprNU5 lynx2.8.9dev.11.orig/www/Library/Implementation/HTDOS.c lynx2.8.9dev.11/www/Library/Implementation/HTDOS.c
--- lynx2.8.9dev.11.orig/www/Library/Implementation/HTDOS.c	2013-11-28 11:11:00 +0000
+++ lynx2.8.9dev.11/www/Library/Implementation/HTDOS.c	2016-12-24 12:50:38 +0000
@@ -213,10 +213,11 @@ void djgpp_idle_loop(void)
  *      returns extended keypress.
  */
 
 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
 
+#if defined(DJGPP_KEYHANDLER) || defined(USE_SLANG)
 int getxkey(void)
 {
 #if defined(DJGPP_KEYHANDLER)
     __dpmi_regs r;
 
@@ -236,6 +237,7 @@ int getxkey(void)
     return SLkp_getkey();
 #else
     /* PDcurses uses myGetChar() in LYString.c */
 #endif
 }
+#endif /* defined(DJGPP_KEYHANDLER) || defined(USE_SLANG) */
 #endif /* DJGPP */
