2017-05-19  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.
	[DOSPATH]: 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.14.orig/scripts/cfg_defs.sh lynx2.8.9dev.14/scripts/cfg_defs.sh
--- lynx2.8.9dev.14.orig/scripts/cfg_defs.sh	2006-01-23 01:26:00 +0000
+++ lynx2.8.9dev.14/scripts/cfg_defs.sh	2017-05-19 21:32:14 +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.14.orig/scripts/cfg_path.sh lynx2.8.9dev.14/scripts/cfg_path.sh
--- lynx2.8.9dev.14.orig/scripts/cfg_path.sh	2006-05-29 23:09:26 +0000
+++ lynx2.8.9dev.14/scripts/cfg_path.sh	2017-05-19 21:32:16 +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.14.orig/src/GridText.c lynx2.8.9dev.14/src/GridText.c
--- lynx2.8.9dev.14.orig/src/GridText.c	2017-02-11 00:50:00 +0000
+++ lynx2.8.9dev.14/src/GridText.c	2017-05-19 21:32:16 +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.14.orig/src/LYMain.c lynx2.8.9dev.14/src/LYMain.c
--- lynx2.8.9dev.14.orig/src/LYMain.c	2017-04-27 22:34:12 +0000
+++ lynx2.8.9dev.14/src/LYMain.c	2017-05-19 21:32:16 +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.14.orig/src/LYrcFile.c lynx2.8.9dev.14/src/LYrcFile.c
--- lynx2.8.9dev.14.orig/src/LYrcFile.c	2016-11-24 16:42:46 +0000
+++ lynx2.8.9dev.14/src/LYrcFile.c	2017-05-19 21:32:16 +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.14.orig/src/LYUtils.c lynx2.8.9dev.14/src/LYUtils.c
--- lynx2.8.9dev.14.orig/src/LYUtils.c	2016-11-24 15:35:28 +0000
+++ lynx2.8.9dev.14/src/LYUtils.c	2017-05-19 21:32:16 +0000
@@ -5263,10 +5263,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.14.orig/userdefs.h lynx2.8.9dev.14/userdefs.h
--- lynx2.8.9dev.14.orig/userdefs.h	2017-04-30 16:02:52 +0000
+++ lynx2.8.9dev.14/userdefs.h	2017-05-19 21:32:16 +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.14.orig/www/Library/Implementation/HTDOS.c lynx2.8.9dev.14/www/Library/Implementation/HTDOS.c
--- lynx2.8.9dev.14.orig/www/Library/Implementation/HTDOS.c	2013-11-28 11:11:04 +0000
+++ lynx2.8.9dev.14/www/Library/Implementation/HTDOS.c	2017-05-19 21:32:16 +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 */




2017-05-21  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* src/LYStyle.c (init_color_styles) [USE_PROGRAM_DIR]: If the style
	file is not available at the canonical places (aka LYNX_LSS and
	lynx_lss), try the program directory.

	* src/LYMain.c (main) [USE_PROGRAM_DIR]: For DJGPP use LYLastPathSep
	to allow to check for backslash and slash as directory separator.

	* userdefs.h [DOSPATH]:  For DJGPP define USE_PROGRAM_DIR to select the
	feature that uses directory of lynx to locate associated configuration
	files.








diff -aprNU5 lynx2.8.9dev.14.orig/src/LYMain.c lynx2.8.9dev.14/src/LYMain.c
--- lynx2.8.9dev.14.orig/src/LYMain.c	2017-05-20 19:28:12 +0000
+++ lynx2.8.9dev.14/src/LYMain.c	2017-05-21 12:34:14 +0000
@@ -1130,11 +1130,15 @@ int main(int argc,
      */
     pgm = argv[0];
     cp = NULL;
 #ifdef USE_PROGRAM_DIR
     StrAllocCopy(program_dir, pgm);
+#ifdef __DJGPP__
+    if ((cp = LYLastPathSep(program_dir)) != NULL) {
+#else
     if ((cp = strrchr(program_dir, '\\')) != NULL) {
+#endif
 	*cp = '\0';
     } else {
 	FREE(program_dir);
 	StrAllocCopy(program_dir, ".");
     }
@@ -1478,12 +1482,19 @@ int main(int argc,
      * If no alternate configuration file was specified on the command line,
      * see if it's in the environment.
      */
     if (!lynx_cfg_file) {
 	if (((cp = LYGetEnv("LYNX_CFG")) != NULL) ||
-	    (cp = LYGetEnv("lynx_cfg")) != NULL)
+	    (cp = LYGetEnv("lynx_cfg")) != NULL) {
 	    StrAllocCopy(lynx_cfg_file, cp);
+#ifdef USE_PROGRAM_DIR
+	    if (!LYCanReadFile(lynx_cfg_file)) {
+		FREE(lynx_cfg_file);
+		lynx_cfg_file = NULL;
+	    }
+#endif
+	}
     }
 #ifdef USE_PROGRAM_DIR
     if (!lynx_cfg_file) {
 	HTSprintf0(&lynx_cfg_file, "%s\\lynx.cfg", program_dir);
 	if (!LYCanReadFile(lynx_cfg_file)) {
diff -aprNU5 lynx2.8.9dev.14.orig/src/LYStyle.c lynx2.8.9dev.14/src/LYStyle.c
--- lynx2.8.9dev.14.orig/src/LYStyle.c	2016-10-12 00:50:04 +0000
+++ lynx2.8.9dev.14/src/LYStyle.c	2017-05-21 21:59:00 +0000
@@ -943,13 +943,21 @@ void init_color_styles(char **from_cmdli
 
     /*
      * If the lynx-style file is not available, inform the user and exit.
      */
     if (isEmpty(lynx_lss_file) || !LYCanReadFile(lynx_lss_file)) {
-	fprintf(stderr, gettext("\nLynx file \"%s\" is not available.\n\n"),
-		NonNull(cp));
-	exit_immediately(EXIT_FAILURE);
+#ifdef USE_PROGRAM_DIR
+	FREE(lynx_lss_file);
+	HTSprintf0(&lynx_lss_file, "%s\\lynx.lss", program_dir);
+	if (isEmpty(lynx_lss_file) || !LYCanReadFile(lynx_lss_file)) {
+#endif
+	    fprintf(stderr, gettext("\nLynx file \"%s\" is not available.\n\n"),
+		    NonNull(cp));
+	    exit_immediately(EXIT_FAILURE);
+#ifdef USE_PROGRAM_DIR
+	}
+#endif
     }
 
     /*
      * Otherwise, load the initial lss-file and add it to the list for the
      * options menu.
diff -aprNU5 lynx2.8.9dev.14.orig/userdefs.h lynx2.8.9dev.14/userdefs.h
--- lynx2.8.9dev.14.orig/userdefs.h	2017-05-20 19:28:12 +0000
+++ lynx2.8.9dev.14/userdefs.h	2017-05-21 08:38:08 +0000
@@ -1561,12 +1561,12 @@
 #ifdef DOSPATH
 
 /*
  * Define this to setup feature that uses directory of lynx.exe to locate
  * associated configuration files.
-#define USE_PROGRAM_DIR 1
  */
+#define USE_PROGRAM_DIR 1
 
 #ifdef _WINDOWS
 
 #ifndef USE_BLAT_MAILER
 #define USE_BLAT_MAILER 1
