• Home
  • Raw
  • Download

Lines Matching +full:- +full:match

6 *   Copyright (C) 2003-2016, International Business Machines
11 * encoding: UTF-8
33 /* to Unicode --------------------------------------------------------------- */
45 limit=(int32_t)UCNV_EXT_TO_U_GET_BYTE(toUSection[length-1]); in ucnv_extFindToU()
50 if(length==((limit-start)+1)) { in ucnv_extFindToU()
52 return UCNV_EXT_TO_U_GET_VALUE(toUSection[byte-start]); /* could be 0 */ in ucnv_extFindToU()
72 i=limit-start; in ucnv_extFindToU()
76 /* start<limit-1 */ in ucnv_extFindToU()
89 /* always break at start==limit-1 */ in ucnv_extFindToU()
112 * or if the match length fits with the current converter state
114 #define UCNV_EXT_TO_U_VERIFY_SISO_MATCH(sisoState, match) \ argument
115 ((sisoState)<0 || ((sisoState)==0) == (match==1))
119 * - the first character is in pre
120 * - no trie is used
121 * - the returned matchLength is not offset by 2
136 return 0; /* no extension data, no match */ in ucnv_extMatchToU()
149 return 0; /* no match of a DBCS sequence in SBCS mode */ in ucnv_extMatchToU()
162 /* match input units until there is a full match or the input is consumed */ in ucnv_extMatchToU()
176 /* remember longest match so far */ in ucnv_extMatchToU()
181 /* match pre[] then src[] */ in ucnv_extMatchToU()
187 /* all input consumed, partial match */ in ucnv_extMatchToU()
190 * end of the entire input stream, stop with the longest match so far in ucnv_extMatchToU()
191 * or: partial match must not be longer than UCNV_EXT_MAX_BYTES in ucnv_extMatchToU()
197 return -length; in ucnv_extMatchToU()
204 /* no match here, stop with the longest match so far */ in ucnv_extMatchToU()
208 /* partial match, continue */ in ucnv_extMatchToU()
215 /* full match, stop with result */ in ucnv_extMatchToU()
219 /* full match on fallback not taken, stop with the longest match so far */ in ucnv_extMatchToU()
227 /* no match at all */ in ucnv_extMatchToU()
251 /* output a string - with correct data we have resultLength>0 */ in ucnv_extWriteToU()
265 * or 1 for DBCS-only,
266 * or -1 if the converter is not SI/SO stateful
269 * cnv->mode==0 is equivalent to firstLength==1.
272 ((cnv)->sharedData->mbcs.outputType==MBCS_OUTPUT_2_SISO ? (int8_t)(cnv)->mode : \
273 (cnv)->sharedData->mbcs.outputType==MBCS_OUTPUT_DBCS_ONLY ? 1 : -1)
286 uint32_t value = 0; /* initialize output-only param to 0 to silence gcc */ in ucnv_extInitialMatchToU()
287 int32_t match; in ucnv_extInitialMatchToU() local
289 /* try to match */ in ucnv_extInitialMatchToU()
290 match=ucnv_extMatchToU(cx, (int8_t)UCNV_SISO_STATE(cnv), in ucnv_extInitialMatchToU()
291 (const char *)cnv->toUBytes, firstLength, in ucnv_extInitialMatchToU()
292 *src, (int32_t)(srcLimit-*src), in ucnv_extInitialMatchToU()
294 cnv->useFallback, flush); in ucnv_extInitialMatchToU()
295 if(match>0) { in ucnv_extInitialMatchToU()
297 *src+=match-firstLength; in ucnv_extInitialMatchToU()
306 } else if(match<0) { in ucnv_extInitialMatchToU()
307 /* save state for partial match */ in ucnv_extInitialMatchToU()
312 s=(const char *)cnv->toUBytes; in ucnv_extInitialMatchToU()
313 cnv->preToUFirstLength=(int8_t)firstLength; in ucnv_extInitialMatchToU()
315 cnv->preToU[j]=*s++; in ucnv_extInitialMatchToU()
320 match=-match; in ucnv_extInitialMatchToU()
321 for(; j<match; ++j) { in ucnv_extInitialMatchToU()
322 cnv->preToU[j]=*s++; in ucnv_extInitialMatchToU()
325 cnv->preToULength=(int8_t)match; in ucnv_extInitialMatchToU()
327 } else /* match==0 no match */ { in ucnv_extInitialMatchToU()
336 uint32_t value = 0; /* initialize output-only param to 0 to silence gcc */ in ucnv_extSimpleMatchToU()
337 int32_t match; in ucnv_extSimpleMatchToU() local
343 /* try to match */ in ucnv_extSimpleMatchToU()
344 match=ucnv_extMatchToU(cx, -1, in ucnv_extSimpleMatchToU()
349 if(match==length) { in ucnv_extSimpleMatchToU()
350 /* write result for simple, single-character conversion */ in ucnv_extSimpleMatchToU()
357 * return no match because in ucnv_extSimpleMatchToU()
358 * - match>0 && value points to string: simple conversion cannot handle multiple code points in ucnv_extSimpleMatchToU()
359 * - match>0 && match!=length: not all input consumed, forbidden for this function in ucnv_extSimpleMatchToU()
360 * - match==0: no match found in the first place in ucnv_extSimpleMatchToU()
361 * - match<0: partial match, not supported for simple conversion (and flush==TRUE) in ucnv_extSimpleMatchToU()
367 * continue partial match with new input
368 * never called for simple, single-character conversion
374 uint32_t value = 0; /* initialize output-only param to 0 to silence gcc */ in ucnv_extContinueMatchToU()
375 int32_t match, length; in ucnv_extContinueMatchToU() local
377 match=ucnv_extMatchToU(cnv->sharedData->mbcs.extIndexes, (int8_t)UCNV_SISO_STATE(cnv), in ucnv_extContinueMatchToU()
378 cnv->preToU, cnv->preToULength, in ucnv_extContinueMatchToU()
379 pArgs->source, (int32_t)(pArgs->sourceLimit-pArgs->source), in ucnv_extContinueMatchToU()
381 cnv->useFallback, pArgs->flush); in ucnv_extContinueMatchToU()
382 if(match>0) { in ucnv_extContinueMatchToU()
383 if(match>=cnv->preToULength) { in ucnv_extContinueMatchToU()
385 pArgs->source+=match-cnv->preToULength; in ucnv_extContinueMatchToU()
386 cnv->preToULength=0; in ucnv_extContinueMatchToU()
388 /* the match did not use all of preToU[] - keep the rest for replay */ in ucnv_extContinueMatchToU()
389 length=cnv->preToULength-match; in ucnv_extContinueMatchToU()
390 uprv_memmove(cnv->preToU, cnv->preToU+match, length); in ucnv_extContinueMatchToU()
391 cnv->preToULength=(int8_t)-length; in ucnv_extContinueMatchToU()
395 ucnv_extWriteToU(cnv, cnv->sharedData->mbcs.extIndexes, in ucnv_extContinueMatchToU()
397 &pArgs->target, pArgs->targetLimit, in ucnv_extContinueMatchToU()
398 &pArgs->offsets, srcIndex, in ucnv_extContinueMatchToU()
400 } else if(match<0) { in ucnv_extContinueMatchToU()
401 /* save state for partial match */ in ucnv_extContinueMatchToU()
406 s=pArgs->source; in ucnv_extContinueMatchToU()
407 match=-match; in ucnv_extContinueMatchToU()
408 for(j=cnv->preToULength; j<match; ++j) { in ucnv_extContinueMatchToU()
409 cnv->preToU[j]=*s++; in ucnv_extContinueMatchToU()
411 pArgs->source=s; /* same as *src=srcLimit; because we reached the end of input */ in ucnv_extContinueMatchToU()
412 cnv->preToULength=(int8_t)match; in ucnv_extContinueMatchToU()
413 } else /* match==0 */ { in ucnv_extContinueMatchToU()
415 * no match in ucnv_extContinueMatchToU()
419 * 1. The first codepage character is unmappable - that's how we got into in ucnv_extContinueMatchToU()
433 uprv_memcpy(cnv->toUBytes, cnv->preToU, cnv->preToUFirstLength); in ucnv_extContinueMatchToU()
434 cnv->toULength=cnv->preToUFirstLength; in ucnv_extContinueMatchToU()
437 length=cnv->preToULength-cnv->preToUFirstLength; in ucnv_extContinueMatchToU()
439 uprv_memmove(cnv->preToU, cnv->preToU+cnv->preToUFirstLength, length); in ucnv_extContinueMatchToU()
443 cnv->preToULength=(int8_t)-length; in ucnv_extContinueMatchToU()
450 /* from Unicode ------------------------------------------------------------- */
452 // Use roundtrips, "good one-way" mappings, and some normal fallbacks.
472 i=limit-start; in ucnv_extFindFromU()
476 /* start<limit-1 */ in ucnv_extFindFromU()
489 /* always break at start==limit-1 */ in ucnv_extFindFromU()
506 return -1; /* not found */ in ucnv_extFindFromU()
513 * @param pre UChars that must match; !initialMatch: partial match with them
515 * @param src UChars that can be used to complete a match
517 * @param pMatchValue [out] output result value for the match from the data structure
518 * @param useFallback "use fallback" flag, usually from cnv->useFallback
520 * @return >1: matched, return value=total match length (number of input units matched)
523 * 0: no match
524 * <0: partial match, return value=negative total match length
548 return 0; /* no extension data, no match */ in ucnv_extMatchFromU()
574 /* partial match, enter the loop below */ in ucnv_extMatchFromU()
586 /* match input units until there is a full match or the input is consumed */ in ucnv_extMatchFromU()
596 /* remember longest match so far */ in ucnv_extMatchFromU()
601 /* match pre[] then src[] */ in ucnv_extMatchFromU()
607 /* all input consumed, partial match */ in ucnv_extMatchFromU()
610 * end of the entire input stream, stop with the longest match so far in ucnv_extMatchFromU()
611 * or: partial match must not be longer than UCNV_EXT_MAX_UCHARS in ucnv_extMatchFromU()
617 return -(2+length); in ucnv_extMatchFromU()
624 /* no match here, stop with the longest match so far */ in ucnv_extMatchFromU()
629 /* partial match, continue */ in ucnv_extMatchFromU()
633 /* full match, stop with result */ in ucnv_extMatchFromU()
637 /* full match on fallback not taken, stop with the longest match so far */ in ucnv_extMatchFromU()
645 /* no match at all */ in ucnv_extMatchFromU()
650 /* full match, stop with result */ in ucnv_extMatchFromU()
713 if((prevLength=cnv->fromUnicodeStatus)!=0) { in ucnv_extWriteFromU()
718 /* change from double-byte mode to single-byte */ in ucnv_extWriteFromU()
720 cnv->fromUnicodeStatus=1; in ucnv_extWriteFromU()
722 /* change from single-byte mode to double-byte */ in ucnv_extWriteFromU()
724 cnv->fromUnicodeStatus=2; in ucnv_extWriteFromU()
757 uint32_t value = 0; /* initialize output-only param to 0 to silence gcc */ in ucnv_extInitialMatchFromU()
758 int32_t match; in ucnv_extInitialMatchFromU() local
760 /* try to match */ in ucnv_extInitialMatchFromU()
761 match=ucnv_extMatchFromU(cx, cp, in ucnv_extInitialMatchFromU()
763 *src, (int32_t)(srcLimit-*src), in ucnv_extInitialMatchFromU()
765 cnv->useFallback, flush); in ucnv_extInitialMatchFromU()
767 /* reject a match if the result is a single byte for DBCS-only */ in ucnv_extInitialMatchFromU()
768 if( match>=2 && in ucnv_extInitialMatchFromU()
770 cnv->sharedData->mbcs.outputType==MBCS_OUTPUT_DBCS_ONLY) in ucnv_extInitialMatchFromU()
773 *src+=match-2; /* remove 2 for the initial code point */ in ucnv_extInitialMatchFromU()
782 } else if(match<0) { in ucnv_extInitialMatchFromU()
783 /* save state for partial match */ in ucnv_extInitialMatchFromU()
788 cnv->preFromUFirstCP=cp; in ucnv_extInitialMatchFromU()
792 match=-match-2; /* remove 2 for the initial code point */ in ucnv_extInitialMatchFromU()
793 for(j=0; j<match; ++j) { in ucnv_extInitialMatchFromU()
794 cnv->preFromU[j]=*s++; in ucnv_extInitialMatchFromU()
797 cnv->preFromULength=(int8_t)match; in ucnv_extInitialMatchFromU()
799 } else if(match==1) { in ucnv_extInitialMatchFromU()
801 cnv->useSubChar1=TRUE; in ucnv_extInitialMatchFromU()
803 } else /* match==0 no match */ { in ucnv_extInitialMatchFromU()
817 int32_t match; in ucnv_extSimpleMatchFromU() local
819 /* try to match */ in ucnv_extSimpleMatchFromU()
820 match=ucnv_extMatchFromU(cx, in ucnv_extSimpleMatchFromU()
826 if(match>=2) { in ucnv_extSimpleMatchFromU()
827 /* write result for simple, single-character conversion */ in ucnv_extSimpleMatchFromU()
837 return isRoundtrip ? length : -length; in ucnv_extSimpleMatchFromU()
840 /* de-serialize a 4-byte result */ in ucnv_extSimpleMatchFromU()
847 return isRoundtrip ? 4 : -4; in ucnv_extSimpleMatchFromU()
853 * return no match because in ucnv_extSimpleMatchFromU()
854 * - match>1 && resultLength>4: result too long for simple conversion in ucnv_extSimpleMatchFromU()
855 * - match==1: no match found, <subchar1> preferred in ucnv_extSimpleMatchFromU()
856 * - match==0: no match found in the first place in ucnv_extSimpleMatchFromU()
857 * - match<0: partial match, not supported for simple conversion (and flush==TRUE) in ucnv_extSimpleMatchFromU()
863 * continue partial match with new input, requires cnv->preFromUFirstCP>=0
864 * never called for simple, single-character conversion
870 uint32_t value = 0; /* initialize output-only param to 0 to silence gcc */ in ucnv_extContinueMatchFromU()
871 int32_t match; in ucnv_extContinueMatchFromU() local
873 match=ucnv_extMatchFromU(cnv->sharedData->mbcs.extIndexes, in ucnv_extContinueMatchFromU()
874 cnv->preFromUFirstCP, in ucnv_extContinueMatchFromU()
875 cnv->preFromU, cnv->preFromULength, in ucnv_extContinueMatchFromU()
876 pArgs->source, (int32_t)(pArgs->sourceLimit-pArgs->source), in ucnv_extContinueMatchFromU()
878 cnv->useFallback, pArgs->flush); in ucnv_extContinueMatchFromU()
879 if(match>=2) { in ucnv_extContinueMatchFromU()
880 match-=2; /* remove 2 for the initial code point */ in ucnv_extContinueMatchFromU()
882 if(match>=cnv->preFromULength) { in ucnv_extContinueMatchFromU()
884 pArgs->source+=match-cnv->preFromULength; in ucnv_extContinueMatchFromU()
885 cnv->preFromULength=0; in ucnv_extContinueMatchFromU()
887 /* the match did not use all of preFromU[] - keep the rest for replay */ in ucnv_extContinueMatchFromU()
888 int32_t length=cnv->preFromULength-match; in ucnv_extContinueMatchFromU()
889 u_memmove(cnv->preFromU, cnv->preFromU+match, length); in ucnv_extContinueMatchFromU()
890 cnv->preFromULength=(int8_t)-length; in ucnv_extContinueMatchFromU()
893 /* finish the partial match */ in ucnv_extContinueMatchFromU()
894 cnv->preFromUFirstCP=U_SENTINEL; in ucnv_extContinueMatchFromU()
897 ucnv_extWriteFromU(cnv, cnv->sharedData->mbcs.extIndexes, in ucnv_extContinueMatchFromU()
899 &pArgs->target, pArgs->targetLimit, in ucnv_extContinueMatchFromU()
900 &pArgs->offsets, srcIndex, in ucnv_extContinueMatchFromU()
902 } else if(match<0) { in ucnv_extContinueMatchFromU()
903 /* save state for partial match */ in ucnv_extContinueMatchFromU()
908 s=pArgs->source; in ucnv_extContinueMatchFromU()
909 match=-match-2; /* remove 2 for the initial code point */ in ucnv_extContinueMatchFromU()
910 for(j=cnv->preFromULength; j<match; ++j) { in ucnv_extContinueMatchFromU()
912 cnv->preFromU[j]=*s++; in ucnv_extContinueMatchFromU()
914 pArgs->source=s; /* same as *src=srcLimit; because we reached the end of input */ in ucnv_extContinueMatchFromU()
915 cnv->preFromULength=(int8_t)match; in ucnv_extContinueMatchFromU()
916 } else /* match==0 or 1 */ { in ucnv_extContinueMatchFromU()
918 * no match in ucnv_extContinueMatchFromU()
922 * 1. The first code point is unmappable - that's how we got into in ucnv_extContinueMatchFromU()
935 if(match==1) { in ucnv_extContinueMatchFromU()
937 cnv->useSubChar1=TRUE; in ucnv_extContinueMatchFromU()
941 cnv->fromUChar32=cnv->preFromUFirstCP; in ucnv_extContinueMatchFromU()
942 cnv->preFromUFirstCP=U_SENTINEL; in ucnv_extContinueMatchFromU()
945 cnv->preFromULength=-cnv->preFromULength; in ucnv_extContinueMatchFromU()
959 // By analogy, also do not add "good one-way" mappings. in extSetUseMapping()
972 // Do not add <subchar1> entries or other (future?) pseudo-entries in extSetUseMapping()
1003 sa->add(sa->set, firstCP); in ucnv_extGetUnicodeSetString()
1006 sa->addString(sa->set, s, length); in ucnv_extGetUnicodeSetString()
1024 sa->addString(sa->set, s, length+1); in ucnv_extGetUnicodeSetString()
1046 cx=sharedData->mbcs.extIndexes; in ucnv_extGetUnicodeSet()
1057 /* enumerate the from-Unicode trie table */ in ucnv_extGetUnicodeSet()
1062 } else if( sharedData->mbcs.outputType==MBCS_OUTPUT_DBCS_ONLY || in ucnv_extGetUnicodeSet()
1065 /* DBCS-only, ignore single-byte results */ in ucnv_extGetUnicodeSet()
1111 … (uint16_t)((value=UCNV_EXT_FROM_U_GET_DATA(value))-0xa1a1)<=(0xfefe - 0xa1a1) && in ucnv_extGetUnicodeSet()
1112 (uint8_t)(value-0xa1)<=(0xfe - 0xa1))) { in ucnv_extGetUnicodeSet()
1118 … (uint16_t)((value=UCNV_EXT_FROM_U_GET_DATA(value))-0xa1a1)<=(0xfdfe - 0xa1a1) && in ucnv_extGetUnicodeSet()
1119 (uint8_t)(value-0xa1)<=(0xfe - 0xa1))) { in ucnv_extGetUnicodeSet()
1130 sa->add(sa->set, c); in ucnv_extGetUnicodeSet()