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

« back to all changes in this revision

Viewing changes to tests/brl_checks.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:
24
24
    printf("%c", buf[i]);
25
25
}
26
26
 
 
27
/* Helper function to convert a typeform string of '0's, '1's, '2's etc.
 
28
   to the required format, which is an array of 0s, 1s, 2s, etc.
 
29
   For example, "0000011111000" is converted to {0,0,0,0,0,1,1,1,1,1,0,0,0}
 
30
   The caller is responsible for freeing the returned array. */
 
31
char *
 
32
convert_typeform(const char* typeform_string)
 
33
{
 
34
  int len = strlen(typeform_string);
 
35
  char *typeform = malloc(len * sizeof(char));
 
36
  for (int i=0; i<len; i++)
 
37
    typeform[i] = typeform_string[i] - '0';
 
38
  return typeform;
 
39
}
 
40
 
27
41
/* Check if a string is translated as expected. Return 0 if the
28
42
   translation is as expected and 1 otherwise. */
29
43
int
50
64
 
51
65
  int expectedlen = strlen(expected);
52
66
 
53
 
  inlen = strlen(str) * 2;
54
 
  outlen = inlen;
 
67
  inlen = strlen(str);
 
68
  outlen = inlen * 2;
55
69
  inbuf = malloc(sizeof(widechar) * inlen);
56
70
  outbuf = malloc(sizeof(widechar) * outlen);
57
71
  if (typeform != NULL)
58
72
    {
59
73
      typeformbuf = malloc(outlen);
60
 
      strcpy(typeformbuf, typeform);
 
74
      memcpy(typeformbuf, typeform, outlen);
61
75
    }
62
 
  if (!extParseChars(str, inbuf))
 
76
  inlen = extParseChars(str, inbuf);
 
77
  if (!inlen)
63
78
    {
64
79
      printf("Cannot parse input string.\n");
65
80
      return 1;
110
125
{
111
126
  widechar *inbuf;
112
127
  widechar *outbuf;
113
 
  int *inpos, *outpos;
 
128
  int *inpos;
114
129
  int inlen;
115
130
  int outlen;
116
131
  int i, rv = 0;
248
263
  int rv = 0;
249
264
 
250
265
  inlen = strlen(str);
251
 
  inbuf = malloc(sizeof(widechar) * (inlen + 1));
252
 
  if (!extParseChars(str, inbuf))
 
266
  inbuf = malloc(sizeof(widechar) * inlen);
 
267
  inlen = extParseChars(str, inbuf);
 
268
  if (!inlen)
253
269
    {
254
270
      printf("Cannot parse input string.\n");
255
271
      return 1;