* 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 {
+21 -3
View File
@@ -1,5 +1,5 @@
#ifndef _B_GENERIC_NUMBER_FORMAT_H_
#define _B_GENERIC_NUMBER_FORMAT_H_
#ifndef _B_GENERIC_NUMBER_FORMAT_H_
#define _B_GENERIC_NUMBER_FORMAT_H_
#include <FloatFormatParameters.h>
#include <IntegerFormatParameters.h>
@@ -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,
@@ -157,4 +175,4 @@ class BGenericNumberFormat {
SignSymbols *fExponentSignSymbols;
};
#endif // _B_GENERIC_NUMBER_FORMAT_H_
#endif // _B_GENERIC_NUMBER_FORMAT_H_
+21 -21
View File
@@ -1,4 +1,4 @@
/*
/*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
@@ -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);
@@ -105,7 +105,7 @@ FrenchCollator::CompareSecondary(compare_context &context)
}
status_t
status_t
FrenchCollator::GetSortKey(const char *string, BString *key, int8 strength,
bool ignorePunctuation)
{
@@ -187,7 +187,7 @@ FrenchCollator::GetSortKey(const char *string, BString *key, int8 strength,
}
int
int
FrenchCollator::Compare(const char *a, const char *b, int32 length, int8 strength,
bool ignorePunctuation)
{
@@ -238,7 +238,7 @@ FrenchCollator::Compare(const char *a, const char *b, int32 length, int8 strengt
}
status_t
status_t
FrenchCollator::Archive(BMessage *archive, bool deep) const
{
status_t status = BArchivable::Archive(archive, deep);
+47 -47
View File
@@ -42,7 +42,7 @@ extern "C" uint32 adler32(uint32 adler, const uint8 *buf, uint32 len);
/*
* CatKey
*/
size_t hash<CatKey>::operator()(const CatKey &key) const
size_t hash<CatKey>::operator()(const CatKey &key) const
{
return key.fHashVal;
}
@@ -98,10 +98,10 @@ CatKey::CatKey()
}
bool
bool
CatKey::operator== (const CatKey& right) const
{
// Two keys are equal if their hashval and key (string,context,comment)
// Two keys are equal if their hashval and key (string,context,comment)
// are equal:
return fHashVal == right.fHashVal
&& fKey == right.fKey;
@@ -140,26 +140,26 @@ CatKey::GetStringParts(BString* str, BString* ctx, BString* cmt) const
}
size_t CatKey::HashFun(const char* s) {
unsigned long h = 0;
for ( ; *s; ++s)
h = 5*h + *s;
size_t CatKey::HashFun(const char* s) {
unsigned long h = 0;
for ( ; *s; ++s)
h = 5*h + *s;
return size_t(h);
return size_t(h);
}
static const char *kCatFolder = "catalogs";
static const char *kCatExtension = ".catalog";
const char *DefaultCatalog::kCatMimeType
const char *DefaultCatalog::kCatMimeType
= "locale/x-vnd.Be.locale-catalog.default";
static int16 kCatArchiveVersion = 1;
// version of the catalog archive structure, bump this if you change it!
/*
/*
* constructs a DefaultCatalog with given signature and language and reads
* the catalog from disk.
* InitCheck() will be B_OK if catalog could be loaded successfully, it will
@@ -178,9 +178,9 @@ DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
nref.node = appInfo.ref.directory;
BDirectory appDir(&nref);
BString catalogName("locale/");
catalogName << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
catalogName << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
BPath catalogPath(&appDir, catalogName.String());
status_t status = ReadFromFile(catalogPath.Path());
@@ -190,10 +190,10 @@ DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
BPath commonEtcPath;
find_directory(B_COMMON_ETC_DIRECTORY, &commonEtcPath);
if (commonEtcPath.InitCheck() == B_OK) {
catalogName = BString(commonEtcPath.Path())
<< "/locale/" << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
catalogName = BString(commonEtcPath.Path())
<< "/locale/" << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
status = ReadFromFile(catalogName.String());
}
@@ -204,9 +204,9 @@ DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
BPath systemEtcPath;
find_directory(B_BEOS_ETC_DIRECTORY, &systemEtcPath);
if (systemEtcPath.InitCheck() == B_OK) {
catalogName = BString(systemEtcPath.Path())
<< "/locale/" << kCatFolder
<< "/" << fSignature
catalogName = BString(systemEtcPath.Path())
<< "/locale/" << kCatFolder
<< "/" << fSignature
<< "/" << fLanguageName
<< kCatExtension;
status = ReadFromFile(catalogName.String());
@@ -214,7 +214,7 @@ DefaultCatalog::DefaultCatalog(const char *signature, const char *language,
}
fInitCheck = status;
log_team(LOG_DEBUG,
log_team(LOG_DEBUG,
"trying to load default-catalog(sig=%s, lang=%s) results in %s",
signature, language, strerror(fInitCheck));
}
@@ -231,7 +231,7 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
BCatalogAddOn("", "", 0)
{
fInitCheck = ReadFromResource(appOrAddOnRef);
log_team(LOG_DEBUG,
log_team(LOG_DEBUG,
"trying to load embedded catalog from resources results in %s",
strerror(fInitCheck));
}
@@ -242,7 +242,7 @@ DefaultCatalog::DefaultCatalog(entry_ref *appOrAddOnRef)
* This is used for editing/testing purposes.
* InitCheck() will always be B_OK.
*/
DefaultCatalog::DefaultCatalog(const char *path, const char *signature,
DefaultCatalog::DefaultCatalog(const char *path, const char *signature,
const char *language)
:
BCatalogAddOn(signature, language, 0),
@@ -279,7 +279,7 @@ DefaultCatalog::ReadFromFile(const char *path)
log_team(LOG_ERR, "couldn't get size for catalog-file %s", path);
return res;
}
auto_ptr<char> buf(new char [sz]);
res = catalogFile.Read(buf.get(), sz);
if (res < B_OK) {
@@ -287,7 +287,7 @@ DefaultCatalog::ReadFromFile(const char *path)
return res;
}
if (res < sz) {
log_team(LOG_ERR, "only got %lu instead of %Lu bytes from catalog-file %s",
log_team(LOG_ERR, "only got %lu instead of %Lu bytes from catalog-file %s",
res, sz, path);
return res;
}
@@ -295,8 +295,8 @@ DefaultCatalog::ReadFromFile(const char *path)
res = Unflatten(&memIO);
if (res == B_OK) {
// some information living in member variables needs to be copied
// to attributes. Although these attributes should have been written
// some information living in member variables needs to be copied
// to attributes. Although these attributes should have been written
// when creating the catalog, we make sure that they exist there:
UpdateAttributes(catalogFile);
}
@@ -315,14 +315,14 @@ DefaultCatalog::ReadFromAttribute(entry_ref *appOrAddOnRef)
status_t res = node.SetTo(appOrAddOnRef);
if (res != B_OK) {
log_team(LOG_ERR, "couldn't find app or add-on (dev=%lu, dir=%Lu, name=%s)",
appOrAddOnRef->device, appOrAddOnRef->directory,
appOrAddOnRef->device, appOrAddOnRef->directory,
appOrAddOnRef->name);
return B_ENTRY_NOT_FOUND;
}
log_team(LOG_DEBUG,
log_team(LOG_DEBUG,
"looking for embedded catalog-attribute in app/add-on"
"(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef->device,
"(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef->device,
appOrAddOnRef->directory, appOrAddOnRef->name);
attr_info attrInfo;
@@ -360,14 +360,14 @@ DefaultCatalog::ReadFromResource(entry_ref *appOrAddOnRef)
status_t res = file.SetTo(appOrAddOnRef, B_READ_ONLY);
if (res != B_OK) {
log_team(LOG_ERR, "couldn't find app or add-on (dev=%lu, dir=%Lu, name=%s)",
appOrAddOnRef->device, appOrAddOnRef->directory,
appOrAddOnRef->device, appOrAddOnRef->directory,
appOrAddOnRef->name);
return B_ENTRY_NOT_FOUND;
}
log_team(LOG_DEBUG,
log_team(LOG_DEBUG,
"looking for embedded catalog-resource in app/add-on"
"(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef->device,
"(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef->device,
appOrAddOnRef->directory, appOrAddOnRef->name);
BResources rsrc;
@@ -378,7 +378,7 @@ DefaultCatalog::ReadFromResource(entry_ref *appOrAddOnRef)
}
size_t sz;
const void *buf = rsrc.LoadResource(B_MESSAGE_TYPE,
const void *buf = rsrc.LoadResource(B_MESSAGE_TYPE,
BLocaleRoster::kEmbeddedCatResId, &sz);
if (!buf) {
log_team(LOG_DEBUG, "file has no catalog-resource");
@@ -416,11 +416,11 @@ DefaultCatalog::WriteToFile(const char *path)
// set mimetype-, language- and signature-attributes:
UpdateAttributes(catalogFile);
// finally write fingerprint:
catalogFile.WriteAttr(BLocaleRoster::kCatFingerprintAttr, B_INT32_TYPE,
catalogFile.WriteAttr(BLocaleRoster::kCatFingerprintAttr, B_INT32_TYPE,
0, &fFingerprint, sizeof(int32));
}
if (res == B_OK)
UpdateAttributes(catalogFile);
UpdateAttributes(catalogFile);
return res;
}
@@ -435,7 +435,7 @@ DefaultCatalog::WriteToAttribute(entry_ref *appOrAddOnRef)
status_t res = node.SetTo(appOrAddOnRef);
if (res != B_OK)
return res;
BMallocIO mallocIO;
mallocIO.SetBlockSize(max(fCatMap.size()*20, 256UL));
// set a largish block-size in order to avoid reallocs
@@ -495,7 +495,7 @@ DefaultCatalog::CountItems() const
const char *
DefaultCatalog::GetString(const char *string, const char *context,
DefaultCatalog::GetString(const char *string, const char *context,
const char *comment)
{
CatKey key(string, context, comment);
@@ -523,7 +523,7 @@ DefaultCatalog::GetString(const CatKey& key)
status_t
DefaultCatalog::SetString(const char *string, const char *translated,
DefaultCatalog::SetString(const char *string, const char *translated,
const char *context, const char *comment)
{
CatKey key(string, context, comment);
@@ -590,19 +590,19 @@ DefaultCatalog::UpdateAttributes(BFile& catalogFile)
char buf[bufSize];
if (catalogFile.ReadAttr("BEOS:TYPE", B_MIME_STRING_TYPE, 0, &buf, bufSize) <= 0
|| strcmp(kCatMimeType, buf) != 0) {
catalogFile.WriteAttr("BEOS:TYPE", B_MIME_STRING_TYPE, 0,
catalogFile.WriteAttr("BEOS:TYPE", B_MIME_STRING_TYPE, 0,
kCatMimeType, strlen(kCatMimeType)+1);
}
if (catalogFile.ReadAttr(BLocaleRoster::kCatLangAttr, B_STRING_TYPE, 0,
if (catalogFile.ReadAttr(BLocaleRoster::kCatLangAttr, B_STRING_TYPE, 0,
&buf, bufSize) <= 0
|| fLanguageName != buf) {
catalogFile.WriteAttr(BLocaleRoster::kCatLangAttr, B_STRING_TYPE, 0,
catalogFile.WriteAttr(BLocaleRoster::kCatLangAttr, B_STRING_TYPE, 0,
fLanguageName.String(), fLanguageName.Length()+1);
}
if (catalogFile.ReadAttr(BLocaleRoster::kCatSigAttr, B_STRING_TYPE, 0,
if (catalogFile.ReadAttr(BLocaleRoster::kCatSigAttr, B_STRING_TYPE, 0,
&buf, bufSize) <= 0
|| fSignature != buf) {
catalogFile.WriteAttr(BLocaleRoster::kCatSigAttr, B_STRING_TYPE, 0,
catalogFile.WriteAttr(BLocaleRoster::kCatSigAttr, B_STRING_TYPE, 0,
fSignature.String(), fSignature.Length()+1);
}
}
@@ -647,7 +647,7 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
int16 version;
BMessage archiveMsg;
status_t res = archiveMsg.Unflatten(dataIO);
if (res == B_OK) {
res = archiveMsg.FindInt16("c:ver", &version)
|| archiveMsg.FindInt32("c:sz", &count);
@@ -660,7 +660,7 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
// if a specific fingerprint has been requested and the catalog does in fact
// have a fingerprint, both are compared. If they mismatch, we do not accept
// this catalog:
if (foundFingerprint != 0 && fFingerprint != 0
if (foundFingerprint != 0 && fFingerprint != 0
&& foundFingerprint != fFingerprint) {
log_team(LOG_INFO, "default-catalog(sig=%s, lang=%s) "
"has mismatching fingerprint (%ld instead of the requested %ld), "
@@ -706,7 +706,7 @@ DefaultCatalog::Unflatten(BDataIO *dataIO)
BCatalogAddOn *
DefaultCatalog::Instantiate(const char *signature, const char *language,
DefaultCatalog::Instantiate(const char *signature, const char *language,
int32 fingerprint)
{
DefaultCatalog *catalog = new DefaultCatalog(signature, language, fingerprint);
+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,
+11 -11
View File
@@ -1,4 +1,4 @@
/*
/*
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
@@ -15,12 +15,12 @@
#include <ctype.h>
static char *gBuiltInStrings[] = {
static const char *gBuiltInStrings[] = {
"Yesterday",
"Today",
"Tomorrow",
"Future",
"Sunday",
"Monday",
"Tuesday",
@@ -28,7 +28,7 @@ static char *gBuiltInStrings[] = {
"Thursday",
"Friday",
"Saturday",
"Sun",
"Mon",
"Tue",
@@ -36,7 +36,7 @@ static char *gBuiltInStrings[] = {
"Thu",
"Fri",
"Sat",
"January",
"February",
"March",
@@ -49,7 +49,7 @@ static char *gBuiltInStrings[] = {
"October",
"November",
"December",
"Jan",
"Feb",
"Mar",
@@ -62,7 +62,7 @@ static char *gBuiltInStrings[] = {
"Oct",
"Nov",
"Dec",
"^[yY]",
"^[nN]",
"yes",
@@ -130,7 +130,7 @@ BLanguage::BLanguage(const char *language)
break;
*family++ = '\0';
// set the direction of writing
// set the direction of writing
char *direction = strchr(family, ',');
if (direction != NULL) {
*direction++ = '\0';
@@ -158,7 +158,7 @@ BLanguage::BLanguage(const char *language)
if (string == NULL)
continue;
fStrings[count++] = string;
fStrings[count++] = string;
}
}
@@ -171,7 +171,7 @@ BLanguage::BLanguage(const char *language)
BLanguage::~BLanguage()
{
if (fName != NULL)
if (fName != NULL)
free(fName);
if (fCode != NULL)
free(fCode);
@@ -198,7 +198,7 @@ BLanguage::Default()
}
uint8
uint8
BLanguage::Direction() const
{
return fDirection;
+3 -3
View File
@@ -1,4 +1,4 @@
/*
/*
** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
@@ -14,7 +14,7 @@ nl_langinfo(nl_item id)
if (be_locale != NULL)
be_locale->GetString(id);
// ToDo: return default values!
return "";
// ToDo: return default values!
return (char*)"";
}
+13 -13
View File
@@ -1,4 +1,4 @@
/*
/*
** Copyright 2003, Oliver Tappe, zooey@hirschkaefer.de. All rights reserved.
** Distributed under the terms of the OpenBeOS License.
*/
@@ -27,8 +27,8 @@ class CatalogTest {
#define catSig "x-vnd.Be.locale.catalogTest"
#define catName catSig".catalog"
void
CatalogTest::Run()
void
CatalogTest::Run()
{
printf("app...");
status_t res;
@@ -46,12 +46,12 @@ CatalogTest::Run()
res = cata.SetString("string", "Schnur", TR_CONTEXT);
assert(res == B_OK);
res = cata.SetString(hashVal, "Schnur_id");
// add a second entry for the same hash-value, but with different
// add a second entry for the same hash-value, but with different
// translation
assert(res == B_OK);
res = cata.SetString("string", "String", "programming");
assert(res == B_OK);
res = cata.SetString("string", "Textpuffer", "programming",
res = cata.SetString("string", "Textpuffer", "programming",
"Deutsches Fachbuch");
assert(res == B_OK);
res = cata.SetString("string", "Leine", TR_CONTEXT, "Deutsches Fachbuch");
@@ -80,7 +80,7 @@ CatalogTest::Run()
// the following id is unique to the embedded catalog:
res = catb.SetString(32, "hashed string");
assert(res == B_OK);
// the following string will be hidden by the definition inside the
// the following string will be hidden by the definition inside the
// german catalog:
res = catb.SetString("string", "hidden", TR_CONTEXT);
assert(res == B_OK);
@@ -96,8 +96,8 @@ CatalogTest::Run()
}
void
CatalogTest::Check()
void
CatalogTest::Check()
{
status_t res;
printf("app-check...");
@@ -106,13 +106,13 @@ CatalogTest::Check()
size_t hashVal = CatKey::HashFun(s.String());
// ok, we now try to re-load the catalog that has just been written:
//
// actually, the following code can be seen as an example of what an
// actually, the following code can be seen as an example of what an
// app needs in order to translate strings:
BCatalog cat;
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;
@@ -140,7 +140,7 @@ CatalogTest::Check()
// the following id doesn't exist anywhere (hopefully):
s = TR_ID(-1);
assert(s == "");
// the following string exists twice, in the embedded as well as in the
// the following string exists twice, in the embedded as well as in the
// external catalog. So we should get the external translation (as it should
// override the embedded one):
s = TR("string");
@@ -163,9 +163,9 @@ CatalogTest::Check()
int
main(int argc, char **argv)
{
BApplication* testApp
BApplication* testApp
= new BApplication("application/"catSig);
// change to app-folder:
app_info appInfo;
be_app->GetAppInfo(&appInfo);
+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;