lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev more DOS patch! (was: Re: DOS weird thing...)


From: Leonid Pauzner
Subject: lynx-dev more DOS patch! (was: Re: DOS weird thing...)
Date: Thu, 31 Dec 1998 05:19:38 +0300 (MSK)

>> While you are reviewing the code for DOS (etc.), please have a look
>> at this, near the beginning of is_url (LYUtils.c):

>> #if defined (DOSPATH) || defined (__EMX__) /* sorry! */
>>     if (strncmp(cp, "file:///", 8) && strlen(cp) == 19 &&
>>         cp[strlen(cp)-1] == ':')
>>         StrAllocCat(cp,"/");
>> #endif

>> That looks very very wrong, and is more likely to create memory
>> corruption than anything useful.  I suspect that nobody knows any
>> more what it was supposed to do, and that's why it is still there.


> I was trying to remove this code, it apperently leads to weird thing,
> lynx file://localhost/c:
> returns a page with a link to file://localhost/c:/.. near the top,
> which results in file://localhost/../ if I try follow the link before.

> Seems conversion c: -> c:/ done not in all plases where neccesary,

OK, against clean dev12 (now forget my previous changes in HTDOS.c)

* DOSPATH or EMX: remove strange code dealing with root of local drive
  from is_url() and HTDOS_name()/HTDOS_wwwname(), add right code
  at the ealier stage in LYFillLocalFileURL(). - LP (thanks KW)


diff -u old/lycharut.c ./lycharut.c
--- old/lycharut.c      Sat Dec 12 20:10:36 1998
+++ ./lycharut.c        Thu Dec 31 04:46:12 1998
@@ -334,13 +334,25 @@
     }

 #if defined(DOSPATH) || defined(__EMX__)
-    if (*(*href+1) == ':') {
+    if (isalpha(*(*href)) && (*(*href+1) == ':'))  {
        /*
         * If it's a local DOS path beginning with drive letter,
         * add file://localhost/ prefix and go ahead.
         */
        StrAllocCopy(temp, *href);
        LYLocalFileToURL (href, temp);
+    }
+
+    /* use below: strlen("file://localhost/") = 17 */
+    if (!strncmp(*href, "file://localhost/", 17)
+          && (strlen(*href) == 19)
+          && isalpha(*(*href+17))
+          && (*(*href+18) == ':')) {
+       /*
+        * terminate DOS drive letter with a slash to surf root successfully.
+        * here seems a proper place to do so.
+        */
+       StrAllocCat(*href, "/");
     }
 #endif /* DOSPATH */


diff -u old/lyutils.c ./lyutils.c
--- old/lyutils.c       Fri Dec 25 13:21:32 1998
+++ ./lyutils.c Thu Dec 31 04:16:06 1998
@@ -2476,12 +2476,6 @@
     if (LYIsHtmlSep(*cp))
        return(0);

-#if defined (DOSPATH) || defined (__EMX__) /* sorry! */
-    if (strncmp(cp, "file:///", 8) && strlen(cp) == 19 &&
-       cp[strlen(cp)-1] == ':')
-       StrAllocCat(cp,"/");
-#endif
-
     if (compare_type(cp, "news:";, 5)) {
        return(NEWS_URL_TYPE);


diff -u old/htdos.c ./htdos.c
--- old/htdos.c Mon Dec 28 12:03:18 1998
+++ ./htdos.c   Thu Dec 31 04:42:58 1998
@@ -38,10 +38,12 @@
     if(strlen(wwwname) > 3 && *cp_url == '/')
        *cp_url = '\0';

+#ifdef NOTUSED
     if(*cp_url == ':') {
        cp_url++;
-       *cp_url = '/';
+       *cp_url = '/';   /* terminate drive letter to survive */
     }
+#endif

     return(wwwname);
 }
@@ -65,19 +67,12 @@

     for (joe = 0; cp_url[joe] != '\0'; joe++)  {
        if (cp_url[joe] == '/') {
-           cp_url[joe] = '\\';
+           cp_url[joe] = '\\';    /* convert slashes to dos-style */
        }
     }

-    /* Needed to surf the root of a local drive. */
-
-    if(strlen(cp_url) < 4) cp_url[2] = ':';
-    if(strlen(cp_url) == 3) strcpy(cp_url+3, "\\");
-    if(strlen(cp_url) == 4) strcpy(cp_url+4, ".");
-
-    if((strlen(cp_url) > 2) && (cp_url[1] == '|'))
-       cp_url[1] = ':';
-
+    /* pesky leading slash, rudiment from file://localhost/  */
+    /* the rest path may be with or without drive letter     */
     if((cp_url[1] == '\\') || (cp_url[0]  != '\\')) {
        result = cp_url;
     } else {



reply via email to

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