Commit Graph

1295 Commits

Author SHA1 Message Date
Chris Pearce
42abbda386 Bug 1399309 - Make nsTSubstring.cpp include MathAlgorithms.h. r=froydnj
nsTSubstring.cpp is calling RoundUpPow2 which is defined in MathAlgorithms.h.

Without this, we get a build failure in non-unified builds.


MozReview-Commit-ID: Dz7VIZk4dLw

--HG--
extra : rebase_source : 7795784894bfca6e921d38cedaa4f543317c2165
2017-09-13 13:50:05 +12:00
Xidorn Quan
e5dc8373fe Bug 1397942 - Disable C5037 in xpcom/string to workaround MSVC bug. r=froydnj
MozReview-Commit-ID: Gzx3gtt9eIF

--HG--
extra : rebase_source : 9d7ae1592ece8444265926e78630005d8776c57e
2017-09-08 15:08:39 +10:00
Eric Rahm
030b39d813 Bug 1393230 - Part 3: Convert the xpcom string classes to be templated on char type. r=njn, r=fitzgen, r=sfink
This removes the double-include macro hackery that we use to define two
separate string types (nsAString and nsACString) in favor of a templated
solution.

Annotations for Valgrind and the JS hazard analysis are updated as well as
the rust binding generations for string code.

--HG--
extra : rebase_source : 63ab2c4620cfcd4b764d42d654c82f30f984d016
extra : source : 9115364cd4aa078c49bba7911069f8178e55166f
2017-08-14 14:22:50 -07:00
Henri Sivonen
d2b0cdbc9c Bug 1395527 part 2 - Delegate IsASCII and IsUTF8 to encoding_rs. r=froydnj
MozReview-Commit-ID: 49AGBPjW4Ca

--HG--
extra : rebase_source : 78dc1b549c97e5e4fb0dc625acdab23806b3e941
2017-09-01 11:53:31 +03:00
Sebastian Hengst
e03f524d85 Backed out changeset d59b62713c66 (bug 1395527) 2017-09-02 10:38:20 +02:00
Henri Sivonen
3c7fa0536e Bug 1395527 part 2 - Delegate IsASCII and IsUTF8 to encoding_rs. r=froydnj
MozReview-Commit-ID: 49AGBPjW4Ca

--HG--
extra : rebase_source : fb20025e98f97210c58c3cf9767eae06ad92349b
2017-09-01 11:53:31 +03:00
Nicholas Nethercote
f582d96b98 Bug 1390428 (part 9) - Remove nsXPIDLCString. r=erahm.
This is straightforward, with only two notable things.

- `#include "nsXPIDLString.h" is replaced with `#include "nsString.h"`
  throughout, because all nsXPIDLString.h did was include nsString.h. The
  exception is for files which already include nsString.h, in which case the
  patch just removes the nsXPIDLString.h inclusion.

- The patch removes the |xpidl_string| gtest, but improves the |voided| test to
  cover some of its ground, e.g. testing Adopt(nullptr).

--HG--
extra : rebase_source : 452cc4a08046a1adb1a8099a7e85a1917de5add8
2017-08-17 15:29:03 +10:00
Nicholas Nethercote
6f90531fbd Bug 1390428 (part 8) - Remove nsXPIDLCString use in NullCString(). r=erahm.
This change makes NullCString() work the same way as NullString().

--HG--
extra : rebase_source : 3835cd75f1cf95c9d0884cb9a73250123129dd07
2017-08-17 14:25:23 +10:00
Eric Rahm
a33f11e0f5 Bug 1391803 - Use nsStringFwd.h for forward declaring string classes. r=froydnj
We should not be declaring forward declarations for nsString classes directly,
instead we should use nsStringFwd.h. This will make changing the underlying
types easier.

--HG--
extra : rebase_source : b2c7554e8632f078167ff2f609392e63a136c299
2017-08-16 16:48:52 -07:00
Nicholas Nethercote
dc5e4a62cf Bug 1386103 (part 2, attempt 3) - Convert nsFixed[C]String uses to nsAuto[C]String. r=erahm. 2017-08-09 20:41:40 +10:00
Nicholas Nethercote
65b902e3ea Bug 1386103 (part 1, attempt 3) - Specify nsAuto[C]String storage size via template parameter. r=dbaron. 2017-08-09 20:41:38 +10:00
Nicholas Nethercote
4d15e13fc4 Bug 1390036 (part 3) - Remove nsXPIDLString. r=erahm.
--HG--
extra : rebase_source : 87094fef8b919094926ec1be26867985a7fe8708
2017-08-14 15:25:04 +10:00
Nicholas Nethercote
64c9cd5e75 Bug 1390036 (part 2) - Remove nsXPIDLString use from NullString(). r=dbaron.
This requires adding a new constructor for ns[C]String that can be used to
create an IsVoid string.

--HG--
extra : rebase_source : 8cb078bd0a41e63af0d9d144b9eef369875a05e0
2017-08-14 14:46:53 +10:00
Phil Ringnalda
858a553b02 Backed out 2 changesets (bug 1386103) for Android x86 build bustage
Backed out changeset eec506d87d03 (bug 1386103)
Backed out changeset 3f9ec011c9bd (bug 1386103)

MozReview-Commit-ID: 8ak71R7vUOC
2017-08-08 22:08:54 -07:00
Nicholas Nethercote
7512aa2dea Bug 1386103 (part 2) - Convert nsFixed[C]String uses to nsAuto[C]String. r=erahm.
In all of these cases the fixed buffer has the same lifetime as the string
object, so we can use nsAuto[C]String for simplicity.

For the 128-length ones in dom/xul/ I just switched to the default of 64 for
simplicity, because the choice of 128 didn't seem that important. (These code
paths weren't hit when I started the browser and opened a few sites.)

Finally, the patch also changes LoggingIdString to use
nsAutoCStringN<NSID_LENGTH>, similar to NullPrincipalURI.
2017-08-01 11:58:56 +10:00
Nicholas Nethercote
e9daf4d245 Bug 1386103 (part 1) - Specify nsAuto[C]String storage size via template parameter. r=dbaron.
This patch parameterizes nsAuto[C]String, renames them as nsAuto[C]StringN, and
redefines nsAuto[C]String as typedefs for nsAuto[C]StringN<64>.

(The alternative would be to templatize nsAuto[C]String and use a default
parameter, but that would require writing "nsAuto[C]String<>" everywhere.)
2017-08-01 11:58:45 +10:00
Nicholas Nethercote
3b50454376 Bug 1388253 - Remove nsTextFormatter:[v]smprintf(). r=erahm.
--HG--
extra : rebase_source : 27f080dda37d107f64eb8f341c6ebb20b874471b
2017-08-09 10:41:21 +10:00
Nicholas Nethercote
d4e19d954a Bug 1388253 - Convert nsTextFormatter:[v]smprintf() use to [v]ssprintf(). r=erahm.
[v]ssprintf() is just a better way of doing things.

--HG--
extra : rebase_source : 25337787b9557f8a7080a67645dba70609a8f646
2017-08-09 10:41:14 +10:00
Tristan Bourvon
3bd6c5f20a Bug 1374024 - add static-analysis annotation for class functions that return dangling pointers. r=mystor
MozReview-Commit-ID: 44Ltj5FZAZD
2017-07-13 12:00:06 +02:00
Nicholas Nethercote
3ab0f8b30f Bug 1384834 (part 4) - Improve comments for Adopt() and getter_Copies(). r=erahm.
--HG--
extra : rebase_source : a7bb27bbdade092bd087a014d31d9c6d019e1d72
2017-08-01 06:06:36 +10:00
Nicholas Nethercote
e5d1c73749 Bug 1384834 (part 3) - Remove nsAdopting[C]String. r=erahm.
--HG--
extra : rebase_source : a87c357fb0166620a33a40e1a01af32d5e7a907d
2017-07-28 11:21:49 +10:00
Julian Seward
408d24da56 Bug 1382563 - Remove ns*String::AssignWithConversion. r=erahm.
This patch replaces four functions of the name AssignWithConversion which
are essentially wrappers around CopyASCIItoUTF16 and LossyCopyUTF16toASCII
with direct calls to the latter two functions.  The replaced functions are:

  void nsCString::AssignWithConversion( const nsAString& aData )
  void nsString::AssignWithConversion( const nsACString& aData )

  void nsTString_CharT::AssignWithConversion(
                            const incompatible_char_type* aData,
                            int32_t aLength = -1);

The last of the three exists inside the double-included nsTString* world and
so describes two functions, giving four in total.

This has two advantages:

* it removes code

* at the call points, it makes clear (from the replacement name) which
  conversion is being carried out.  The generic name "AssignWithConversion"
  doesn't make that obvious -- one had to infer it from the types.

The patch also removes two commented out lines from
editor/composer/nsComposerCommands.cpp, that appear to be related.  They are
at top level, where they would never have compiled.  They look like
leftovers from some previous change.

--HG--
extra : rebase_source : fb47bf450771c3c9ee3341dd14520f5da69ec4f5
2017-07-24 19:23:52 +02:00
Nicholas Nethercote
d97f8b05ed Bug 1381726 - Remove nsTextFormatter::smprintf_free(). r=erahm.
We can just use free() instead.

--HG--
extra : rebase_source : d1fa65550f22d0531ec4cc3b173fb2de36dee6e6
2017-07-25 09:09:27 +10:00
L. David Baron
97a8a3c332 Bug 1381080 patch 7 - Mark nsLiteral[C]String constructor as constexpr. r=erahm
MozReview-Commit-ID: 5ASqQAGBqq

--HG--
extra : transplant_source : y%CB%BE%82%E7%E0%C9%2C%DE%26%1A%86%C8%17_%1E%A6E%9C%7B
2017-07-20 15:47:00 -07:00
L. David Baron
6a5b0be9fc Bug 1381080 patch 4 - Assert that strings whose static type requires a null-terminated buffer aren't assign a non-null-terminated buffer. r=erahm
I actually couldn't figure out a way to trigger this assertion with the
current string code without doing invalid casts, but there are things we
may want to add to the string code in the future that might risk hitting
this (e.g., move constructors, promoting various rebind methods to
nsA[C]String), so I think it's worth asserting.

MozReview-Commit-ID: 4R0dYuTfrFW

--HG--
extra : transplant_source : %B6%87I%0E%7F%21%CC2%19%CD%A7%E6TRA%9D%AEO%90%D7
2017-07-20 15:46:59 -07:00
L. David Baron
cb0e6b4512 Bug 1381080 patch 3 - Encapsulate setting mData/mLength/mDataFlags in a new method. r=erahm
This is needed for patch 4.

MozReview-Commit-ID: 4BFlTtQdtoN

--HG--
extra : transplant_source : %7C%F7%FDN%E5%7Df%0C%7D%10%EF%C0%25%B9%D6%18%1E%93%BE%A0
2017-07-20 15:46:59 -07:00
L. David Baron
7c15789222 Bug 1381080 patch 2 - Encapsulate setting to empty buffer in a new method. r=erahm
This is needed for patch 4.

MozReview-Commit-ID: 7xKQv37cy5k

--HG--
extra : transplant_source : %ED%16%85q%7F%E7%117%29%D2c%C2%21%20%D7%C9%BA%CCC%CC
2017-07-20 15:46:59 -07:00
L. David Baron
eb59a21402 Bug 1381080 patch 1 - Add ClassFlags::NULL_TERMINATED to strings that require null-termination. r=erahm
This is needed for patch 4.

MozReview-Commit-ID: 5ikQFIL9O0i

--HG--
extra : transplant_source : %88%80%E3%04%11%7E%7F%A4%7E%15%1B%1A%84%E2%13%3E%F6%E8%2A%1C
2017-07-20 15:46:58 -07:00
Carsten "Tomcat" Book
f193d6bbd3 Backed out changeset a5c0a74876ae (bug 1376323) for causing bug 1379578 2017-07-13 16:24:26 +02:00
Carsten "Tomcat" Book
95745c2ae6 Backed out changeset ced6c13e61e9 (bug 1376472) 2017-07-13 16:23:54 +02:00
L. David Baron
57e3e8641f Bug 1343715 - Remove nsA[C]String::SetDataFlags. r=dmajor
MozReview-Commit-ID: EDQbH9pZKtZ

--HG--
extra : transplant_source : %FA%16%DC%A2C%DAM%F8%AC9%B6%F3d%DF%9E%5B%80%99%7E%B3
2017-07-10 12:23:11 -07:00
L. David Baron
c59666d841 Bug 1343715 - Split nsTSubstring::mFlags into separate variables for class and data flags. r=dmajor
MozReview-Commit-ID: JW1p5BxpHKA

--HG--
extra : transplant_source : %20e%CF%FA%60%A2%1Bn%1A%C6%A2%DBAy%3C%E0b%0C%077
2017-07-10 12:23:10 -07:00
L. David Baron
539cb0d5a7 Bug 1343715 - Use SetDataFlags in ForgetSharedBuffer. r=dmajor
I believe this should fix some incorrect clearing of F_CLASS_FIXED.

MozReview-Commit-ID: 4ga2NEM9M5Z

--HG--
extra : transplant_source : %ECF%CF%D0%F6%19%9F%24%86%EFR%CAVZ%ED%60%D5nU%D8
2017-07-10 12:23:10 -07:00
Sylvestre Ledru
4e9cf83ee8 Bug 1378712 - Remove all trailing whitespaces r=Ehsan
MozReview-Commit-ID: Kdz2xtTF9EG

--HG--
extra : rebase_source : 7235b3802f25bab29a8c6ba40a181a722f3df0ce
2017-07-06 14:00:35 +02:00
Nicholas Nethercote
3e439bb4f8 Bug 1376638 - Minimize uses of prmem.h. r=glandium.
It's silly to use prmem.h within Firefox code given that in our configuration
its functions are just wrappers for malloc() et al. (Indeed, in some places we
mix PR_Malloc() with free(), or malloc() with PR_Free().)

This patch removes all uses, except for the places where we need to use
PR_Free() to free something allocated by another NSPR function; in those cases
I've added a comment explaining which function did the allocation.

--HG--
extra : rebase_source : 0f781bca68b5bf3c4c191e09e277dfc8becffa09
2017-06-30 19:05:41 -07:00
Ehsan Akhgari
8e07c31301 Bug 1376472 - Annotate likely branches in nsTSubstring_CharT::StripTaggedASCII(); r=froydnj 2017-06-27 18:18:31 -04:00
Ehsan Akhgari
cb111ebec5 Bug 1376323 - Unroll the loop in nsTSubstring_CharT::StripTaggedASCII() in order to speed up StripCRLF(); r=froydnj 2017-06-27 01:56:57 -04:00
Nicholas Nethercote
f1364a75ea Bug 1374580 (part 3) - Remove ns{,C}Substring typedefs. r=froydnj.
All the instances are converted as follows.

- nsSubstring  --> nsAString
- nsCSubstring --> nsACString

--HG--
extra : rebase_source : cfd2238c52e3cb4d13e3bd5ddb80ba6584ab6d91
2017-06-20 19:19:52 +10:00
Nicholas Nethercote
fe9268c4cd Bug 1374580 (part 2) - Remove nsAFlat{,C}String typedefs. r=froydnj.
All the instances are converted as follows.

- nsAFlatString  --> nsString
- nsAFlatCString --> nsCString

--HG--
extra : rebase_source : b37350642c58a85a08363df2e7c610873faa6e41
2017-06-20 19:19:05 +10:00
Nicholas Nethercote
1572f96f5d Bug 1374580 (part 1) - Remove nsASingleFragment{,C}String typedefs. r=froydnj.
All the instances are converted as follows.

- nsASingleFragmentString  --> nsAString
- nsASingleFragmentCString --> nsACString

--HG--
extra : rebase_source : e6a1ddc8938fecd9a735b15e872c054edf4c7910
2017-06-20 19:18:17 +10:00
Eric Rahm
ab9516d40d Bug 1353593 - Part 2: Remove wwc functions. r=froydnj
This removes the use of |wwc| functions in favor of char16ptr_t's implicit
conversion operators.

MozReview-Commit-ID: GHONYieMPla
2017-06-12 16:20:49 -07:00
Milan Sreckovic
831111d1d7 Bug 1361724: Remove unused offset parameter from StripChar, StripChars, StripTaggedASCII, StripCRLF. r=froydnj
MozReview-Commit-ID: 3MV5TFMxGjn

--HG--
extra : rebase_source : de7ee1fd36e1b18427c67d9ac6e98f50f780a498
2017-05-17 13:49:52 -04:00
Nathan Froyd
e75f6bd810 Bug 1353755 - remove nsCharTraits::assign; r=erahm
We don't need the tiny helper function for single-character assignment,
and the multi-argument assign() method is the only thing that uses it,
which is also itself unused.  So remove them both.
2017-05-22 09:23:09 -04:00
Eric Rahm
e449ec82f3 Bug 1356025 - Add Capacity checks to nsTSubstring constructor. r=froydnj
MozReview-Commit-ID: 6RIwuvalcRz
2017-05-15 16:52:43 -07:00
Milan Sreckovic
f6ada26ae2 Bug 1358297: Part 4. Optimize Strip/CompressWhitespace as a special case using ASCIIMask. r=froydnj
MozReview-Commit-ID: 2RVV3rPqOhl

--HG--
extra : rebase_source : 4ea81a961124b8a273472ba70cb333d1527cba9d
2017-05-10 13:12:42 -04:00
Milan Sreckovic
725d1c193f Bug 1358297: Part 3. Create special case for stripping CR and LF on TSubstring, and use it in all the places that it is called. Use ASCIIMask to make it fast. r=froydnj
MozReview-Commit-ID: 5ugh3Ma0OtH

--HG--
extra : rebase_source : 956a7a0535c3b7433fadfa65d0cfc26d9915f61a
2017-05-10 13:12:36 -04:00
Milan Sreckovic
40b6fdfb4b Bug 1358297: Part 2. Helper class to mask ascii characters, letting us do a faster test for membership in a string/character set. r=froydnj
MozReview-Commit-ID: 1s3mYNVThoD

--HG--
extra : rebase_source : d9c845addaa4a7a326b787a99f5cc83abb567848
2017-05-10 13:12:30 -04:00
Tom Tromey
aa6e054b71 Bug 1334279 - mark vsprintf-likes with MOZ_FORMAT_PRINTF; r=froydnj
This annotates vsprintf-like functions with MOZ_FORMAT_PRINTF.  This may
provide some minimal checking of such calls (the GCC docs say that it
checks for the string for "consistency"); but in any case shouldn't
hurt.

MozReview-Commit-ID: HgnAK1LiorE

--HG--
extra : rebase_source : 9c8d715d6560f89078c26ba3934e52a2b5778b6a
2017-05-04 12:10:19 -06:00
Nathan Froyd
f6465f98b9 Bug 1362194 - part 1 - add a fallible CopyASCIItoUTF16 function; r=mccr8
We already have all the machinery to expose a function like this, we
just need to write it.
2017-05-05 11:33:36 -04:00
Henri Sivonen
778981d9cc Bug 1359353 - Make the backing buffers of XPCOM strings available as mutable slices. r=mystor.
MozReview-Commit-ID: KeJ2Qb3R5ET

--HG--
extra : rebase_source : 175a6dcac973d72a167a4e0e8d6d7e3c695203c8
2017-04-25 13:17:48 +03:00