Closed
Bug 173408
Opened 22 years ago
Closed 22 years ago
Bug fix for Ethiopic Number Conversion Algorithm
Categories
(Core :: Internationalization, defect)
Core
Internationalization
Tracking
()
RESOLVED
FIXED
People
(Reporter: yacob, Assigned: smontagu)
Details
(Keywords: intl)
Attachments
(3 files, 3 obsolete files)
4.09 KB,
text/html
|
Details | |
4.84 KB,
patch
|
smontagu
:
review+
jag+mozilla
:
superreview+
|
Details | Diff | Splinter Review |
8.22 KB,
application/pdf
|
Details |
The existing algorithm in mozilla trips over certain cases where large numbers
have big sequences of zeros and doesn't always remove superfluous '1's when it
should. A patch is provided to fix this along with a test page.
Reporter | ||
Comment 1•22 years ago
|
||
Once applied this patch will need some tweaking. I don't know how the ns
string class works and made some guesses. The routine adjustments are modelled
after: http://www.ethiopic.org/Numerals/ArabicToEthiopic.c which implements
the algorithm (recently updated) http://www.ethiopic.org/Numerals/
Reporter | ||
Comment 2•22 years ago
|
||
Some of these test case will probably fail just because the list item value
overflows the data type used for integers.
Comment 3•22 years ago
|
||
==> internationalization
Assignee: dbaron → yokoyama
Component: Style System → Internationalization
QA Contact: ian → ruixu
Updated•22 years ago
|
Status: UNCONFIRMED → NEW
Ever confirmed: true
Attachment #102295 -
Flags: review?(ian)
Comment 4•22 years ago
|
||
Given that I don't actually understand the algorithm yet (I am discussing this
with Daniel by e-mail) I don't think I should review it... at least not yet. :-)
Reporter | ||
Comment 5•22 years ago
|
||
This patch replaces the previous. It is identical except updated for todays
nsBulletFrame.cpp.
Attachment #102295 -
Attachment is obsolete: true
Assignee | ||
Comment 7•22 years ago
|
||
Comment on attachment 112414 [details] [diff] [review]
Refreshed patch with 23/01/03 CVS snapshot
>+ if ( (n % 2) == 0 ) { // number length was odd
>+ // precondition the string to always have the leading tens place
>+ // populated, this avoids a check within the loop:
>+
>+ // I have no idea if this prefixing works, but you get the idea..
>+ asciiNumberString = (nsAutoString)"0" + asciiNumberString;
>+ n++;
>+ }
asciiNumberString.Insert("0", 0) is the way to do this, but I think it would
be more efficient to initialize asciiNumberString to "0" before the call to
DecimalToText() and then use the substring from 1 to the end if the length of
the string is odd.
>+ for (PRInt32 place = n; place >= n; place--) {
This should be place >= 0, no?
>+ PRUnichar asciiTen = asciiNumberString.CharAt(n-place--);
>+ PRUnichar asciiOne = asciiNumberString.CharAt(n-place);
Now I'm confused. Are you iterating from highest digit to lowest digit or from
lowest to highest? The first version of the patch has a comment
+ // Iterate from the highest digit to lowest digit
but this version keeps the original comment
// Iterate from the lowest digit to higher digits
If you are going from high to low, please change the comment.
>+ // pos indicates if our grouping subscript is even or odd
>+ PRInt32 pos = (place % 4) / 2;
>+
>+ // find a separator, if any, to follow Ethiopic ten and one
>+ PRUnichar sep
>+ = ( place )
>+ ? ( pos )
>+ ? ( ethioOne || ethioTen )
>+ ? (PRUnichar) 0x137B
>+ : 0x0
>+ : (PRUnichar) 0x137C
>+ : 0x0
>+ ;
ethioOne and ethioTen are used here before they are defined.
Triple nesting of [? :] ternaries is going too far, IMO.
>+ // map onto Ethiopic "tens": U+1372=Ethiopic number ten
>+ ethioTen = (PRUnichar) ((PRInt32) asciiTen + 0x1372 - 0x31);
>+ }
>+ if (asciiOne > '0')
>+ {
>+ //map onto Ethiopic "ones": 0x1369=Ethiopic digit one
>+ ethioOne = (PRUnichar) ((PRInt32) asciiOne + 0x1369 - 0x31);
Use #defined constants instead of the hardcoded numbers (and maybe also instead
of the hardcoded literal '0' and '1').
Nit: "tens" and "units" is better English than "tens" and "ones".
>+ result.Insert(ethioNumber, 0);
If you are going from highest digit to lowest, then you want to use Append(),
not Insert().
Attachment #112414 -
Flags: review-
Reporter | ||
Comment 8•22 years ago
|
||
This patch should contain all of the suggestions made by simon. Please review
to see that I have understood the suggestions as intended.
Attachment #112414 -
Attachment is obsolete: true
Assignee | ||
Comment 9•22 years ago
|
||
I had to make a few changes to make the patch compile, and while I was at it I
made the names more descriptive, and made the logic a bit clearer, at least in
my eyes.
One of my earlier comments was wrong: it doesn't work to initialize
asciiNumberString to "0", because we then get the leading zero for values where
we bail out of the algorithm, e.g. "0-1" for -1.
The testcases all seem to work now, except when the values overflow.
Attachment #125521 -
Attachment is obsolete: true
Assignee | ||
Comment 10•22 years ago
|
||
The testcase is too large for a screenshot. I hope a .pdf will work.
Reporter | ||
Comment 11•22 years ago
|
||
Simon, it looks really super! I'll print and examine the list carefully. On
the overflow issue, what is the highest number that mozilla can handle in
lists?
Assignee | ||
Comment 12•22 years ago
|
||
>what is the highest number that mozilla can handle in lists?
The list index is passed around in a PRInt32, so the maximum value is 2147483647
(0x7FFFFFFF)
Assignee | ||
Comment 13•22 years ago
|
||
Comment on attachment 125863 [details] [diff] [review]
Simplified version
r=smontagu (I attached this, but it's in effect Daniel's patch incorporating my
review comments). jag, can you sr?
Attachment #125863 -
Flags: superreview?(jaggernaut)
Attachment #125863 -
Flags: review+
Comment 14•22 years ago
|
||
Comment on attachment 125863 [details] [diff] [review]
Simplified version
sr=jag
Attachment #125863 -
Flags: superreview?(jaggernaut) → superreview+
Assignee | ||
Comment 15•22 years ago
|
||
Fix checked in.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 16•22 years ago
|
||
Comment on attachment 102295 [details] [diff] [review]
cvs diff -u against nsBulletFrame.cpp
clearing obsolete review request
Attachment #102295 -
Flags: review?(ian)
You need to log in
before you can comment on or make changes to this bug.
Description
•