Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(336)

Side by Side Diff: source/common/rbbidata.cpp

Issue 845603002: Update ICU to 54.1 step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: remove unusued directories Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/common/rbbidata.h ('k') | source/common/rbbiscan.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 *************************************************************************** 2 ***************************************************************************
3 * Copyright (C) 1999-2010 International Business Machines Corporation * 3 * Copyright (C) 1999-2014 International Business Machines Corporation *
4 * and others. All rights reserved. * 4 * and others. All rights reserved. *
5 *************************************************************************** 5 ***************************************************************************
6 */ 6 */
7 7
8 #include "unicode/utypes.h" 8 #include "unicode/utypes.h"
9 9
10 #if !UCONFIG_NO_BREAK_ITERATION 10 #if !UCONFIG_NO_BREAK_ITERATION
11 11
12 #include "unicode/utypes.h" 12 #include "unicode/utypes.h"
13 #include "rbbidata.h" 13 #include "rbbidata.h"
(...skipping 25 matching lines...) Expand all
39 U_CDECL_END 39 U_CDECL_END
40 40
41 U_NAMESPACE_BEGIN 41 U_NAMESPACE_BEGIN
42 42
43 //----------------------------------------------------------------------------- 43 //-----------------------------------------------------------------------------
44 // 44 //
45 // Constructors. 45 // Constructors.
46 // 46 //
47 //----------------------------------------------------------------------------- 47 //-----------------------------------------------------------------------------
48 RBBIDataWrapper::RBBIDataWrapper(const RBBIDataHeader *data, UErrorCode &status) { 48 RBBIDataWrapper::RBBIDataWrapper(const RBBIDataHeader *data, UErrorCode &status) {
49 init0();
49 init(data, status); 50 init(data, status);
50 } 51 }
51 52
52 RBBIDataWrapper::RBBIDataWrapper(const RBBIDataHeader *data, enum EDontAdopt, UE rrorCode &status) { 53 RBBIDataWrapper::RBBIDataWrapper(const RBBIDataHeader *data, enum EDontAdopt, UE rrorCode &status) {
54 init0();
53 init(data, status); 55 init(data, status);
54 fDontFreeData = TRUE; 56 fDontFreeData = TRUE;
55 } 57 }
56 58
57 RBBIDataWrapper::RBBIDataWrapper(UDataMemory* udm, UErrorCode &status) { 59 RBBIDataWrapper::RBBIDataWrapper(UDataMemory* udm, UErrorCode &status) {
58 const RBBIDataHeader *d = (const RBBIDataHeader *) 60 init0();
59 // ((char *)&(udm->pHeader->info) + udm->pHeader->info.size); 61 if (U_FAILURE(status)) {
60 // taking into consideration the padding added in by udata_write 62 return;
61 ((char *)(udm->pHeader) + udm->pHeader->dataHeader.headerSize); 63 }
62 init(d, status); 64 const DataHeader *dh = udm->pHeader;
65 int32_t headerSize = dh->dataHeader.headerSize;
66 if ( !(headerSize >= 20 &&
67 dh->info.isBigEndian == U_IS_BIG_ENDIAN &&
68 dh->info.charsetFamily == U_CHARSET_FAMILY &&
69 dh->info.dataFormat[0] == 0x42 && // dataFormat="Brk "
70 dh->info.dataFormat[1] == 0x72 &&
71 dh->info.dataFormat[2] == 0x6b &&
72 dh->info.dataFormat[3] == 0x20)
73 // Note: info.fFormatVersion is duplicated in the RBBIDataHeader, an d is
74 // validated when checking that.
75 ) {
76 status = U_INVALID_FORMAT_ERROR;
77 return;
78 }
79 const char *dataAsBytes = reinterpret_cast<const char *>(dh);
80 const RBBIDataHeader *rbbidh = reinterpret_cast<const RBBIDataHeader *>(data AsBytes + headerSize);
81 init(rbbidh, status);
63 fUDataMem = udm; 82 fUDataMem = udm;
64 } 83 }
65 84
66 //----------------------------------------------------------------------------- 85 //-----------------------------------------------------------------------------
67 // 86 //
68 // init(). Does most of the work of construction, shared between the 87 // init(). Does most of the work of construction, shared between the
69 // constructors. 88 // constructors.
70 // 89 //
71 //----------------------------------------------------------------------------- 90 //-----------------------------------------------------------------------------
91 void RBBIDataWrapper::init0() {
92 fHeader = NULL;
93 fForwardTable = NULL;
94 fReverseTable = NULL;
95 fSafeFwdTable = NULL;
96 fSafeRevTable = NULL;
97 fRuleSource = NULL;
98 fRuleStatusTable = NULL;
99 fUDataMem = NULL;
100 fRefCount = 0;
101 fDontFreeData = TRUE;
102 }
103
72 void RBBIDataWrapper::init(const RBBIDataHeader *data, UErrorCode &status) { 104 void RBBIDataWrapper::init(const RBBIDataHeader *data, UErrorCode &status) {
73 if (U_FAILURE(status)) { 105 if (U_FAILURE(status)) {
74 return; 106 return;
75 } 107 }
76 fHeader = data; 108 fHeader = data;
77 if (fHeader->fMagic != 0xb1a0 || fHeader->fFormatVersion[0] != 3) 109 if (fHeader->fMagic != 0xb1a0 || fHeader->fFormatVersion[0] != 3)
78 { 110 {
79 status = U_INVALID_FORMAT_ERROR; 111 status = U_INVALID_FORMAT_ERROR;
80 return; 112 return;
81 } 113 }
82 // Note: in ICU version 3.2 and earlier, there was a formatVersion 1 114 // Note: in ICU version 3.2 and earlier, there was a formatVersion 1
83 // that is no longer supported. At that time fFormatVersion was 115 // that is no longer supported. At that time fFormatVersion was
84 // an int32_t field, rather than an array of 4 bytes. 116 // an int32_t field, rather than an array of 4 bytes.
85 117
86 fDontFreeData = FALSE; 118 fDontFreeData = FALSE;
87 fUDataMem = NULL;
88 fReverseTable = NULL;
89 fSafeFwdTable = NULL;
90 fSafeRevTable = NULL;
91 if (data->fFTableLen != 0) { 119 if (data->fFTableLen != 0) {
92 fForwardTable = (RBBIStateTable *)((char *)data + fHeader->fFTable); 120 fForwardTable = (RBBIStateTable *)((char *)data + fHeader->fFTable);
93 } 121 }
94 if (data->fRTableLen != 0) { 122 if (data->fRTableLen != 0) {
95 fReverseTable = (RBBIStateTable *)((char *)data + fHeader->fRTable); 123 fReverseTable = (RBBIStateTable *)((char *)data + fHeader->fRTable);
96 } 124 }
97 if (data->fSFTableLen != 0) { 125 if (data->fSFTableLen != 0) {
98 fSafeFwdTable = (RBBIStateTable *)((char *)data + fHeader->fSFTable); 126 fSafeFwdTable = (RBBIStateTable *)((char *)data + fHeader->fSFTable);
99 } 127 }
100 if (data->fSRTableLen != 0) { 128 if (data->fSRTableLen != 0) {
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // Swap the whole thing as int32_t, then re-swap the one field. 465 // Swap the whole thing as int32_t, then re-swap the one field.
438 // 466 //
439 ds->swapArray32(ds, inBytes, sizeof(RBBIDataHeader), outBytes, status); 467 ds->swapArray32(ds, inBytes, sizeof(RBBIDataHeader), outBytes, status);
440 ds->swapArray32(ds, outputDH->fFormatVersion, 4, outputDH->fFormatVersion, s tatus); 468 ds->swapArray32(ds, outputDH->fFormatVersion, 4, outputDH->fFormatVersion, s tatus);
441 469
442 return totalSize; 470 return totalSize;
443 } 471 }
444 472
445 473
446 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */ 474 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
OLDNEW
« no previous file with comments | « source/common/rbbidata.h ('k') | source/common/rbbiscan.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698