4e4f5951fed8f4d923dcbbc313b3596c62374091 tdreszer Mon Jun 25 12:13:22 2012 -0700 Next batch of many checkins as dictated by Jim. Formatting space after if and limiting lines to 100 chars. Changes limited to lines last touched by tdreszer (git blame) so as not to ruin history. None of these changes should affect executables in any way. Only affect is to my sanity and Jim's. diff --git src/lib/htmshell.c src/lib/htmshell.c index fd08ee8..2bfbadb 100644 --- src/lib/htmshell.c +++ src/lib/htmshell.c @@ -193,31 +193,32 @@ } size += countChars(s,'"' ) * 6; size += countChars(s,'\'') * 5; char *cleanQuote = needMem(size); safecpy(cleanQuote,size,s); // NOTE: While some internal HTML should work, a single quote (') will will screw it up! if(tagsOkay) strSwapStrs(cleanQuote, size,"\n","<BR>" ); // new lines also break the html else { strSwapStrs(cleanQuote, size,"&" ,"&" ); // '&' is not the start of a control char strSwapStrs(cleanQuote, size,">" ,">" ); // '>' is not the close of a tag strSwapStrs(cleanQuote, size,"<" ,"<" ); // '<' is not the open of a tag if(cgiClientBrowser(NULL,NULL,NULL) == btFF) - strSwapStrs(cleanQuote, size,"\n","|"); // FF does not support! Use "|" for '|' instead + strSwapStrs(cleanQuote, size,"\n","|"); // FF does not support! Use "|" for '|' + // instead else strSwapStrs(cleanQuote, size,"\n","
"); // '\n' is supported on some browsers } strSwapStrs(cleanQuote, size,"\"","""); // Shield double quotes strSwapStrs(cleanQuote, size,"'" ,"'" ); // Shield single quotes return cleanQuote; } char *attributeEncode(char *str) { // encode double and single quotes in a string to be used as an element attribute return replaceChars(replaceChars(str, "\"", """), "'", "'"); } @@ -238,69 +239,72 @@ * and then made visible. */ { // Only set this up once per page static boolean htmlWarnBoxSetUpAlready=FALSE; if(htmlWarnBoxSetUpAlready) return; htmlWarnBoxSetUpAlready=TRUE; // NOTE: Making both IE and FF work is almost impossible. Currently, in IE, if the message // is forced to the top (calling this routine after <BODY> then the box is not resizable // (dynamically adjusting to its contents). But if this setup is done later in the page // (at first warning), then IE does resize it. Why? // FF3.0 (but not FF2.0) was resizable with the following, but it took some experimentation. // Remember what worked nicely on FF3.0: // "var app=navigator.appName.substr(0,9); " -// "if(app == 'Microsoft') {warnBox.style.display='';} else {warnBox.style.display=''; warnBox.style.width='auto';}" +// "if(app == 'Microsoft') {warnBox.style.display='';} +// else {warnBox.style.display=''; warnBox.style.width='auto';}" fprintf(f, "<script type='text/javascript'>\n"); fprintf(f, "document.write(\"<center>" "<div id='warnBox' style='display:none; background-color:Beige; " "border: 3px ridge DarkRed; width:640px; padding:10px; margin:10px; " "text-align:left;'>" "<CENTER><B id='warnHead' style='color:DarkRed;'></B></CENTER>" "<UL id='warnList'></UL>" "<CENTER><button id='warnOK' onclick='hideWarnBox();return false;'></button></CENTER>" "</div></center>\");\n"); fprintf(f,"function showWarnBox() {" "document.getElementById('warnOK').innerHTML=' OK ';" "var warnBox=document.getElementById('warnBox');" "warnBox.style.display=''; warnBox.style.width='65%%';" "document.getElementById('warnHead').innerHTML='Warning/Error(s):';" "window.scrollTo(0, 0);" "}\n"); fprintf(f,"function hideWarnBox() {" "var warnBox=document.getElementById('warnBox');" "warnBox.style.display='none';warnBox.innerHTML='';" "var endOfPage = document.body.innerHTML.substr(document.body.innerHTML.length-20);" "if(endOfPage.lastIndexOf('-- ERROR --') > 0) { history.back(); }" - "}\n"); // Note that the OK button goes to prev page when this page is interrupted by the error. + "}\n"); // Note OK button goes to prev page when this page is interrupted by the error. fprintf(f,"window.onunload = function(){}; // Trick to avoid FF back button issue.\n"); fprintf(f,"</script>\n"); } void htmlVaWarn(char *format, va_list args) /* Write an error message. */ { va_list argscp; va_copy(argscp, args); htmlWarnBoxSetup(stdout); // sets up the warnBox if it hasn't already been done. char warning[1024]; vsnprintf(warning,sizeof(warning),format, args); -char *encodedMessage = htmlEncodeText(warning,TRUE); // NOTE: While some internal HTML should work, a single quote (') will will screw it all up! +char *encodedMessage = htmlEncodeText(warning,TRUE); // NOTE: While some internal HTML should work, + // a single quote (') will will screw it up! printf("<script type='text/javascript'>{showWarnBox();" "var warnList=document.getElementById('warnList');" - "warnList.innerHTML += '<li>%s</li>';}</script><!-- ERROR -->\n",encodedMessage); // NOTE that "--ERROR --" is needed at the end of this print!! + "warnList.innerHTML += '<li>%s</li>';}</script><!-- ERROR -->\n",encodedMessage); + // NOTE that "--ERROR --" is needed at the end of this print!! freeMem(encodedMessage); /* Log useful CGI info to stderr */ logCgiToStderr(); /* write warning/error message to stderr so they get logged. */ vfprintf(stderr, format, argscp); va_end(argscp); fflush(stderr); } void htmlAbort() /* Terminate HTML file. */ { longjmp(htmlRecover, -1); @@ -441,43 +445,42 @@ void _htmStartWithHead(FILE *f, char *head, char *title, boolean printDocType, int dirDepth) /* Write out bits of header that both stand-alone .htmls * and CGI returned .htmls need, including optional head info */ { if (printDocType) { //#define TOO_TIMID_FOR_CURRENT_HTML_STANDARDS #ifdef TOO_TIMID_FOR_CURRENT_HTML_STANDARDS fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n", f); #else///ifndef TOO_TIMID_FOR_CURRENT_HTML_STANDARDS char *browserVersion; if (btIE == cgiClientBrowser(&browserVersion, NULL, NULL) && *browserVersion < '8') fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">\n", f); else - fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",f); + fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " + "\"http://www.w3.org/TR/html4/loose.dtd\">",f); // Strict would be nice since it fixes atleast one IE problem (use of :hover CSS pseudoclass) - //fputs("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">\n",f); #endif///ndef TOO_TIMID_FOR_CURRENT_HTML_STANDARDS } fputs("<HTML>", f); fprintf(f,"<HEAD>\n%s<TITLE>%s</TITLE>\n", head, title); fprintf(f, "\t<META http-equiv=\"Content-Script-Type\" content=\"text/javascript\">\n"); if (htmlStyle != NULL) fputs(htmlStyle, f); if (htmlStyleSheet != NULL) - fprintf(f,"<link href=\"%s\" rel=\"stylesheet\" type=\"text/css\">\n" - , htmlStyleSheet); + fprintf(f,"<link href=\"%s\" rel=\"stylesheet\" type=\"text/css\">\n", htmlStyleSheet); if (htmlStyleTheme != NULL) fputs(htmlStyleTheme, f); fputs("</HEAD>\n\n",f); fputs("<BODY",f); if (htmlFormClass != NULL ) fprintf(f, " CLASS=\"%s\"", htmlFormClass); if (htmlBackground != NULL ) fprintf(f, " BACKGROUND=\"%s\"", htmlBackground); if (gotBgColor) fprintf(f, " BGCOLOR=\"#%X\"", htmlBgColor); fputs(">\n",f); htmlWarnBoxSetup(f); }