* applied several fixes to make locale kit buildable with gcc4, too

* actually, all those fixes were already contained in PulkoMandys patch,
  but I just missed that :-/


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30566 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Tappe
2009-05-02 13:44:35 +00:00
parent 5c3441b4a2
commit 3a268d9080
9 changed files with 199 additions and 149 deletions
+18 -1
View File
@@ -4,16 +4,21 @@
#ifdef __MWERKS__
# include <hashmap.h>
#else
# if __GNUC__ > 2
# include <ext/hash_map>
# else
# include <hash_map>
# endif
#endif
#include <assert.h>
#include <Catalog.h>
#include <DataIO.h>
#include <String.h>
class BFile;
namespace BPrivate {
struct CatKey;
}
@@ -29,10 +34,22 @@ template <class T> struct hash : public unary_function<T,size_t> {
};
#endif
#if __GNUC__ > 2
namespace __gnu_cxx {
#endif // __GNUC__ > 2
template<>
struct hash<BPrivate::CatKey> {
size_t operator() (const BPrivate::CatKey &key) const;
};
#if __GNUC__ > 2
} // namespace __gnu_cxx
using namespace __gnu_cxx;
#endif // __GNUC__ > 2
using namespace std;
namespace BPrivate {
+18
View File
@@ -116,6 +116,24 @@ class BGenericNumberFormat {
void Unset() { SetTo(NULL); }
};
static const Symbol kDefaultDigitSymbols[];
static const Symbol kDefaultFractionSeparator;
static const Symbol kDefaultExponentSymbol;
static const Symbol kDefaultUpperCaseExponentSymbol;
static const Symbol kDefaultNaNSymbol;
static const Symbol kDefaultUpperCaseNaNSymbol;
static const Symbol kDefaultInfinitySymbol;
static const Symbol kDefaultUpperCaseInfinitySymbol;
static const Symbol kDefaultNegativeInfinitySymbol;
static const Symbol kDefaultUpperCaseNegativeInfinitySymbol;
static const GroupingInfo kDefaultGroupingInfo;
static const GroupingInfo kNoGroupingInfo;
static const SignSymbols kDefaultSignSymbols;
static const SignSymbols kDefaultMantissaSignSymbols;
static const SignSymbols kDefaultExponentSignSymbols;
status_t FormatInteger(const BIntegerFormatParameters *parameters,
const Integer &integer, char *buffer,
size_t bufferSize,
+17 -17
View File
@@ -12,24 +12,24 @@
#include <ctype.h>
struct compare_context {
compare_context(bool ignorePunctuation)
:
inputA(ignorePunctuation),
inputB(ignorePunctuation)
{
}
typedef BCollatorAddOn::input_context input_context;
const char *a;
const char *b;
input_context inputA;
input_context inputB;
size_t length;
};
class FrenchCollator : public BCollatorAddOn {
struct compare_context {
compare_context(bool ignorePunctuation)
:
inputA(ignorePunctuation),
inputB(ignorePunctuation)
{
}
typedef BCollatorAddOn::input_context input_context;
const char *a;
const char *b;
input_context inputA;
input_context inputB;
size_t length;
};
public:
FrenchCollator();
FrenchCollator(BMessage *archive);
+61 -46
View File
@@ -8,6 +8,8 @@
#include <String.h>
#include <UnicodeChar.h>
using namespace std;
// constants (more below the helper classes)
static const int kMaxIntDigitCount = 20; // int64: 19 + sign, uint64: 20
@@ -98,7 +100,8 @@ class BGenericNumberFormat::GroupingInfo {
// unset old
Unset();
// set new
if (!separators && separatorCount <= 0 || !sizes && sizeCount <= 0)
if ((!separators && separatorCount <= 0)
|| (!sizes && sizeCount <= 0))
return B_OK;
// allocate arrays
fSeparators = new(nothrow) Symbol[separatorCount];
@@ -157,8 +160,8 @@ class BGenericNumberFormat::GroupingInfo {
for (int i = fSizeCount - 1; i >= 0; i--) {
if (fSumSizes[i] <= position) {
if (fSumSizes[i] == position
|| i == fSizeCount - 1
&& (position - fSumSizes[i]) % fSizes[i] == 0) {
|| (i == fSizeCount - 1
&& (position - fSumSizes[i]) % fSizes[i] == 0)) {
return fSumSeparators[i];
}
return NULL;
@@ -407,12 +410,14 @@ class BGenericNumberFormat::BufferWriter {
// constants
// digit symbols
static const BGenericNumberFormat::Symbol kDefaultDigitSymbols[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
};
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultDigitSymbols[] = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
};
// decimal separator symbol
static const BGenericNumberFormat::Symbol kDefaultFractionSeparator = ".";
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultFractionSeparator = ".";
// grouping separator symbols
static const char *kDefaultGroupingSeparators[] = { "," };
@@ -429,53 +434,61 @@ static const size_t kNoGroupingSizes[] = { 0 }; // to please mwcc
static const int32 kNoGroupingSizeCount = 0;
// grouping info
static const BGenericNumberFormat::GroupingInfo kDefaultGroupingInfo(
kDefaultGroupingSeparators, kDefaultGroupingSeparatorCount,
kDefaultGroupingSizes, kDefaultGroupingSizeCount
);
static const BGenericNumberFormat::GroupingInfo kNoGroupingInfo(
kNoGroupingSeparators, kNoGroupingSeparatorCount,
kNoGroupingSizes, kNoGroupingSizeCount
);
const BGenericNumberFormat::GroupingInfo
BGenericNumberFormat::kDefaultGroupingInfo(
kDefaultGroupingSeparators, kDefaultGroupingSeparatorCount,
kDefaultGroupingSizes, kDefaultGroupingSizeCount
);
const BGenericNumberFormat::GroupingInfo
BGenericNumberFormat::kNoGroupingInfo(
kNoGroupingSeparators, kNoGroupingSeparatorCount,
kNoGroupingSizes, kNoGroupingSizeCount
);
// exponent symbol
static const BGenericNumberFormat::Symbol kDefaultExponentSymbol = "e";
static const BGenericNumberFormat::Symbol kDefaultUpperCaseExponentSymbol
= "E";
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultExponentSymbol = "e";
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultUpperCaseExponentSymbol = "E";
// NaN symbol
static const BGenericNumberFormat::Symbol kDefaultNaNSymbol = "NaN";
static const BGenericNumberFormat::Symbol kDefaultUpperCaseNaNSymbol = "NaN";
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultNaNSymbol = "NaN";
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultUpperCaseNaNSymbol = "NaN";
// infinity symbol
static const BGenericNumberFormat::Symbol kDefaultInfinitySymbol
= "infinity";
static const BGenericNumberFormat::Symbol kDefaultUpperCaseInfinitySymbol
= "INFINITY";
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultInfinitySymbol = "infinity";
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultUpperCaseInfinitySymbol = "INFINITY";
// negative infinity symbol
static const BGenericNumberFormat::Symbol kDefaultNegativeInfinitySymbol
= "-infinity";
static const BGenericNumberFormat::Symbol
kDefaultUpperCaseNegativeInfinitySymbol = "-INFINITY";
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultNegativeInfinitySymbol = "-infinity";
const BGenericNumberFormat::Symbol
BGenericNumberFormat::kDefaultUpperCaseNegativeInfinitySymbol = "-INFINITY";
// sign symbols
static const BGenericNumberFormat::SignSymbols kDefaultSignSymbols(
"+", "-", " ", "", // prefixes
"", "", "", "" // suffixes
);
const BGenericNumberFormat::SignSymbols
BGenericNumberFormat::kDefaultSignSymbols(
"+", "-", " ", "", // prefixes
"", "", "", "" // suffixes
);
// mantissa sign symbols
static const BGenericNumberFormat::SignSymbols kDefaultMantissaSignSymbols(
"", "", "", "", // prefixes
"", "", "", "" // suffixes
);
const BGenericNumberFormat::SignSymbols
BGenericNumberFormat::kDefaultMantissaSignSymbols(
"", "", "", "", // prefixes
"", "", "", "" // suffixes
);
// exponent sign symbols
static const BGenericNumberFormat::SignSymbols kDefaultExponentSignSymbols(
"+", "-", " ", "", // prefixes
"", "", "", "" // suffixes
);
const BGenericNumberFormat::SignSymbols
BGenericNumberFormat::kDefaultExponentSignSymbols(
"+", "-", " ", "", // prefixes
"", "", "", "" // suffixes
);
// Integer
@@ -786,7 +799,7 @@ class BGenericNumberFormat::Float {
// integer part
int32 existingIntegerDigits = min(integerDigits, digitCount);
for (int i = 0; i < existingIntegerDigits; i++)
writer.Append(digitSymbols[digits[digitCount - i - 1]]);
writer.Append(digitSymbols[(int)digits[digitCount - i - 1]]);
// pad with zeros to get the desired number of integer digits
if (existingIntegerDigits < integerDigits) {
writer.Append(digitSymbols,
@@ -801,7 +814,7 @@ class BGenericNumberFormat::Float {
int32 existingFractionDigits
= min(digitCount - integerDigits, fractionDigits);
for (int i = existingFractionDigits - 1; i >= 0; i--)
writer.Append(digitSymbols[digits[i]]);
writer.Append(digitSymbols[(int)digits[i]]);
// pad with zeros to get the desired number of fraction digits
if (fractionDigits > existingFractionDigits) {
writer.Append(digitSymbols,
@@ -888,7 +901,7 @@ class BGenericNumberFormat::Float {
for (int i = existingIntegerDigits - 1; i >= 0; i--) {
if (i != integerDigits - 1)
writer.Append(groupingInfo->SeparatorForDigit(i));
writer.Append(digitSymbols[digits[
writer.Append(digitSymbols[(int)digits[
digitCount - existingIntegerDigits + i]]);
}
} else {
@@ -899,8 +912,10 @@ class BGenericNumberFormat::Float {
integerDigits - existingIntegerDigits);
}
// write digits
for (int i = 0; i < existingIntegerDigits; i++)
writer.Append(digitSymbols[digits[digitCount - i - 1]]);
for (int i = 0; i < existingIntegerDigits; i++) {
writer.Append(
digitSymbols[(int)digits[digitCount - i - 1]]);
}
}
// fraction part
if (fractionDigits > 0 || forceFractionSeparator)
@@ -908,7 +923,7 @@ class BGenericNumberFormat::Float {
int32 existingFractionDigits
= min(digitCount - existingIntegerDigits, fractionDigits);
for (int i = existingFractionDigits - 1; i >= 0; i--)
writer.Append(digitSymbols[digits[i]]);
writer.Append(digitSymbols[(int)digits[i]]);
// pad with zeros to get the desired number of fraction digits
if (fractionDigits > existingFractionDigits) {
writer.Append(digitSymbols,
+1 -1
View File
@@ -15,7 +15,7 @@
#include <ctype.h>
static char *gBuiltInStrings[] = {
static const char *gBuiltInStrings[] = {
"Yesterday",
"Today",
"Tomorrow",
+1 -1
View File
@@ -15,6 +15,6 @@ nl_langinfo(nl_item id)
be_locale->GetString(id);
// ToDo: return default values!
return "";
return (char*)"";
}
+1 -1
View File
@@ -112,7 +112,7 @@ CatalogTest::Check()
res = be_locale->GetAppCatalog(&cat);
assert(res == B_OK);
// fetch basic data:
int32 fingerprint;
int32 fingerprint = 0;
res = cat.GetFingerprint(&fingerprint);
assert(res == B_OK);
BString lang;
+4 -4
View File
@@ -31,7 +31,7 @@ main()
BUnicodeChar::IsUpper(i), BUnicodeChar::IsDefined(i), BUnicodeChar::Type(i));
}
uint32 chars[] = {(uint8)'ä', (uint8)'Ö', (uint8)'ß', (uint8)'č', (uint8)'á', (uint8)'é', 0};
uint32 chars[] = {(uint8)'', (uint8)'', (uint8)'', (uint8)'', (uint8)'', (uint8)'', 0};
for (int32 j = 0, i; (i = chars[j]) != 0; j++) {
unicode_char_to_string(i, text);
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, defined == %d, charType == %d\n",
@@ -45,7 +45,7 @@ main()
printf("toLower == %s\n", text);
}
char *utf8chars[] = {"à", "ß", "ñ", "é", "ç", "ä", NULL};
const char *utf8chars[] = {"à", "ß", "ñ", "é", "ç", "ä", NULL};
for (int32 j = 0, i; (i = BUnicodeChar::FromUTF8(utf8chars[j])) != 0; j++) {
unicode_char_to_string(i, text);
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, defined == %d, charType == %d\n",
@@ -63,9 +63,9 @@ main()
// Test BCollator class
BCollator *collator = be_locale->Collator();
char *strings[] = {"gehen", "géhen", "aus", "äUß", "auss", "äUß", "WO",
const char *strings[] = {"gehen", "géhen", "aus", "äUß", "auss", "äUß", "WO",
"", "SO", "so", "açñ", "acn", NULL};
char *strengths[] = {"primary: ", "secondary:", "tertiary: "};
const char *strengths[] = {"primary: ", "secondary:", "tertiary: "};
for (int32 i = 0; strings[i]; i += 2) {
for (int32 strength = B_COLLATE_PRIMARY; strength < 4; strength++) {
BString a, b;