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