ICU-701 add code to test if a subchar byte sequence is valid in the codepage structure

X-SVN-Rev: 3365
This commit is contained in:
Markus Scherer 2001-01-03 00:30:31 +00:00
parent 11b0460fe4
commit 95a8083095

View File

@ -676,6 +676,24 @@ void loadTableFromFile(FileStream* convFile, UConverterSharedData* sharedData, U
}
}
if(cnvData->isValid!=NULL)
{
const uint8_t *p = staticData->subChar;
codepageValue = 0;
switch(staticData->subCharLen) {
case 4: codepageValue = (codepageValue << 8) | *p++;
case 3: codepageValue = (codepageValue << 8) | *p++;
case 2: codepageValue = (codepageValue << 8) | *p++;
case 1: codepageValue = (codepageValue << 8) | *p;
default: break; /* must never occur */
}
if(!cnvData->isValid(cnvData, staticData->subChar, staticData->subCharLen, codepageValue)) {
fprintf(stderr, " the substitution character byte sequence is illegal in this codepage structure!\n");
*err = U_INVALID_TABLE_FORMAT;
isOK = FALSE;
}
}
staticData->hasFromUnicodeFallback = staticData->hasToUnicodeFallback = FALSE;
while (T_FileStream_readLine(convFile, storageLine, sizeof(storageLine)))