Coverage Report

Created: 2026-01-25 07:18

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/gettext-0.26/gettext-tools/libgettextpo/streq.h
Line
Count
Source
1
/* Optimized string comparison.
2
   Copyright (C) 2001-2002, 2007, 2009-2025 Free Software Foundation, Inc.
3
4
   This file is free software: you can redistribute it and/or modify
5
   it under the terms of the GNU Lesser General Public License as
6
   published by the Free Software Foundation; either version 2.1 of the
7
   License, or (at your option) any later version.
8
9
   This file is distributed in the hope that it will be useful,
10
   but WITHOUT ANY WARRANTY; without even the implied warranty of
11
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
   GNU Lesser General Public License for more details.
13
14
   You should have received a copy of the GNU Lesser General Public License
15
   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
16
17
/* Written by Bruno Haible <bruno@clisp.org>.  */
18
19
#ifndef _GL_STREQ_H
20
#define _GL_STREQ_H
21
22
#include <string.h>
23
24
#ifdef __cplusplus
25
extern "C" {
26
#endif
27
28
29
/* STREQ_OPT optimizes string comparison with a small literal string.
30
     STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)
31
   is semantically equivalent to
32
     strcmp (s, "EUC-KR") == 0
33
   just faster.  */
34
35
/* Help GCC to generate good code for string comparisons with
36
   immediate strings. */
37
#if (defined __GNUC__ || defined __clang__) && defined __OPTIMIZE__
38
39
static inline int
40
streq9 (const char *s1, const char *s2)
41
0
{
42
0
  return strcmp (s1 + 9, s2 + 9) == 0;
43
0
}
Unexecuted instantiation: width.c:streq9
Unexecuted instantiation: u8-possible-linebreaks.c:streq9
44
45
static inline int
46
streq8 (const char *s1, const char *s2, char s28)
47
0
{
48
0
  if (s1[8] == s28)
49
0
    {
50
0
      if (s28 == 0)
51
0
        return 1;
52
0
      else
53
0
        return streq9 (s1, s2);
54
0
    }
55
0
  else
56
0
    return 0;
57
0
}
Unexecuted instantiation: width.c:streq8
Unexecuted instantiation: u8-possible-linebreaks.c:streq8
58
59
static inline int
60
streq7 (const char *s1, const char *s2, char s27, char s28)
61
0
{
62
0
  if (s1[7] == s27)
63
0
    {
64
0
      if (s27 == 0)
65
0
        return 1;
66
0
      else
67
0
        return streq8 (s1, s2, s28);
68
0
    }
69
0
  else
70
0
    return 0;
71
0
}
Unexecuted instantiation: width.c:streq7
Unexecuted instantiation: u8-possible-linebreaks.c:streq7
72
73
static inline int
74
streq6 (const char *s1, const char *s2, char s26, char s27, char s28)
75
0
{
76
0
  if (s1[6] == s26)
77
0
    {
78
0
      if (s26 == 0)
79
0
        return 1;
80
0
      else
81
0
        return streq7 (s1, s2, s27, s28);
82
0
    }
83
0
  else
84
0
    return 0;
85
0
}
Unexecuted instantiation: width.c:streq6
Unexecuted instantiation: u8-possible-linebreaks.c:streq6
86
87
static inline int
88
streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28)
89
0
{
90
0
  if (s1[5] == s25)
91
0
    {
92
0
      if (s25 == 0)
93
0
        return 1;
94
0
      else
95
0
        return streq6 (s1, s2, s26, s27, s28);
96
0
    }
97
0
  else
98
0
    return 0;
99
0
}
Unexecuted instantiation: width.c:streq5
Unexecuted instantiation: u8-possible-linebreaks.c:streq5
100
101
static inline int
102
streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28)
103
0
{
104
0
  if (s1[4] == s24)
105
0
    {
106
0
      if (s24 == 0)
107
0
        return 1;
108
0
      else
109
0
        return streq5 (s1, s2, s25, s26, s27, s28);
110
0
    }
111
0
  else
112
0
    return 0;
113
0
}
Unexecuted instantiation: width.c:streq4
Unexecuted instantiation: u8-possible-linebreaks.c:streq4
114
115
static inline int
116
streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28)
117
12.1k
{
118
12.1k
  if (s1[3] == s23)
119
12.1k
    {
120
12.1k
      if (s23 == 0)
121
12.1k
        return 1;
122
0
      else
123
0
        return streq4 (s1, s2, s24, s25, s26, s27, s28);
124
12.1k
    }
125
0
  else
126
0
    return 0;
127
12.1k
}
width.c:streq3
Line
Count
Source
117
12.1k
{
118
12.1k
  if (s1[3] == s23)
119
12.1k
    {
120
12.1k
      if (s23 == 0)
121
12.1k
        return 1;
122
0
      else
123
0
        return streq4 (s1, s2, s24, s25, s26, s27, s28);
124
12.1k
    }
125
0
  else
126
0
    return 0;
127
12.1k
}
Unexecuted instantiation: u8-possible-linebreaks.c:streq3
128
129
static inline int
130
streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
131
24.3k
{
132
24.3k
  if (s1[2] == s22)
133
12.1k
    {
134
12.1k
      if (s22 == 0)
135
0
        return 1;
136
12.1k
      else
137
12.1k
        return streq3 (s1, s2, s23, s24, s25, s26, s27, s28);
138
12.1k
    }
139
12.1k
  else
140
12.1k
    return 0;
141
24.3k
}
width.c:streq2
Line
Count
Source
131
24.3k
{
132
24.3k
  if (s1[2] == s22)
133
12.1k
    {
134
12.1k
      if (s22 == 0)
135
0
        return 1;
136
12.1k
      else
137
12.1k
        return streq3 (s1, s2, s23, s24, s25, s26, s27, s28);
138
12.1k
    }
139
12.1k
  else
140
12.1k
    return 0;
141
24.3k
}
Unexecuted instantiation: u8-possible-linebreaks.c:streq2
142
143
static inline int
144
streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
145
24.3k
{
146
24.3k
  if (s1[1] == s21)
147
24.3k
    {
148
24.3k
      if (s21 == 0)
149
0
        return 1;
150
24.3k
      else
151
24.3k
        return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
152
24.3k
    }
153
0
  else
154
0
    return 0;
155
24.3k
}
width.c:streq1
Line
Count
Source
145
24.3k
{
146
24.3k
  if (s1[1] == s21)
147
24.3k
    {
148
24.3k
      if (s21 == 0)
149
0
        return 1;
150
24.3k
      else
151
24.3k
        return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
152
24.3k
    }
153
0
  else
154
0
    return 0;
155
24.3k
}
Unexecuted instantiation: u8-possible-linebreaks.c:streq1
156
157
static inline int
158
streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)
159
36.5k
{
160
36.5k
  if (s1[0] == s20)
161
24.3k
    {
162
24.3k
      if (s20 == 0)
163
0
        return 1;
164
24.3k
      else
165
24.3k
        return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
166
24.3k
    }
167
12.1k
  else
168
12.1k
    return 0;
169
36.5k
}
width.c:streq0
Line
Count
Source
159
36.5k
{
160
36.5k
  if (s1[0] == s20)
161
24.3k
    {
162
24.3k
      if (s20 == 0)
163
0
        return 1;
164
24.3k
      else
165
24.3k
        return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
166
24.3k
    }
167
12.1k
  else
168
12.1k
    return 0;
169
36.5k
}
Unexecuted instantiation: u8-possible-linebreaks.c:streq0
170
171
#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
172
121k
  streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28)
173
174
#else
175
176
#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \
177
  (strcmp (s1, s2) == 0)
178
179
#endif
180
181
182
#ifdef __cplusplus
183
}
184
#endif
185
186
#endif /* _GL_STREQ_H */