[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Lynx-dev] Re: [PATCH 2.8.5] Conditional table logic
From: |
Ilya Zakharevich |
Subject: |
[Lynx-dev] Re: [PATCH 2.8.5] Conditional table logic |
Date: |
Tue, 27 Apr 2004 05:50:06 -0700 |
User-agent: |
Mutt/1.4i |
----- Forwarded message from Ilya Zakharevich <address@hidden> -----
From: Ilya Zakharevich <address@hidden>
Subject: [PATCH 2.8.5] Conditional table logic
To: address@hidden
Date: Tue, 20 Apr 2004 00:49:06 -0700
User-Agent: Mutt/1.4i
This introduces a new integer-valued option -tables_disable.
Different bits in its binary representation switch off different
improvements made to the table processing logic. The order of bits is
roughly chronological: 0x01 is the first change I made, 0x80 is the
latest. Currently, 0xFF is the maximal recognized value; it should
restore the old, "simple", way to render tables.
The only supported...
=======================================================
Apparently, at this place my mailbox was cut of (due to power outage
during saving?), so I do not have the rest of this message saved (it
was sent to the old address, and, apparently, the old address is not
valid any more)... So I need to guess what I wanted to write there:
=======================================================
The only supported value of this option is 0; however, non-0 values of
this option may be used for debugging purposes, and also as a last
resort to avoid bugs in recently-introduced table rendering code. So
it is a sane-man replacement for -nested-tables options (which was a
misnomer, and was not supported anyway ;-).
The meaning of the flags is
+ TABLES_DISABLE_TABLE_IN_TABLE = 1
+ , TABLES_DISABLE_AGRESSIVE_NEW_ROW = 2
+ , TABLES_DISABLE_TRIM_STARTCELL = 4
+ , TABLES_DISABLE_TRIM_ENDCELL = 8
+ , TABLES_DISABLE_SPLIT_AT_CELLSTART = 0x10
+ , TABLES_DISABLE_UNSPLIT = 0x20
+ , TABLES_DISABLE_VERT_MOVE = 0x40
+ , TABLES_DISABLE_SMART_INDENT = 0x80
Enjoy,
Ilya
--- ./GridText.c-ppre Tue Feb 3 04:10:58 2004
+++ ./GridText.c Mon Apr 19 18:24:30 2004
@@ -2917,7 +2917,8 @@ PRIVATE BOOL split_line_at_cellstart ARG
{
int pos = text->last_line->size, startpos;
- if (!text->stbl || AT_START_OF_CELL(text))
+ if ( !text->stbl || AT_START_OF_CELL(text)
+ || (tables_disable & TABLES_DISABLE_SPLIT_AT_CELLSTART) )
return FALSE;
startpos = START_OF_LAST_CELL(text);
if (startpos <= 0 || startpos >= before_pos)
@@ -2936,12 +2937,14 @@ PRIVATE void split_line ARGS2(
{
HTStyle * style = text->style;
int spare;
- int indent = text->stbl
+ int indent_as_stbl = (text->stbl
+ && !(tables_disable & TABLES_DISABLE_SMART_INDENT));
+ int indent = indent_as_stbl
? 0
: (text->in_line_1
? text->style->indent1st
: text->style->leftIndent);
- int extra_space = indent + (text->stbl ? 0 : text->style->rightIndent);
+ int extra_space = indent + (indent_as_stbl ? 0 : text->style->rightIndent);
short alignment;
TextAnchor * a;
int CurLine = text->Lines;
@@ -3033,7 +3036,7 @@ PRIVATE void split_line ARGS2(
text->permissible_split = 0; /* 12/13/93 */
line->data[0] = '\0';
- alignment = text->stbl ? HT_LEFT : style->alignment;
+ alignment = indent_as_stbl ? HT_LEFT : style->alignment;
if (split > 0) { /* Restore flags to the value at the splitting point */
if (!(dump_output_immediately && use_underscore))
@@ -3715,7 +3718,8 @@ PUBLIC void HText_appendParagraph ARGS1(
{
int after = text->style->spaceAfter;
int before = text->style->spaceBefore;
- if (!AT_START_OF_CELL(text))
+ if ( !AT_START_OF_CELL(text)
+ || (tables_disable & TABLES_DISABLE_TRIM_STARTCELL) )
blank_lines(text, ((after > before) ? after : before));
}
@@ -3752,12 +3756,14 @@ PUBLIC void HText_appendCharacter ARGS2(
{
HTLine * line;
HTStyle * style = text->style;
- int indent = text->stbl
+ int indent_as_stbl = (text->stbl
+ && !(tables_disable & TABLES_DISABLE_SMART_INDENT));
+ int indent = indent_as_stbl
? 0
: (text->in_line_1
? style->indent1st
: style->leftIndent);
- int right_indent = text->stbl ? 0 : text->style->rightIndent;
+ int right_indent = indent_as_stbl ? 0 : text->style->rightIndent;
int limit = 0;
int actual;
int flush_cell = 1;
@@ -4302,7 +4308,8 @@ PUBLIC void HText_appendCharacter ARGS2(
* New Line.
*/
if (ch == '\n') {
- if (AT_START_OF_CELL(text))
+ if ( AT_START_OF_CELL(text)
+ && !(tables_disable & TABLES_DISABLE_TRIM_STARTCELL) )
return;
new_line(text);
text->in_line_1 = YES; /* First line of new paragraph */
@@ -4337,7 +4344,8 @@ PUBLIC void HText_appendCharacter ARGS2(
* i.e., use the second line indenting.
*/
if (ch == '\r') {
- if (AT_START_OF_CELL(text))
+ if ( AT_START_OF_CELL(text)
+ && !(tables_disable & TABLES_DISABLE_TRIM_STARTCELL) )
return;
new_line(text);
text->in_line_1 = NO;
@@ -4829,7 +4837,7 @@ PRIVATE int HText_insertBlanksInStblLine
int i = 0, prevline_len = -1, do_unsplit, deleted = 0;
int row_start_line = -1, cur_col = -1, cell_line_count = -1;
int last_row_start_line, startrow_deleted = 0, vert_move = 1;
- STable_info *enclosing;
+ bool enclosing;
lineno = first_lineno = Stbl_getStartLine(me->stbl);
if (lineno < 0 || lineno > me->Lines)
@@ -4856,6 +4864,7 @@ PRIVATE int HText_insertBlanksInStblLine
nextline = line->next;
last_row_start_line = row_start_line;
+ do_unsplit = !(tables_disable & TABLES_DISABLE_UNSPLIT);
ninserts = Stbl_getFixupPositions(me->stbl, lineno, oldpos, newpos,
prevline_len, &do_unsplit,
&row_start_line,
@@ -4941,7 +4950,8 @@ PRIVATE int HText_insertBlanksInStblLine
}
#endif
}
- if (has_multiline_anchor(me,line, lineno - deleted))
+ if ( (tables_disable & TABLES_DISABLE_VERT_MOVE)
+ || has_multiline_anchor(me,line, lineno - deleted) )
vert_move = 0;
if (vert_move && row_start_line != -1 && cell_line_count != -1
&& lineno - deleted > (row_start_line - startrow_deleted +
cell_line_count) + 1)
@@ -5038,7 +5048,8 @@ PRIVATE int HText_insertBlanksInStblLine
* HTML_TABLE should take care of this.
*/
style = me->style;
- enclosing = Stbl_get_enclosing(me->stbl);
+ enclosing = (Stbl_get_enclosing(me->stbl) /* Fake"unnested" to dumb down */
+ && !(tables_disable & TABLES_DISABLE_SMART_INDENT));
alignment = enclosing ? HT_LEFT : Stbl_getAlignment(me->stbl);
if (alignment == HT_ALIGN_NONE)
alignment = style->alignment;
@@ -5215,7 +5226,8 @@ PUBLIC int HText_trimCellLines ARGS1(
HTStyleChange *laststyles;
#endif
- if (!(text && text->stbl))
+ if ( !(text && text->stbl)
+ || (tables_disable & TABLES_DISABLE_TRIM_ENDCELL) )
return 0;
lastline = text->last_line;
--- ./HTML.c-ppre Mon Jan 19 04:16:02 2004
+++ ./HTML.c Tue Feb 3 15:10:34 2004
@@ -5319,7 +5319,8 @@ PRIVATE int HTML_start_element ARGS6(
#ifdef EXP_NESTED_TABLES
if (!nested_tables)
#endif
- HText_cancelStbl(me->text);
+ if (tables_disable & TABLES_DISABLE_TABLE_IN_TABLE)
+ HText_cancelStbl(me->text);
if (me->inA) {
SET_SKIP_STACK(HTML_A);
--- ./LYGlobalDefs.h-ppre Wed Jan 28 11:30:38 2004
+++ ./LYGlobalDefs.h Mon Apr 19 18:22:46 2004
@@ -380,6 +380,19 @@ extern BOOLEAN pseudo_inline_alts;
extern BOOLEAN crawl;
extern BOOLEAN traversal;
extern BOOLEAN check_realm;
+
+enum tables_disable_t {
+ TABLES_DISABLE_TABLE_IN_TABLE = 1
+ , TABLES_DISABLE_AGRESSIVE_NEW_ROW = 2
+ , TABLES_DISABLE_TRIM_STARTCELL = 4
+ , TABLES_DISABLE_TRIM_ENDCELL = 8
+ , TABLES_DISABLE_SPLIT_AT_CELLSTART = 0x10
+ , TABLES_DISABLE_UNSPLIT = 0x20
+ , TABLES_DISABLE_VERT_MOVE = 0x40
+ , TABLES_DISABLE_SMART_INDENT = 0x80
+};
+
+extern long tables_disable;
extern char * startrealm;
extern BOOLEAN more_links;
extern int ccount;
--- ./LYMain.c-ppre Tue Feb 3 12:03:46 2004
+++ ./LYMain.c Tue Feb 3 15:05:24 2004
@@ -464,6 +464,8 @@ PUBLIC BOOLEAN nested_tables =
;
#endif
+PUBLIC long tables_disable = 0;
+
PUBLIC BOOLEAN LYShowTransferRate = TRUE;
PUBLIC int LYTransferRate = rateKB;
PUBLIC char * LYTransferName = NULL;
@@ -3776,6 +3778,10 @@ treated '>' as a co-terminator for doubl
PARSE_SET(
"tagsoup", 4|SET_ARG, DTD_recovery,
"use TagSoup rather than SortaSGML parser"
+ ),
+ PARSE_SET(
+ "tables_disable", 4|INT_ARG, tables_disable,
+ "=NUMBER\nbits disable table support in certain situations"
),
PARSE_SET(
"telnet", 4|UNSET_ARG, telnet_ok,
--- ./TRSTable.c-ppre Mon Feb 2 21:42:54 2004
+++ ./TRSTable.c Mon Apr 19 17:37:26 2004
@@ -42,7 +42,7 @@
#define EOCOLG (-2) /* sumcols' Line field isn't used for line
info, this
special value means end of COLGROUP */
#ifndef NO_AGGRESSIVE_NEWROW
-# define NO_AGGRESSIVE_NEWROW 0
+# define NO_AGGRESSIVE_NEWROW (tables_disable &
TABLES_DISABLE_AGRESSIVE_NEW_ROW)
#endif
typedef enum {
@@ -2119,7 +2119,8 @@ PRIVATE int get_fixup_positions ARGS9(
int i = 0, ip = 0;
int next_i, newlen;
int ninserts;
- int unsplit = ((me->content & IS_UNSPLIT_CANDIDATE) && prevline_len >= 0);
+ int unsplit = (*do_unsplit && (me->content & IS_UNSPLIT_CANDIDATE)
+ && prevline_len >= 0);
int did_unsplit = 0, delta = 0;
if (!me)
- [Lynx-dev] Re: [PATCH 2.8.5] Conditional table logic,
Ilya Zakharevich <=