/*
*******************************************************************************
*
-* Copyright (C) 2003-2007, International Business Machines
+* Copyright (C) 2003-2014, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
#include "makeconv.h"
#include "genmbcs.h"
-#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0]))
-
-
static void
CnvExtClose(NewConverter *cnvData);
utm_close(extData->fromUTableUChars);
utm_close(extData->fromUTableValues);
utm_close(extData->fromUBytes);
+ uprv_free(extData);
}
}
/* allocate it and put its length and index into the value */
value=
- (((uint32_t)m->uLen+UCNV_EXT_TO_U_LENGTH_OFFSET)<<UCNV_EXT_TO_U_LENGTH_SHIFT)|
+ (((uint32_t)u16Length+UCNV_EXT_TO_U_LENGTH_OFFSET)<<UCNV_EXT_TO_U_LENGTH_SHIFT)|
((uint32_t)utm_countItems(extData->toUUChars));
u=utm_allocN(extData->toUUChars, u16Length);
flag&=MBCS_FROM_U_EXT_MASK;
m->f=flag;
}
- if(flag==0 || flag==1 || (flag==2 && m->bLen==1)) {
+ if(flag==0 || flag==1 || (flag==2 && m->bLen==1) || flag==4) {
map[j++]=i;
if(m->uLen>1) {
value|=(uint32_t)m->bLen<<UCNV_EXT_FROM_U_LENGTH_SHIFT;
if(m->f==0) {
value|=UCNV_EXT_FROM_U_ROUNDTRIP_FLAG;
+ } else if(m->f==4) {
+ value|=UCNV_EXT_FROM_U_GOOD_ONE_WAY_FLAG;
}
/* calculate the real UTF-16 length (see recoding in prepareFromUMappings()) */
extData->stage1[i1]=(uint16_t)newBlock;
extData->stage2Top=newBlock+MBCS_STAGE_2_BLOCK_SIZE;
- if(extData->stage2Top>LENGTHOF(extData->stage2)) {
+ if(extData->stage2Top>UPRV_LENGTHOF(extData->stage2)) {
fprintf(stderr, "error: too many stage 2 entries at U+%04x\n", (int)c);
exit(U_MEMORY_ALLOCATION_ERROR);
}
extData->stage2[i2]=(uint16_t)(newBlock>>UCNV_EXT_STAGE_2_LEFT_SHIFT);
extData->stage3Top=newBlock+MBCS_STAGE_3_BLOCK_SIZE;
- if(extData->stage3Top>LENGTHOF(extData->stage3)) {
+ if(extData->stage3Top>UPRV_LENGTHOF(extData->stage3)) {
fprintf(stderr, "error: too many stage 3 entries at U+%04x\n", (int)c);
exit(U_MEMORY_ALLOCATION_ERROR);
}
}
}
} else {
- if((i3b=extData->stage3bTop++)>=LENGTHOF(extData->stage3b)) {
+ if((i3b=extData->stage3bTop++)>=UPRV_LENGTHOF(extData->stage3b)) {
fprintf(stderr, "error: too many stage 3b entries at U+%04x\n", (int)c);
exit(U_MEMORY_ALLOCATION_ERROR);
}