[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
lynx-dev [PATCH] to dev13 - various fixes
From: |
Vlad Harchev |
Subject: |
lynx-dev [PATCH] to dev13 - various fixes |
Date: |
Sun, 31 Oct 1999 18:04:50 +0400 (SAMT) |
* Bug in psrcmode code fixed. Now htmlsrc_tag encloses only tagname, not
everything in generalized brackets <,>,</,/> - reported by KW
* Bug with 'g' command fixed - reported by KW
* default value for 'OPT' in SGML.c made '1', removed alternatives to code
surrounded by #if OPT1
Notes:
* Seems that 'OPT' stuff doesn't contain errors. Let's enable it for several
releases, and then remove alternative code.
* Added comments about pools.
* Docs updated to reflect new functionality of -dont-wrap-pre
Best regards,
-Vlad
diff -ru lynx2-8-3dev13u-was/WWW/Library/Implementation/SGML.c
lynx2-8-3dev13u/WWW/Library/Implementation/SGML.c
--- lynx2-8-3dev13u-was/WWW/Library/Implementation/SGML.c Fri Oct 29
16:43:40 1999
+++ lynx2-8-3dev13u/WWW/Library/Implementation/SGML.c Sun Oct 31 17:09:04 1999
@@ -90,9 +90,8 @@
#define PUTS(str) ((*context->actions->put_string)(context->target, str))
-#define OPT 0 /* don't make it 1 otherwise something wrong will be with
- TagSoup parser mode - I was unable to undestand why it works incorrectly -HV*/
-#define OPT1 1 /* set to 1 for several optimizations */
+#define OPT 1
+
/*the following macros are used for pretty source view. */
#define IS_C(attr) (attr.type == HTMLA_CLASS)
@@ -410,11 +409,7 @@
FREE(context->value[i]);
#ifdef USE_COLOR_STYLE
# ifdef USE_PSRC
-# if !OPT1
- current_is_class = (!strcasecomp("class", s));
-# else
current_is_class = IS_C(attributes[i]);
-# endif
# else
current_is_class = (!strcasecomp("class", s));
# endif
@@ -1133,10 +1128,8 @@
{
int status;
HTTag * new_tag = context->current_tag;
-#if OPT1
HTMLElement e = TAGNUM_OF_TAGP(new_tag);
BOOL ok = FALSE;
-#endif
#ifdef EXTENDED_HTMLDTD
@@ -1234,16 +1227,6 @@
/*
** Ugh, it is not an OPTION. - FM
*/
-#if !OPT1
- if (!strcasecomp(new_tag->name, "INPUT") ||
- !strcasecomp(new_tag->name, "TEXTAREA") ||
- !strcasecomp(new_tag->name, "SELECT") ||
- !strcasecomp(new_tag->name, "BUTTON") ||
- !strcasecomp(new_tag->name, "FIELDSET") ||
- !strcasecomp(new_tag->name, "LABEL") ||
- !strcasecomp(new_tag->name, "LEGEND") ||
- !strcasecomp(new_tag->name, "FORM"))
-#else
switch (e) {
case HTML_INPUT: case HTML_TEXTAREA: case HTML_SELECT:
case HTML_BUTTON: case HTML_FIELDSET: case HTML_LABEL:
@@ -1254,7 +1237,6 @@
break;
}
if (ok)
-#endif
{
/*
** It is another form-related start tag, so terminate
@@ -1295,11 +1277,7 @@
context->element_stack = N;
context->no_lynx_specialcodes = (new_tag->flags & Tgf_nolyspcl);
-#if OPT
} else if (e == HTML_META ) {
-#else
- } else if (!strcasecomp(new_tag->name, "META")) {
-#endif
/*
** Check for result of META tag. - KW & FM
*/
@@ -3001,9 +2979,8 @@
else
LYUpperCase(string->data);
}
- PUTS(string->data);
-
- if (c == '>' ) {
+ PUTS(string->data);
+ if (c == '>' ) {
PSRCSTOP(badtag);
PSRCSTART(abracket);PUTC('>');PSRCSTOP(abracket);
} else {
@@ -3038,32 +3015,26 @@
LYUpperCase(string->data);
}
PUTS(string->data);
+ if (t != context->unknown_tag)
+ PSRCSTOP(tag);
+ else
+ PSRCSTOP(badtag);
}
if (!psrc_view) /*don't waste time */
#endif
+ {
/*
** Clear out attributes.
*/
- {
-#if !OPT1
- int i;
- for (i = 0; i < context->current_tag->number_of_attributes; i++)
- context->present[i] = NO;
-#else
memset( (void*)context->present, 0 , sizeof(BOOL)*
context->current_tag->number_of_attributes);
-#endif
}
-
+
string->size = 0;
context->current_attribute_number = INVALID;
#ifdef USE_PSRC
if (psrc_view) {
if (c == '>' || c == '<' || (c == '/' && context->slashedtag)) {
- if (t != context->unknown_tag)
- PSRCSTOP(tag);
- else
- PSRCSTOP(badtag);
if (c != '<') {
PSRCSTART(abracket);
PUTC(c);
@@ -3446,10 +3417,6 @@
start_element(context);
#ifdef USE_PSRC
if (psrc_view) {
- if (context->current_tag != context->unknown_tag)
- PSRCSTOP(tag);
- else
- PSRCSTOP(badtag);
PSRCSTART(abracket);
PUTC('>');
PSRCSTOP(abracket);
@@ -3497,10 +3464,6 @@
else
PSRCSTOP(attrib);
if (c == '>') {
- if (context->current_tag != context->unknown_tag)
- PSRCSTOP(tag);
- else
- PSRCSTOP(badtag);
PSRCSTART(abracket);
PUTC('>');
PSRCSTOP(abracket);
@@ -3526,10 +3489,6 @@
PSRCSTOP(badattr);
else
PSRCSTOP(attrib);
- if (context->current_tag != context->unknown_tag)
- PSRCSTOP(tag);
- else
- PSRCSTOP(badtag);
PSRCSTART(abracket);
PUTC('>');
PSRCSTOP(abracket);
@@ -3570,10 +3529,6 @@
CTRACE((tfp, "SGML: found = but no value\n"));
#ifdef USE_PSRC
if (psrc_view) {
- if (context->current_tag != context->unknown_tag)
- PSRCSTOP(tag);
- else
- PSRCSTOP(badtag);
PSRCSTART(abracket);
PUTC('>');
PSRCSTOP(abracket);
@@ -3654,10 +3609,6 @@
if (c == '>') { /* End of tag */
#ifdef USE_PSRC
if (psrc_view) {
- if (context->current_tag != context->unknown_tag)
- PSRCSTOP(tag);
- else
- PSRCSTOP(badtag);
PSRCSTART(abracket);
PUTC('>');
PSRCSTOP(abracket);
diff -ru lynx2-8-3dev13u-was/lynx.cfg lynx2-8-3dev13u/lynx.cfg
--- lynx2-8-3dev13u-was/lynx.cfg Thu Oct 28 13:58:05 1999
+++ lynx2-8-3dev13u/lynx.cfg Sun Oct 31 17:13:36 1999
@@ -2258,7 +2258,7 @@
# Lexem LEXEMNAME FURTHER EXPLANATION
# ------------------------------------
# comment COMM
-# tag TAG everything in gen. brackets
+# tag TAG tag name only
# attribute ATTRIB
# attribute value ATTRVAL
# generalized brackets ABRACKET < > </
@@ -2284,7 +2284,7 @@
# style in lss file (for lynx compiled with lss support), that tag/class
# combination will be anyway emitted during internal html markup. Such
# combinations will be also reported to the trace log.
-# 4) Lexeme 'tag' means everything contained in generalized angle brackets
+# 4) Lexeme 'tag' means tag name only
# 5) Angle brackets of html specials won't be surrounded by markup for ABRACKET
#
# Examples:
@@ -2316,15 +2316,15 @@
# For lynx compiled without lss support, the following settings are the
default:
#HTMLSRC_COMM:b:!b
#HTMLSRC_TAG:b:!b
-#HTMLSRC_ATTRIB::
-#HTMLSRC_ATTRVAL:!b:b
+#HTMLSRC_ATTRIB:b:!b
+#HTMLSRC_ATTRVAL::
#HTMLSRC_ABRACKET:b:!b
#HTMLSRC_ENTITY:b:!b
#HTMLSRC_HREF::
#HTMLSRC_ENTIRE::
#HTMLSRC_BADSEQ:b:!b
#HTMLSRC_BADTAG::
-#HTMLSRC_BADATTR:!b:b
+#HTMLSRC_BADATTR::
#HTMLSRC_SGMLSPECIAL:b:!b
#
# Other source-view related options:
diff -ru lynx2-8-3dev13u-was/lynx.hlp lynx2-8-3dev13u/lynx.hlp
--- lynx2-8-3dev13u-was/lynx.hlp Thu Oct 14 16:18:42 1999
+++ lynx2-8-3dev13u/lynx.hlp Sun Oct 31 14:44:11 1999
@@ -140,8 +140,9 @@
-dont_wrap_pre
inhibit wrapping of text in <pre> when -dump'ing
- and -crawl'ing.
-
+ and -crawl'ing, mark wrapped lines in interactive
+ session.
+
-dump dumps the formatted output of the default document
or one specified on the command line to standard
output. This can be used in the following way:
diff -ru lynx2-8-3dev13u-was/lynx.man lynx2-8-3dev13u/lynx.man
--- lynx2-8-3dev13u-was/lynx.man Thu Oct 14 16:18:42 1999
+++ lynx2-8-3dev13u/lynx.man Sun Oct 31 14:43:07 1999
@@ -158,7 +158,8 @@
set the display variable for X rexec-ed programs.
.TP
.B -dont_wrap_pre
-inhibit wrapping of text in <pre> when -dump'ing and -crawl'ing.
+inhibit wrapping of text in <pre> when -dump'ing and -crawl'ing, mark
+wrapped lines in interactive session.
.TP
.B -dump
dumps the formatted output of the default document or one
diff -ru lynx2-8-3dev13u-was/src/GridText.c lynx2-8-3dev13u/src/GridText.c
--- lynx2-8-3dev13u-was/src/GridText.c Fri Oct 29 18:26:35 1999
+++ lynx2-8-3dev13u/src/GridText.c Sun Oct 31 15:24:34 1999
@@ -195,8 +195,61 @@
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.*/
+same members as HTStyleChangePool). Pools are used for allocation of groups
+of objects of the same type T. Pools are represented as a list of structures
+of type P (called pool chunks here). Structure P has an array of N objects of
+type T named 'data' (the number N in the array can be chosen arbitrary),
+pointer to the next pool chunk named 'pool', and the number of free items
+in that pool chunk named 'free_items'. Ie, here is a definition of the
+structure P:
+ struct P
+ {
+ T data[N];
+ struct P* next;
+ int free_items;
+ };
+ It's recommened that sizeof(P) be memory page size minus 32 in order malloced
+chunks to fit in machine page size.
+ Allocation of 'n' items in the pool is implemented as decrementing member
+'free_items' by 'n' if 'free_items' >= 'n', or allocating a new pool chunk and
+allocating 'n' items in that new chunk. It's task of programmer to assert that
+'n' is <= N. Only entire pool may be freed - this limitation makes allocation
+algorithms trivial and fast - so the use of pools is limited to objects that
+are freed in batch, that are not deallocated not in the batch, and not
+reallocated.
+ Pools greatly reduce memory fragmentation and memory allocation/deallocation
+speed due to the simple algorithms used. Due to the fact that memory is
+'allocated' in array, aligment overhead is minimal. Allocating strings in a
+pool provided thier length will never exceed N and is much smaller than N
+seems to be very efficient.
+
+ Pool are referenced by pointer to the chunk that contains free slots. Macros
+that allocate memory in pools update that pointer if needed.
+ There are 3 macros that deal with pools - POOL_NEW, POOL_FREE and
+ALLOC_IN_POOL.
+ Here is a description of those macros as C++ functionts (with names mentioned
+above and with use of C++ references)
+
+void ALLOC_IN_POOL( P*& pool, pool_type, int toalloc, T*& ptr)
+ - allocates 'toalloc' items in the pool of type 'pool_type' pointed by
+ 'pool', sets the pointer 'ptr' to the "allocated" memory and updates 'pool'
+ if necessary. Sets 'ptr' to NULL if fails.
+
+void POOL_NEW( pool_type , P*& ptr)
+ Initializes a pool of type 'pool_type' pointed by 'ptr', updating 'ptr'.
+ Sets 'ptr' to NULL if fails.
+
+void POOL_FREE( pool_type , P* ptr)
+ Frees a pool of type 'pool_type' pointed by ptr.
+
+ - VH */
+
+/*
+void ALLOC_IN_POOL( P*& pool, pool_type, int toalloc, T*& ptr)
+ - allocates 'toalloc' items in the pool of type 'pool_type' pointed by
+ 'pool', sets the pointer 'ptr' to the "allocated" memory and updates 'pool'
+ if necessary. Sets 'ptr' to NULL if fails.
+*/
#define ALLOC_IN_POOL(pool,pool_type,toalloc,ptr) \
if (!pool) \
ptr = NULL; \
@@ -217,7 +270,11 @@
} \
} \
}
-/*this macro sets 'ptr' to the newly "allocated" pool or NULL on failure.*/
+/*
+void POOL_NEW( pool_type , P*& ptr)
+ Initializes a pool of type 'pool_type' pointed by 'ptr', updating 'ptr'.
+ Sets 'ptr' to NULL if fails.
+*/
#define POOL_NEW(pool_type,ptr) \
{ \
pool_type* newpool = (pool_type*)malloc(sizeof(pool_type)); \
@@ -229,7 +286,10 @@
ptr = newpool; \
} \
}
- /*this macro frees entire pool pointed by 'xptr'*/
+/*
+void POOL_FREE( pool_type , P* ptr)
+ Frees a pool of type 'pool_type' pointed by ptr.
+*/
#define POOL_FREE(pool_type,xptr) \
{ \
pool_type* ptr = xptr; \
diff -ru lynx2-8-3dev13u-was/src/LYMain.c lynx2-8-3dev13u/src/LYMain.c
--- lynx2-8-3dev13u-was/src/LYMain.c Fri Oct 29 22:06:56 1999
+++ lynx2-8-3dev13u/src/LYMain.c Sun Oct 31 17:50:44 1999
@@ -3097,7 +3097,8 @@
),
PARSE_SET(
"dont_wrap_pre", SET_ARG, &dont_wrap_pre,
- "inhibit wrapping of text in <pre> when -dump'ing and -crawl'ing"
+ "inhibit wrapping of text in <pre> when -dump'ing and \n"
+ "-crawl'ing, mark wrapped lines in interactive session"
),
PARSE_FUN(
"dump", FUNCTION_ARG, dump_output_fun,
diff -ru lynx2-8-3dev13u-was/src/LYMainLoop.c lynx2-8-3dev13u/src/LYMainLoop.c
--- lynx2-8-3dev13u-was/src/LYMainLoop.c Thu Oct 28 13:58:31 1999
+++ lynx2-8-3dev13u/src/LYMainLoop.c Sun Oct 31 17:45:06 1999
@@ -534,7 +534,8 @@
}
}
-PRIVATE void do_check_recall ARGS7(
+/* returns FALSE if user cancelled input or URL was invalid, TRUE otherwise */
+PRIVATE BOOL do_check_recall ARGS7(
int, ch,
char *, user_input_buffer,
char **, old_user_input,
@@ -544,6 +545,7 @@
BOOLEAN *, FirstURLRecall)
{
char *cp;
+ BOOL ret = FALSE;
if (*old_user_input == 0)
StrAllocCopy(*old_user_input, "");
@@ -569,6 +571,7 @@
HTUserMsg2(WWW_ILLEGAL_URL_MESSAGE, user_input_buffer);
strcpy(user_input_buffer, *old_user_input);
FREE(*old_user_input);
+ ret = FALSE;
break;
}
}
@@ -584,6 +587,7 @@
strcpy(user_input_buffer, *old_user_input);
FREE(*old_user_input);
HTInfoMsg(CANCELLED);
+ ret = FALSE;
break;
}
if (recall && ch == UPARROW) {
@@ -627,6 +631,7 @@
strcpy(user_input_buffer, *old_user_input);
FREE(*old_user_input);
HTInfoMsg(CANCELLED);
+ ret = FALSE;
break;
}
continue;
@@ -670,14 +675,17 @@
strcpy(user_input_buffer, *old_user_input);
FREE(*old_user_input);
HTInfoMsg(CANCELLED);
+ ret = FALSE;
break;
}
continue;
}
} else {
+ ret = TRUE;
break;
}
}
+ return ret;
}
PRIVATE void do_cleanup_after_delete NOARGS
@@ -6623,7 +6631,7 @@
case LYK_TO_CLIPBOARD: /* ^S */
{
if (put_clip(links[curdoc.link].lname) == 0) {
- HTInfoMsg("URL to Clip Borad.");
+ HTInfoMsg("URL to Clip Board.");
} else {
HTInfoMsg("Current URL is empty.");
}
@@ -6767,9 +6775,9 @@
if (handle_LYK_GOTO(&ch, user_input_buffer, &temp, &recall,
&URLTotal, &URLNum, &FirstURLRecall, &old_c,
real_c)) {
- do_check_recall (ch, user_input_buffer, &temp, URLTotal,
- &URLNum, recall, &FirstURLRecall);
- do_check_goto_URL(user_input_buffer, &temp, &force_load);
+ if (do_check_recall (ch, user_input_buffer, &temp, URLTotal,
+ &URLNum, recall, &FirstURLRecall))
+ do_check_goto_URL(user_input_buffer, &temp, &force_load);
}
break;
@@ -6971,9 +6979,9 @@
if (handle_LYK_JUMP(c, user_input_buffer, &temp, &recall,
&FirstURLRecall, &URLNum, &URLTotal, &ch,
&old_c, real_c)) {
- do_check_recall (ch, user_input_buffer, &temp, URLTotal,
- &URLNum, recall, &FirstURLRecall);
- do_check_goto_URL(user_input_buffer, &temp, &force_load);
+ if (do_check_recall (ch, user_input_buffer, &temp, URLTotal,
+ &URLNum, recall, &FirstURLRecall))
+ do_check_goto_URL(user_input_buffer, &temp, &force_load);
}
break;
diff -ru lynx2-8-3dev13u-was/src/LYPrettySrc.c lynx2-8-3dev13u/src/LYPrettySrc.c
--- lynx2-8-3dev13u-was/src/LYPrettySrc.c Sun Oct 31 14:39:25 1999
+++ lynx2-8-3dev13u/src/LYPrettySrc.c Sun Oct 31 16:11:04 1999
@@ -42,18 +42,18 @@
"span.htmlsrc_badattr:!span",
"span.htmlsrc_sgmlspecial:!span"
#else
- "b:!b",
- "b:!b",
- ":",
- "!b:b",
- "b:!b",
- "b:!b",
- ":",
- ":",
- "b:!b",
- ":",
- "!b:b",
- "b:!b"
+ "b:!b", /* comment */
+ "b:!b", /* tag */
+ "b:!b", /* attrib */
+ ":", /* attrval */
+ "b:!b", /* abracket*/
+ "b:!b", /* entity */
+ ":", /* href */
+ ":", /* entire */
+ "b:!b", /* badseq */
+ ":", /* badtag */
+ ":", /* badattr */
+ "b:!b" /* sgmlspec*/
#endif
};
@@ -107,7 +107,9 @@
subj->present = (BOOL*)calloc( nattr*sizeof (BOOL), 1);
subj->value = (char**)calloc( nattr*sizeof (char*), 1);
subj->start = FALSE;
+#ifdef USE_COLOR_STYLE
subj->class_name = NULL;
+#endif
if (!*head) {
*head = subj; *tail = subj;
} else {
- lynx-dev [PATCH] to dev13 - various fixes,
Vlad Harchev <=