415
edits
Eriktorbjorn (talk | contribs) (Added lengthy, rambling note about the line break bug in Oracle.) |
Eriktorbjorn (talk | contribs) (Updated my thoughts about the missing line breaks.) |
||
Line 43: | Line 43: | ||
So how did this happen? Shouldn't the line have been broken at the previous word? No, in fact it should not. At that point, <tt>_printCharCurPos</tt> is 327 and <tt>count</tt> is 31. The word fits, just barely, and <tt>_printCharCurPos</tt> is increased to 358. Problem is, the line break check is triggered, here as almost always, by a space. And in that case the width of that space will ''also'' be added to <tt>_printCharCurPos</tt>, bringing it up to 366. | So how did this happen? Shouldn't the line have been broken at the previous word? No, in fact it should not. At that point, <tt>_printCharCurPos</tt> is 327 and <tt>count</tt> is 31. The word fits, just barely, and <tt>_printCharCurPos</tt> is increased to 358. Problem is, the line break check is triggered, here as almost always, by a space. And in that case the width of that space will ''also'' be added to <tt>_printCharCurPos</tt>, bringing it up to 366. | ||
There are several possible fixes. A few that comes to mind: | |||
* Change the variables from unsigned to signed. | |||
* Check for overflow when adding the width of the space. (I don't like this one myself.) | |||
* Rewrite the test so that signedness doesn't matter, e.g. <tt>if (_printCharPos + count <= _printCharMaxPos)</tt> | |||
Oddly enough, the original ''does'' use unsigned variables, and take none of these precautions. Is it possible that the compiler ''Adventure Soft'' used behaved differently (buggily?), or are we missing some subtle detail...? |
edits