+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
- * Copyright (C) 2003-2004, International Business Machines
+ * Copyright (C) 2003-2012, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: spreptst.c
- * encoding: US-ASCII
+ * encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
#include "unicode/putil.h"
#include "cintltst.h"
#include "unicode/usprep.h"
+#include "unicode/utf16.h"
#include "sprpimpl.h"
#include "uparse.h"
#include "cmemory.h"
int32_t length=0;
UBool isIndex = FALSE;
UStringPrepType retType;
- int32_t value=0, index=0, delta=0;
+ int32_t value=0, idx=0, delta=0;
int32_t* indexes = data->indexes;
UTrie trie = data->sprepTrie;
const uint16_t* mappingData = data->mappingData;
}
if(isIndex){
- index = value;
- if(index >= indexes[_SPREP_ONE_UCHAR_MAPPING_INDEX_START] &&
- index < indexes[_SPREP_TWO_UCHARS_MAPPING_INDEX_START]){
+ idx = value;
+ if(idx >= indexes[_SPREP_ONE_UCHAR_MAPPING_INDEX_START] &&
+ idx < indexes[_SPREP_TWO_UCHARS_MAPPING_INDEX_START]){
length = 1;
- }else if(index >= indexes[_SPREP_TWO_UCHARS_MAPPING_INDEX_START] &&
- index < indexes[_SPREP_THREE_UCHARS_MAPPING_INDEX_START]){
+ }else if(idx >= indexes[_SPREP_TWO_UCHARS_MAPPING_INDEX_START] &&
+ idx < indexes[_SPREP_THREE_UCHARS_MAPPING_INDEX_START]){
length = 2;
- }else if(index >= indexes[_SPREP_THREE_UCHARS_MAPPING_INDEX_START] &&
- index < indexes[_SPREP_FOUR_UCHARS_MAPPING_INDEX_START]){
+ }else if(idx >= indexes[_SPREP_THREE_UCHARS_MAPPING_INDEX_START] &&
+ idx < indexes[_SPREP_FOUR_UCHARS_MAPPING_INDEX_START]){
length = 3;
}else{
- length = mappingData[index++];
+ length = mappingData[idx++];
}
}else{
delta = value;
if(isIndex){
for(i =0; i< mapLength; i++){
if(mapping[i] <= 0xFFFF){
- if(mappingData[index+i] != (uint16_t)mapping[i]){
- log_err("Did not get the expected result. Expected: 0x%04X Got: 0x%04X \n", mapping[i], mappingData[index+i]);
+ if(mappingData[idx+i] != (uint16_t)mapping[i]){
+ log_err("Did not get the expected result. Expected: 0x%04X Got: 0x%04X \n", mapping[i], mappingData[idx+i]);
}
}else{
- UChar lead = UTF16_LEAD(mapping[i]);
- UChar trail = UTF16_TRAIL(mapping[i]);
- if(mappingData[index+i] != lead ||
- mappingData[index+i+1] != trail){
- log_err( "Did not get the expected result. Expected: 0x%04X 0x%04X Got: 0x%04X 0x%04X\n", lead, trail, mappingData[index+i], mappingData[index+i+1]);
+ UChar lead = U16_LEAD(mapping[i]);
+ UChar trail = U16_TRAIL(mapping[i]);
+ if(mappingData[idx+i] != lead ||
+ mappingData[idx+i+1] != trail){
+ log_err( "Did not get the expected result. Expected: 0x%04X 0x%04X Got: 0x%04X 0x%04X\n", lead, trail, mappingData[idx+i], mappingData[idx+i+1]);
}
}
}
UTrie trie = data->sprepTrie;
/*
// supplementary code point
- UChar __lead16=UTF16_LEAD(0x2323E);
+ UChar __lead16=U16_LEAD(0x2323E);
int32_t __offset;
// get data for lead surrogate
relativepath = ".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING"test"U_FILE_SEP_STRING"testdata"U_FILE_SEP_STRING;
#endif
- filename = (char*) malloc(strlen(srcdatapath)+strlen(relativepath)+strlen(txtFileName)+10 );
profile = usprep_open(testdatapath, binFileName, errorCode);
- if(U_FAILURE(*errorCode)){
+ if(*errorCode == U_FILE_ACCESS_ERROR) {
+ log_data_err("Failed to load %s data file. Error: %s \n", binFileName, u_errorName(*errorCode));
+ return;
+ } else if(U_FAILURE(*errorCode)){
log_err("Failed to load %s data file. Error: %s \n", binFileName, u_errorName(*errorCode));
return;
}
+ filename = (char*) malloc(strlen(srcdatapath)+strlen(relativepath)+strlen(txtFileName)+10 );
/* open and load the txt file */
strcpy(filename,srcdatapath);
strcat(filename,relativepath);