diff options
Diffstat (limited to 'src/LYStyle.c')
-rw-r--r-- | src/LYStyle.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/src/LYStyle.c b/src/LYStyle.c index 8a95d2b6..3953621f 100644 --- a/src/LYStyle.c +++ b/src/LYStyle.c @@ -1,9 +1,10 @@ /* character level styles for Lynx * (c) 1996 Rob Partington -- donated to the Lyncei (if they want it :-) - * @Id: LYStyle.c 1.19 Thu, 06 Aug 1998 06:28:22 -0600 dickey @ + * @Id: LYStyle.c 1.17 Wed, 25 Mar 1998 06:58:54 -0700 dickey @ */ #include <HTUtils.h> #include <HTML.h> +#include <tcp.h> #include <LYSignal.h> #include <LYGlobalDefs.h> @@ -49,6 +50,9 @@ PUBLIC int s_alink = NOSTYLE, s_a = NOSTYLE, s_status = NOSTYLE, PRIVATE int colorPairs = 0; PRIVATE int last_fA = COLOR_WHITE, last_bA = COLOR_BLACK; + +#define FREE(x) if (x) {free(x); x = NULL;} + /* icky parsing of the style options */ PRIVATE void parse_attributes ARGS5(char*,mono,char*,fg,char*,bg,int,style,char*,element) { @@ -56,7 +60,8 @@ PRIVATE void parse_attributes ARGS5(char*,mono,char*,fg,char*,bg,int,style,char* int mA = 0, fA = default_fg, bA = default_bg, cA = A_NORMAL; int newstyle = hash_code(element); - CTRACE(tfp, "CSS(PA):style d=%d / h=%d, e=%s\n", style, newstyle,element); + if (TRACE) + fprintf(stderr, "CSS(PA):style d=%d / h=%d, e=%s\n", style, newstyle,element); for (i = 0; i <7; i++) { @@ -65,7 +70,8 @@ PRIVATE void parse_attributes ARGS5(char*,mono,char*,fg,char*,bg,int,style,char* mA = ncursesMono[i]; } } - CTRACE(tfp, "CSS(CP):%d\n", colorPairs); + if (TRACE) + fprintf(stderr, "CSS(CP):%d\n", colorPairs); fA = check_color(fg, default_fg); bA = check_color(bg, default_bg); @@ -171,9 +177,13 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n", buffer); } } - CTRACE(tfp, "CSSPARSE:%s => %d %s\n", - element, hash_code(element), - (hashStyles[hash_code(element)].name ? "used" : "")); + if (TRACE) + { + int bkt = hash_code(element); + fprintf(stderr, "CSSPARSE:%s => %d %s\n", + element, bkt, + (hashStyles[bkt].name ? "used" : "")); + } strtolower(element); @@ -225,7 +235,8 @@ where OBJECT is one of EM,STRONG,B,I,U,BLINK etc.\n\n", buffer); { if (!strcasecomp (HTML_dtd.tags[i].name, element)) { - CTRACE(tfp, "PARSECSS:applying style <%s,%s,%s> for HTML_%s\n",mono,fg,bg,HTML_dtd.tags[i].name); + if (TRACE) + fprintf(stderr, "PARSECSS:applying style <%s,%s,%s> for HTML_%s\n",mono,fg,bg,HTML_dtd.tags[i].name); parse_attributes(mono,fg,bg,i+STARTAT,element); break; } @@ -307,7 +318,8 @@ PUBLIC void parse_userstyles NOARGS while ((name = HTList_nextObject(cur)) != NULL) { - CTRACE(tfp, "LSS:%s\n", name ? name : "!?! empty !?!"); + if (TRACE) + fprintf(stderr, "LSS:%s\n", name ? name : "!?! empty !?!"); if (name != NULL) parse_style(name); } @@ -322,7 +334,8 @@ PUBLIC void HStyle_addStyle ARGS1(char*,buffer) if (lss_styles == NULL) lss_styles = HTList_new(); strtolower(name); - CTRACE(tfp, "READCSS:%s\n", name ? name : "!?! empty !?!"); + if (TRACE) + fprintf(stderr, "READCSS:%s\n", name ? name : "!?! empty !?!"); HTList_addObject (lss_styles, name); } @@ -353,14 +366,16 @@ PUBLIC int style_readFromFile ARGS1(char*, file) char buffer[1024]; int len; - CTRACE(tfp, "CSS:Reading styles from file: %s\n", file ? file : "?!? empty ?!?"); + if (TRACE) + fprintf(stderr, "CSS:Reading styles from file: %s\n", file ? file : "?!? empty ?!?"); if (file == NULL || *file == '\0') return -1; fh = fopen(file, "r"); if (!fh) { /* this should probably be an alert or something */ - CTRACE(tfp, "CSS:Can't open style file %s, using defaults\n", file); + if (TRACE) + fprintf(stderr, "CSS:Can't open style file %s, using defaults\n", file); return -1; } |