OpenCoverage

streq.h

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/lib/streq.h
Source codeSwitch to Preprocessed file
LineSourceCount
1/* Optimized string comparison.-
2 Copyright (C) 2001-2002, 2007, 2009-2018 Free Software Foundation, Inc.-
3-
4 This program is free software: you can redistribute it and/or modify it-
5 under the terms of the GNU General Public License as published-
6 by the Free Software Foundation; either version 3 of the License, or-
7 (at your option) any later version.-
8-
9 This program 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 GNU-
12 General Public License for more details.-
13-
14 You should have received a copy of the GNU 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/* STREQ_OPT allows to optimize string comparison with a small literal string.-
25 STREQ_OPT (s, "EUC-KR", 'E', 'U', 'C', '-', 'K', 'R', 0, 0, 0)-
26 is semantically equivalent to-
27 strcmp (s, "EUC-KR") == 0-
28 just faster. */-
29-
30/* Help GCC to generate good code for string comparisons with-
31 immediate strings. */-
32#if defined (__GNUC__) && defined (__OPTIMIZE__)-
33-
34static inline int-
35streq9 (const char *s1, const char *s2)-
36{-
37 return strcmp (s1 + 9, s2 + 9) == 0;
never executed: return __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p ( s1 + 9 ) && __builtin_constant_p ( s2 + 9 ) && (__s1_len = __builtin_strlen ( s1 + 9 ), __s2_len = __builtin_strlen ( s2 + 9 ), (!((size_t)(const void *)(( s1 + 9 ) + 1) - (size_t)... = (((const unsigned char *) (const char *) ( s2 + 9 ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ( s2 + 9 ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp ( s1 + 9 , s2 + 9 )))); }) == 0;
never executed: __result = (((const unsigned char *) (const char *) ( s1 + 9 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
never executed: __result = (((const unsigned char *) (const char *) ( s2 + 9 ))[3] - __s2[3]);
never executed: end of block
never executed: end of block
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
38}-
39-
40static inline int-
41streq8 (const char *s1, const char *s2, char s28)-
42{-
43 if (s1[8] == s28)
s1[8] == s28Description
TRUEnever evaluated
FALSEnever evaluated
0
44 {-
45 if (s28 == 0)
s28 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
46 return 1;
never executed: return 1;
0
47 else-
48 return streq9 (s1, s2);
never executed: return streq9 (s1, s2);
0
49 }-
50 else-
51 return 0;
never executed: return 0;
0
52}-
53-
54static inline int-
55streq7 (const char *s1, const char *s2, char s27, char s28)-
56{-
57 if (s1[7] == s27)
s1[7] == s27Description
TRUEnever evaluated
FALSEnever evaluated
0
58 {-
59 if (s27 == 0)
s27 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
60 return 1;
never executed: return 1;
0
61 else-
62 return streq8 (s1, s2, s28);
never executed: return streq8 (s1, s2, s28);
0
63 }-
64 else-
65 return 0;
never executed: return 0;
0
66}-
67-
68static inline int-
69streq6 (const char *s1, const char *s2, char s26, char s27, char s28)-
70{-
71 if (s1[6] == s26)
s1[6] == s26Description
TRUEnever evaluated
FALSEnever evaluated
0
72 {-
73 if (s26 == 0)
s26 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
74 return 1;
never executed: return 1;
0
75 else-
76 return streq7 (s1, s2, s27, s28);
never executed: return streq7 (s1, s2, s27, s28);
0
77 }-
78 else-
79 return 0;
never executed: return 0;
0
80}-
81-
82static inline int-
83streq5 (const char *s1, const char *s2, char s25, char s26, char s27, char s28)-
84{-
85 if (s1[5] == s25)
s1[5] == s25Description
TRUEnever evaluated
FALSEnever evaluated
0
86 {-
87 if (s25 == 0)
s25 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
88 return 1;
never executed: return 1;
0
89 else-
90 return streq6 (s1, s2, s26, s27, s28);
never executed: return streq6 (s1, s2, s26, s27, s28);
0
91 }-
92 else-
93 return 0;
never executed: return 0;
0
94}-
95-
96static inline int-
97streq4 (const char *s1, const char *s2, char s24, char s25, char s26, char s27, char s28)-
98{-
99 if (s1[4] == s24)
s1[4] == s24Description
TRUEnever evaluated
FALSEnever evaluated
0
100 {-
101 if (s24 == 0)
s24 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
102 return 1;
never executed: return 1;
0
103 else-
104 return streq5 (s1, s2, s25, s26, s27, s28);
never executed: return streq5 (s1, s2, s25, s26, s27, s28);
0
105 }-
106 else-
107 return 0;
never executed: return 0;
0
108}-
109-
110static inline int-
111streq3 (const char *s1, const char *s2, char s23, char s24, char s25, char s26, char s27, char s28)-
112{-
113 if (s1[3] == s23)
s1[3] == s23Description
TRUEnever evaluated
FALSEnever evaluated
0
114 {-
115 if (s23 == 0)
s23 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
116 return 1;
never executed: return 1;
0
117 else-
118 return streq4 (s1, s2, s24, s25, s26, s27, s28);
never executed: return streq4 (s1, s2, s24, s25, s26, s27, s28);
0
119 }-
120 else-
121 return 0;
never executed: return 0;
0
122}-
123-
124static inline int-
125streq2 (const char *s1, const char *s2, char s22, char s23, char s24, char s25, char s26, char s27, char s28)-
126{-
127 if (s1[2] == s22)
s1[2] == s22Description
TRUEnever evaluated
FALSEnever evaluated
0
128 {-
129 if (s22 == 0)
s22 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
130 return 1;
never executed: return 1;
0
131 else-
132 return streq3 (s1, s2, s23, s24, s25, s26, s27, s28);
never executed: return streq3 (s1, s2, s23, s24, s25, s26, s27, s28);
0
133 }-
134 else-
135 return 0;
never executed: return 0;
0
136}-
137-
138static inline int-
139streq1 (const char *s1, const char *s2, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)-
140{-
141 if (s1[1] == s21)
s1[1] == s21Description
TRUEnever evaluated
FALSEnever evaluated
0
142 {-
143 if (s21 == 0)
s21 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
144 return 1;
never executed: return 1;
0
145 else-
146 return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
never executed: return streq2 (s1, s2, s22, s23, s24, s25, s26, s27, s28);
0
147 }-
148 else-
149 return 0;
never executed: return 0;
0
150}-
151-
152static inline int-
153streq0 (const char *s1, const char *s2, char s20, char s21, char s22, char s23, char s24, char s25, char s26, char s27, char s28)-
154{-
155 if (s1[0] == s20)
s1[0] == s20Description
TRUEnever evaluated
FALSEnever evaluated
0
156 {-
157 if (s20 == 0)
s20 == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
158 return 1;
never executed: return 1;
0
159 else-
160 return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
never executed: return streq1 (s1, s2, s21, s22, s23, s24, s25, s26, s27, s28);
0
161 }-
162 else-
163 return 0;
never executed: return 0;
0
164}-
165-
166#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \-
167 streq0 (s1, s2, s20, s21, s22, s23, s24, s25, s26, s27, s28)-
168-
169#else-
170-
171#define STREQ_OPT(s1,s2,s20,s21,s22,s23,s24,s25,s26,s27,s28) \-
172 (strcmp (s1, s2) == 0)-
173-
174#endif-
175-
176#endif /* _GL_STREQ_H */-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.1.2