X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fthird_party%2Fliblouis%2Fsrc%2Fliblouis%2Ftranscommon.ci;h=2205092dfcff70e7fc46c88b502aa45bda0fde38;hb=3545e9f2671f595d2a2f3ee75ca0393b01e35ef6;hp=e2783836f380dbb77e9e19c904cffdcc0e22e42f;hpb=7d210d4c7e9ba36e635eabc5b5780495f8a63292;p=platform%2Fframework%2Fweb%2Fcrosswalk.git diff --git a/src/third_party/liblouis/src/liblouis/transcommon.ci b/src/third_party/liblouis/src/liblouis/transcommon.ci index e278383..2205092 100644 --- a/src/third_party/liblouis/src/liblouis/transcommon.ci +++ b/src/third_party/liblouis/src/liblouis/transcommon.ci @@ -62,9 +62,9 @@ static int transCharslen; static int checkAttr (const widechar c, const TranslationTableCharacterAttributes a, int nm); static int putCharacter (widechar c); -static int makeCorrections (void); -static int passDoTest (void); -static int passDoAction (void); +static int makeCorrections (); +static int passDoTest (); +static int passDoAction (); static int passVariables[NUMVAR]; static int passCharDots; static int passSrc; @@ -80,6 +80,9 @@ static int *outputPositions; static int *inputPositions; static int cursorPosition; static int cursorStatus; +static const TranslationTableRule **appliedRules; +static int maxAppliedRules; +static int appliedRulesCount; static TranslationTableCharacter * findCharOrDots (widechar c, int m) @@ -130,7 +133,7 @@ checkAttr (const widechar c, const TranslationTableCharacterAttributes } static int -findAttribOrSwapRules (void) +findAttribOrSwapRules () { int save_transCharslen = transCharslen; const TranslationTableRule *save_transRule = transRule; @@ -167,16 +170,14 @@ compareChars (const widechar * address1, const widechar * address2, int } static int -makeCorrections (void) +makeCorrections () { - int k; if (!table->corrections) return 1; src = 0; dest = 0; srcIncremented = 1; - for (k = 0; k < NUMVAR; k++) - passVariables[k] = 0; + memset (passVariables, 0, sizeof(int) * NUMVAR); while (src < srcmax) { int length = srcmax - src; @@ -245,6 +246,8 @@ makeCorrections (void) currentOutput[dest++] = currentInput[src++]; break; case CTO_Correct: + if (appliedRules != NULL && appliedRulesCount < maxAppliedRules) + appliedRules[appliedRulesCount++] = transRule; if (!passDoAction ()) goto failure; if (endReplace == src) @@ -255,13 +258,25 @@ makeCorrections (void) break; } } + + { // We have to transform typebuf accordingly + int pos; + unsigned short *typebuf_temp; + if ((typebuf_temp = malloc (dest * sizeof (unsigned short))) == NULL) + outOfMemory (); + for (pos = 0; pos < dest; pos++) + typebuf_temp[pos] = typebuf[srcMapping[pos]]; + memcpy (typebuf, typebuf_temp, dest * sizeof (unsigned short)); + free (typebuf_temp); + } + failure: realInlen = src; return 1; } static int -matchcurrentInput (void) +matchCurrentInput () { int k; int kk = passSrc; @@ -393,7 +408,7 @@ static TranslationTableRule *groupingRule; static widechar groupingOp; static int -replaceGrouping (void) +replaceGrouping () { widechar startCharDots = groupingRule->charsdots[2 * passCharDots]; widechar endCharDots = groupingRule->charsdots[2 * passCharDots + 1]; @@ -450,7 +465,7 @@ replaceGrouping (void) } static int -removeGrouping (void) +removeGrouping () { widechar startCharDots = groupingRule->charsdots[2 * passCharDots]; widechar endCharDots = groupingRule->charsdots[2 * passCharDots + 1]; @@ -500,7 +515,7 @@ static int searchIC; static int searchSrc; static int -doPassSearch (void) +doPassSearch () { int level = 0; int k, kk; @@ -669,13 +684,13 @@ doPassSearch (void) } static int -passDoTest (void) +passDoTest () { int k; int not = 0; - TranslationTableOffset ruleOffset; - TranslationTableRule *rule; - TranslationTableCharacterAttributes attributes; + TranslationTableOffset ruleOffset = 0; + TranslationTableRule *rule = NULL; + TranslationTableCharacterAttributes attributes = 0; groupingRule = NULL; passSrc = src; passInstructions = &transRule->charsdots[transCharslen]; @@ -715,7 +730,7 @@ passDoTest (void) continue; case pass_string: case pass_dots: - itsTrue = matchcurrentInput (); + itsTrue = matchCurrentInput (); passSrc += passInstructions[passIC + 1]; passIC += passInstructions[passIC + 1] + 2; break; @@ -847,11 +862,11 @@ passDoTest (void) } static int -passDoAction (void) +passDoAction () { int k; - TranslationTableOffset ruleOffset; - TranslationTableRule *rule; + TranslationTableOffset ruleOffset = 0; + TranslationTableRule *rule = NULL; if ((dest + startReplace - startMatch) > destmax) return 0; if (transOpcode != CTO_Context) @@ -945,7 +960,7 @@ passDoAction (void) } static int -checkDots (void) +checkDots () { int k; int kk = src; @@ -956,7 +971,7 @@ checkDots (void) } static void -passSelectRule (void) +passSelectRule () { int length = srcmax - src; const TranslationTableCharacter *dots; @@ -1028,14 +1043,12 @@ passSelectRule (void) } static int -translatePass (void) +translatePass () { - int k; prevTransOpcode = CTO_None; src = dest = 0; srcIncremented = 1; - for (k = 0; k < NUMVAR; k++) - passVariables[k] = 0; + memset (passVariables, 0, sizeof(int) * NUMVAR); while (src < srcmax) { /*the main multipass translation loop */ passSelectRule (); @@ -1046,6 +1059,8 @@ translatePass (void) case CTO_Pass2: case CTO_Pass3: case CTO_Pass4: + if (appliedRules != NULL && appliedRulesCount < maxAppliedRules) + appliedRules[appliedRulesCount++] = transRule; if (!passDoAction ()) goto failure; if (endReplace == src)