lynx-dev
[Top][All Lists]
Advanced

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

LYNX-DEV Re: Why use `cp' and `rm' when _WINDOWS defined?


From: afn06760
Subject: LYNX-DEV Re: Why use `cp' and `rm' when _WINDOWS defined?
Date: Sun, 15 Mar 1998 07:53:39 GMT

>     * From: address@hidden
>     * Date: Sun, 15 Mar 1998 04:54:24 GMT
>   
>When _WINDOWS is defined src/GlobalDefs.h cleverly defines paths
>to things like `cp', `rm', etc.  Which is fine, if all users have
>Dos versions of these programs.  You run into a little trouble
>when the user has the cygwin system mounted, and things like
>cp.exe and rm.exe, which assume Unix file names, are on the Windows
>PATH.  Do you know what happens when Windows' lynx calls `cp.exe',
>giving it a Windows file path, (well, not, quite,
>`C:\windows\temp/897532.html' isn't exactly what the developers
>mean when DOSPATH is defined in lynx)?  (Sorry for the nested
>question.)
>     _________________________________________________________________

What follows is a series of minor patches to LYDownload.c, LYutils.c,
and LYGlobaldefs.c that make things like file downloads using Dos
copy.exe work properly.  It also gets rid of the stray Unix slash
that has been cropping up when DOSPATH and _WINDOWS is defined.
========================================================================
lynx-copy.diff:
========================================================================

--- userdefs.h.orig     Tue Mar 10 07:07:57 1998
+++ userdefs.h  Sun Mar 15 02:42:51 1998
@@ -1280,9 +1280,9 @@
 #define ZIP_PATH        "zip"
 #define UNZIP_PATH      "unzip"
 #define MKDIR_PATH      "mkdir"
-#define MV_PATH         "mv"
-#define RM_PATH         "rm"
-#define COPY_PATH       "cp"
+#define MV_PATH         "move"
+#define RM_PATH         "erase"
+#define COPY_PATH       "copy"
 #define CHMOD_PATH      "chmod"
 
 #else  /* Unix */
--- src/LYUtils.c.orig  Sat Mar 07 14:01:43 1998
+++ src/LYutils.c       Sun Mar 15 02:19:47 1998
@@ -15,6 +15,7 @@
 
 #ifdef DOSPATH
 #include "HTDOS.h"
+#define FNAMES_8_3
 #endif
 #ifdef VMS
 #include <descrip.h>
@@ -2811,12 +2812,15 @@
 PUBLIC char * quote_pathname ARGS1(
        char *,         pathname)
 {
+#ifdef DOSPATH
+       return pathname;
+#else
     size_t i, n = 0;
     char * result;
 
     for (i=0; i < strlen(pathname); ++i)
        if (pathname[i] == '\'') ++n;
-
+    /* Granddaddy of memory leaks: */
     result = (char *)malloc(strlen(pathname) + 5*n + 3);
     if (result == NULL)
        outofmem(__FILE__, "quote_pathname");
@@ -2835,6 +2839,7 @@
     result[n++] = '\'';
     result[n] = '\0';
     return result;
+#endif
 }
 
 #if HAVE_UTMP
@@ -3341,11 +3346,21 @@
 #ifdef FNAMES_8_3
            sprintf(namebuffer,
                    "%s%d%u.txt",
-                   lynx_temp_space, (int)getpid(), counter-1);
+#ifdef DOSPATH
+                   HTDOS_name(lynx_temp_space),
+#else
+               lynx_temp_space,
+#endif
+               (unsigned)getpid()%10000, counter-1);
            remove(namebuffer);
            sprintf(namebuffer,
                    "%s%d%u%s",
-                   lynx_temp_space, (int)getpid(), counter-1, HTML_SUFFIX);
+#ifdef DOSPATH
+                   HTDOS_name(lynx_temp_space),
+#else
+               lynx_temp_space,
+#endif
+               (unsigned)getpid()%10000, counter-1, HTML_SUFFIX);
            remove(namebuffer);
 #else
            sprintf(namebuffer,
@@ -3379,7 +3394,12 @@
 #ifdef FNAMES_8_3
            sprintf(namebuffer,
                    "%s%d%u.txt",
-                   lynx_temp_space, (int)getpid(), counter);
+#ifdef DOSPATH
+                   HTDOS_name(lynx_temp_space),
+#else
+               lynx_temp_space,
+#endif
+               (unsigned)getpid()%10000, counter);
 #else
            sprintf(namebuffer,
                    "%sL%d-%uTMP.txt",
@@ -3397,7 +3417,12 @@
 #ifdef FNAMES_8_3
            sprintf(namebuffer,
                    "%s%d%u.bin",
-                   lynx_temp_space, (int)getpid(), counter);
+#ifdef DOSPATH
+                   HTDOS_name(lynx_temp_space),
+#else
+               lynx_temp_space,
+#endif
+               (unsigned)getpid()%10000, counter);
 #else
            sprintf(namebuffer,
                    "%sL%d-%uTMP.bin",
@@ -3415,7 +3440,12 @@
 #ifdef FNAMES_8_3
            sprintf(namebuffer,
                    "%s%d%u%s",
-                   lynx_temp_space, (int)getpid(), counter++, HTML_SUFFIX);
+#ifdef DOSPATH
+                   HTDOS_name(lynx_temp_space),
+#else
+               lynx_temp_space,
+#endif
+               (unsigned)getpid()%10000, counter++, HTML_SUFFIX);
 #else
            sprintf(namebuffer,
                    "%sL%d-%uTMP%s",
--- src/LYDownload.c.orig       Fri Feb 27 13:25:05 1998
+++ src/LYDownload.c    Sun Mar 15 02:16:57 1998
@@ -354,6 +354,9 @@
            fflush(stderr);
            fflush(stdout);
            stop_curses();
+#ifdef DOSPATH
+           HTDOS_name(command);
+#endif
            system(command);
            fflush(stdout);
            fflush(stderr);
@@ -367,7 +370,7 @@
            LYDidRename = TRUE;
        }
        chmod(buffer, HIDE_CHMOD);
-#else /* Unix: */
+#else /* _WINDOWS and Unix: */
        /*
         *  Prevent spoofing of the shell.
         */

reply via email to

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