Closed Bug 620252 Opened 9 years ago Closed 9 years ago

RomanToText could use // FALLTHROUGH comments for 3 and 2

Categories

(Core :: Layout: Text and Fonts, enhancement)

enhancement
Not set

Tracking

()

RESOLVED FIXED
mozilla2.0b9

People

(Reporter: timeless, Assigned: timeless)

References

(Blocks 1 open bug)

Details

(Keywords: coverity)

Attachments

(1 file)

452 static PRBool RomanToText(PRInt32 ordinal, nsString& result, const char* achars, const char* bchars)
453 {
454   if (ordinal < 1 || ordinal > 3999) {
455     DecimalToText(ordinal, result);
456     return PR_FALSE;
457   }
458   nsAutoString addOn, decStr;
459   decStr.AppendInt(ordinal, 10);
460   PRIntn len = decStr.Length();
461   const PRUnichar* dp = decStr.get();
462   const PRUnichar* end = dp + len;
463   PRIntn romanPos = len;
464   PRIntn n;
465 
466   for (; dp < end; dp++) {
467     romanPos--;
468     addOn.SetLength(0);
469     switch(*dp) {
coverity complains about cases '3' and '2':
470       case '3':  addOn.Append(PRUnichar(achars[romanPos]));
471       case '2':  addOn.Append(PRUnichar(achars[romanPos]));
472       case '1':  addOn.Append(PRUnichar(achars[romanPos]));
473         break;
it doesn't complain about case '4' because there's a fallthrough comment which it understands:
474       case '4':
475         addOn.Append(PRUnichar(achars[romanPos]));
476         // FALLTHROUGH
477       case '5': case '6':
478       case '7': case  '8':
479         addOn.Append(PRUnichar(bchars[romanPos]));
480         for(n=0;'5'+n<*dp;n++) {
481           addOn.Append(PRUnichar(achars[romanPos]));
482         }
483         break;
484       case '9':
485         addOn.Append(PRUnichar(achars[romanPos]));
486         addOn.Append(PRUnichar(achars[romanPos+1]));
487         break;
488       default:
489         break;
490     }
Assignee: nobody → timeless
Status: NEW → ASSIGNED
Attachment #498670 - Flags: review?(dbaron)
Attachment #498670 - Flags: approval2.0?
Comment on attachment 498670 [details] [diff] [review]
add fallthrough comments

r=dbaron
Attachment #498670 - Flags: review?(dbaron)
Attachment #498670 - Flags: review+
Attachment #498670 - Flags: approval2.0?
Attachment #498670 - Flags: approval2.0+
Keywords: checkin-needed
http://hg.mozilla.org/mozilla-central/rev/3aab15091aa0
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Flags: in-testsuite-
Resolution: --- → FIXED
Target Milestone: --- → mozilla2.0b9
You need to log in before you can comment on or make changes to this bug.