Closed
Bug 63923
Opened 25 years ago
Closed 24 years ago
[API] Fix NS_LITERAL_STRING
Categories
(Core :: XPCOM, defect, P2)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla1.0
People
(Reporter: jag+mozbugs, Assigned: scc)
References
Details
Attachments
(5 files)
857 bytes,
patch
|
Details | Diff | Splinter Review | |
5.05 KB,
patch
|
Details | Diff | Splinter Review | |
2.22 KB,
patch
|
Details | Diff | Splinter Review | |
2.22 KB,
patch
|
Details | Diff | Splinter Review | |
663 bytes,
patch
|
Details | Diff | Splinter Review |
NS_(NAMED_)LITERAL_STRING currently is defined as either a nsLiteralString
(nsAReadableString) or a NS_ConvertASCIItoUCS2 (nsAutoString), depending on
whether your platform supports short wchar or not (in that order).
The problem here is that code which compiles fine on a system which doesn't
support short wchar, may not compile on systems which do, because "suddenly" a
nsAReadableString is passed into something which was expecting a ns(Auto)String.
To prevent people being bitten by this (yes, they should know better, but it's
an easy mistake, and needlessly wastes time) NS_(NAMED_LITERAL_STRING should
cast the NS_ConvertASCIItoUCS2 to a nsAReadableString.
Patch will follow.
Reporter | ||
Comment 1•25 years ago
|
||
Patch will take a little longer than I expected. I overlooked the fact that
nsAReadableString doesn't have a |.get()| (nor can have one, it's not guaranteed
to be flat). I don't immediately see a way around this, other than adapting
nsLiteralString to interally do something like ASCIItoUCS2 (in which case it
will probably need to be untemplatized), or add a new class which does for
nsAReadableString what NS_ConvertASCIItoUCS2 does for nsAutoString.
I hope someone else sees a better way :-)
Can you put a simple, entirely inlined wrapper class (inheriting from
nsAReadableString) around NS_ConvertASCIItoUCS2?
Assignee | ||
Comment 3•25 years ago
|
||
Yes, as part of the string release work, I'll make sure this casts appropriately
to a common base class so the same behavior is statically expected on all platforms.
Status: NEW → ASSIGNED
OS: Linux → All
Target Milestone: --- → mozilla0.8
Assignee | ||
Comment 4•25 years ago
|
||
want to base the solution to this on the flat abstract class that will be
inserted into the hierarchy in 0.9. So, moving this out as a dependency.
Target Milestone: mozilla0.8 → mozilla0.9
Assignee | ||
Updated•25 years ago
|
Priority: -- → P2
Hardware: PC → All
Assignee | ||
Updated•24 years ago
|
Target Milestone: mozilla0.9 → mozilla0.8.1
Assignee | ||
Comment 5•24 years ago
|
||
(mass change) didn't get these in for target milestone mozilla0.8.1 but they are
very close. Moving all to mozilla0.9.
Target Milestone: mozilla0.8.1 → mozilla0.9
Assignee | ||
Comment 6•24 years ago
|
||
this didn't get fixed in the branch
Assignee | ||
Comment 7•24 years ago
|
||
These are the 0.9 bugs that didn't make it, and that I intend to fix in 0.9.1
Target Milestone: mozilla0.9 → mozilla0.9.1
Assignee | ||
Updated•24 years ago
|
Summary: Fix NS_(NAMED_)LITERAL_STRING → [API] Fix NS_(NAMED_)LITERAL_STRING
Assignee | ||
Comment 8•24 years ago
|
||
re-targeting milestones, starting from a clean slate
Target Milestone: mozilla0.9.1 → ---
Assignee | ||
Comment 9•24 years ago
|
||
All planned string API fixes need to be in by mozilla1.0.
Target Milestone: --- → mozilla1.0
Assignee | ||
Comment 10•24 years ago
|
||
Assignee | ||
Comment 11•24 years ago
|
||
Assignee | ||
Comment 12•24 years ago
|
||
This latest patch builds, but there's trouble when you run ... so we're not
ready for prime time yet. A look in the patch, though, shows where some really
funky stuff was already going on, particularly in history.
Assignee | ||
Comment 13•24 years ago
|
||
I think the original patch is basically sound ... but only for
|NS_LITERAL_STRING|. The same fixes in the rest of the tree (from the second
patch: 05/16/01 05:57) still apply. I'll attach a new patch anon.
Assignee | ||
Comment 14•24 years ago
|
||
Someone (me?, hewitt?) probably needs to fix bug #82208 for this to work. See
the patch attached there:
http://bugzilla.mozilla.org/showattachment.cgi?attach_id=35647
Assignee | ||
Comment 15•24 years ago
|
||
Assignee | ||
Comment 16•24 years ago
|
||
hmmm, I think previous patches (and this latest one) suffer from object
`slicing', two possible fixes are (1) cast to a reference, or else (2) always
produce an |nsDependentString|, in the hard case, over the buffer of the
|NS_ConvertASCIItoUCS2|
Assignee | ||
Comment 17•24 years ago
|
||
in any case, we're only going to fix this for the common case; uses of the
`named' version are much less frequent
Summary: [API] Fix NS_(NAMED_)LITERAL_STRING → [API] Fix NS_LITERAL_STRING
Assignee | ||
Comment 18•24 years ago
|
||
Assignee | ||
Comment 19•24 years ago
|
||
I don't think suggestion (2) above is possible without dangling; testing my new
patch now, then I think I'm ready for review and super-review.
Comment 20•24 years ago
|
||
The nsGlobalHistory changes scare me. In that file, I see (with the patch)
nsString temp = new nsString;
*temp = NS_LITERAL_STRING("http://www.");
mIgnorePrefixes->ReplaceElementAt(NS_STATIC_CAST(void*, temp), 0);
and
for(PRInt32 i = 0; i < mIgnorePrefixes->Count(); ++i) {
nsDependentString* entry = NS_STATIC_CAST(nsDependentString*,
mIgnorePrefixes->ElementAt(i));
delete entry;
}
and
for (PRInt32 i = 0; i < mIgnorePrefixes->Count(); ++i) {
nsString* string = (nsString*) mIgnorePrefixes->ElementAt(i);
Can we be consistent about what's in mIgnorePrefixes? Why use nsDependentString
in the second case?
Also, | mIgnorePrefixes| itself is leaked.
There must be a better way to store a list of ignored prefixes, like a static
const array of char[].
Assignee | ||
Comment 22•24 years ago
|
||
the non-slicing version of the patch builds and runs, now I just need to address
sfraser's concerns re "nsGlobalHistory.cpp"
Comment 23•24 years ago
|
||
sr=sfraser on the nsLiteralString.h change.
Assignee | ||
Comment 24•24 years ago
|
||
Comment 25•24 years ago
|
||
r=thrill-kitty
Assignee | ||
Comment 26•24 years ago
|
||
fix checked in
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Updated•5 years ago
|
Component: String → XPCOM
You need to log in
before you can comment on or make changes to this bug.
Description
•