bug in handling of strings that run off the right edge of the margin

(in HTMLCheckerImpl) - thanks to Chuq von Rospach for reporting this
This commit is contained in:
Eric J. Bowersox 2001-10-02 18:00:43 +00:00
parent 334fdb5c6b
commit 2db3b44e7e

View File

@ -7,7 +7,7 @@
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License. * language governing rights and limitations under the License.
* *
* The Original Code is the Venice Web Community System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
@ -404,7 +404,7 @@ class HTMLCheckerImpl implements HTMLChecker, HTMLCheckerBackend, RewriterServic
private void emitFromStartOfTempBuffer(int nchars) private void emitFromStartOfTempBuffer(int nchars)
{ {
if (nchars<=0) if (nchars<=0)
return; return; // can't emit less than 1 character!
if ((config.getWordWrapLength()>0) && (nobreak_count<=0)) if ((config.getWordWrapLength()>0) && (nobreak_count<=0))
{ // we can output the line break anywhere in the subsequence... { // we can output the line break anywhere in the subsequence...
@ -415,12 +415,16 @@ class HTMLCheckerImpl implements HTMLChecker, HTMLCheckerBackend, RewriterServic
if (curlen>remaining_space) if (curlen>remaining_space)
curlen = remaining_space; curlen = remaining_space;
// output those characters // EJB 10/2/2001 - only output if we have something to output (and there is space for it)
emitString(temp_buffer.substring(0,curlen),config.getOutputFilters(),true); if (curlen>0)
temp_buffer.delete(0,curlen); { // output those characters
nchars -= curlen; emitString(temp_buffer.substring(0,curlen),config.getOutputFilters(),true);
temp_buffer.delete(0,curlen);
nchars -= curlen;
if (columns==config.getWordWrapLength()) } // end if
if (columns>=config.getWordWrapLength()) // EJB 10/2/2001 - might be greater
emitLineBreak(); // and line break us to get to the next line emitLineBreak(); // and line break us to get to the next line
} // end while } // end while
@ -750,7 +754,7 @@ class HTMLCheckerImpl implements HTMLChecker, HTMLCheckerBackend, RewriterServic
i++; i++;
break; break;
case '\r': // compress 1 or more \r's followe by optional \n to a single \n case '\r': // compress 1 or more \r's followed by optional \n to a single \n
if ( (i==(str.length()-1)) if ( (i==(str.length()-1))
|| ((str.charAt(i+1)!='\r') && (str.charAt(i+1)!='\n'))) || ((str.charAt(i+1)!='\r') && (str.charAt(i+1)!='\n')))
temp_buffer.append('\n'); temp_buffer.append('\n');
@ -783,7 +787,7 @@ class HTMLCheckerImpl implements HTMLChecker, HTMLCheckerBackend, RewriterServic
i++; i++;
break; break;
case '\\': // backslash processing is complext - shift to ST_CHARS state to handle it case '\\': // backslash processing is complex - shift to ST_CHARS state to handle it
doFlushWhitespace(); doFlushWhitespace();
state = ST_CHARS; state = ST_CHARS;
break; break;