From 0417c0fd7e07ea7573a9ca06c21766da07db08c6 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 11 Aug 2010 12:00:59 +0000 Subject: [PATCH] * 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 --- headers/private/locale/PropertyFile.h | 23 ------- headers/private/locale/UnicodeProperties.h | 25 ------- src/kits/locale/Jamfile | 3 - src/kits/locale/PropertyFile.cpp | 49 -------------- src/kits/locale/UnicodeChar.cpp | 78 +--------------------- 5 files changed, 3 insertions(+), 175 deletions(-) delete mode 100644 headers/private/locale/PropertyFile.h delete mode 100644 headers/private/locale/UnicodeProperties.h delete mode 100644 src/kits/locale/PropertyFile.cpp diff --git a/headers/private/locale/PropertyFile.h b/headers/private/locale/PropertyFile.h deleted file mode 100644 index b25623656e..0000000000 --- a/headers/private/locale/PropertyFile.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. - * Distributed under the terms of the MIT License. - */ -#ifndef PROPERTY_FILE_H -#define PROPERTY_FILE_H - - -#include - - -// 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 */ diff --git a/headers/private/locale/UnicodeProperties.h b/headers/private/locale/UnicodeProperties.h deleted file mode 100644 index ec6cf43ce3..0000000000 --- a/headers/private/locale/UnicodeProperties.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. - * Distributed under the terms of the MIT License. - */ -#ifndef _UNICODE_PROPERTIES_H_ -#define _UNICODE_PROPERTIES_H_ - - -#include -#include - - -#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_ */ diff --git a/src/kits/locale/Jamfile b/src/kits/locale/Jamfile index ab9c9e1a10..2197235ec1 100644 --- a/src/kits/locale/Jamfile +++ b/src/kits/locale/Jamfile @@ -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 diff --git a/src/kits/locale/PropertyFile.cpp b/src/kits/locale/PropertyFile.cpp deleted file mode 100644 index aac95e1048..0000000000 --- a/src/kits/locale/PropertyFile.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de. - * Distributed under the terms of the MIT License. - */ - - -#include "PropertyFile.h" -#include "UnicodeProperties.h" - -#include -#include - - -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); -} - diff --git a/src/kits/locale/UnicodeChar.cpp b/src/kits/locale/UnicodeChar.cpp index 23d627b6be..a86192e782 100644 --- a/src/kits/locale/UnicodeChar.cpp +++ b/src/kits/locale/UnicodeChar.cpp @@ -22,24 +22,12 @@ #include #include -#include "UnicodeProperties.h" -#include "PropertyFile.h" #include #include #include -#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) {