* Remove everything related to direct access to unicode.properties file. All of it should be done through ICU.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38017 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Adrien Destugues
2010-08-11 12:00:59 +00:00
parent 4bfbfb4da5
commit 0417c0fd7e
5 changed files with 3 additions and 175 deletions
-23
View File
@@ -1,23 +0,0 @@
/*
* Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef PROPERTY_FILE_H
#define PROPERTY_FILE_H
#include <File.h>
// This is the read-only version of the PropertyFile class - the
// genprops tool contains the write-only version of it
class PropertyFile : public BFile {
public:
status_t SetTo(const char *directory, const char *name);
off_t Size();
};
#endif /* PROPERTY_FILE_H */
@@ -1,25 +0,0 @@
/*
* Copyright 2003, Axel Dörfler, [email protected]. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _UNICODE_PROPERTIES_H_
#define _UNICODE_PROPERTIES_H_
#include <SupportDefs.h>
#include <ByteOrder.h>
#define PROPERTIES_DIRECTORY "locale"
#define PROPERTIES_FILE_NAME "unicode.properties"
#define PROPERTIES_FORMAT 'UPro'
typedef struct {
uint8 size;
uint8 isBigEndian;
uint32 format;
uint8 version[3];
} UnicodePropertiesHeader;
#endif /* _UNICODE_PROPERTIES_H_ */
-3
View File
@@ -30,9 +30,6 @@ local sources =
Format.cpp # Used by some of the above.
UnicodeChar.cpp # Already used in ReadOnlyBootPrompt.
# Should go away
PropertyFile.cpp # Used by UnicodeChar which should rely on ICU instead
# old, needs investigation
# Currency.cpp
# FloatFormat.cpp
-49
View File
@@ -1,49 +0,0 @@
/*
* Copyright 2003-2009, Axel Dörfler, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "PropertyFile.h"
#include "UnicodeProperties.h"
#include <Path.h>
#include <FindDirectory.h>
status_t
PropertyFile::SetTo(const char *directory, const char *name)
{
BPath path;
status_t status = find_directory(B_BEOS_DATA_DIRECTORY, &path);
if (status != B_OK)
return status;
path.Append(directory);
path.Append(name);
status = BFile::SetTo(path.Path(), B_READ_ONLY);
if (status < B_OK)
return status;
UnicodePropertiesHeader header;
ssize_t bytes = Read(&header, sizeof(header));
if (bytes < (ssize_t)sizeof(header)
|| header.size != (uint8)sizeof(header)
|| header.isBigEndian != B_HOST_IS_BENDIAN
|| header.format != PROPERTIES_FORMAT)
return B_BAD_DATA;
return B_OK;
}
off_t
PropertyFile::Size()
{
off_t size;
if (GetSize(&size) < B_OK)
return 0;
return size - sizeof(UnicodePropertiesHeader);
}
+3 -75
View File
@@ -22,24 +22,12 @@
#include <OS.h>
#include <UnicodeChar.h>
#include "UnicodeProperties.h"
#include "PropertyFile.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if B_BEOS_VERSION <= B_BEOS_VERSION_5 && !defined(__HAIKU__)
// B_BAD_DATA was introduced with DANO, so we define it for R5:
#define B_BAD_DATA -2147483632L
#endif
static const uint16 *sPropsTable = NULL;
#define sProps32Table ((uint32 *)sPropsTable)
static uint16 *sIndices;
static vint32 sHavePropsData = 0;
#define FLAG(n) ((uint32)1 << (n))
enum {
UF_UPPERCASE = FLAG(B_UNICODE_UPPERCASE_LETTER),
@@ -179,11 +167,7 @@ getProperties(uint32 c)
if (c > 0x10ffff)
return 0;
if (sHavePropsData > 0)
return sProps32Table[sPropsTable[
sPropsTable[sPropsTable[8 + (c >> sStage23Bits)]
+ ((c >> sStage3Bits) & sStage2Mask)]
+ (c & sStage3Mask)]];
// TODO : Data from unicode
return c > 0x9f ? 0 : gStaticProps32Table[c];
}
@@ -220,7 +204,8 @@ getSignedValue(uint32 properties)
static inline uint32 *
getExceptions(uint32 properties)
{
return sProps32Table + sIndices[INDEX_EXCEPTIONS] + getUnsignedValue(properties);
// TODO : data from unicode
return 0;
}
@@ -243,67 +228,11 @@ addExceptionOffset(uint32 &flags, int16 &index, uint32 **offset)
}
static status_t
loadPropsData()
{
PropertyFile file;
status_t status = file.SetTo(PROPERTIES_DIRECTORY, PROPERTIES_FILE_NAME);
if (status < B_OK) {
fprintf(stderr, "could not open unicode.properties file: %s\n", strerror(status));
return status;
}
off_t size = file.Size();
uint16 *table = (uint16 *)malloc(size);
if (table == NULL)
return B_NO_MEMORY;
if (file.Read(table, size) < size) {
free(table);
return B_IO_ERROR;
}
// check if the property file matches our needs
if (table[INDEX_STAGE_2_BITS] != 6 || table[INDEX_STAGE_3_BITS] != 4) {
free(table);
return B_BAD_DATA;
}
sIndices = table;
#ifdef UCHAR_VARIABLE_TRIE_BITS
sStage23Bits = uint16(sIndices[INDEX_STAGE_2_BITS] + sIndices[INDEX_STAGE_3_BITS]);
sStage2Mask = uint16((1 << sIndices[INDEX_STAGE_2_BITS]) - 1);
sStage3Mask = uint16((1 << sIndices[INDEX_STAGE_3_BITS]) - 1);
#endif
sPropsTable = table;
sHavePropsData = 1;
return B_OK;
}
// #pragma mark -
/** If the constructor is used for the first time, the property
* file gets loaded from disk.
* It makes sure that this will only happen once throughout the
* application's lifetime.
*/
BUnicodeChar::BUnicodeChar()
{
static int32 lock = 0;
if (atomic_add(&lock, 1) > 0) {
while (sHavePropsData == 0)
snooze(10000);
return;
}
if (loadPropsData() < B_OK)
sHavePropsData = -1;
}
@@ -318,7 +247,6 @@ BUnicodeChar::IsAlpha(uint32 c)
/** Returns the type code of the specified unicode character */
int8
BUnicodeChar::Type(uint32 c)
{