Lines Matching defs:states

154         /* adjust "final valid" states according to the state flags */
186 ucm_addState(UCMStates *states, const char *s) {
189 if(states->countStates==MBCS_MAX_STATE_COUNT) {
190 fprintf(stderr, "ucm error: too many states (maximum %u)\n", MBCS_MAX_STATE_COUNT);
194 error=parseState(s, states->stateTable[states->countStates],
195 &states->stateFlags[states->countStates]);
201 ++states->countStates;
207 UCMStates *states;
211 states=&ucm->states;
265 states->conversionType=UCNV_DBCS;
267 states->conversionType = UCNV_SBCS;
269 states->conversionType = UCNV_MBCS;
271 states->conversionType = UCNV_EBCDIC_STATEFUL;
280 states->maxCharLength=(int8_t)(c-'0');
281 states->outputType=(int8_t)(states->maxCharLength-1);
290 states->minCharLength=(int8_t)(c-'0');
298 switch(states->conversionType) {
302 states->conversionType=UCNV_MBCS;
311 if(states->maxCharLength==0) {
315 ucm_addState(states, *pValue);
332 sumUpStates(UCMStates *states) {
337 * Sum up the offsets for all states.
345 for(count=states->countStates; !allStatesReady && count>=0; --count) {
347 for(state=states->countStates-1; state>=0; --state) {
348 if(!(states->stateFlags[state]&MBCS_STATE_FLAG_READY)) {
354 entry=states->stateTable[state][cell];
358 states->stateTable[state][cell]=MBCS_ENTRY_FINAL_SET_VALUE(entry, sum);
362 states->stateTable[state][cell]=MBCS_ENTRY_FINAL_SET_VALUE(entry, sum);
374 entry=states->stateTable[state][cell];
376 if(states->stateFlags[MBCS_ENTRY_TRANSITION_STATE(entry)]&MBCS_STATE_FLAG_READY) {
377 states->stateTable[state][cell]=MBCS_ENTRY_TRANSITION_SET_OFFSET(entry, sum);
378 sum+=states->stateOffsetSum[MBCS_ENTRY_TRANSITION_STATE(entry)];
388 states->stateOffsetSum[state]=sum;
389 states->stateFlags[state]|=MBCS_STATE_FLAG_READY;
401 * For all "direct" (i.e., initial) states>0,
403 * the previous initial states.
405 sum=states->stateOffsetSum[0];
406 for(state=1; state<states->countStates; ++state) {
407 if((states->stateFlags[state]&0xf)==MBCS_STATE_FLAG_DIRECT) {
409 sum+=states->stateOffsetSum[state];
411 entry=states->stateTable[state][cell];
413 states->stateTable[state][cell]=MBCS_ENTRY_TRANSITION_ADD_OFFSET(entry, sum2);
420 return states->countToUCodeUnits=(sum+1)&~1;
424 ucm_processStates(UCMStates *states, UBool ignoreSISOCheck) {
427 if(states->conversionType==UCNV_UNSUPPORTED_CONVERTER) {
432 if(states->countStates==0) {
433 switch(states->conversionType) {
436 if(states->maxCharLength!=1) {
440 states->conversionType=UCNV_MBCS;
441 ucm_addState(states, "0-ff");
449 if(states->minCharLength!=1 || states->maxCharLength!=2) {
453 states->conversionType=UCNV_MBCS;
454 ucm_addState(states, "0-ff, e:1.s, f:0.s");
455 ucm_addState(states, "initial, 0-3f:4, e:1.s, f:0.s, 40:3, 41-fe:2, ff:4");
456 ucm_addState(states, "0-40:1.i, 41-fe:1., ff:1.i");
457 ucm_addState(states, "0-ff:1.i, 40:1.");
458 ucm_addState(states, "0-ff:1.i");
462 if(states->minCharLength!=2 || states->maxCharLength!=2) {
466 states->conversionType = UCNV_MBCS;
467 ucm_addState(states, "0-3f:3, 40:2, 41-fe:1, ff:3");
468 ucm_addState(states, "41-fe");
469 ucm_addState(states, "40");
470 ucm_addState(states, "");
485 if(states->maxCharLength<states->minCharLength) {
490 /* count non-direct states and compare with max B/char */
492 for(state=0; state<states->countStates; ++state) {
493 if((states->stateFlags[state]&0xf)!=MBCS_STATE_FLAG_DIRECT) {
497 if(states->maxCharLength>count+1) {
502 if(states->minCharLength==1) {
507 * then the initial state must have direct result states
510 entry=states->stateTable[0][cell];
526 * and that all next states after final ones have the "direct"
527 * flag of initial states
529 for(state=states->countStates-1; state>=0; --state) {
531 entry=states->stateTable[state][cell];
532 if((uint8_t)MBCS_ENTRY_STATE(entry)>=states->countStates) {
537 if(MBCS_ENTRY_IS_FINAL(entry) && (states->stateFlags[MBCS_ENTRY_STATE(entry)]&0xf)!=MBCS_STATE_FLAG_DIRECT) {
541 } else if(MBCS_ENTRY_IS_TRANSITION(entry) && (states->stateFlags[MBCS_ENTRY_STATE(entry)]&0xf)==MBCS_STATE_FLAG_DIRECT) {
550 if(states->countStates>=2 && (states->stateFlags[1]&0xf)==MBCS_STATE_FLAG_DIRECT) {
551 if(states->maxCharLength!=2) {
552 fprintf(stderr, "ucm error: SI/SO codepages must have max 2 bytes/char (not %x)\n", (int)states->maxCharLength);
555 if(states->countStates<3) {
556 fprintf(stderr, "ucm error: SI/SO codepages must have at least 3 states (not %x)\n", (int)states->countStates);
561 (states->stateTable[0][0xe]==MBCS_ENTRY_FINAL(1, MBCS_STATE_CHANGE_ONLY, 0) &&
562 states->stateTable[0][0xf]==MBCS_ENTRY_FINAL(0, MBCS_STATE_CHANGE_ONLY, 0) &&
563 states->stateTable[1][0xe]==MBCS_ENTRY_FINAL(1, MBCS_STATE_CHANGE_ONLY, 0) &&
564 states->stateTable[1][0xf]==MBCS_ENTRY_FINAL(0, MBCS_STATE_CHANGE_ONLY, 0))
566 states->outputType=MBCS_OUTPUT_2_SISO;
568 fprintf(stderr, "ucm error: SI/SO codepages must have in states 0 and 1 transitions e:1.s, f:0.s\n");
577 while(state<states->countStates) {
578 if((states->stateFlags[state]&0xf)==MBCS_STATE_FLAG_DIRECT) {
585 sumUpStates(states);
614 compactToUnicode2(UCMStates *states,
626 if(states->outputType==MBCS_OUTPUT_2_SISO) {
636 entry=states->stateTable[leadState][i];
642 for(i=1; i<states->countStates; ++i) {
653 entry=states->stateTable[leadState][i];
659 entry=states->stateTable[trailState][j];
697 if(states->countStates>=MBCS_MAX_STATE_COUNT) {
698 fprintf(stderr, "cannot compact toUnicode because the maximum number of states is reached\n");
703 oldStateTable=(int32_t (*)[256])uprv_malloc(states->countStates*1024);
708 uprv_memcpy(oldStateTable, states->stateTable, states->countStates*1024);
715 newState=states->countStates++;
716 states->stateFlags[newState]=0;
717 /* copy the old trail state, turning all assigned states into unassigned ones */
719 entry=states->stateTable[trailState][i];
723 states->stateTable[newState][i]=MBCS_ENTRY_FINAL_SET_ACTION_VALUE(entry, MBCS_STATE_UNASSIGNED, 0xfffe);
726 states->stateTable[newState][i]=entry;
734 states->stateTable[leadState][i]=MBCS_ENTRY_SET_STATE(states->stateTable[leadState][i], newState);
739 for(i=0; i<states->countStates; ++i) {
740 states->stateFlags[i]&=~MBCS_STATE_FLAG_READY;
742 sum=sumUpStates(states);
760 --states->countStates;
761 uprv_memcpy(states->stateTable, oldStateTable, states->countStates*1024);
771 * The old state table has the same lead _and_ trail states for assigned characters!
772 * The differences are in the offsets, and in the trail states for some unassigned characters.
779 for(leadState=0; leadState<states->countStates; ++leadState) {
780 if((states->stateFlags[leadState]&0xf)==MBCS_STATE_FLAG_DIRECT) {
783 entry=states->stateTable[leadState][i];
786 /* the new state does not have assigned states */
792 entry=states->stateTable[trailState][j];
840 findUnassigned(UCMStates *states,
850 entry=states->stateTable[state][i];
852 savings=findUnassigned(states,
897 compactToUnicodeHelper(UCMStates *states,
903 for(state=0; state<states->countStates; ++state) {
904 if((states->stateFlags[state]&0xf)==MBCS_STATE_FLAG_DIRECT) {
905 savings=findUnassigned(states,
923 ucm_optimizeStates(UCMStates *states,
931 for(state=0; state<states->countStates; ++state) {
933 entry=states->stateTable[state][cell];
940 states->stateTable[state][cell]=MBCS_ENTRY_FINAL_SET_ACTION(entry, MBCS_STATE_UNASSIGNED);
946 if(states->maxCharLength==2) {
947 compactToUnicode2(states, pUnicodeCodeUnits, toUFallbacks, countToUFallbacks, verbose);
948 } else if(states->maxCharLength>2) {
950 compactToUnicodeHelper(states, *pUnicodeCodeUnits, toUFallbacks, countToUFallbacks);
972 ucm_countChars(UCMStates *states,
982 if(states->countStates==0) {
988 if(length==2 && states->outputType==MBCS_OUTPUT_2_SISO) {
998 entry=states->stateTable[state][bytes[i]];
1039 if(count>1 && states->outputType==MBCS_OUTPUT_2_SISO && length!=2*count) {