lynx-dev
[Top][All Lists]
Advanced

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

lynx-dev [PATCH] misc changes


From: Vlad Harchev
Subject: lynx-dev [PATCH] misc changes
Date: Fri, 29 Oct 1999 23:50:07 +0500 (SAMST)

* Old psrcview bug fixed  - markup was unbalanced in some situations
* Content of SAMP tag made justificable
* Implemented HTStyleChange pooling - sizeof(HTStyleChange) is 4 times smaller
    than before, and only necessary number of stylechanges is allocated now, 
    instead of some constant (1024 by default).
* Functionality of dont-wrap-pre improved and extened. Now it's possible to 
    avoid wrapping the document being dumped completely (size of the non-wrapped
    line before the patch was limited by MAX_LINE = 1024 by default). Specifying
    -dont-wrap-pre with interactive session enables wrapped lines (in PRE) to
    be marked as in source view - with '+' in normal view.
* Functionality of -force-empty-hrefless-a was cleaned up, 
    #ifndefs NO_EMPTY_HREFLESS_A and endif's were removed.
* Colorstyle changes are not emitted in HTML_end_element if me->skip_stack was 
    >0 on entry to this function. This caused some glitches if
    -force-empty-hrefless-a was enabled.
* LYPrettySrc.c was slightly cleaned up, added support for lynx.cfg reloading,
    memory deallocation
* Possible bug in print_wwwfile_to_fd fixed - when quoting the page, seems that
  several '>' could be emitted on the long line formed by concatenating ilnes 
  with LY_SOFT_NEWLINEs at the begining of them.
        
 General notes:
* This patch is designed to be applied after all 4 current Klaus' patches.
* Users that use lss-enabled lynx should consider on upgrading the lynx - at 
 least those who use lynx for viewing huge files. By default, each line on the 
 screen took 1K for colorstyles (on x86). With new approach colorstyle changes
 take 24 bytes (on x86) per line in average document. Old lynx with 900K html 
 file loaded as startfile occupied 30M of virtual memory, lynx with patch 
 applied occupied 5 Mb on the same file. Old code is still accessible by 
 defining OLD_STYLECHANGE.
* I spent 4 hours debugging attempting to write/fix code that cleans up the 
 memory allocated in LYPrettySrc.c, but Lynx.leaks shows that I didn't 
 succeeded. I fear that leak detection stuff is broken - I checked/traced the 
 code very carefully several times. 

 Best regards,
  -Vlad

diff -ru lynx2-8-3dev13u-orig/WWW/Library/Implementation/HTMLDTD.c 
lynx2-8-3dev13u/WWW/Library/Implementation/HTMLDTD.c
--- lynx2-8-3dev13u-orig/WWW/Library/Implementation/HTMLDTD.c   Thu Oct 28 
13:58:30 1999
+++ lynx2-8-3dev13u/WWW/Library/Implementation/HTMLDTD.c        Fri Oct 29 
16:40:11 1999
@@ -1473,7 +1473,7 @@
  { P0("PRE")   , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_PRE},
  { P("Q")      , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_Q},
  { P("S")      , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_S},
- { P0("SAMP")  , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_SAMP},
+ { P("SAMP")   , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_SAMP},
  { P("SCRIPT") , script_attr,  HTML_SCRIPT_ATTRIBUTES, SGML_LITTERAL,T_SCRIPT},
  { P("SELECT") , select_attr,  HTML_SELECT_ATTRIBUTES, SGML_MIXED,T_SELECT},
  { P("SHY")    , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_EMPTY,T_SHY},
@@ -1598,7 +1598,7 @@
  { P0("PRE")   , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_PRE},
  { P("Q")      , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_Q},
  { P("S")      , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_S},
- { P0("SAMP")  , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_SAMP},
+ { P("SAMP")   , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_MIXED,T_SAMP},
  { P("SCRIPT") , script_attr,  HTML_SCRIPT_ATTRIBUTES, SGML_CDATA,T_SCRIPT},
  { P("SELECT") , select_attr,  HTML_SELECT_ATTRIBUTES, SGML_ELEMENT,T_SELECT},
  { P("SHY")    , gen_attr,     HTML_GEN_ATTRIBUTES,    SGML_EMPTY,T_SHY},
diff -ru lynx2-8-3dev13u-orig/WWW/Library/Implementation/SGML.c 
lynx2-8-3dev13u/WWW/Library/Implementation/SGML.c
--- lynx2-8-3dev13u-orig/WWW/Library/Implementation/SGML.c      Thu Oct 28 
13:59:04 1999
+++ lynx2-8-3dev13u/WWW/Library/Implementation/SGML.c   Fri Oct 29 16:43:40 1999
@@ -3491,13 +3491,11 @@
                        LYUpperCase(string->data);
                }
                PUTS(string->data);
-               if (c == '=' || c == '>') {
-                   if (c == '=' ) PUTC('=');
-                   if (context->current_attribute_number == INVALID)
-                       PSRCSTOP(badattr);
-                   else
-                       PSRCSTOP(attrib);
-               }
+                if (c == '=' ) PUTC('=');
+                if (context->current_attribute_number == INVALID)
+                   PSRCSTOP(badattr);
+                else
+                   PSRCSTOP(attrib);           
                if (c == '>') {
                    if (context->current_tag != context->unknown_tag)
                        PSRCSTOP(tag);
diff -ru lynx2-8-3dev13u-orig/src/GridText.c lynx2-8-3dev13u/src/GridText.c
--- lynx2-8-3dev13u-orig/src/GridText.c Thu Oct 28 13:59:12 1999
+++ lynx2-8-3dev13u/src/GridText.c      Fri Oct 29 18:26:35 1999
@@ -145,12 +145,22 @@
 #if defined(USE_COLOR_STYLE)
 #define MAX_STYLES_ON_LINE 64
 
+#ifdef OLD_HTSTYLECHANGE
 typedef struct _stylechange {
        int     horizpos;       /* horizontal position of this change */
        int     style;          /* which style to change to */
        int     direction;      /* on or off */
        int     previous;       /* previous style */
 } HTStyleChange;
+#else
+    /*try to fit in 2 shorts*/
+typedef struct _stylechange {
+       unsigned int    direction:2;    /* on or off */
+       unsigned int    horizpos: (sizeof(short)*CHAR_BIT-2);   
+           /* horizontal position of this change */
+       unsigned short  style;          /* which style to change to */
+} HTStyleChange;
+#endif
 #endif
 
 typedef struct _line {
@@ -162,12 +172,75 @@
        BOOL    bullet;                 /* Do we bullet? */
        BOOL    expansion_line;         /* TEXTAREA edit new line flag */
 #if defined(USE_COLOR_STYLE)
+#ifdef OLD_HTSTYLECHANGE
        HTStyleChange   styles[MAX_STYLES_ON_LINE];
+#else
+       HTStyleChange* styles;
+#endif 
        int     numstyles;
 #endif
        char    data[1];                /* Space for terminator at least! */
 } HTLine;
 
+#if defined(USE_COLOR_STYLE) && !defined(OLD_HTSTYLECHANGE)
+typedef struct _HTStyleChangePool {    
+       HTStyleChange   data[4092];
+       struct _HTStyleChangePool* next; 
+       int free_items;
+} HTStyleChangePool;
+
+/*these are used when current line is being aggregated. */
+HTStyleChange stylechanges_buffers[2][MAX_STYLES_ON_LINE];
+int stylechanges_buffers_free;/*this is an index of the free buffer. 
+    Can be 0 or 1*/
+
+/*these are generic macors for any pools (provided those structures have the 
+    same members as HTStyleChangePool) - VH */
+/*this macro sets 'ptr' to the "allocated" storage or NULL on failure.*/
+#define ALLOC_IN_POOL(pool,pool_type,toalloc,ptr)     \
+if (!pool)  \
+    ptr = NULL; \
+else { \
+    if ((pool)->free_items > toalloc) { \
+       (pool)->free_items -= toalloc; \
+       ptr = (pool)->data + (pool)->free_items; \
+    } else { \
+       pool_type* newpool = (pool_type*)malloc(sizeof(pool_type)); \
+       if (!newpool) { \
+           ptr = NULL; \
+       } else { \
+           newpool->next = pool; \
+           newpool->free_items = sizeof newpool->data/ \
+                   sizeof newpool->data[0] - toalloc; \
+           pool = newpool; \
+           ptr = newpool->data + sizeof newpool->data/sizeof newpool->data[0] 
- toalloc; \
+       } \
+    } \
+}
+/*this macro sets 'ptr' to the newly "allocated" pool or NULL on failure.*/
+#define POOL_NEW(pool_type,ptr) \
+    { \
+       pool_type* newpool = (pool_type*)malloc(sizeof(pool_type)); \
+       if (!newpool) { \
+           ptr = NULL; \
+       } else { \
+           newpool->next = NULL; \
+           newpool->free_items = sizeof newpool->data/sizeof newpool->data[0]; 
\
+           ptr = newpool; \
+       }        \
+    }
+    /*this macro frees entire pool pointed by 'xptr'*/
+#define POOL_FREE(pool_type,xptr)  \
+    { \
+       pool_type* ptr = xptr; \
+       do { \
+           pool_type* prevpool = ptr; \
+           ptr = ptr->next;     \
+           FREE(prevpool); \
+       } while (ptr); \
+    }
+#endif    
+
 #define LINE_SIZE(l) (sizeof(HTLine)+(l))      /* Allow for terminator */
 
 typedef struct _TextAnchor {
@@ -269,6 +342,9 @@
 
        HTStream *              target;                 /* Output stream */
        HTStreamClass           targetClass;            /* Output routines */
+#if defined(USE_COLOR_STYLE) && !defined(OLD_HTSTYLECHANGE)
+       HTStyleChangePool*      styles_pool;
+#endif
 };
 
 PRIVATE void HText_AddHiddenLink PARAMS((HText *text, TextAnchor *textanchor));
@@ -615,6 +691,13 @@
     line->offset = line->size = 0;
 #ifdef USE_COLOR_STYLE
     line->numstyles = 0;
+#ifndef  OLD_HTSTYLECHANGE    
+    POOL_NEW(HTStyleChangePool,self->styles_pool);
+    if (!self->styles_pool)
+       outofmem(__FILE__, "HText_New");
+    stylechanges_buffers_free = 0;
+    line->styles = stylechanges_buffers[0];
+#endif
 #endif
     self->Lines = self->chars = 0;
     self->first_anchor = self->last_anchor = NULL;
@@ -775,7 +858,9 @@
        return;
 
     HTAnchor_setDocument(self->node_anchor, (HyperDoc *)0);
-
+#if defined(USE_COLOR_STYLE) && !defined(OLD_HTSTYLECHANGE)
+    POOL_FREE(HTStyleChangePool,self->styles_pool);
+#endif    
     while (YES) {      /* Free off line array */
        HTLine * l = self->last_line;
        if (l) {
@@ -2197,7 +2282,9 @@
     HTLine * line = (HTLine *)LY_CALLOC(1, LINE_SIZE(MAX_LINE)+2);
     if (line == NULL)
        outofmem(__FILE__, "split_line_1");
-
+#if defined(USE_COLOR_STYLE) && !defined(OLD_HTSTYLECHANGE)
+    line->styles = stylechanges_buffers[stylechanges_buffers_free = 
(stylechanges_buffers_free + 1) &1];    
+#endif
     ctrl_chars_on_this_line = 0; /*reset since we are going to a new line*/
     utfxtra_on_this_line = 0;  /*reset too, we'll count them*/
     text->LastChar = ' ';
@@ -2594,6 +2681,12 @@
     if (temp == NULL)
        outofmem(__FILE__, "split_line_2");
     memcpy(temp, previous, LINE_SIZE(previous->size));
+#if defined(USE_COLOR_STYLE) && !defined(OLD_HTSTYLECHANGE)
+    
ALLOC_IN_POOL((text->styles_pool),HTStyleChangePool,previous->numstyles,temp->styles);
+    memcpy(temp->styles, previous->styles, 
sizeof(HTStyleChange)*previous->numstyles);
+    if (!temp->styles)
+       outofmem(__FILE__, "split_line_2");
+#endif 
     FREE(previous);
     previous = temp;
 
@@ -2931,7 +3024,9 @@
            jline = (HTLine *)LY_CALLOC(1, LINE_SIZE(previous->size+spare));
            if (jline == NULL)
                outofmem(__FILE__, "split_line_1");
-
+#if defined(USE_COLOR_STYLE) && !defined(OLD_HTSTYLECHANGE)
+           jline->styles = previous->styles;
+#endif     
            jdata = jline->data;
 
            /*
@@ -2997,8 +3092,9 @@
 
                jline->styles[i].style = previous->styles[i].style;
                jline->styles[i].direction = previous->styles[i].direction;
+#ifdef OLD_HTSTYLECHANGE               
                jline->styles[i].previous = previous->styles[i].previous;
-
+#endif
                /*there are stylechanges with hpos > line length */
                jline->styles[i].horizpos = (hpos > previous->size)
                        ? previous->size + spare
@@ -3781,7 +3877,7 @@
        }
        return;
     } /* if tab */
-    else if (text->source && text == HTMainText) {
+    else if ( (text->source || dont_wrap_pre) && text == HTMainText) {
        /*
         * If we're displaying document source, wrap long lines to keep all of
         * the source visible.
@@ -4164,7 +4260,7 @@
     if (line == text->last_line)
        mod_line = (HTLine *) calloc(1, LINE_SIZE(MAX_LINE));
     else
-       mod_line = (HTLine *) calloc(1, LINE_SIZE(line->size + added_chars));
+       mod_line = (HTLine *) calloc(1, LINE_SIZE(line->size + added_chars));   
 
     if (!mod_line)
        return NULL;
     memcpy(mod_line, line, LINE_SIZE(1));
@@ -7203,17 +7299,18 @@
     line = HTMainText->last_line->next;
     for (;; line = line->next) {
        if (!first
-        && line->data[0] != LY_SOFT_NEWLINE)
+        && line->data[0] != LY_SOFT_NEWLINE && line->data[1] != 
LY_SOFT_NEWLINE) {
+           /* data[0] can be LY_*START_CHAR, so LY_SOFT_NEWLINE can be in [1] 
- VH */
            fputc('\n',fp);
-       first = FALSE;
-
-       /*
-        *  Add news-style quotation if requested. - FM
-        */
-       if (is_reply) {
-           fputc('>',fp);
-       }
+           /*
+            *  Add news-style quotation if requested. - FM
+            */
+           if (is_reply) {
+               fputc('>',fp);
+           }
+       };
 
+       first = FALSE;
        /*
         *  Add offset.
         */
@@ -7327,8 +7424,9 @@
 
     for (;; line = line->next) {
        if (!first
-        && line->data[0] != LY_SOFT_NEWLINE)
-           fputc('\n',fp);
+        && line->data[0] != LY_SOFT_NEWLINE && line->data[1] != 
LY_SOFT_NEWLINE)
+           /* data[0] can be LY_*START_CHAR, so LY_SOFT_NEWLINE can be in [1] 
- VH */   
+           fputc('\n',fp);         
        first = FALSE;
        /*
         *  Add offset.
diff -ru lynx2-8-3dev13u-orig/src/HTML.c lynx2-8-3dev13u/src/HTML.c
--- lynx2-8-3dev13u-orig/src/HTML.c     Thu Oct 28 13:58:56 1999
+++ lynx2-8-3dev13u/src/HTML.c  Fri Oct 29 21:37:01 1999
@@ -3176,20 +3176,24 @@
                                            me->inUnderline, me->CurrentA);
        if (me->inBoldA == TRUE && me->inBoldH == FALSE)
            HText_appendCharacter(me->text, LY_BOLD_START_CHAR);
-#if defined(NOTUSED_FOTEMODS) || !defined(NO_EMPTY_HREFLESS_A)
+#if defined(NOTUSED_FOTEMODS)
        /*
         *  Close an HREF-less NAMED-ed now if we aren't making their
         *  content bold, and let the check in HTML_end_element() deal
         *  with any dangling end tag this creates. - FM
         */
-# ifndef NO_EMPTY_HREFLESS_A
-       if (force_empty_hrefless_a)
-# endif
-           if (href == NULL && me->inBoldA == FALSE) {
-               SET_SKIP_STACK(HTML_A);
-               HTML_end_element(me, HTML_A, include);
-           }
-#endif /* NOTUSED_FOTEMODS || !defined(NO_EMPTY_HREFLESS_A)*/
+       if (href == NULL && me->inBoldA == FALSE) {             
+           SET_SKIP_STACK(HTML_A);
+           HTML_end_element(me, HTML_A, include);
+       }
+#else
+       /*Close an HREF-less NAMED-ed now if force_empty_hrefless_a was 
+           requested - VH*/
+       if (href == NULL) {             
+           SET_SKIP_STACK(HTML_A);
+           HTML_end_element(me, HTML_A, include);
+       }
+#endif
        FREE(href);
        break;
 
@@ -6144,6 +6148,7 @@
     int status = HT_OK;
     char *temp = NULL, *cp = NULL;
     BOOL BreakFlag = FALSE;
+    BOOL skip_stack_requested = FALSE;
     EMIT_IFDEF_EXP_JUSTIFY_ELTS(BOOL reached_awaited_stacked_elt=FALSE;)
 
 #ifdef USE_PSRC
@@ -6203,6 +6208,7 @@
      * SGML_EMPTY in HTMLDTD.c. - FM & KW
      */
     if (HTML_dtd.tags[element_number].contents != SGML_EMPTY) {
+       skip_stack_requested = me->skip_stack > 0;    
        if ((element_number != me->sp[0].tag_number) &&
            me->skip_stack <= 0 &&
            HTML_dtd.tags[HTML_LH].contents != SGML_EMPTY &&
@@ -7713,27 +7719,29 @@
     }
 
 #ifdef USE_COLOR_STYLE
+    if (!skip_stack_requested) { /*don't emit stylechanges if skipped stack 
element - VH*/
 #if !OPT_SCN
-    TrimColorClass(HTML_dtd.tags[element_number].name,
+       TrimColorClass(HTML_dtd.tags[element_number].name,
                   Style_className, &hcode);
 #else
 # if !OMIT_SCN_KEEPING
-    FastTrimColorClass(HTML_dtd.tags[element_number].name,
+       FastTrimColorClass(HTML_dtd.tags[element_number].name,
                       HTML_dtd.tags[element_number].name_len,
                       Style_className,
                       &Style_className_end, &hcode);
 #  endif
 #endif
 
-    if (!ReallyEmptyTagNum(element_number))
-    {
-       CTRACE((tfp, "STYLE:end_element: ending non-EMPTY style\n"));
+       if (!ReallyEmptyTagNum(element_number))
+       {
+           CTRACE((tfp, "STYLE:end_element: ending non-EMPTY style\n"));
 #if !defined(USE_HASH)
-       HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF);
+           HText_characterStyle(me->text, element_number+STARTAT, STACK_OFF);
 #else
-       HText_characterStyle(me->text, HCODE_TO_STACK_OFF(hcode), STACK_OFF);
+           HText_characterStyle(me->text, HCODE_TO_STACK_OFF(hcode), 
STACK_OFF);
 #endif /* USE_HASH */
-    }
+       }
+    };
 #endif /* USE_COLOR_STYLE */
     return status;
 }
diff -ru lynx2-8-3dev13u-orig/src/LYGlobalDefs.h 
lynx2-8-3dev13u/src/LYGlobalDefs.h
--- lynx2-8-3dev13u-orig/src/LYGlobalDefs.h     Thu Oct 28 13:58:10 1999
+++ lynx2-8-3dev13u/src/LYGlobalDefs.h  Fri Oct 29 21:38:23 1999
@@ -396,9 +396,7 @@
 extern BOOLEAN with_backspaces;
 #endif
 
-#ifndef NO_EMPTY_HREFLESS_A
 extern BOOL force_empty_hrefless_a;
-#endif
 
 #ifndef NO_NONSTICKY_INPUTS
 extern BOOL sticky_inputs;
diff -ru lynx2-8-3dev13u-orig/src/LYMain.c lynx2-8-3dev13u/src/LYMain.c
--- lynx2-8-3dev13u-orig/src/LYMain.c   Thu Oct 28 13:58:33 1999
+++ lynx2-8-3dev13u/src/LYMain.c        Fri Oct 29 22:06:56 1999
@@ -444,9 +444,7 @@
 PUBLIC BOOLEAN with_backspaces = FALSE;
 #endif
 
-#ifndef NO_EMPTY_HREFLESS_A
 PUBLIC BOOL force_empty_hrefless_a = FALSE;
-#endif
 
 #ifndef NO_NONSTICKY_INPUTS
 PUBLIC BOOL sticky_inputs = TRUE;
@@ -1872,8 +1870,12 @@
      *  interruptible (terminal is in raw mode, select() works).  -BL
      */
 #ifdef USE_PSRC
-    if (!dump_output_immediately)
-       HTMLSRC_init_caches(); /* do it before terminal is initialized*/
+    if (!dump_output_immediately) {
+       HTMLSRC_init_caches(FALSE); /* do it before terminal is initialized*/
+#ifdef LY_FIND_LEAKS
+       atexit(html_src_clean_data);
+#endif
+    };
 #endif
 
     if (!dump_output_immediately) {
@@ -2127,6 +2129,10 @@
        custom_display_charset = FALSE;
        memset((char*)charset_subsets, 0, sizeof(charset_subset_t)*MAXCHARSETS);
 #endif
+
+#ifdef USE_PSRC
+       html_src_on_lynxcfg_reload();
+#endif
        free_lynx_cfg(); /* free downloaders, printers, environments */
        /*
         *  Process the configuration file.
@@ -3148,12 +3154,10 @@
       "from",          TOGGLE_ARG,             &LYNoFromHeader,
       "toggle transmissions of From headers"
    ),
-#ifndef NO_EMPTY_HREFLESS_A
    PARSE_SET(
       "force_empty_hrefless_a",        SET_ARG,        &force_empty_hrefless_a,
       "force HREF-less 'A' elements to be empy (close them as soon as they are 
seen)"
    ),
-#endif
 #if !defined(NO_OPTION_FORMS) && !defined(NO_OPTION_MENU)
    PARSE_SET(
       "forms_options", TOGGLE_ARG,             &LYUseFormsOptions,
diff -ru lynx2-8-3dev13u-orig/src/LYPrettySrc.c 
lynx2-8-3dev13u/src/LYPrettySrc.c
--- lynx2-8-3dev13u-orig/src/LYPrettySrc.c      Thu Oct 28 13:58:34 1999
+++ lynx2-8-3dev13u/src/LYPrettySrc.c   Fri Oct 29 22:48:08 1999
@@ -25,7 +25,7 @@
      support), the style cache and markup are created before entering the
      mainloop. */
 PUBLIC BOOL psrcview_no_anchor_numbering = FALSE;
-PUBLIC char* HTL_tagspecs[HTL_num_lexems] = {
+PRIVATE char* HTL_tagspecs_defaults[HTL_num_lexems] = {
  /* these values are defaults. They are also listed in comments of 
distibution's
      lynx.cfg.*/
 #ifdef USE_COLOR_STYLE
@@ -57,6 +57,7 @@
 #endif
 };
 
+PUBLIC char* HTL_tagspecs[HTL_num_lexems];
 
  /* these are pointers since tagspec can be empty (the pointer will be NULL
     in that case) */
@@ -106,6 +107,7 @@
     subj->present = (BOOL*)calloc( nattr*sizeof (BOOL), 1);
     subj->value = (char**)calloc( nattr*sizeof (char*), 1);
     subj->start = FALSE;
+    subj->class_name = NULL;
 
     if (!*head) {
        *head = subj; *tail = subj;
@@ -118,7 +120,7 @@
    append to the list, possibly modifying head and modifying tail */
 PRIVATE void append_open_tag ARGS4(
            char*,        tagname,
-           char*,        classname GCC_UNUSED,
+           char*,        classname,
            HT_tagspec**, head,
            HT_tagspec**,  tail)
 {
@@ -154,13 +156,12 @@
        hcode = hash_code_aggregate_lower_str(classname, hcode);
        StrAllocCopy(subj->class_name, classname);
     } else {
-       subj->class_name = "";
+       StrAllocCopy(subj->class_name,"");
     }
     subj->style = hcode;
 #endif
 }
 
-
 /* returns 1 if incorrect */
 PUBLIC int html_src_parse_tagspec ARGS4(
        char*,          ts,
@@ -278,25 +279,66 @@
     return 0;
 }
 
-/*it shouldn't fail anyway - since everything is checked before it's called. */
-PUBLIC void HTMLSRC_init_caches NOARGS
+/*this will clean the data associated with lexem 'l' */
+PUBLIC void html_src_clean_item ARGS1(
+       HTlexem, l)
+{
+    int i;
+    if (HTL_tagspecs[l])
+       FREE(HTL_tagspecs[l]);
+    for(i=0;i<2;++i) {
+       HT_tagspec* cur,** pts = ( i ? lexem_start : lexem_end)+l,*ts = *pts;
+       *pts = NULL;
+       while (ts) {
+           FREE(ts->present);
+           FREE(ts->value);
+#ifdef USE_COLOR_STYLE         
+           if (ts->start) {
+               FREE(ts->class_name);
+           };
+#endif         
+           cur = ts;
+           ts = ts->next;
+           FREE(cur);
+       };
+    };/*i*/
+};
+
+/*this will be registered with atexit*/
+PUBLIC void html_src_clean_data NOARGS
+{
+    int i;
+    for (i = 0; i < HTL_num_lexems; ++i)       
+       html_src_clean_item(i); 
+};
+
+PUBLIC void html_src_on_lynxcfg_reload NOARGS
+{
+    html_src_clean_data();
+    HTMLSRC_init_caches(TRUE);
+};
+
+PUBLIC void HTMLSRC_init_caches ARGS1(
+       BOOL,   dont_exit)
 {
     int i;
     char* p;
     char buf[1000];
 
     for (i = 0; i < HTL_num_lexems; ++i) {
-       if (HTL_tagspecs[i])
-           strcpy(buf, HTL_tagspecs[i]);
-       else
-           buf[0] = '\0';
+
+       strcpy(buf, HTL_tagspecs_defaults[i]);
+       p = HTL_tagspecs_defaults[i];
+       HTL_tagspecs[i] = NULL;
+       StrAllocCopy(HTL_tagspecs[i],p);
+
        if ((p = strchr(buf, ':')) != 0)
            *p = '\0';
-       if (html_src_parse_tagspec(buf, i, FALSE, TRUE) ) {
+       if (html_src_parse_tagspec(buf, i, FALSE, TRUE) && !dont_exit ) {
            fprintf(stderr, "internal error while caching 1st tagspec of %d 
lexem", i);
            exit_immediately(-1);
        }
-       if (html_src_parse_tagspec( p ? p+1 : NULL , i, FALSE, FALSE) )  {
+       if (html_src_parse_tagspec( p ? p+1 : NULL , i, FALSE, FALSE) && 
!dont_exit) {
            fprintf(stderr, "internal error while caching 2nd tagspec of %d 
lexem", i);
            exit_immediately(-1);
        }
diff -ru lynx2-8-3dev13u-orig/src/LYPrettySrc.h 
lynx2-8-3dev13u/src/LYPrettySrc.h
--- lynx2-8-3dev13u-orig/src/LYPrettySrc.h      Tue Aug 31 10:00:01 1999
+++ lynx2-8-3dev13u/src/LYPrettySrc.h   Fri Oct 29 21:27:43 1999
@@ -61,7 +61,10 @@
 
 extern int html_src_parse_tagspec PARAMS((char* ts, HTlexem lexem,
                      BOOL checkonly,BOOL isstart));
-extern void HTMLSRC_init_caches NOPARAMS;
+extern void HTMLSRC_init_caches PARAMS((BOOL dont_exit));
+extern void html_src_clean_item PARAMS((HTlexem l));
+extern void html_src_clean_data NOPARAMS;
+extern void html_src_on_lynxcfg_reload NOPARAMS;
 
 /* these 2 vars tell what kind of transform should be appiled to tag names
   and attribute names. 0 - lowercase, 1 - as is, 2 uppercase. */
diff -ru lynx2-8-3dev13u-orig/src/LYReadCFG.c lynx2-8-3dev13u/src/LYReadCFG.c
--- lynx2-8-3dev13u-orig/src/LYReadCFG.c        Thu Oct 28 13:58:33 1999
+++ lynx2-8-3dev13u/src/LYReadCFG.c     Fri Oct 29 21:37:45 1999
@@ -1123,15 +1123,16 @@
        BS();
     *ts2 = '\0';
 
-    if ( html_src_parse_tagspec(value, lexem_code, TRUE, TRUE)
-       || html_src_parse_tagspec(ts2, lexem_code, TRUE, TRUE) )
+    CTRACE((tfp,"ReadCFG - parsing tagspec '%s:%s' for option 
'%s'\n",value,ts2,option_name));
+    html_src_clean_item(lexem_code);
+    if ( html_src_parse_tagspec(value, lexem_code, FALSE, TRUE)
+       || html_src_parse_tagspec(ts2, lexem_code, FALSE, FALSE) )
     {
        *ts2 = ':';
        BS();
     }
 
-    *ts2 = ':';
-    HTL_tagspecs[lexem_code] = NULL;
+    *ts2 = ':';    
     StrAllocCopy(HTL_tagspecs[lexem_code],value);
 #undef BS
     return 0;
@@ -1267,9 +1268,7 @@
      PARSE_SET("focus_window", CONF_BOOL, &focus_window),
 #endif
      PARSE_SET("force_8bit_toupper", CONF_BOOL, &UCForce8bitTOUPPER),
-#ifndef NO_EMPTY_HREFLESS_A
      PARSE_SET("force_empty_hrefless_a", CONF_BOOL, &force_empty_hrefless_a),
-#endif
      PARSE_SET("force_ssl_cookies_secure", CONF_BOOL, 
&LYForceSSLCookiesSecure),
 #if !defined(NO_OPTION_FORMS) && !defined(NO_OPTION_MENU)
      PARSE_SET("forms_options", CONF_BOOL, &LYUseFormsOptions),


reply via email to

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