~ubuntu-branches/debian/experimental/liblouis/experimental

« back to all changes in this revision

Viewing changes to liblouis/lou_translateString.c

  • Committer: Package Import Robot
  • Author(s): Samuel Thibault
  • Date: 2012-12-18 23:52:16 UTC
  • mfrom: (1.1.11)
  • Revision ID: package-import@ubuntu.com-20121218235216-nxoqw6pmfcdf02gh
Tags: 2.5.2-1
* New upstream release
  - Update copyright
  - Remove patches/format, merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
               char *typeform, char *spacing, int *outputPos,
59
59
               int *inputPos, int *cursorPos, int modex)
60
60
{
 
61
  return trace_translate (tableList, inbufx, inlen, outbuf, outlen,
 
62
                          typeform, spacing, outputPos, inputPos, cursorPos,
 
63
                          NULL, NULL, modex);
 
64
}
 
65
 
 
66
int
 
67
trace_translate (const char *tableList, const widechar * inbufx,
 
68
                 int *inlen, widechar * outbuf, int *outlen,
 
69
                 char *typeform, char *spacing, int *outputPos,
 
70
                 int *inputPos, int *cursorPos,
 
71
                 const TranslationTableRule ** rules, int *rulesLen, int modex)
 
72
{
61
73
  int k;
62
74
  int goodTrans = 1;
63
75
  if (tableList == NULL || inbufx == NULL || inlen == NULL || outbuf ==
147
159
      else
148
160
        memset (destSpacing, '*', destmax);
149
161
    }
 
162
  appliedRulesCount = 0;
 
163
  if (rules != NULL && rulesLen != NULL)
 
164
    {
 
165
      appliedRules = rules;
 
166
      maxAppliedRules = *rulesLen;
 
167
    }
 
168
  else
 
169
    {
 
170
      appliedRules = NULL;
 
171
      maxAppliedRules = 0;
 
172
    }
150
173
  currentPass = 0;
151
174
  if ((mode & pass1Only))
152
175
    {
238
261
    }
239
262
  if (cursorPos != NULL)
240
263
    *cursorPos = cursorPosition;
 
264
  if (rulesLen != NULL)
 
265
    *rulesLen = appliedRulesCount;
241
266
  return goodTrans;
242
267
}
243
268
 
 
269
int EXPORT_CALL
 
270
lou_translatePrehyphenated (const char *tableList,
 
271
                            const widechar * inbufx, int *inlen,
 
272
                            widechar * outbuf, int *outlen,
 
273
                            char *typeform, char *spacing,
 
274
                            int *outputPos, int *inputPos, int *cursorPos,
 
275
                            char *inputHyphens, char *outputHyphens,
 
276
                            int modex)
 
277
{
 
278
  int rv = 1;
 
279
  int *alloc_inputPos = NULL;
 
280
  if (inputHyphens != NULL)
 
281
    {
 
282
      if (outputHyphens == NULL)
 
283
        return 0;
 
284
      if (inputPos == NULL)
 
285
        {
 
286
          alloc_inputPos = malloc (*outlen * sizeof (int));
 
287
          inputPos = alloc_inputPos;
 
288
        }
 
289
    }
 
290
  if (lou_translate (tableList, inbufx, inlen, outbuf, outlen, typeform,
 
291
                     spacing, outputPos, inputPos, cursorPos, modex))
 
292
    {
 
293
      if (inputHyphens != NULL)
 
294
        {
 
295
          int inpos = 0;
 
296
          int outpos;
 
297
          for (outpos = 0; outpos < *outlen; outpos++)
 
298
            {
 
299
              int new_inpos = inputPos[outpos];
 
300
              if (new_inpos < inpos)
 
301
                {
 
302
                  rv = 0;
 
303
                  break;
 
304
                }
 
305
              if (new_inpos > inpos)
 
306
                outputHyphens[outpos] = inputHyphens[new_inpos];
 
307
              else
 
308
                outputHyphens[outpos] = '0';
 
309
              inpos = new_inpos;
 
310
            }
 
311
        }
 
312
    }
 
313
  if (alloc_inputPos != NULL)
 
314
    free (alloc_inputPos);
 
315
  return rv;
 
316
}
 
317
 
244
318
static TranslationTableOpcode indicOpcode;
245
319
static const TranslationTableRule *indicRule;
246
320
static int dontContract = 0;
628
702
{
629
703
  int k;
630
704
  for (k = 0; k < table->lenBeginCaps; k++)
631
 
    if (!checkAttr (currentInput[src + k], CTC_UpperCase, 0))
 
705
    if (k >= srcmax - src || 
 
706
        !checkAttr (currentInput[src + k], CTC_UpperCase, 0))
632
707
      return 0;
633
708
  return 1;
634
709
}
1062
1137
  int curSrc;
1063
1138
  if (start >= srcmax)
1064
1139
    return 1;
1065
 
  while (checkAttr (currentInput[start], CTC_Space, 0) && start < srcmax)
 
1140
  while (start < srcmax && checkAttr (currentInput[start], CTC_Space, 0))
1066
1141
    start++;
1067
1142
  if (start == srcmax || (transOpcode == CTO_JoinableWord && (!checkAttr
1068
1143
                                                              (currentInput
1077
1152
                                                               0))))
1078
1153
    return 1;
1079
1154
  end = start;
1080
 
  while (!checkAttr (currentInput[end], CTC_Space, 0) && end < srcmax)
 
1155
  while (end < srcmax && !checkAttr (currentInput[end], CTC_Space, 0))
1081
1156
    end++;
1082
1157
  if ((mode & (compbrlAtCursor | compbrlLeftCursor)) && cursorPosition
1083
1158
      >= start && cursorPosition < end)
1730
1805
      if (!insertIndicators ())
1731
1806
        goto failure;
1732
1807
      for_selectRule ();
 
1808
      if (appliedRules != NULL && appliedRulesCount < maxAppliedRules)
 
1809
        appliedRules[appliedRulesCount++] = transRule;
1733
1810
      srcIncremented = 1;
1734
1811
      prevSrc = src;
1735
1812
      switch (transOpcode)      /*Rules that pre-empt context and swap */
1748
1825
        switch (transOpcode)
1749
1826
          {
1750
1827
          case CTO_Context:
 
1828
            if (appliedRules != NULL && appliedRulesCount < maxAppliedRules)
 
1829
              appliedRules[appliedRulesCount++] = transRule;
1751
1830
            if (!passDoAction ())
1752
1831
              goto failure;
1753
1832
            if (endReplace == src)