about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTAnchor.c41
-rw-r--r--WWW/Library/Implementation/HTMLGen.c20
-rw-r--r--WWW/Library/Implementation/HTString.c7
-rw-r--r--WWW/Library/Implementation/HTString.h2
-rw-r--r--WWW/Library/Implementation/HTUtils.h36
-rw-r--r--WWW/Library/Implementation/HTWAIS.c3
6 files changed, 79 insertions, 30 deletions
diff --git a/WWW/Library/Implementation/HTAnchor.c b/WWW/Library/Implementation/HTAnchor.c
index d49b9d95..976679df 100644
--- a/WWW/Library/Implementation/HTAnchor.c
+++ b/WWW/Library/Implementation/HTAnchor.c
@@ -1398,6 +1398,20 @@ PUBLIC int HTAnchor_getUCLYhndl ARGS2(
     return( -1);
 }
 
+#ifdef CAN_SWITCH_DISPLAY_CHARSET
+PRIVATE void setup_switch_display_charset ARGS2(HTParentAnchor *, me, int, h)
+{
+    if (!Switch_Display_Charset(h,0))
+	return;
+    HTAnchor_setUCInfoStage(me, current_char_set,
+			    UCT_STAGE_HTEXT, UCT_SETBY_MIME); /* highest priorty! */
+    HTAnchor_setUCInfoStage(me, current_char_set,
+			    UCT_STAGE_STRUCTURED, UCT_SETBY_MIME); /* highest priorty! */
+    CTRACE((tfp, "changing UCInfoStage: HTEXT/STRUCTURED stages charset='%s'.\n",
+	    LYCharSet_UC[current_char_set].MIMEname));
+}
+#endif
+
 PUBLIC LYUCcharset * HTAnchor_setUCInfoStage ARGS4(
 	HTParentAnchor *,	me,
 	int,			LYhndl,
@@ -1413,10 +1427,18 @@ PUBLIC LYUCcharset * HTAnchor_setUCInfoStage ARGS4(
 	 *  Can we override?
 	 */
 	if (set_by >= me->UCStages->s[which_stage].lock) {
+#ifdef CAN_SWITCH_DISPLAY_CHARSET
+	    int ohandle = me->UCStages->s[which_stage].LYhndl;
+#endif
 	    me->UCStages->s[which_stage].lock = set_by;
 	    me->UCStages->s[which_stage].LYhndl = LYhndl;
 	    if (LYhndl >= 0) {
 		memcpy(p, &LYCharSet_UC[LYhndl], sizeof(LYUCcharset));
+#ifdef CAN_SWITCH_DISPLAY_CHARSET
+		/* Allow a switch to a more suitable display charset */
+		if ( LYhndl != ohandle && which_stage == UCT_STAGE_PARSER )
+		    setup_switch_display_charset(me, LYhndl);
+#endif
 	    }
 	    else {
 		p->UChndl = -1;
@@ -1433,10 +1455,18 @@ PUBLIC LYUCcharset * HTAnchor_resetUCInfoStage ARGS4(
 	int,			which_stage,
 	int,			set_by)
 {
+    int ohandle;
+
     if (!me || !me->UCStages)
 	return(NULL);
     me->UCStages->s[which_stage].lock = set_by;
+    ohandle = me->UCStages->s[which_stage].LYhndl;
     me->UCStages->s[which_stage].LYhndl = LYhndl;
+#ifdef CAN_SWITCH_DISPLAY_CHARSET
+    /* Allow a switch to a more suitable display charset */
+    if (LYhndl >= 0 && LYhndl != ohandle && which_stage == UCT_STAGE_PARSER)
+	setup_switch_display_charset(me, LYhndl);
+#endif
     return( &me->UCStages->s[which_stage].C);
 }
 
@@ -1463,9 +1493,20 @@ PUBLIC LYUCcharset * HTAnchor_copyUCInfoStage ARGS4(
 	if (set_by == UCT_SETBY_NONE)
 	    set_by = UCT_SETBY_DEFAULT;
 	if (set_by >= me->UCStages->s[to_stage].lock) {
+#ifdef CAN_SWITCH_DISPLAY_CHARSET
+	    int ohandle = me->UCStages->s[to_stage].LYhndl;
+#endif
 	    me->UCStages->s[to_stage].lock = set_by;
 	    me->UCStages->s[to_stage].LYhndl =
 		me->UCStages->s[from_stage].LYhndl;
+#ifdef CAN_SWITCH_DISPLAY_CHARSET
+	    /* Allow a switch to a more suitable display charset */
+	    if ( me->UCStages->s[to_stage].LYhndl >= 0
+		 && me->UCStages->s[to_stage].LYhndl != ohandle
+		 && to_stage == UCT_STAGE_PARSER )
+		setup_switch_display_charset(me, 
+					     me->UCStages->s[to_stage].LYhndl);
+#endif
 	    if (p_to != p_from)
 		memcpy(p_to, p_from, sizeof(LYUCcharset));
 	    return(p_to);
diff --git a/WWW/Library/Implementation/HTMLGen.c b/WWW/Library/Implementation/HTMLGen.c
index 3516d201..6047d074 100644
--- a/WWW/Library/Implementation/HTMLGen.c
+++ b/WWW/Library/Implementation/HTMLGen.c
@@ -346,17 +346,17 @@ PRIVATE int HTMLGen_start_element ARGS6(
 	hcode = hash_code(myHash);
 	strtolower(Style_className);
 
-	if (TRACE)
+	if (TRACE_STYLE)
 	{
 	    fprintf(tfp, "CSSTRIM:%s -> %d", myHash, hcode);
 	    if (hashStyles[hcode].code!=hcode)
 	    {
-		char *rp=strrchr(myHash, '.');
+		char *rp = strrchr(myHash, '.');
 		fprintf(tfp, " (undefined) %s\n", myHash);
 		if (rp)
 		{
 		    int hcd;
-		    *rp='\0'; /* trim the class */
+		    *rp = '\0'; /* trim the class */
 		    hcd = hash_code(myHash);
 		    fprintf(tfp, "CSS:%s -> %d", myHash, hcd);
 		    if (hashStyles[hcd].code!=hcd)
@@ -371,8 +371,9 @@ PRIVATE int HTMLGen_start_element ARGS6(
 
 	if (displayStyles[element_number + STARTAT].color > -2) /* actually set */
 	{
-	    CTRACE((tfp, "CSSTRIM: start_element: top <%s>\n",
-		   HTML_dtd.tags[element_number].name));
+	    CTRACE2(TRACE_STYLE,
+		    (tfp, "CSSTRIM: start_element: top <%s>\n",
+			  HTML_dtd.tags[element_number].name));
 	    do_cstyle_flush(me);
 	    HText_characterStyle(me->text, hcode, 1);
 	}
@@ -411,7 +412,8 @@ PRIVATE int HTMLGen_start_element ARGS6(
 		    if (title && *title) {
 			HTSprintf0(&title_tmp, "link.%s.%s",
 				   value[HTML_LINK_CLASS], title);
-			CTRACE((tfp, "CSSTRIM:link=%s\n", title_tmp));
+			CTRACE2(TRACE_STYLE,
+				(tfp, "CSSTRIM:link=%s\n", title_tmp));
 
 			do_cstyle_flush(me);
 			HText_characterStyle(me->text, hash_code(title_tmp), 1);
@@ -488,7 +490,8 @@ PRIVATE int HTMLGen_start_element ARGS6(
     /* end really empty tags straight away */
     if (LYPreparsedSource && ReallyEmptyTagNum(element_number))
     {
-	CTRACE((tfp, "STYLE:begin_element:ending EMPTY element style\n"));
+	CTRACE2(TRACE_STYLE,
+		(tfp, "STYLE:begin_element:ending EMPTY element style\n"));
 	do_cstyle_flush(me);
 	HText_characterStyle(me->text, hcode, STACK_OFF);
 	TrimColorClass(HTML_dtd.tags[element_number].name,
@@ -555,7 +558,8 @@ PRIVATE int HTMLGen_end_element ARGS3(
 		   Style_className, &hcode);
 
     if (LYPreparsedSource && !ReallyEmptyTagNum(element_number)) {
-	CTRACE((tfp, "STYLE:end_element: ending non-EMPTY style\n"));
+	CTRACE2(TRACE_STYLE,
+		(tfp, "STYLE:end_element: ending non-EMPTY style\n"));
 	do_cstyle_flush(me);
 	HText_characterStyle(me->text, hcode, STACK_OFF);
     }
diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c
index b81e60d1..09d37f8c 100644
--- a/WWW/Library/Implementation/HTString.c
+++ b/WWW/Library/Implementation/HTString.c
@@ -13,7 +13,10 @@
 #include <LYLeaks.h>
 #include <LYStrings.h>
 
-PUBLIC int WWW_TraceFlag = 0;	/* Global trace flag for ALL W3 code */
+#ifndef NO_LYNX_TRACE
+PUBLIC BOOLEAN WWW_TraceFlag = 0;	/* Global trace flag for ALL W3 code */
+PUBLIC unsigned WWW_TraceMask = 0;	/* Global trace flag for ALL W3 code */
+#endif
 
 #ifndef VC
 #define VC "unknown"
@@ -501,7 +504,7 @@ PRIVATE char *HTAlloc ARGS2(char *, ptr, size_t, length)
  * in each invocation.  They only grow and never shrink, and won't be
  * cleaned up on exit. - kw
  */
-#if defined(_REENTRANT) || defined(_THREAD_SAFE)
+#if defined(_REENTRANT) || defined(_THREAD_SAFE) || defined(LY_FIND_LEAKS)
 #undef SAVE_TIME_NOT_SPACE
 #endif
 
diff --git a/WWW/Library/Implementation/HTString.h b/WWW/Library/Implementation/HTString.h
index 2b167a8c..53c52cd6 100644
--- a/WWW/Library/Implementation/HTString.h
+++ b/WWW/Library/Implementation/HTString.h
@@ -11,8 +11,6 @@
 #include <HTUtils.h>
 #endif /* HTUTILS_H */
 
-extern int WWW_TraceFlag;       /* Global flag for all W3 trace */
-
 extern CONST char * HTLibraryVersion;   /* String for help screen etc */
 
 /*
diff --git a/WWW/Library/Implementation/HTUtils.h b/WWW/Library/Implementation/HTUtils.h
index 2017f36a..9f153265 100644
--- a/WWW/Library/Implementation/HTUtils.h
+++ b/WWW/Library/Implementation/HTUtils.h
@@ -167,19 +167,8 @@ typedef unsigned short mode_t;
 #  define NO_EMPTY_HREFLESS_A
 #endif
 
-/*
-
-Debug message control.
-
- */
-
-#ifdef NO_LYNX_TRACE
-#define TRACE 0
-#define PROGRESS(str) /* nothing for now */
-#else
-#define TRACE (WWW_TraceFlag)
-#define PROGRESS(str) printf(str)
-        extern int WWW_TraceFlag;
+#if  defined(__EMX__) || defined(WIN_EX)
+#  define CAN_CUT_AND_PASTE
 #endif
 
 /*
@@ -491,10 +480,27 @@ The local equivalents of CR and LF
 #define LF   FROMASCII('\012')  /* ASCII line feed LOCAL EQUIVALENT */
 #define CR   FROMASCII('\015')  /* Will be converted to ^M for transmission */
 
-#define CTRACE(p) if(TRACE)fprintf p
+/*
+ * Debug message control.
+ */
+#ifdef NO_LYNX_TRACE
+#define WWW_TraceFlag   0
+#define WWW_TraceMask   0
+#else
+extern BOOLEAN WWW_TraceFlag;
+extern unsigned WWW_TraceMask;
+#endif
+
+#define TRACE           (WWW_TraceFlag)
+#define TRACE_bit(n)    (TRACE && (WWW_TraceMask & (1 << n)) != 0)
+#define TRACE_STYLE     (TRACE_bit(1))
+#define TRACE_TRST      (TRACE_bit(2))
+
+#define CTRACE(p)          if (TRACE) fprintf p
+#define CTRACE2(m,p)       if (m)     fprintf p
 #define tfp TraceFP()
 #define CTRACE_SLEEP(secs) if (TRACE && LYTraceLogFP == 0) sleep(secs)
-#define CTRACE_FLUSH(fp) if(TRACE) fflush(fp)
+#define CTRACE_FLUSH(fp)   if (TRACE) fflush(fp)
 
 extern FILE *TraceFP NOPARAMS;
 
diff --git a/WWW/Library/Implementation/HTWAIS.c b/WWW/Library/Implementation/HTWAIS.c
index c5ed3338..35277c6d 100644
--- a/WWW/Library/Implementation/HTWAIS.c
+++ b/WWW/Library/Implementation/HTWAIS.c
@@ -87,9 +87,6 @@
 
 #define HEX_ESCAPE '%'
 
-extern int WWW_TraceFlag;	/* Control diagnostic output */
-extern FILE * logfile;		/* Log file output */
-
 PRIVATE BOOL	as_gate;	/* Client is using us as gateway */
 
 PRIVATE char	line[2048];	/* For building strings to display */