* 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:
@@ -4,16 +4,21 @@
|
|||||||
#ifdef __MWERKS__
|
#ifdef __MWERKS__
|
||||||
# include <hashmap.h>
|
# include <hashmap.h>
|
||||||
#else
|
#else
|
||||||
|
# if __GNUC__ > 2
|
||||||
|
# include <ext/hash_map>
|
||||||
|
# else
|
||||||
# include <hash_map>
|
# include <hash_map>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
class BFile;
|
class BFile;
|
||||||
|
|
||||||
|
|
||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
struct CatKey;
|
struct CatKey;
|
||||||
}
|
}
|
||||||
@@ -29,10 +34,22 @@ template <class T> struct hash : public unary_function<T,size_t> {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if __GNUC__ > 2
|
||||||
|
namespace __gnu_cxx {
|
||||||
|
#endif // __GNUC__ > 2
|
||||||
|
|
||||||
|
template<>
|
||||||
struct hash<BPrivate::CatKey> {
|
struct hash<BPrivate::CatKey> {
|
||||||
size_t operator() (const BPrivate::CatKey &key) const;
|
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 {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,24 @@ class BGenericNumberFormat {
|
|||||||
void Unset() { SetTo(NULL); }
|
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,
|
status_t FormatInteger(const BIntegerFormatParameters *parameters,
|
||||||
const Integer &integer, char *buffer,
|
const Integer &integer, char *buffer,
|
||||||
size_t bufferSize,
|
size_t bufferSize,
|
||||||
|
|||||||
@@ -12,24 +12,24 @@
|
|||||||
#include <ctype.h>
|
#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 {
|
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:
|
public:
|
||||||
FrenchCollator();
|
FrenchCollator();
|
||||||
FrenchCollator(BMessage *archive);
|
FrenchCollator(BMessage *archive);
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <UnicodeChar.h>
|
#include <UnicodeChar.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
// constants (more below the helper classes)
|
// constants (more below the helper classes)
|
||||||
|
|
||||||
static const int kMaxIntDigitCount = 20; // int64: 19 + sign, uint64: 20
|
static const int kMaxIntDigitCount = 20; // int64: 19 + sign, uint64: 20
|
||||||
@@ -98,7 +100,8 @@ class BGenericNumberFormat::GroupingInfo {
|
|||||||
// unset old
|
// unset old
|
||||||
Unset();
|
Unset();
|
||||||
// set new
|
// set new
|
||||||
if (!separators && separatorCount <= 0 || !sizes && sizeCount <= 0)
|
if ((!separators && separatorCount <= 0)
|
||||||
|
|| (!sizes && sizeCount <= 0))
|
||||||
return B_OK;
|
return B_OK;
|
||||||
// allocate arrays
|
// allocate arrays
|
||||||
fSeparators = new(nothrow) Symbol[separatorCount];
|
fSeparators = new(nothrow) Symbol[separatorCount];
|
||||||
@@ -157,8 +160,8 @@ class BGenericNumberFormat::GroupingInfo {
|
|||||||
for (int i = fSizeCount - 1; i >= 0; i--) {
|
for (int i = fSizeCount - 1; i >= 0; i--) {
|
||||||
if (fSumSizes[i] <= position) {
|
if (fSumSizes[i] <= position) {
|
||||||
if (fSumSizes[i] == position
|
if (fSumSizes[i] == position
|
||||||
|| i == fSizeCount - 1
|
|| (i == fSizeCount - 1
|
||||||
&& (position - fSumSizes[i]) % fSizes[i] == 0) {
|
&& (position - fSumSizes[i]) % fSizes[i] == 0)) {
|
||||||
return fSumSeparators[i];
|
return fSumSeparators[i];
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -407,12 +410,14 @@ class BGenericNumberFormat::BufferWriter {
|
|||||||
// constants
|
// constants
|
||||||
|
|
||||||
// digit symbols
|
// digit symbols
|
||||||
static const BGenericNumberFormat::Symbol kDefaultDigitSymbols[] = {
|
const BGenericNumberFormat::Symbol
|
||||||
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
|
BGenericNumberFormat::kDefaultDigitSymbols[] = {
|
||||||
};
|
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
|
||||||
|
};
|
||||||
|
|
||||||
// decimal separator symbol
|
// decimal separator symbol
|
||||||
static const BGenericNumberFormat::Symbol kDefaultFractionSeparator = ".";
|
const BGenericNumberFormat::Symbol
|
||||||
|
BGenericNumberFormat::kDefaultFractionSeparator = ".";
|
||||||
|
|
||||||
// grouping separator symbols
|
// grouping separator symbols
|
||||||
static const char *kDefaultGroupingSeparators[] = { "," };
|
static const char *kDefaultGroupingSeparators[] = { "," };
|
||||||
@@ -429,53 +434,61 @@ static const size_t kNoGroupingSizes[] = { 0 }; // to please mwcc
|
|||||||
static const int32 kNoGroupingSizeCount = 0;
|
static const int32 kNoGroupingSizeCount = 0;
|
||||||
|
|
||||||
// grouping info
|
// grouping info
|
||||||
static const BGenericNumberFormat::GroupingInfo kDefaultGroupingInfo(
|
const BGenericNumberFormat::GroupingInfo
|
||||||
kDefaultGroupingSeparators, kDefaultGroupingSeparatorCount,
|
BGenericNumberFormat::kDefaultGroupingInfo(
|
||||||
kDefaultGroupingSizes, kDefaultGroupingSizeCount
|
kDefaultGroupingSeparators, kDefaultGroupingSeparatorCount,
|
||||||
);
|
kDefaultGroupingSizes, kDefaultGroupingSizeCount
|
||||||
static const BGenericNumberFormat::GroupingInfo kNoGroupingInfo(
|
);
|
||||||
kNoGroupingSeparators, kNoGroupingSeparatorCount,
|
const BGenericNumberFormat::GroupingInfo
|
||||||
kNoGroupingSizes, kNoGroupingSizeCount
|
BGenericNumberFormat::kNoGroupingInfo(
|
||||||
);
|
kNoGroupingSeparators, kNoGroupingSeparatorCount,
|
||||||
|
kNoGroupingSizes, kNoGroupingSizeCount
|
||||||
|
);
|
||||||
|
|
||||||
// exponent symbol
|
// exponent symbol
|
||||||
static const BGenericNumberFormat::Symbol kDefaultExponentSymbol = "e";
|
const BGenericNumberFormat::Symbol
|
||||||
static const BGenericNumberFormat::Symbol kDefaultUpperCaseExponentSymbol
|
BGenericNumberFormat::kDefaultExponentSymbol = "e";
|
||||||
= "E";
|
const BGenericNumberFormat::Symbol
|
||||||
|
BGenericNumberFormat::kDefaultUpperCaseExponentSymbol = "E";
|
||||||
|
|
||||||
// NaN symbol
|
// NaN symbol
|
||||||
static const BGenericNumberFormat::Symbol kDefaultNaNSymbol = "NaN";
|
const BGenericNumberFormat::Symbol
|
||||||
static const BGenericNumberFormat::Symbol kDefaultUpperCaseNaNSymbol = "NaN";
|
BGenericNumberFormat::kDefaultNaNSymbol = "NaN";
|
||||||
|
const BGenericNumberFormat::Symbol
|
||||||
|
BGenericNumberFormat::kDefaultUpperCaseNaNSymbol = "NaN";
|
||||||
|
|
||||||
// infinity symbol
|
// infinity symbol
|
||||||
static const BGenericNumberFormat::Symbol kDefaultInfinitySymbol
|
const BGenericNumberFormat::Symbol
|
||||||
= "infinity";
|
BGenericNumberFormat::kDefaultInfinitySymbol = "infinity";
|
||||||
static const BGenericNumberFormat::Symbol kDefaultUpperCaseInfinitySymbol
|
const BGenericNumberFormat::Symbol
|
||||||
= "INFINITY";
|
BGenericNumberFormat::kDefaultUpperCaseInfinitySymbol = "INFINITY";
|
||||||
|
|
||||||
// negative infinity symbol
|
// negative infinity symbol
|
||||||
static const BGenericNumberFormat::Symbol kDefaultNegativeInfinitySymbol
|
const BGenericNumberFormat::Symbol
|
||||||
= "-infinity";
|
BGenericNumberFormat::kDefaultNegativeInfinitySymbol = "-infinity";
|
||||||
static const BGenericNumberFormat::Symbol
|
const BGenericNumberFormat::Symbol
|
||||||
kDefaultUpperCaseNegativeInfinitySymbol = "-INFINITY";
|
BGenericNumberFormat::kDefaultUpperCaseNegativeInfinitySymbol = "-INFINITY";
|
||||||
|
|
||||||
// sign symbols
|
// sign symbols
|
||||||
static const BGenericNumberFormat::SignSymbols kDefaultSignSymbols(
|
const BGenericNumberFormat::SignSymbols
|
||||||
"+", "-", " ", "", // prefixes
|
BGenericNumberFormat::kDefaultSignSymbols(
|
||||||
"", "", "", "" // suffixes
|
"+", "-", " ", "", // prefixes
|
||||||
);
|
"", "", "", "" // suffixes
|
||||||
|
);
|
||||||
|
|
||||||
// mantissa sign symbols
|
// mantissa sign symbols
|
||||||
static const BGenericNumberFormat::SignSymbols kDefaultMantissaSignSymbols(
|
const BGenericNumberFormat::SignSymbols
|
||||||
"", "", "", "", // prefixes
|
BGenericNumberFormat::kDefaultMantissaSignSymbols(
|
||||||
"", "", "", "" // suffixes
|
"", "", "", "", // prefixes
|
||||||
);
|
"", "", "", "" // suffixes
|
||||||
|
);
|
||||||
|
|
||||||
// exponent sign symbols
|
// exponent sign symbols
|
||||||
static const BGenericNumberFormat::SignSymbols kDefaultExponentSignSymbols(
|
const BGenericNumberFormat::SignSymbols
|
||||||
"+", "-", " ", "", // prefixes
|
BGenericNumberFormat::kDefaultExponentSignSymbols(
|
||||||
"", "", "", "" // suffixes
|
"+", "-", " ", "", // prefixes
|
||||||
);
|
"", "", "", "" // suffixes
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// Integer
|
// Integer
|
||||||
@@ -786,7 +799,7 @@ class BGenericNumberFormat::Float {
|
|||||||
// integer part
|
// integer part
|
||||||
int32 existingIntegerDigits = min(integerDigits, digitCount);
|
int32 existingIntegerDigits = min(integerDigits, digitCount);
|
||||||
for (int i = 0; i < existingIntegerDigits; i++)
|
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
|
// pad with zeros to get the desired number of integer digits
|
||||||
if (existingIntegerDigits < integerDigits) {
|
if (existingIntegerDigits < integerDigits) {
|
||||||
writer.Append(digitSymbols,
|
writer.Append(digitSymbols,
|
||||||
@@ -801,7 +814,7 @@ class BGenericNumberFormat::Float {
|
|||||||
int32 existingFractionDigits
|
int32 existingFractionDigits
|
||||||
= min(digitCount - integerDigits, fractionDigits);
|
= min(digitCount - integerDigits, fractionDigits);
|
||||||
for (int i = existingFractionDigits - 1; i >= 0; i--)
|
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
|
// pad with zeros to get the desired number of fraction digits
|
||||||
if (fractionDigits > existingFractionDigits) {
|
if (fractionDigits > existingFractionDigits) {
|
||||||
writer.Append(digitSymbols,
|
writer.Append(digitSymbols,
|
||||||
@@ -888,7 +901,7 @@ class BGenericNumberFormat::Float {
|
|||||||
for (int i = existingIntegerDigits - 1; i >= 0; i--) {
|
for (int i = existingIntegerDigits - 1; i >= 0; i--) {
|
||||||
if (i != integerDigits - 1)
|
if (i != integerDigits - 1)
|
||||||
writer.Append(groupingInfo->SeparatorForDigit(i));
|
writer.Append(groupingInfo->SeparatorForDigit(i));
|
||||||
writer.Append(digitSymbols[digits[
|
writer.Append(digitSymbols[(int)digits[
|
||||||
digitCount - existingIntegerDigits + i]]);
|
digitCount - existingIntegerDigits + i]]);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -899,8 +912,10 @@ class BGenericNumberFormat::Float {
|
|||||||
integerDigits - existingIntegerDigits);
|
integerDigits - existingIntegerDigits);
|
||||||
}
|
}
|
||||||
// write digits
|
// write digits
|
||||||
for (int i = 0; i < existingIntegerDigits; i++)
|
for (int i = 0; i < existingIntegerDigits; i++) {
|
||||||
writer.Append(digitSymbols[digits[digitCount - i - 1]]);
|
writer.Append(
|
||||||
|
digitSymbols[(int)digits[digitCount - i - 1]]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// fraction part
|
// fraction part
|
||||||
if (fractionDigits > 0 || forceFractionSeparator)
|
if (fractionDigits > 0 || forceFractionSeparator)
|
||||||
@@ -908,7 +923,7 @@ class BGenericNumberFormat::Float {
|
|||||||
int32 existingFractionDigits
|
int32 existingFractionDigits
|
||||||
= min(digitCount - existingIntegerDigits, fractionDigits);
|
= min(digitCount - existingIntegerDigits, fractionDigits);
|
||||||
for (int i = existingFractionDigits - 1; i >= 0; i--)
|
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
|
// pad with zeros to get the desired number of fraction digits
|
||||||
if (fractionDigits > existingFractionDigits) {
|
if (fractionDigits > existingFractionDigits) {
|
||||||
writer.Append(digitSymbols,
|
writer.Append(digitSymbols,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
|
||||||
static char *gBuiltInStrings[] = {
|
static const char *gBuiltInStrings[] = {
|
||||||
"Yesterday",
|
"Yesterday",
|
||||||
"Today",
|
"Today",
|
||||||
"Tomorrow",
|
"Tomorrow",
|
||||||
|
|||||||
@@ -15,6 +15,6 @@ nl_langinfo(nl_item id)
|
|||||||
be_locale->GetString(id);
|
be_locale->GetString(id);
|
||||||
|
|
||||||
// ToDo: return default values!
|
// ToDo: return default values!
|
||||||
return "";
|
return (char*)"";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ CatalogTest::Check()
|
|||||||
res = be_locale->GetAppCatalog(&cat);
|
res = be_locale->GetAppCatalog(&cat);
|
||||||
assert(res == B_OK);
|
assert(res == B_OK);
|
||||||
// fetch basic data:
|
// fetch basic data:
|
||||||
int32 fingerprint;
|
int32 fingerprint = 0;
|
||||||
res = cat.GetFingerprint(&fingerprint);
|
res = cat.GetFingerprint(&fingerprint);
|
||||||
assert(res == B_OK);
|
assert(res == B_OK);
|
||||||
BString lang;
|
BString lang;
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ main()
|
|||||||
BUnicodeChar::IsUpper(i), BUnicodeChar::IsDefined(i), BUnicodeChar::Type(i));
|
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++) {
|
for (int32 j = 0, i; (i = chars[j]) != 0; j++) {
|
||||||
unicode_char_to_string(i, text);
|
unicode_char_to_string(i, text);
|
||||||
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, defined == %d, charType == %d\n",
|
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);
|
printf("toLower == %s\n", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *utf8chars[] = {"à ", "ß", "ñ", "é", "ç", "ä", NULL};
|
const char *utf8chars[] = {"à", "ß", "ñ", "é", "ç", "ä", NULL};
|
||||||
for (int32 j = 0, i; (i = BUnicodeChar::FromUTF8(utf8chars[j])) != 0; j++) {
|
for (int32 j = 0, i; (i = BUnicodeChar::FromUTF8(utf8chars[j])) != 0; j++) {
|
||||||
unicode_char_to_string(i, text);
|
unicode_char_to_string(i, text);
|
||||||
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, defined == %d, charType == %d\n",
|
printf("%s: alpha == %d, alNum == %d, lower == %d, upper == %d, defined == %d, charType == %d\n",
|
||||||
@@ -63,9 +63,9 @@ main()
|
|||||||
// Test BCollator class
|
// Test BCollator class
|
||||||
|
|
||||||
BCollator *collator = be_locale->Collator();
|
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",
|
||||||
"wÖ", "SO", "so", "açñ", "acn", NULL};
|
"wÖ", "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 i = 0; strings[i]; i += 2) {
|
||||||
for (int32 strength = B_COLLATE_PRIMARY; strength < 4; strength++) {
|
for (int32 strength = B_COLLATE_PRIMARY; strength < 4; strength++) {
|
||||||
BString a, b;
|
BString a, b;
|
||||||
|
|||||||
Reference in New Issue
Block a user