Coverage Report

Created: 2026-11-21 06:30

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
78
_lou_resetPassVariables(void) {
36
78
  memset(passVariables, 0, sizeof(passVariables[0]) * NUMVAR);
37
78
}
38
39
int EXPORT_CALL
40
3
_lou_handlePassVariableTest(const widechar *instructions, int *IC, int *itsTrue) {
41
3
  switch (instructions[*IC]) {
42
1
  case pass_eq:
43
1
    if (passVariables[instructions[*IC + 1]] != instructions[*IC + 2]) *itsTrue = 0;
44
1
    *IC += 3;
45
1
    return 1;
46
47
2
  case pass_lt:
48
2
    if (passVariables[instructions[*IC + 1]] >= instructions[*IC + 2]) *itsTrue = 0;
49
2
    *IC += 3;
50
2
    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
0
  case pass_lteq:
58
0
    if (passVariables[instructions[*IC + 1]] > instructions[*IC + 2]) *itsTrue = 0;
59
0
    *IC += 3;
60
0
    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
3
  }
70
3
}
71
72
int EXPORT_CALL
73
0
_lou_handlePassVariableAction(const widechar *instructions, int *IC) {
74
0
  switch (instructions[*IC]) {
75
0
  case pass_eq:
76
0
    passVariables[instructions[*IC + 1]] = instructions[*IC + 2];
77
0
    *IC += 3;
78
0
    return 1;
79
80
0
  case pass_hyphen:
81
0
    passVariables[instructions[*IC + 1]] -= 1;
82
0
    if (passVariables[instructions[*IC + 1]] < 0)
83
0
      passVariables[instructions[*IC + 1]] = 0;
84
0
    *IC += 2;
85
0
    return 1;
86
87
0
  case pass_plus:
88
0
    passVariables[instructions[*IC + 1]] += 1;
89
0
    *IC += 2;
90
0
    return 1;
91
92
0
  default:
93
0
    return 0;
94
0
  }
95
0
}