2017-07-12  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.
	(main) [USE_PROGRAM_DIR]: For DJGPP use LYLastPathSep to allow to check
	for backslash and slash as directory separator.

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

	* 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/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.
	[DOSPATH]:  For DJGPP define USE_PROGRAM_DIR to select the feature that
	uses directory of lynx to locate associated configuration files.

	* 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.16.orig/scripts/cfg_defs.sh lynx2.8.9dev.16/scripts/cfg_defs.sh
--- lynx2.8.9dev.16.orig/scripts/cfg_defs.sh	2006-01-23 01:26:00 +0000
+++ lynx2.8.9dev.16/scripts/cfg_defs.sh	2017-07-12 20:01:34 +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.16.orig/scripts/cfg_path.sh lynx2.8.9dev.16/scripts/cfg_path.sh
--- lynx2.8.9dev.16.orig/scripts/cfg_path.sh	2006-05-29 23:09:26 +0000
+++ lynx2.8.9dev.16/scripts/cfg_path.sh	2017-07-12 20:01:34 +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.16.orig/src/GridText.c lynx2.8.9dev.16/src/GridText.c
--- lynx2.8.9dev.16.orig/src/GridText.c	2017-07-04 17:27:06 +0000
+++ lynx2.8.9dev.16/src/GridText.c	2017-07-12 20:01:34 +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.16.orig/src/LYMain.c lynx2.8.9dev.16/src/LYMain.c
--- lynx2.8.9dev.16.orig/src/LYMain.c	2017-07-03 23:31:20 +0000
+++ lynx2.8.9dev.16/src/LYMain.c	2017-07-12 20:01:34 +0000
@@ -334,10 +334,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 */
@@ -1130,11 +1131,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 +1483,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.16.orig/src/LYrcFile.c lynx2.8.9dev.16/src/LYrcFile.c
--- lynx2.8.9dev.16.orig/src/LYrcFile.c	2017-07-04 20:30:02 +0000
+++ lynx2.8.9dev.16/src/LYrcFile.c	2017-07-12 20:01:34 +0000
@@ -387,10 +387,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.16.orig/src/LYStyle.c lynx2.8.9dev.16/src/LYStyle.c
--- lynx2.8.9dev.16.orig/src/LYStyle.c	2016-10-12 00:50:04 +0000
+++ lynx2.8.9dev.16/src/LYStyle.c	2017-07-12 20:01:34 +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.16.orig/src/LYUtils.c lynx2.8.9dev.16/src/LYUtils.c
--- lynx2.8.9dev.16.orig/src/LYUtils.c	2017-07-02 20:42:32 +0000
+++ lynx2.8.9dev.16/src/LYUtils.c	2017-07-12 20:01:34 +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.16.orig/userdefs.h lynx2.8.9dev.16/userdefs.h
--- lynx2.8.9dev.16.orig/userdefs.h	2017-07-11 08:45:14 +0000
+++ lynx2.8.9dev.16/userdefs.h	2017-07-12 20:01:34 +0000
@@ -1478,35 +1478,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
 
@@ -1538,12 +1564,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
diff -aprNU5 lynx2.8.9dev.16.orig/www/Library/Implementation/HTDOS.c lynx2.8.9dev.16/www/Library/Implementation/HTDOS.c
--- lynx2.8.9dev.16.orig/www/Library/Implementation/HTDOS.c	2013-11-28 11:11:04 +0000
+++ lynx2.8.9dev.16/www/Library/Implementation/HTDOS.c	2017-07-12 20:01:34 +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-07-15  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* src/LYMain.c (main) [FNAMES_8_3]:  On plain DOS check if LFN support
	is available to decide if leading dots in file names are allowed or not.
	Set no_dotfiles and show_dotfiles accordingly.


2017-07-14  Juan Manuel Guerrero  <juan.guerrero@gmx.de>

	* src/LYEdit.c [DOSPATH]: New macro HTAddParamWithProperQuoting defined.
	For DJGPP it checks for the true OS version.  If less or equal than 6.22
	the arguments passed to edit.com are not quoted else yes.  For all other
	DOS compilers this is macro ressambles to the original function.
	(edit_temporary_file) [DOSPATH]: Use HTAddParamWithProperQuoting instead
	of HTAddParam.







diff -aprNU5 lynx2.8.9dev.16.orig/src/LYEdit.c lynx2.8.9dev.16/src/LYEdit.c
--- lynx2.8.9dev.16.orig/src/LYEdit.c	2013-11-28 11:18:14 +0000
+++ lynx2.8.9dev.16/src/LYEdit.c	2017-07-15 20:03:42 +0000
@@ -12,10 +12,37 @@
 #endif /* VMS */
 
 #include <LYLeaks.h>
 #include <www_wait.h>
 
+#ifdef DOSPATH
+/*
+ *  The edit.com program of MS-DOS does not allow quoted arguments.
+ *  For DJGPP check the DOS version and if greater than 6.22 like
+ *  Win95 and greather then allow quoted arguments else not.
+ */
+# ifdef __DJGPP__
+#  include <dos.h>
+#  if defined (__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
+#   define __gnuc_extension__  __extension__
+#  else
+#   define __gnuc_extension__
+#  endif
+#  define HTAddParamWithProperQuoting(COMMAND, FORMAT, PARAMETERS, FILENAME)  \
+   (__gnuc_extension__                                                        \
+     ({                                                                       \
+        if (_get_dos_version(1) < 0x0617)  /*  MSDOS 6.22 or minor.  */       \
+          HTAddToCmd((COMMAND), (FORMAT), (PARAMETERS), (FILENAME));          \
+        else                                                                  \
+          HTAddParam((COMMAND), (FORMAT), (PARAMETERS), (FILENAME));          \
+     })                                                                       \
+   )
+# else   /*  !__DJGPP__  */
+#  define HTAddParamWithProperQuoting  HTAddParam
+# endif  /*  !__DJGPP__  */
+#endif  /*  DOSPATH  */
+
 BOOLEAN editor_can_position(void)
 {
     char *value;
     HTList *p = positionable_editor;
     static const char *table[] =
@@ -222,11 +249,11 @@ void edit_temporary_file(char *filename,
 	HTAddParam(&command, format, params++, position);
 	HTEndParam(&command, format, params);
     } else if (StrNCmp(editor, "edit", 4) == 0) {
 	/* for standard editor */
 	HTAddXpand(&command, format, params++, editor);
-	HTAddParam(&command, format, params++, HTDOS_short_name(filename));
+	HTAddParamWithProperQuoting(&command, format, params++, HTDOS_short_name(filename));
 	HTEndParam(&command, format, params);
     }
 #endif
     else {
 #ifdef _WINDOWS
diff -aprNU5 lynx2.8.9dev.16.orig/src/LYMain.c lynx2.8.9dev.16/src/LYMain.c
--- lynx2.8.9dev.16.orig/src/LYMain.c	2017-07-13 19:02:08 +0000
+++ lynx2.8.9dev.16/src/LYMain.c	2017-07-15 20:05:52 +0000
@@ -1024,10 +1024,20 @@ int main(int argc,
 
 #ifdef _WINDOWS
     WSADATA WSAData;
 #endif /* _WINDOWS */
 
+#ifdef FNAMES_8_3
+    /*
+     * On plain DOS, check for LFN support to
+     * decide what shall the default value be.
+     */
+    no_dotfiles = HAVE_LFN_SUPPORT("./") ? FALSE : TRUE;
+    show_dotfiles = !no_dotfiles;
+#endif
+
+
     /*
      * Just in case someone has the idea to install lynx set-uid, let's try
      * to discourage it.
      */
 #if defined(GETUID) && defined(SETUID)
