| Index: source/tools/genrb/wrtxml.cpp
|
| diff --git a/source/tools/genrb/wrtxml.cpp b/source/tools/genrb/wrtxml.cpp
|
| index 1e9c5519d2e7e10b9cdc356bbe0baa30c30c4514..c250fc29b41e58982da963605e49fd9ba4752073 100644
|
| --- a/source/tools/genrb/wrtxml.cpp
|
| +++ b/source/tools/genrb/wrtxml.cpp
|
| @@ -1,7 +1,7 @@
|
| /*
|
| *******************************************************************************
|
| *
|
| -* Copyright (C) 2002-2014, International Business Machines
|
| +* Copyright (C) 2002-2015, International Business Machines
|
| * Corporation and others. All Rights Reserved.
|
| *
|
| *******************************************************************************
|
| @@ -136,7 +136,7 @@ static char* getID(const char* id, const char* curKey, char* result) {
|
| * conversion is not portable across platforms with different endianess.
|
| */
|
|
|
| -uint32_t computeCRC(char *ptr, uint32_t len, uint32_t lastcrc){
|
| +uint32_t computeCRC(const char *ptr, uint32_t len, uint32_t lastcrc){
|
| int32_t crc;
|
| uint32_t temp1;
|
| uint32_t temp2;
|
| @@ -419,7 +419,7 @@ print(UChar* src, int32_t srcLen,const char *tagStart,const char *tagEnd, UErro
|
| }
|
| }
|
| static void
|
| -printNoteElements(struct UString *src, UErrorCode *status){
|
| +printNoteElements(const UString *src, UErrorCode *status){
|
|
|
| #if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpressions are available */
|
|
|
| @@ -500,6 +500,7 @@ printComments(struct UString *src, const char *resName, UBool printTranslate, UE
|
| uprv_free(trans);
|
| return;
|
| }
|
| + // TODO: make src const, stop modifying it in-place, make printContainer() take const resource, etc.
|
| src->fLength = removeCmtText(src->fChars, src->fLength, status);
|
| descLen = getDescription(src->fChars,src->fLength, &desc, capacity, status);
|
| transLen = getTranslate(src->fChars,src->fLength, &trans, capacity, status);
|
| @@ -543,15 +544,14 @@ printComments(struct UString *src, const char *resName, UBool printTranslate, UE
|
| * <trans-unit id = "blah" resname = "blah" restype = "x-id-alias" translate = "no">
|
| * <group id "calendar_gregorian" resname = "gregorian" restype = "x-icu-array">
|
| */
|
| -static char *printContainer(struct SResource *res, const char *container, const char *restype, const char *mimetype, const char *id, UErrorCode *status)
|
| +static char *printContainer(SResource *res, const char *container, const char *restype, const char *mimetype, const char *id, UErrorCode *status)
|
| {
|
| - char resKeyBuffer[8];
|
| const char *resname = NULL;
|
| char *sid = NULL;
|
|
|
| write_tabs(out);
|
|
|
| - resname = res_getKeyString(srBundle, res, resKeyBuffer);
|
| + resname = res->getKeyString(srBundle);
|
| if (resname != NULL && *resname != 0) {
|
| sid = getID(id, resname, sid);
|
| } else {
|
| @@ -613,7 +613,7 @@ static const char *intvector_restype = "x-icu-intvector";
|
| static const char *table_restype = "x-icu-table";
|
|
|
| static void
|
| -string_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
| +string_write_xml(StringResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
|
|
| char *sid = NULL;
|
| char* buf = NULL;
|
| @@ -629,7 +629,7 @@ string_write_xml(struct SResource *res, const char* id, const char* /*language*/
|
|
|
| write_utf8_file(out, UnicodeString(source));
|
|
|
| - buf = convertAndEscape(&buf, 0, &bufLen, res->u.fString.fChars, res->u.fString.fLength, status);
|
| + buf = convertAndEscape(&buf, 0, &bufLen, res->getBuffer(), res->length(), status);
|
|
|
| if (U_FAILURE(*status)) {
|
| return;
|
| @@ -650,7 +650,7 @@ string_write_xml(struct SResource *res, const char* id, const char* /*language*/
|
| }
|
|
|
| static void
|
| -alias_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
| +alias_write_xml(AliasResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
| char *sid = NULL;
|
| char* buf = NULL;
|
| int32_t bufLen=0;
|
| @@ -661,7 +661,7 @@ alias_write_xml(struct SResource *res, const char* id, const char* /*language*/,
|
|
|
| write_utf8_file(out, UnicodeString(source));
|
|
|
| - buf = convertAndEscape(&buf, 0, &bufLen, res->u.fString.fChars, res->u.fString.fLength, status);
|
| + buf = convertAndEscape(&buf, 0, &bufLen, res->getBuffer(), res->length(), status);
|
|
|
| if(U_FAILURE(*status)){
|
| return;
|
| @@ -681,7 +681,7 @@ alias_write_xml(struct SResource *res, const char* id, const char* /*language*/,
|
| }
|
|
|
| static void
|
| -array_write_xml(struct SResource *res, const char* id, const char* language, UErrorCode *status) {
|
| +array_write_xml(ArrayResource *res, const char* id, const char* language, UErrorCode *status) {
|
| char* sid = NULL;
|
| int index = 0;
|
|
|
| @@ -689,7 +689,7 @@ array_write_xml(struct SResource *res, const char* id, const char* language, UEr
|
|
|
| sid = printContainer(res, group, array_restype, NULL, id, status);
|
|
|
| - current = res->u.fArray.fFirst;
|
| + current = res->fFirst;
|
|
|
| while (current != NULL) {
|
| char c[256] = {0};
|
| @@ -718,7 +718,7 @@ array_write_xml(struct SResource *res, const char* id, const char* language, UEr
|
| }
|
|
|
| static void
|
| -intvector_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
| +intvector_write_xml(IntVectorResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
| char* sid = NULL;
|
| char* ivd = NULL;
|
| uint32_t i=0;
|
| @@ -727,12 +727,12 @@ intvector_write_xml(struct SResource *res, const char* id, const char* /*languag
|
|
|
| sid = printContainer(res, group, intvector_restype, NULL, id, status);
|
|
|
| - for(i = 0; i < res->u.fIntVector.fCount; i += 1) {
|
| + for(i = 0; i < res->fCount; i += 1) {
|
| char c[256] = {0};
|
|
|
| itostr(c, i, 10, 0);
|
| ivd = getID(sid, c, ivd);
|
| - len = itostr(buf, res->u.fIntVector.fArray[i], 10, 0);
|
| + len = itostr(buf, res->fArray[i], 10, 0);
|
|
|
| write_tabs(out);
|
| write_utf8_file(out, UnicodeString("<"));
|
| @@ -767,7 +767,7 @@ intvector_write_xml(struct SResource *res, const char* id, const char* /*languag
|
| }
|
|
|
| static void
|
| -int_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
| +int_write_xml(IntResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
| char* sid = NULL;
|
| char buf[256] = {0};
|
| uint32_t len = 0;
|
| @@ -778,7 +778,7 @@ int_write_xml(struct SResource *res, const char* id, const char* /*language*/, U
|
|
|
| write_utf8_file(out, UnicodeString(source));
|
|
|
| - len = itostr(buf, res->u.fIntValue.fValue, 10, 0);
|
| + len = itostr(buf, res->fValue, 10, 0);
|
| write_utf8_file(out, UnicodeString(buf, len));
|
|
|
| write_utf8_file(out, UnicodeString(close_source));
|
| @@ -795,7 +795,7 @@ int_write_xml(struct SResource *res, const char* id, const char* /*language*/, U
|
| }
|
|
|
| static void
|
| -bin_write_xml(struct SResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
| +bin_write_xml(BinaryResource *res, const char* id, const char* /*language*/, UErrorCode *status) {
|
| const char* m_type = application_mimetype;
|
| char* sid = NULL;
|
| uint32_t crc = 0xFFFFFFFF;
|
| @@ -803,16 +803,16 @@ bin_write_xml(struct SResource *res, const char* id, const char* /*language*/, U
|
| char fileName[1024] ={0};
|
| int32_t tLen = ( outDir == NULL) ? 0 :(int32_t)uprv_strlen(outDir);
|
| char* fn = (char*) uprv_malloc(sizeof(char) * (tLen+1024 +
|
| - (res->u.fBinaryValue.fFileName !=NULL ?
|
| - uprv_strlen(res->u.fBinaryValue.fFileName) :0)));
|
| + (res->fFileName !=NULL ?
|
| + uprv_strlen(res->fFileName) :0)));
|
| const char* ext = NULL;
|
|
|
| char* f = NULL;
|
|
|
| fn[0]=0;
|
|
|
| - if(res->u.fBinaryValue.fFileName != NULL){
|
| - uprv_strcpy(fileName, res->u.fBinaryValue.fFileName);
|
| + if(res->fFileName != NULL){
|
| + uprv_strcpy(fileName, res->fFileName);
|
| f = uprv_strrchr(fileName, '\\');
|
|
|
| if (f != NULL) {
|
| @@ -875,8 +875,8 @@ bin_write_xml(struct SResource *res, const char* id, const char* /*language*/, U
|
| write_utf8_file(out, UnicodeString(internal_file));
|
| printAttribute("form", application_mimetype, (int32_t) uprv_strlen(application_mimetype));
|
|
|
| - while(i <res->u.fBinaryValue.fLength){
|
| - len = itostr(temp, res->u.fBinaryValue.fData[i], 16, 2);
|
| + while(i <res->fLength){
|
| + len = itostr(temp, res->fData[i], 16, 2);
|
| crc = computeCRC(temp, len, crc);
|
| i++;
|
| }
|
| @@ -887,8 +887,8 @@ bin_write_xml(struct SResource *res, const char* id, const char* /*language*/, U
|
| write_utf8_file(out, UnicodeString(">"));
|
|
|
| i = 0;
|
| - while(i <res->u.fBinaryValue.fLength){
|
| - len = itostr(temp, res->u.fBinaryValue.fData[i], 16, 2);
|
| + while(i <res->fLength){
|
| + len = itostr(temp, res->fData[i], 16, 2);
|
| write_utf8_file(out, UnicodeString(temp));
|
| i += 1;
|
| }
|
| @@ -915,7 +915,7 @@ bin_write_xml(struct SResource *res, const char* id, const char* /*language*/, U
|
|
|
|
|
| static void
|
| -table_write_xml(struct SResource *res, const char* id, const char* language, UBool isTopLevel, UErrorCode *status) {
|
| +table_write_xml(TableResource *res, const char* id, const char* language, UBool isTopLevel, UErrorCode *status) {
|
|
|
| uint32_t i = 0;
|
|
|
| @@ -932,7 +932,7 @@ table_write_xml(struct SResource *res, const char* id, const char* language, UBo
|
| sid[0] = '\0';
|
| }
|
|
|
| - current = res->u.fTable.fFirst;
|
| + current = res->fFirst;
|
| i = 0;
|
|
|
| while (current != NULL) {
|
| @@ -965,31 +965,31 @@ res_write_xml(struct SResource *res, const char* id, const char* language, UBoo
|
| if (res != NULL) {
|
| switch (res->fType) {
|
| case URES_STRING:
|
| - string_write_xml (res, id, language, status);
|
| + string_write_xml (static_cast<StringResource *>(res), id, language, status);
|
| return;
|
|
|
| case URES_ALIAS:
|
| - alias_write_xml (res, id, language, status);
|
| + alias_write_xml (static_cast<AliasResource *>(res), id, language, status);
|
| return;
|
|
|
| case URES_INT_VECTOR:
|
| - intvector_write_xml (res, id, language, status);
|
| + intvector_write_xml (static_cast<IntVectorResource *>(res), id, language, status);
|
| return;
|
|
|
| case URES_BINARY:
|
| - bin_write_xml (res, id, language, status);
|
| + bin_write_xml (static_cast<BinaryResource *>(res), id, language, status);
|
| return;
|
|
|
| case URES_INT:
|
| - int_write_xml (res, id, language, status);
|
| + int_write_xml (static_cast<IntResource *>(res), id, language, status);
|
| return;
|
|
|
| case URES_ARRAY:
|
| - array_write_xml (res, id, language, status);
|
| + array_write_xml (static_cast<ArrayResource *>(res), id, language, status);
|
| return;
|
|
|
| case URES_TABLE:
|
| - table_write_xml (res, id, language, isTopLevel, status);
|
| + table_write_xml (static_cast<TableResource *>(res), id, language, isTopLevel, status);
|
| return;
|
|
|
| default:
|
|
|