summaryrefslogtreecommitdiffstats
path: root/xpcom/string/nsTSubstring.h
diff options
context:
space:
mode:
authorathenian200 <athenian200@outlook.com>2019-10-01 07:26:40 -0500
committerathenian200 <athenian200@outlook.com>2019-10-21 04:53:39 -0500
commit64e03d0149bed895d00e20e71da775e2aabf2f81 (patch)
tree0aebdd9ccee38be173e066472ff83668b09fae73 /xpcom/string/nsTSubstring.h
parent9d449ce614ef70479228dd119f6361624d4a6b88 (diff)
downloadUXP-64e03d0149bed895d00e20e71da775e2aabf2f81.tar
UXP-64e03d0149bed895d00e20e71da775e2aabf2f81.tar.gz
UXP-64e03d0149bed895d00e20e71da775e2aabf2f81.tar.lz
UXP-64e03d0149bed895d00e20e71da775e2aabf2f81.tar.xz
UXP-64e03d0149bed895d00e20e71da775e2aabf2f81.zip
MoonchildProductions#1251 - Part 3: Finally end the long tradition of casting getpid() to int.
https://bugzilla.mozilla.org/show_bug.cgi?id=535106 https://bugzilla.mozilla.org/show_bug.cgi?id=1359841 Like many parts of the busted Solaris support, this one has its origins in the pre-Firefox days. Bug 535106, another Mozilla suite bug. It keeps coming up because the core issue is never addressed, the fact that nsTSubstring doesn't know how to handle pid_t. I think the explicit cast to int is a band-aid they use because they know if they touch that substring header file to make it handle pid_t, they'll probably be asked to fix all the other problems with it. I honestly think it just works by accident on other platforms because it's implicitly cast to signed or unsigned int, even though the POSIX standard says pid_t can be either long or int, and work as either a signed or unsigned integer. Whatever the case may be, it's handled better on Solaris now than it was. Ironically enough, the main point of having pid_t rather than just having pids be int or something is to hide this little implementation detail so you can just use pid_t for the return type in portable code without having to worry about what it is on a specific platform. The unfortunate way Mozilla implemented string functions turns that on its head and makes the good things about pid_t into liabilities rather than assets.
Diffstat (limited to 'xpcom/string/nsTSubstring.h')
-rw-r--r--xpcom/string/nsTSubstring.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/xpcom/string/nsTSubstring.h b/xpcom/string/nsTSubstring.h
index 53b4fb9a8..2b0723c04 100644
--- a/xpcom/string/nsTSubstring.h
+++ b/xpcom/string/nsTSubstring.h
@@ -9,6 +9,9 @@
#include "mozilla/MemoryReporting.h"
#include "mozilla/IntegerTypeTraits.h"
#include "mozilla/Span.h"
+#ifdef XP_SOLARIS
+#include <unistd.h>
+#endif
#ifndef MOZILLA_INTERNAL_API
#error Cannot use internal string classes without MOZILLA_INTERNAL_API defined. Use the frozen header nsStringAPI.h instead.
@@ -587,6 +590,17 @@ public:
const char* fmt = aRadix == 10 ? "%d" : aRadix == 8 ? "%o" : "%x";
AppendPrintf(fmt, aInteger);
}
+#ifdef XP_SOLARIS
+ void AppendInt(pid_t aInteger)
+ {
+ AppendPrintf("%lu", aInteger);
+ }
+ void AppendInt(pid_t aInteger, int aRadix)
+ {
+ const char* fmt = aRadix == 10 ? "%lu" : aRadix == 8 ? "%lo" : "%lx";
+ AppendPrintf(fmt, aInteger);
+ }
+#endif
void AppendInt(uint32_t aInteger)
{
AppendPrintf("%u", aInteger);