Coverage Report

Created: 2023-09-25 06:03

/src/fribidi/lib/fribidi-mirroring.c
Line
Count
Source (jump to first uncovered line)
1
/* fribidi-mirroring.c - get mirrored character
2
 *
3
 * Copyright (C) 2004  Sharif FarsiWeb, Inc
4
 * Copyright (C) 2001, 2002, 2004  Behdad Esfahbod
5
 * Copyright (C) 1999, 2000, 2017  Dov Grobgeld
6
 *
7
 * This file is part of GNU FriBidi.
8
 * 
9
 * GNU FriBidi is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU Lesser General Public License
11
 * as published by the Free Software Foundation; either version 2.1
12
 * of the License, or (at your option) any later version.
13
 * 
14
 * GNU FriBidi is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU Lesser General Public License for more details.
18
 * 
19
 * You should have received a copy of the GNU Lesser General Public License
20
 * along with GNU FriBidi; if not, write to the Free Software
21
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
 * 
23
 * For licensing issues, contact <fribidi.license@gmail.com> or write to
24
 * Sharif FarsiWeb, Inc., PO Box 13445-389, Tehran, Iran.
25
 *
26
 * Author(s):
27
 *   Behdad Esfahbod, 2001, 2002, 2004
28
 *   Dov Grobgeld, 1999, 2000
29
 */
30
31
#include "common.h"
32
33
#include <fribidi-mirroring.h>
34
35
#include "mirroring.tab.i"
36
37
FRIBIDI_ENTRY fribidi_boolean
38
fribidi_get_mirror_char (
39
  /* input */
40
  FriBidiChar ch,
41
  /* output */
42
  FriBidiChar *mirrored_ch
43
)
44
0
{
45
0
  register FriBidiChar result;
46
0
  result = FRIBIDI_GET_MIRRORING (ch);
47
0
  if (mirrored_ch)
48
0
    *mirrored_ch = result;
49
0
  return ch != result ? true : false;
50
0
}
51
52
53
FRIBIDI_ENTRY void
54
fribidi_shape_mirroring (
55
  /* input */
56
  const FriBidiLevel *embedding_levels,
57
  const FriBidiStrIndex len,
58
  /* input and output */
59
  FriBidiChar *str
60
)
61
0
{
62
0
  register FriBidiStrIndex i;
63
64
0
  DBG ("in fribidi_shape_mirroring");
65
66
0
  if UNLIKELY
67
0
    (len == 0 || !str) return;
68
69
0
  fribidi_assert (embedding_levels);
70
71
  /* L4. Mirror all characters that are in odd levels and have mirrors. */
72
0
  for (i = len - 1; i >= 0; i--)
73
0
    if (FRIBIDI_LEVEL_IS_RTL (embedding_levels[i]))
74
0
      {
75
0
  FriBidiChar mirrored_ch;
76
77
0
  if (fribidi_get_mirror_char (str[i], &mirrored_ch))
78
0
    str[i] = mirrored_ch;
79
0
      }
80
0
}
81
82
/* Editor directions:
83
 * Local Variables:
84
 *   mode: c
85
 *   c-basic-offset: 2
86
 *   indent-tabs-mode: t
87
 *   tab-width: 8
88
 * End:
89
 * vim: textwidth=78: autoindent: cindent: shiftwidth=2: tabstop=8:
90
 */