* a dozen of HTMLSRC_ lynx.cfg settings were substituted with PSRCSPEC setting. Old "HTMLSRC_foo:bar1:bar2" should be written as "PSRCSPEC:foo:bar1:bar2". Comments: Feel free to substitute the name PSRCSPEC with any you like. Best regards, -Vlad diff -ru old/lynx.cfg fixed/lynx.cfg --- old/lynx.cfg Mon Dec 4 23:08:49 2000 +++ fixed/lynx.cfg Mon Dec 4 23:14:07 2000 @@ -2702,21 +2702,9 @@ # RULE:Redirect http://old.server/* http://new.server/* .h1 Appearance - -.h2 HTMLSRC_ABRACKET -.h2 HTMLSRC_ATTRIB .h2 HTMLSRC_ATTRNAME_XFORM -.h2 HTMLSRC_ATTRVAL -.h2 HTMLSRC_BADATTR -.h2 HTMLSRC_BADSEQ -.h2 HTMLSRC_BADTAG -.h2 HTMLSRC_COMM -.h2 HTMLSRC_ENTIRE -.h2 HTMLSRC_ENTITY -.h2 HTMLSRC_HREF -.h2 HTMLSRC_SGMLSPECIAL -.h2 HTMLSRC_TAG .h2 HTMLSRC_TAGNAME_XFORM +.h2 PSRCSPEC # Pretty source view settings. These settings are in effect when -prettysrc # is specified. # The following lexical elements (lexemes) are recognized: @@ -2725,7 +2713,7 @@ # bad tag, bad attribute, sgml special. # The following group of option tells which styles will surround each # lexeme. The syntax of option in this group is: -#HTMLSRC_<LEXEMENAME>:<TAGSPEC>:<TAGSPEC> +#PSRCSPEC:<LEXEMENAME>:<TAGSPEC>:<TAGSPEC> # The first <TAGSPEC> specifies what tags will precede lexemes of that class # in the internal html markup. The second - what will be placed (internally) # after it. @@ -2775,46 +2763,46 @@ # 5) Angle brackets of html specials won't be surrounded by markup for ABRACKET # .ex -# HTMLSRC_COMM:B I:!I !B +# PSRCSPEC:COMM:B I:!I !B # HTML comments will be surrounded by <b><i> and </i></b> in the # internal html markup .ex -# HTMLSRC_ATTRVAL: span.attrval : !span +# PSRCSPEC:ATTRVAL: span.attrval : !span # Values of the attributes will be surrounded by the # <SPAN class=attrval> </SPAN> .ex -# HTMLSRC_HREF:: +# PSRCSPEC:HREF:: # No special html markup will surround hyperlink destinations ( # this means that only default color style for hrefs will be applied # to them) # # For lynx compiled with lss support, the following settings are the default: -#HTMLSRC_COMM:span.htmlsrc_comment:!span -#HTMLSRC_TAG:span.htmlsrc_tag:!span -#HTMLSRC_ATTRIB:span.htmlsrc_attrib:!span -#HTMLSRC_ATTRVAL:span.htmlsrc_attrval:!span -#HTMLSRC_ABRACKET:span.htmlsrc_abracket:!span -#HTMLSRC_ENTITY:span.htmlsrc_entity:!span -#HTMLSRC_HREF:span.htmlsrc_href:!span -#HTMLSRC_ENTIRE:span.htmlsrc_entire:!span -#HTMLSRC_BADSEQ:span.htmlsrc_badseq:!span -#HTMLSRC_BADTAG:span.htmlsrc_badtag:!span -#HTMLSRC_BADATTR:span.htmlsrc_badattr:!span -#HTMLSRC_SGMLSPECIAL:span.htmlsrc_sgmlspecial:!span +#PSRCSPEC:COMM:span.htmlsrc_comment:!span +#PSRCSPEC:TAG:span.htmlsrc_tag:!span +#PSRCSPEC:ATTRIB:span.htmlsrc_attrib:!span +#PSRCSPEC:ATTRVAL:span.htmlsrc_attrval:!span +#PSRCSPEC:ABRACKET:span.htmlsrc_abracket:!span +#PSRCSPEC:ENTITY:span.htmlsrc_entity:!span +#PSRCSPEC:HREF:span.htmlsrc_href:!span +#PSRCSPEC:ENTIRE:span.htmlsrc_entire:!span +#PSRCSPEC:BADSEQ:span.htmlsrc_badseq:!span +#PSRCSPEC:BADTAG:span.htmlsrc_badtag:!span +#PSRCSPEC:BADATTR:span.htmlsrc_badattr:!span +#PSRCSPEC:SGMLSPECIAL:span.htmlsrc_sgmlspecial:!span # the styles corresponding to them are present in sample .lss file. # For lynx compiled without lss support, the following settings are the default: -#HTMLSRC_COMM:b:!b -#HTMLSRC_TAG: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:: -#HTMLSRC_SGMLSPECIAL:b:!b +#PSRCSPEC:COMM:b:!b +#PSRCSPEC:TAG:b:!b +#PSRCSPEC:ATTRIB:b:!b +#PSRCSPEC:ATTRVAL:: +#PSRCSPEC:ABRACKET:b:!b +#PSRCSPEC:ENTITY:b:!b +#PSRCSPEC:HREF:: +#PSRCSPEC:ENTIRE:: +#PSRCSPEC:BADSEQ:b:!b +#PSRCSPEC:BADTAG:: +#PSRCSPEC:BADATTR:: +#PSRCSPEC:SGMLSPECIAL:b:!b # # Other source-view related options: # diff -ru old/src/LYPrettySrc.c fixed/src/LYPrettySrc.c --- old/src/LYPrettySrc.c Thu Nov 4 00:31:19 1999 +++ fixed/src/LYPrettySrc.c Mon Dec 4 22:58:02 2000 @@ -328,11 +328,9 @@ char buf[1000]; for (i = 0; i < HTL_num_lexemes; ++i) { - - strcpy(buf, HTL_tagspecs_defaults[i]); - p = HTL_tagspecs_defaults[i]; - HTL_tagspecs[i] = NULL; - StrAllocCopy(HTL_tagspecs[i],p); + /*we assume that HT_tagspecs was NULLs at when program started*/ + strcpy(buf, HTL_tagspecs[i] ? HTL_tagspecs[i] : HTL_tagspecs_defaults[i]); + StrAllocCopy(HTL_tagspecs[i],buf); if ((p = strchr(buf, ':')) != 0) *p = '\0'; diff -ru old/src/LYReadCFG.c fixed/src/LYReadCFG.c --- old/src/LYReadCFG.c Mon Dec 4 20:18:55 2000 +++ fixed/src/LYReadCFG.c Mon Dec 4 23:10:56 2000 @@ -1113,7 +1113,6 @@ #endif /* EXP_CHARSET_CHOICE */ #ifdef USE_PSRC - static void html_src_bad_syntax ARGS2( char*, value, char*, option_name) @@ -1149,8 +1148,8 @@ CTRACE((tfp,"ReadCFG - parsing tagspec '%s:%s' for option '%s'\n",value,ts2,option_name)); html_src_clean_item(lexeme_code); - if ( html_src_parse_tagspec(value, lexeme_code, FALSE, TRUE) - || html_src_parse_tagspec(ts2, lexeme_code, FALSE, FALSE) ) + if ( html_src_parse_tagspec(value, lexeme_code, TRUE, TRUE) + || html_src_parse_tagspec(ts2, lexeme_code, TRUE, TRUE) ) { *ts2 = ':'; BS(); @@ -1162,28 +1161,52 @@ return 0; } -#if defined(__STDC__) || defined(_WIN_CC) -#define defHTSRC_parse_fun(x) static int html_src_set_##x ARGS1( char*,str) \ - { parse_html_src_spec(HTL_##x,str,#x); return 0; } -#else -#define defHTSRC_parse_fun(x) static int html_src_set_/**/x ARGS1( char*,str) \ - { parse_html_src_spec(HTL_/**/x,str,"x"); return 0; } -#endif - -defHTSRC_parse_fun(comm) -defHTSRC_parse_fun(tag) -defHTSRC_parse_fun(attrib) -defHTSRC_parse_fun(attrval) -defHTSRC_parse_fun(abracket) -defHTSRC_parse_fun(entity) -defHTSRC_parse_fun(href) -defHTSRC_parse_fun(entire) -defHTSRC_parse_fun(badseq) -defHTSRC_parse_fun(badtag) -defHTSRC_parse_fun(badattr) -defHTSRC_parse_fun(sgmlspecial) +typedef struct string_int_pair_ +{ + char* str; + int val; +} string_int_pair; -#undef defHTSRC_parse_fun +PRIVATE int psrcspec_fun ARGS1(char*,s) +{ + char* e; + static string_int_pair lexemnames[] = + { + { "comm", HTL_comm}, + { "tag", HTL_tag}, + { "attrib", HTL_attrib}, + { "attrval", HTL_attrval}, + { "abracket", HTL_abracket}, + { "entity", HTL_entity}, + { "href", HTL_href}, + { "entire", HTL_entire}, + { "badseq", HTL_badseq}, + { "badtag", HTL_badtag}, + { "badattr", HTL_badattr}, + { "sgmlspecial", HTL_sgmlspecial}, + { NULL, -1} + }; + string_int_pair* cur = lexemnames; + BOOL found = FALSE; + + e = strchr(s,':'); + if (!e) { + CTRACE((tfp,"bad format of PSRCSPEC setting value, ignored %s\n",s)); + return 0; + }; + *e = '\0'; + while (cur->str) { + if (found = !strcasecomp(s,cur->str)) + break; + ++cur; + }; + if (!found) { + CTRACE((tfp,"bad format of PSRCSPEC setting value, ignored %s:%s\n",s,e+1)); + return 0; + } + parse_html_src_spec(cur->val,e+1,s); + return 0; +}; static int read_htmlsrc_attrname_xform ARGS1( char*,str) { @@ -1214,20 +1237,8 @@ } return 0; } - - -#ifdef __STDC__ -#define defHTSRC_option(x) \ - PARSE_FUN( "htmlsrc_" #x ,CONF_FUN, html_src_set_##x), -#else -#define defHTSRC_option(x) \ - PARSE_FUN( "htmlsrc_" #x ,CONF_FUN, html_src_set_/**/x), - /* ^^ (cannot adapt to K&R) */ -#endif - #endif - /* This table should be sorted alphabetically */ static Config_Type Config_Table [] = { @@ -1304,31 +1315,10 @@ PARSE_SET("gotobuffer", CONF_BOOL, &goto_buffer), PARSE_STR("helpfile", CONF_STR, &helpfile), PARSE_SET("historical_comments", CONF_BOOL, &historical_comments), - -#if defined(USE_PSRC) && defined(__STDC__) - - defHTSRC_option(abracket) - defHTSRC_option(attrib) - +#ifdef USE_PSRC PARSE_FUN("htmlsrc_attrname_xform", CONF_FUN, read_htmlsrc_attrname_xform), - - defHTSRC_option(attrval) - defHTSRC_option(badattr) - defHTSRC_option(badseq) - defHTSRC_option(badtag) - defHTSRC_option(comm) - defHTSRC_option(entire) - defHTSRC_option(entity) - defHTSRC_option(href) - defHTSRC_option(sgmlspecial) - defHTSRC_option(tag) - PARSE_FUN("htmlsrc_tagname_xform", CONF_FUN, read_htmlsrc_tagname_xform), - - -# undef defHTSRC_option #endif - PARSE_ENV("http_proxy", CONF_ENV, 0 ), PARSE_ENV("https_proxy", CONF_ENV, 0 ), #ifndef NO_HYPHENATE @@ -1425,6 +1415,7 @@ PARSE_SET("prepend_charset_to_source", CONF_BOOL, &LYPrependCharsetToSource), PARSE_FUN("printer", CONF_FUN, printer_fun), #ifdef USE_PSRC + PARSE_FUN("psrcspec" ,CONF_FUN, psrcspec_fun), PARSE_SET("psrcview_no_anchor_numbering", CONF_BOOL, &psrcview_no_anchor_numbering), #endif PARSE_SET("quit_default_yes", CONF_BOOL, &LYQuitDefaultYes),
