Coverage Report

Created: 2025-07-18 06:48

/src/tmux/utf8-combined.c
Line
Count
Source (jump to first uncovered line)
1
/* $OpenBSD$ */
2
3
/*
4
 * Copyright (c) 2023 Nicholas Marriott <nicholas.marriott@gmail.com>
5
 *
6
 * Permission to use, copy, modify, and distribute this software for any
7
 * purpose with or without fee is hereby granted, provided that the above
8
 * copyright notice and this permission notice appear in all copies.
9
 *
10
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14
 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15
 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
 */
18
19
#include <sys/types.h>
20
21
#include <stdlib.h>
22
#include <string.h>
23
#include <wchar.h>
24
25
#include "tmux.h"
26
27
/* Has this got a zero width joiner at the end? */
28
int
29
utf8_has_zwj(const struct utf8_data *ud)
30
1.50k
{
31
1.50k
  if (ud->size < 3)
32
1.50k
    return (0);
33
0
  return (memcmp(ud->data + ud->size - 3, "\342\200\215", 3) == 0);
34
1.50k
}
35
36
/* Is this a zero width joiner? */
37
int
38
utf8_is_zwj(const struct utf8_data *ud)
39
17.6k
{
40
17.6k
  if (ud->size != 3)
41
17.4k
    return (0);
42
209
  return (memcmp(ud->data, "\342\200\215", 3) == 0);
43
17.6k
}
44
45
/* Is this a variation selector? */
46
int
47
utf8_is_vs(const struct utf8_data *ud)
48
17.6k
{
49
17.6k
  if (ud->size != 3)
50
17.4k
    return (0);
51
209
  return (memcmp(ud->data, "\357\270\217", 3) == 0);
52
17.6k
}
53
54
/* Is this in the modifier table? */
55
int
56
utf8_is_modifier(const struct utf8_data *ud)
57
1.50k
{
58
1.50k
  wchar_t wc;
59
60
1.50k
  if (utf8_towc(ud, &wc) != UTF8_DONE)
61
0
    return (0);
62
1.50k
  switch (wc) {
63
0
  case 0x1F1E6:
64
0
  case 0x1F1E7:
65
0
  case 0x1F1E8:
66
0
  case 0x1F1E9:
67
0
  case 0x1F1EA:
68
0
  case 0x1F1EB:
69
0
  case 0x1F1EC:
70
0
  case 0x1F1ED:
71
0
  case 0x1F1EE:
72
0
  case 0x1F1EF:
73
0
  case 0x1F1F0:
74
0
  case 0x1F1F1:
75
0
  case 0x1F1F2:
76
0
  case 0x1F1F3:
77
0
  case 0x1F1F4:
78
0
  case 0x1F1F5:
79
0
  case 0x1F1F6:
80
0
  case 0x1F1F7:
81
0
  case 0x1F1F8:
82
0
  case 0x1F1F9:
83
0
  case 0x1F1FA:
84
0
  case 0x1F1FB:
85
0
  case 0x1F1FC:
86
0
  case 0x1F1FD:
87
0
  case 0x1F1FE:
88
0
  case 0x1F1FF:
89
0
  case 0x1F3FB:
90
0
  case 0x1F3FC:
91
0
  case 0x1F3FD:
92
0
  case 0x1F3FE:
93
0
  case 0x1F3FF:
94
0
    return (1);
95
1.50k
  }
96
1.50k
  return (0);
97
1.50k
}