Closed
Bug 58284
Opened 25 years ago
Closed 24 years ago
wide string literals created by NS_ConvertASCIItoUCS2
Categories
(Core :: XPCOM, defect, P3)
Tracking
()
RESOLVED
DUPLICATE
of bug 104159
mozilla1.0
People
(Reporter: dbaron, Assigned: jag+mozilla)
References
()
Details
(Keywords: meta)
Attachments
(6 files)
356.02 KB,
patch
|
Details | Diff | Splinter Review | |
356.23 KB,
patch
|
Details | Diff | Splinter Review | |
355.76 KB,
patch
|
Details | Diff | Splinter Review | |
9.60 KB,
patch
|
Details | Diff | Splinter Review | |
1.33 KB,
patch
|
Details | Diff | Splinter Review | |
342.58 KB,
patch
|
Details | Diff | Splinter Review |
There are lots of wide string literals that should use NS_LITERAL_STRING that
are being created using NS_ConvertASCIItoUCS2 (which is how NS_LITERAL_STRING
works on platforms that don't support 2-byte L"literal").
The following LXR search should show a nearly complete list:
http://lxr.mozilla.org/seamonkey/search?string=NS_ConvertASCIItoUCS2%28%22
It also shows some examples of other bad string usage.
Reporter | ||
Comment 1•24 years ago
|
||
Some other bad (IMO) string usage I've seen in that query:
- Using AppendWithConversion when only Append is needed
- nsAutoString() [although this may sometimes be an out param that is ignored]
- appending a single-character string instead of a PRUnichar
- "nsString(NS_ConvertASCIItoUCS2("Server: %s - port %d")).GetUnicode()"
Comment 2•24 years ago
|
||
Comment 3•24 years ago
|
||
Comment 4•24 years ago
|
||
Comment 5•24 years ago
|
||
Reporter | ||
Comment 6•24 years ago
|
||
Blake accidentally checked in the changes to nsNNTPProtocol.cpp, which caused
the following bustage on speedracer:
nsNNTPProtocol.cpp: In method `int nsNNTPProtocol::DisplayNewsRC()':
nsNNTPProtocol.cpp:3679: ambiguous conversion from `nsCString' to `bool'
nsNNTPProtocol.cpp:3679: candidate conversions include `const char *' and `char *'
nsNNTPProtocol.cpp:3679: `class nsCString' used where a `bool' was expected
nsNNTPProtocol.cpp:3679: ambiguous default type conversion for `operator &&'
nsNNTPProtocol.cpp:3730: warning: negative value `-1' passed as argument 2 of
`nsNNTPProtocol::SetProgressBarPercent(unsigned int, unsigned int)'
I'm not sure if that ever returns false without the change...
Comment 7•24 years ago
|
||
Comment 8•24 years ago
|
||
Okay, I've updated the patch and split it up. I just attached the |get()|
addition to nsString.h and moving |GetBuffer()| from nsString.cpp to nsString.h,
as soon as my build is done compiling (like, tomorrow) I will attach the actual
conversions to NS_LITERAL_STRING themselves.
Reporter | ||
Comment 9•24 years ago
|
||
r=dbaron on the most recent patch, assuming scc super-reviews it, since he's
module owner.
Comment 10•24 years ago
|
||
Reporter | ||
Comment 11•24 years ago
|
||
A few thoughts:
* you're changing code generated by the DOM idlc. It would be trivial to fix
the DOM idlc, but it looks like the code it calls takes an nsString& and just
converts it to a C string. So why bother with either NS_LITERAL_STRING or
NS_ConvertASCIItoUCS2?
* What happens when the NS_ConvertASCIItoUCS2 was used as a parameter to a
function taking an nsString& (or something similar). How does that compile? I
thought those constructors were |explicit|. So what conversion is used?
Comment 12•24 years ago
|
||
It turns out I'm bitten by this compiling on linux with gcc 2.95.2 because the macro for NS_LITERAL_STRING here is just NS_ConvertASCIItoUCS2. On other platforms it's nsLiteralString which is derived from nsAReadableString and isn't interchangable with nsAutoString (which via via inherits from nsAReadableString) for some uses, so half of this wouldn't have compiled on those platforms. I'll go over these changes closely and will attach a new patch sometime.
Comment 13•24 years ago
|
||
I'm gotten a partial patch from jag for nsNNTPProtocol and I'm going to land it
with other fixes.
Comment 14•24 years ago
|
||
sr=scc for the <a
href="http://bugzilla.mozilla.org/showattachment.cgi?attach_id=20389">|.get()|
patch</a> (12/08/00 19:59)
Reporter | ||
Comment 15•24 years ago
|
||
NS_ConvertToString is just |#define|d to be NS_ConvertASCIItoUCS2, so we should
also deal with all the cases shown in:
http://lxr.mozilla.org/seamonkey/search?string=NS_ConvertToString%28%22
Assignee | ||
Comment 18•24 years ago
|
||
*** This bug has been marked as a duplicate of 104159 ***
Status: NEW → RESOLVED
Closed: 24 years ago
Resolution: --- → DUPLICATE
Updated•4 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•