Bug 8937 - EncodingMap uses 0 as its empty value but 0 is a valid TextEncodingID
Summary: EncodingMap uses 0 as its empty value but 0 is a valid TextEncodingID
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 420+
Hardware: Mac OS X 10.4
: P1 Normal
Assignee: Nobody
URL:
Keywords: EasyFix, Regression
Depends on:
Blocks:
 
Reported: 2006-05-16 01:22 PDT by mitz
Modified: 2006-05-18 09:08 PDT (History)
1 user (show)

See Also:


Attachments
A fix (818 bytes, patch)
2006-05-17 09:29 PDT, mitz
darin: review-
Details | Formatted Diff | Diff
Patch w/change log (3.07 KB, patch)
2006-05-18 07:20 PDT, mitz
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description mitz 2006-05-16 01:22:25 PDT
EncodingMap uses 0 as its empty value but 0 is a valid encoding ID (MacRoman), which is actually added to the map by buildDictionaries().

I think the empty value should be changed to something else (but not InvalidEncoding, which is used as the deleted value), and emptyValueIsZero should be defined as false.
Comment 1 mitz 2006-05-17 09:29:41 PDT
Created attachment 8367 [details]
A fix
Comment 2 mitz 2006-05-17 09:35:48 PDT
Comment on attachment 8367 [details]
A fix

I'm really not sure about this one (except that it fixes the bug, of course).
Comment 3 Darin Adler 2006-05-17 22:00:37 PDT
Comment on attachment 8367 [details]
A fix

Actually, the specialization of the HashKeyStorageTraits can and should be removed entirely if we have to change the empty value. The reason that's there is to make the hash table implementation get shared. But that sharing can't take place if the traits are not the standard traits for the integer type.

Otherwise, this patch looks fine.
Comment 4 Darin Adler 2006-05-17 22:02:58 PDT
This second invalid encoding should probably go in the TextEncoding.h header and have a symbolic name, too. I agree that the value 0xFFFFFFFEU is a good value to use. We can probably call it InvalidEncoding2 or some other lovely name like that.
Comment 5 mitz 2006-05-18 07:20:28 PDT
Created attachment 8391 [details]
Patch w/change log

InvalidEncoding2 it is!
Comment 6 Darin Adler 2006-05-18 08:46:58 PDT
Comment on attachment 8391 [details]
Patch w/change log

Looks great, r=me.

One comment for the future. When you have an assert that has an && in it, it's usually better to have two asserts. That way each one has a smaller expression in it, and also if one fails you know which half failed.
Comment 7 Darin Adler 2006-05-18 09:08:49 PDT
Committed revision 14465.