[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lynx-dev] Proposal of DJGPP specific improvements.

From: Juan Manuel Guerrero
Subject: [Lynx-dev] Proposal of DJGPP specific improvements.
Date: Mon, 05 Jun 2017 21:37:27 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv: Gecko/20101206 SUSE/3.1.7 Thunderbird/3.1.7

I would like to propose some DJGPP specific improvements.  They have no impact
in the way lynx works on other operating systems.

1: if compiled with DJGPP, the target OS is some king of DOS.  MS-DOS or
FreeDOS do not know anything about iso-8859-1 character set.  Thus making
this selection as the default character makes no much sense for this OS.
IMO making cp850 the default character set (aka code page) when compiling
lynx for DOS is the better choice.  It gives far better result for a
larger set of western/latin languages than having iso-8859-1 that in the
best case is only good for english but that does not even work neither with
spanish or german.  I am aware that the used character set can be changed by
adjusting some environment variables and/or configuration files but does is
not the point IMHO.  The program should work out-of-the-box without that the
user should have to change to much settings for every OS supported.  This is
not possible for DOS because the iso-8859-1 choice is to much posix centric
than DOS has ever been.

2: On DOS there is nothing like a HOME directory nor HOME environment variable.
There is only one single user and he is always a super-user.  Thus I have 
that the current working directory is used as HOME directory if and only if
no HOME variable is defined.  The original behaviour would be to refuse to start
and that is really an annoying behaviour for a DOS user.

3: DJGPP supports long file names if the underlying file system supports it.
Thus I have implemented some code that detects at run-time if LFN supports is
available and in this case the original file names file ".lynx_cookies" are
supported as well as as the DOS specific ones.  This means that first, the long
file names are tryied to be used and if they failed to be loaded then the short
ones are used.

4: If compiled using DJGPP I have allowed to have all configuration files in
the installation file of lynx.  A lot of support for this feature was already
available and could be activated by defining the USE_PROGRAM_DIR selection 
Only some minor adjustments to this code was necessary.

If there is any interest in the changes proposed and there are suggestions,
objection or comments related to this, please contact me.
The patch is based on lynx2.8.9dev.14.tar.bz2.

Kind regards,
Juan M. Guerrero

2017-06-05  Juan Manuel Guerrero  <address@hidden>

        * 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.
        (main) [USE_PROGRAM_DIR]:  For DJGPP allow to look for the associated
        configuration files also in the lynx installation directory if they are
        not located in their canonical places.

        * 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 
        assume that the current directory can be used as writable directory.

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

        * 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.

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-06-05 17:06:04 +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 */
@@ -1129,11 +1130,15 @@ int main(int argc,
     pgm = argv[0];
     cp = NULL;
     StrAllocCopy(program_dir, pgm);
+#ifdef __DJGPP__
+    if ((cp = LYLastPathSep(program_dir)) != NULL) {
     if ((cp = strrchr(program_dir, '\\')) != NULL) {
        *cp = '\0';
     } else {
        StrAllocCopy(program_dir, ".");
@@ -1477,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);
+           if (!LYCanReadFile(lynx_cfg_file)) {
+               FREE(lynx_cfg_file);
+               lynx_cfg_file = NULL;
+           }
+       }
     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/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-06-05 17:06:04 +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\
+#if defined(FNAMES_8_3) && !defined(HAVE_LFN_SUPPORT)
+#define FNAME_LYNX_COOKIES "cookies"
+#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\
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-06-05 17:06:04 +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);
+       FREE(lynx_lss_file);
+       HTSprintf0(&lynx_lss_file, "%s\\lynx.lss", program_dir);
+       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);
+       }

      * Otherwise, load the initial lss-file and add it to the list for the
      * options menu.
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-06-05 17:06:04 +0000
@@ -5263,10 +5263,16 @@ const char *Home_Dir(void)
                 * Use /tmp; it should be writable.
                StrAllocCopy(HomeDir, "/tmp");
+#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-06-05 17:06:04 +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

+#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)
+#define HAVE_LFN_SUPPORT(name)  (0)
+/*  On plain DOS, a DOS code page is the better choice.  */
+#ifdef DOSPATH
+#define CHARACTER_SET "cp850"
 #ifdef FNAMES_8_3
-#define HTML_SUFFIX ".htm"
+#define HTML_SUFFIX (HAVE_LFN_SUPPORT("./") ? ".html" : ".htm")
 #define HTML_SUFFIX ".html"

+#ifdef FNAMES_8_3
+#define PERSONAL_EXTENSION_MAP (HAVE_LFN_SUPPORT("./") ? "~/.mime.types" : 
+#define PERSONAL_MAILCAP (HAVE_LFN_SUPPORT("./") ? "~/.mailcap" : "~/mailcap")
+#undef  LYNX_SIG_FILE
+#define LYNX_SIG_FILE (HAVE_LFN_SUPPORT("./") ? "~/.lynxsig" : "~/lynxsig")
 #ifdef FNAMES_8_3
-#define FNAME_LYNXRC "lynx.rc"
+#define FNAME_LYNXRC (HAVE_LFN_SUPPORT("./") ? ".lynxrc" : "lynx.rc")
 #define FNAME_LYNXRC ".lynxrc"
 #endif /* FNAMES_8_3 */

 #ifdef FNAMES_8_3
-#define FNAME_LYNX_COOKIES "cookies"
+#define FNAME_LYNX_COOKIES (HAVE_LFN_SUPPORT("./") ? ".lynx_cookies" : 
 #define FNAME_LYNX_COOKIES ".lynx_cookies"
 #endif /* FNAMES_8_3 */

 #ifdef FNAMES_8_3
+#define FNAME_LYNX_TRACE (HAVE_LFN_SUPPORT("./") ? "Lynx.trace" : 
 #define FNAME_LYNX_TRACE "Lynx.trace"
 #endif /* FNAMES_8_3 */

@@ -1537,10 +1563,13 @@
  * Define this to setup feature that uses directory of lynx.exe to locate
  * associated configuration files.
 #define USE_PROGRAM_DIR 1
+#if defined(__DJGPP__)
+#define USE_PROGRAM_DIR 1

 #ifdef _WINDOWS

 #define USE_BLAT_MAILER 1
diff -aprNU5 lynx2.8.9dev.14.orig/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-06-05 17:06:04 
@@ -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();
     /* PDcurses uses myGetChar() in LYString.c */
+#endif /* defined(DJGPP_KEYHANDLER) || defined(USE_SLANG) */
 #endif /* DJGPP */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]