lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev (patch) for 2.8.3dev1 - SOURCE CACHE...


From: Leonid Pauzner
Subject: lynx-dev (patch) for 2.8.3dev1 - SOURCE CACHE...
Date: Mon, 7 Jun 1999 16:30:06 +0400 (MSD)

* SOURCE_CACHE: source_cache_file and source_cache_chunk now members of
  HTParentAnchor (where they should belong to, not HText nor mutable globals).
  Add one more parse setting member (verbose_img) to HText structure.




diff -u old/gridtext.c ./gridtext.c
--- old/gridtext.c      Fri May 28 07:04:02 1999
+++ ./gridtext.c        Mon Jun  7 16:21:48 1999
@@ -120,8 +120,6 @@
 PUBLIC BOOLEAN bold_on      = OFF;

 #ifdef SOURCE_CACHE
-PUBLIC char * source_cache_filename = NULL;
-PUBLIC HTChunk * source_cache_chunk = NULL;
 PUBLIC int LYCacheSource = SOURCE_CACHE_NONE;
 PUBLIC BOOLEAN from_source_cache = FALSE;  /* mutable */
 #endif
@@ -187,13 +185,12 @@
        HTParentAnchor *        node_anchor;
 #ifdef SOURCE_CACHE
 #undef lines                   /* FIXME */
-       char *                  source_cache_file;
-       HTChunk *               source_cache_chunk;
        /*
         * Parse settings when this HText was generated.
         */
        BOOLEAN                 clickable_images;
        BOOLEAN                 pseudo_inline_alts;
+       BOOLEAN                 verbose_img;
        BOOLEAN                 raw_mode;
        BOOLEAN                 historical_comments;
        BOOLEAN                 minimal_comments;
@@ -516,24 +513,11 @@
     self->tabs = NULL;
 #ifdef SOURCE_CACHE
     /*
-     * Yes, this is a Gross And Disgusting Hack(TM), I know...
-     */
-    self->source_cache_file = NULL;
-    if (LYCacheSource == SOURCE_CACHE_FILE && source_cache_filename) {
-      StrAllocCopy(self->source_cache_file, source_cache_filename);
-      FREE(source_cache_filename);
-    }
-    self->source_cache_chunk = NULL;
-    if (LYCacheSource == SOURCE_CACHE_MEMORY && source_cache_chunk) {
-       self->source_cache_chunk = source_cache_chunk;
-       source_cache_chunk = NULL;
-    }
-
-    /*
      * Remember the parse settings.
      */
     self->clickable_images = clickable_images;
     self->pseudo_inline_alts = pseudo_inline_alts;
+    self->verbose_img = verbose_img;
     self->raw_mode = LYUseDefaultRawMode;
     self->historical_comments = historical_comments;
     self->minimal_comments = minimal_comments;
@@ -792,23 +776,6 @@
            HTMainAnchor = NULL;
     }

-#ifdef SOURCE_CACHE
-    /*
-     * Clean up the source cache, if any.
-     */
-    if (self->source_cache_file) {
-       CTRACE(tfp, "Removing source cache file %s\n",
-              self->source_cache_file);
-       LYRemoveTemp(self->source_cache_file);
-       FREE(self->source_cache_file);
-    }
-    if (self->source_cache_chunk) {
-       CTRACE(tfp, "Removing memory source cache %p\n",
-              (void *)self->source_cache_chunk);
-       HTChunkFree(self->source_cache_chunk);
-    }
-#endif
-
     FREE(self);
 }

@@ -6157,7 +6124,7 @@
                FREE(htmain_anchor->UCStages);
            }
        }
-       CTRACE(tfp, "\rHTuncache.. freeing document for '%s'%s\n",
+       CTRACE(tfp, "\nHTuncache.. freeing document for '%s'%s\n",
                            ((htmain_anchor &&
                              htmain_anchor->address) ?
                               htmain_anchor->address : "unknown anchor"),
@@ -6177,30 +6144,30 @@
 {
     BOOLEAN ok = FALSE;

-    if (!HTMainText || LYCacheSource == SOURCE_CACHE_NONE ||
+    if (!HTMainAnchor || LYCacheSource == SOURCE_CACHE_NONE ||
        (LYCacheSource == SOURCE_CACHE_FILE &&
-        !HTMainText->source_cache_file) ||
+        !HTMainAnchor->source_cache_file) ||
        (LYCacheSource == SOURCE_CACHE_MEMORY &&
-        !HTMainText->source_cache_chunk))
+        !HTMainAnchor->source_cache_chunk))
        return FALSE;

-    if (LYCacheSource == SOURCE_CACHE_FILE && HTMainText->source_cache_file) {
+    if (LYCacheSource == SOURCE_CACHE_FILE && HTMainAnchor->source_cache_file) 
{
        FILE * fp;
        HTFormat format;
        int ret;

        CTRACE(tfp, "Reparsing source cache file %s\n",
-              HTMainText->source_cache_file);
+              HTMainAnchor->source_cache_file);

        /*
         * This is more or less copied out of HTLoadFile(), except we don't
         * get a content encoding.  This may be overkill.  -dsb
         */
-       if (HTMainText->node_anchor->content_type) {
-           format = HTAtom_for(HTMainText->node_anchor->content_type);
+       if (HTMainAnchor->content_type) {
+           format = HTAtom_for(HTMainAnchor->content_type);
        } else {
-           format = HTFileFormat(HTMainText->source_cache_file, NULL, NULL);
-           format = HTCharsetFormat(format, HTMainText->node_anchor,
+           format = HTFileFormat(HTMainAnchor->source_cache_file, NULL, NULL);
+           format = HTCharsetFormat(format, HTMainAnchor,
                                             UCLYhndl_for_unspec);
            /* not UCLYhndl_HTFile_for_unspec - we are talking about remote
             * documents...
@@ -6208,17 +6175,10 @@
        }
        CTRACE(tfp, "  Content type is \"%s\"\n", format->name);

-       /*
-        * Pass the source cache filename on to the next HText.  Mark it
-        * NULL here so that it won't get deleted by HText_free().
-        */
-       source_cache_filename = HTMainText->source_cache_file;
-       HTMainText->source_cache_file = NULL;
-
-       fp = fopen(source_cache_filename, "r");
+       fp = fopen(HTMainAnchor->source_cache_file, "r");
        if (!fp) {
-           CTRACE(tfp, "  Cannot read file %s\n", source_cache_filename);
-           FREE(source_cache_filename);
+           CTRACE(tfp, "  Cannot read file %s\n", 
HTMainAnchor->source_cache_file);
+           FREE(HTMainAnchor->source_cache_file);
            return FALSE;
        }
 #ifdef DISP_PARTIAL
@@ -6231,22 +6191,22 @@
             */
            HTAlert(RELOADING_FORM);
        }
-       ret = HTParseFile(format, HTOutputFormat, HTMainText->node_anchor,
+       ret = HTParseFile(format, HTOutputFormat, HTMainAnchor,
                          fp, NULL);
        fclose(fp);
        ok = (ret == HT_LOADED);
        if (!ok) {
-           FREE(source_cache_filename);
+           FREE(HTMainAnchor->source_cache_file);
        }
     }

     if (LYCacheSource == SOURCE_CACHE_MEMORY &&
-       HTMainText->source_cache_chunk) {
+       HTMainAnchor->source_cache_chunk) {
        HTFormat format = WWW_HTML;
        int ret;

        CTRACE(tfp, "Reparsing from source memory cache %p\n",
-              (void *)HTMainText->source_cache_chunk);
+              (void *)HTMainAnchor->source_cache_chunk);

        /*
         * This is only done to make things aligned with SOURCE_CACHE_NONE and
@@ -6256,17 +6216,10 @@
         * user-visible benefits, seems just '=' Info Page will show source's
         * effective charset as "(assumed)".
         */
-       format = HTCharsetFormat(format, HTMainText->node_anchor,
+       format = HTCharsetFormat(format, HTMainAnchor,
                                         UCLYhndl_for_unspec);
        /* not UCLYhndl_HTFile_for_unspec - we are talking about remote 
documents... */

-       /*
-        * Pass the source cache HTChunk on to the next HText.  Clear it
-        * here so that it won't get deleted by HText_free().
-        */
-       source_cache_chunk = HTMainText->source_cache_chunk;
-       HTMainText->source_cache_chunk = NULL;
-
 #ifdef DISP_PARTIAL
        display_partial = display_partial_flag;  /* restore */
        Newline_partial = Newline;  /* initialize */
@@ -6277,12 +6230,12 @@
             */
            HTAlert(RELOADING_FORM);
        }
-       ret = HTParseMem(format, HTOutputFormat, HTMainText->node_anchor,
-                        source_cache_chunk, NULL);
+       ret = HTParseMem(format, HTOutputFormat, HTMainAnchor,
+                        HTMainAnchor->source_cache_chunk, NULL);
        ok = (ret == HT_LOADED);
        if (!ok) {
-           HTChunkFree(source_cache_chunk);
-           source_cache_chunk = NULL;
+           HTChunkFree(HTMainAnchor->source_cache_chunk);
+           HTMainAnchor->source_cache_chunk = NULL;
        }
     }

@@ -6297,17 +6250,17 @@

 PUBLIC BOOLEAN HTcan_reparse_document NOARGS
 {
-    if (!HTMainText || LYCacheSource == SOURCE_CACHE_NONE ||
+    if (!HTMainAnchor || LYCacheSource == SOURCE_CACHE_NONE ||
        (LYCacheSource == SOURCE_CACHE_FILE &&
-        !HTMainText->source_cache_file) ||
+        !HTMainAnchor->source_cache_file) ||
        (LYCacheSource == SOURCE_CACHE_MEMORY &&
-        !HTMainText->source_cache_chunk))
+        !HTMainAnchor->source_cache_chunk))
        return FALSE;

-    if (LYCacheSource == SOURCE_CACHE_FILE && HTMainText->source_cache_file) {
+    if (LYCacheSource == SOURCE_CACHE_FILE && HTMainAnchor->source_cache_file) 
{
        FILE * fp;

-       fp = fopen(HTMainText->source_cache_file, "r");
+       fp = fopen(HTMainAnchor->source_cache_file, "r");
        if (!fp) {
            return FALSE;
        }
@@ -6316,7 +6269,7 @@
     }

     if (LYCacheSource == SOURCE_CACHE_MEMORY &&
-       HTMainText->source_cache_chunk) {
+       HTMainAnchor->source_cache_chunk) {
        return TRUE;
     }

@@ -6339,11 +6292,11 @@
      * Annoying Hack(TM):  If we don't have a source cache, we can't
      * reparse anyway, so pretend the settings haven't changed.
      */
-    if (!HTMainText || LYCacheSource == SOURCE_CACHE_NONE ||
+    if (!HTMainAnchor || !HTMainText || LYCacheSource == SOURCE_CACHE_NONE ||
        (LYCacheSource == SOURCE_CACHE_FILE &&
-        !HTMainText->source_cache_file) ||
+        !HTMainAnchor->source_cache_file) ||
        (LYCacheSource == SOURCE_CACHE_MEMORY &&
-        !HTMainText->source_cache_chunk))
+        !HTMainAnchor->source_cache_chunk))
        return FALSE;

     if (TRACE) {
@@ -6355,6 +6308,9 @@
        trace_setting_change("PSEUDO_INLINE_ALTS",
                             HTMainText->pseudo_inline_alts,
                             pseudo_inline_alts);
+       trace_setting_change("VERBOSE_IMG",
+                            HTMainText->verbose_img,
+                            verbose_img);
        trace_setting_change("RAW_MODE", HTMainText->raw_mode,
                             LYUseDefaultRawMode);
        trace_setting_change("HISTORICAL_COMMENTS",
@@ -6373,6 +6329,7 @@

     return (HTMainText->clickable_images != clickable_images ||
            HTMainText->pseudo_inline_alts != pseudo_inline_alts ||
+           HTMainText->verbose_img != verbose_img ||
            HTMainText->raw_mode != LYUseDefaultRawMode ||
            HTMainText->historical_comments != historical_comments ||
            HTMainText->minimal_comments != minimal_comments ||
diff -u old/htanchor.c ./htanchor.c
--- old/htanchor.c      Tue Apr 13 02:39:16 1999
+++ ./htanchor.c        Mon Jun  7 16:21:50 1999
@@ -75,6 +75,10 @@
     newAnchor->isISMAPScript = FALSE;  /* Lynx appends ?0,0 if TRUE. - FM */
     newAnchor->isHEAD = FALSE;         /* HEAD request if TRUE. - FM */
     newAnchor->safe = FALSE;           /* Safe. - FM */
+#ifdef SOURCE_CACHE
+    newAnchor->source_cache_file = NULL;
+    newAnchor->source_cache_chunk = NULL;
+#endif
     newAnchor->FileCache = NULL;       /* Path to a disk-cached copy. - FM */
     newAnchor->SugFname = NULL;        /* Suggested filename. - FM */
     newAnchor->RevTitle = NULL;        /* TITLE for a LINK with REV. - FM */
@@ -689,6 +693,22 @@
     FREE(me->bookmark);
     FREE(me->owner);
     FREE(me->RevTitle);
+#ifdef SOURCE_CACHE
+    /*
+     * Clean up the source cache, if any.
+     */
+    if (me->source_cache_file) {
+       CTRACE(tfp, "Removing source cache file %s\n",
+              me->source_cache_file);
+       LYRemoveTemp(me->source_cache_file);
+       FREE(me->source_cache_file);
+    }
+    if (me->source_cache_chunk) {
+       CTRACE(tfp, "Removing memory source cache %p\n",
+              (void *)me->source_cache_chunk);
+       HTChunkFree(me->source_cache_chunk);
+    }
+#endif
     if (me->FileCache) {
        FILE *fd;
        if ((fd = fopen(me->FileCache, "r")) != NULL) {
diff -u old/htanchor.h ./htanchor.h
--- old/htanchor.h      Tue Mar 30 09:10:38 1999
+++ ./htanchor.h        Mon Jun  7 16:21:50 1999
@@ -77,7 +77,11 @@
   BOOL         isISMAPScript;  /* Script for clickable image map */
   BOOL         isHEAD;         /* Document is headers from a HEAD request */
   BOOL         safe;                   /* Safe */
-  char *       FileCache;      /* Path to a disk-cached copy */
+#ifdef SOURCE_CACHE
+  char *       source_cache_file;
+  HTChunk *    source_cache_chunk;
+#endif
+  char *       FileCache;      /* Path to a disk-cached copy (see 
src/HTFWriter.c) */
   char *       SugFname;       /* Suggested filename */
   char *       cache_control;  /* Cache-Control */
   BOOL         no_cache;       /* Cache-Control, Pragma or META "no-cache"? */
diff -u old/html.c ./html.c
--- old/html.c  Thu May 20 05:48:10 1999
+++ ./html.c    Mon Jun  7 16:23:16 1999
@@ -7764,9 +7764,9 @@
     stream->actions = target->isa;

     if (LYCacheSource == SOURCE_CACHE_FILE) {
-       if (source_cache_filename) {
+       if (anchor->source_cache_file) {
            CTRACE(tfp, "Reusing source cache file %s\n",
-                  source_cache_filename);
+                  anchor->source_cache_file);
            FREE(stream);
            return target;
        }
@@ -7784,25 +7784,22 @@
            return target;
        }

-       /*
-        * Yes, this is a Gross And Disgusting Hack(TM), I know...
-        */
-       StrAllocCopy(source_cache_filename, filename);
+       StrAllocCopy(anchor->source_cache_file, filename);

        CTRACE(tfp, "Caching source for URL %s in file %s\n",
               HTAnchor_address((HTAnchor *)anchor), filename);
     }

     if (LYCacheSource == SOURCE_CACHE_MEMORY) {
-       if (source_cache_chunk) {
+       if (anchor->source_cache_chunk) {
            CTRACE(tfp, "Reusing source memory cache %p\n",
-                  (void *)source_cache_chunk);
+                  (void *)anchor->source_cache_chunk);
            FREE(stream);
            return target;
        }

        /* I think this is right... */
-       source_cache_chunk = stream->chunk = HTChunkCreate(128);
+       anchor->source_cache_chunk = stream->chunk = HTChunkCreate(128);
        CTRACE(tfp, "Caching source for URL %s in memory cache %p\n",
               HTAnchor_address((HTAnchor *)anchor), (void *)stream->chunk);

diff -u old/lyglobal.h ./lyglobal.h
--- old/lyglobal.h      Sat May 29 20:27:26 1999
+++ ./lyglobal.h        Mon Jun  7 16:21:52 1999
@@ -251,8 +251,6 @@
 extern BOOLEAN minimal_comments;
 extern BOOLEAN soft_dquotes;
 #ifdef SOURCE_CACHE
-extern char * source_cache_filename;
-extern HTChunk * source_cache_chunk;
 extern BOOLEAN from_source_cache; /* mutable */
 extern int LYCacheSource;
 #define SOURCE_CACHE_NONE      0




reply via email to

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