Coverage Report

Created: 2026-09-01 06:54

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/liblouis/liblouis/commonTranslationFunctions.c
Line
Count
Source
1
/* liblouis Braille Translation and Back-Translation Library
2
3
   Based on the Linux screenreader BRLTTY, copyright (C) 1999-2006 by The
4
   BRLTTY Team
5
6
   Copyright (C) 2004, 2005, 2006 ViewPlus Technologies, Inc. www.viewplus.com
7
   Copyright (C) 2004, 2005, 2006 JJB Software, Inc. www.jjb-software.com
8
   Copyright (C) 2016 Mike Gray, American Printing House for the Blind
9
   Copyright (C) 2016 Davy Kager, Dedicon
10
11
   This file is part of liblouis.
12
13
   liblouis is free software: you can redistribute it and/or modify it
14
   under the terms of the GNU Lesser General Public License as published
15
   by the Free Software Foundation, either version 2.1 of the License, or
16
   (at your option) any later version.
17
18
   liblouis is distributed in the hope that it will be useful, but
19
   WITHOUT ANY WARRANTY; without even the implied warranty of
20
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
   Lesser General Public License for more details.
22
23
   You should have received a copy of the GNU Lesser General Public
24
   License along with liblouis. If not, see <http://www.gnu.org/licenses/>.
25
*/
26
27
#include "config.h"
28
29
#include <string.h>
30
#include "internal.h"
31
32
static int passVariables[NUMVAR];
33
34
void EXPORT_CALL
35
336
_lou_resetPassVariables(void) {
36
336
  memset(passVariables, 0, sizeof(passVariables[0]) * NUMVAR);
37
336
}
38
39
int EXPORT_CALL
40
17.2k
_lou_handlePassVariableTest(const widechar *instructions, int *IC, int *itsTrue) {
41
17.2k
  switch (instructions[*IC]) {
42
0
  case pass_eq:
43
0
    if (passVariables[instructions[*IC + 1]] != instructions[*IC + 2]) *itsTrue = 0;
44
0
    *IC += 3;
45
0
    return 1;
46
47
17.2k
  case pass_lt:
48
17.2k
    if (passVariables[instructions[*IC + 1]] >= instructions[*IC + 2]) *itsTrue = 0;
49
17.2k
    *IC += 3;
50
17.2k
    return 1;
51
52
0
  case pass_gt:
53
0
    if (passVariables[instructions[*IC + 1]] <= instructions[*IC + 2]) *itsTrue = 0;
54
0
    *IC += 3;
55
0
    return 1;
56
57
19
  case pass_lteq:
58
19
    if (passVariables[instructions[*IC + 1]] > instructions[*IC + 2]) *itsTrue = 0;
59
19
    *IC += 3;
60
19
    return 1;
61
62
0
  case pass_gteq:
63
0
    if (passVariables[instructions[*IC + 1]] < instructions[*IC + 2]) *itsTrue = 0;
64
0
    *IC += 3;
65
0
    return 1;
66
67
0
  default:
68
0
    return 0;
69
17.2k
  }
70
17.2k
}
71
72
int EXPORT_CALL
73
180k
_lou_handlePassVariableAction(const widechar *instructions, int *IC) {
74
180k
  switch (instructions[*IC]) {
75
131
  case pass_eq:
76
131
    passVariables[instructions[*IC + 1]] = instructions[*IC + 2];
77
131
    *IC += 3;
78
131
    return 1;
79
80
20.4k
  case pass_hyphen:
81
20.4k
    passVariables[instructions[*IC + 1]] -= 1;
82
20.4k
    if (passVariables[instructions[*IC + 1]] < 0)
83
20.4k
      passVariables[instructions[*IC + 1]] = 0;
84
20.4k
    *IC += 2;
85
20.4k
    return 1;
86
87
114k
  case pass_plus:
88
114k
    passVariables[instructions[*IC + 1]] += 1;
89
114k
    *IC += 2;
90
114k
    return 1;
91
92
45.5k
  default:
93
45.5k
    return 0;
94
180k
  }
95
180k
}