NeoMutt  2024-04-16-36-g75b6fb
Teaching an old dog new tricks
DOXYGEN
Loading...
Searching...
No Matches
eqi.h File Reference

Case-insensitive fixed-chunk comparisons. More...

#include <stdbool.h>
#include <stdint.h>
#include <string.h>
+ Include dependency graph for eqi.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static uint64_t make_lowercase_mask (uint64_t x, int bytenum)
 Create a mask to lowercase alphabetic characters.
 
static bool eqi1 (const char *a, const char b[1])
 Compare two 1-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
 
static bool eqi2 (const char *a, const char b[2])
 Compare two 2-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
 
static bool eqi4 (const char *a, const char b[4])
 Compare two 4-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
 
static bool eqi8 (const char *a, const char b[8])
 Compare two 8-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
 
static bool eqi5 (const char *a, const char b[5])
 eqi5 - Compare two 5-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi6 (const char *a, const char b[6])
 eqi6 - Compare two 6-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi9 (const char *a, const char b[9])
 eqi9 - Compare two 9-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi10 (const char *a, const char b[10])
 eqi10 - Compare two 10-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi11 (const char *a, const char b[11])
 eqi11 - Compare two 11-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi12 (const char *a, const char b[12])
 eqi12 - Compare two 12-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi13 (const char *a, const char b[13])
 eqi13 - Compare two 13-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi14 (const char *a, const char b[14])
 eqi14 - Compare two 14-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi15 (const char *a, const char b[15])
 eqi15 - Compare two 15-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi16 (const char *a, const char b[16])
 eqi16 - Compare two 16-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 
static bool eqi17 (const char *a, const char b[17])
 eqi17 - Compare two 17-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
 

Detailed Description

Case-insensitive fixed-chunk comparisons.

Authors
  • Steinar H Gunderson

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file eqi.h.

Function Documentation

◆ make_lowercase_mask()

static uint64_t make_lowercase_mask ( uint64_t  x,
int  bytenum 
)
inlinestatic

Create a mask to lowercase alphabetic characters.

Parameters
xCharacter to test
bytenumWhich byte position to set
Return values
numBitmask

Utility for the functions below

If the character is alphabetic, then the position determines where to shift the 0x20 mask.

  • Position 0: 0x00000020
  • Position 1: 0x00002000
  • Position 2: 0x00200000
  • Position 3: 0x20000000

Definition at line 63 of file eqi.h.

64{
65 const char ch = x >> (bytenum * 8);
66 const uint64_t mask = ((ch >= 'a') && (ch <= 'z')) ? 0x20 : 0;
67 return mask << (bytenum * 8);
68}
+ Here is the caller graph for this function:

◆ eqi1()

static bool eqi1 ( const char *  a,
const char  b[1] 
)
inlinestatic

Compare two 1-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.

Parameters
aFirst string
bSecond string, must be lower case
Return values
trueStrings match

Definition at line 76 of file eqi.h.

77{
78 uint8_t b8 = b[0];
79 return (*a | make_lowercase_mask(b8, 0)) == (unsigned char) b[0];
80}
static uint64_t make_lowercase_mask(uint64_t x, int bytenum)
Create a mask to lowercase alphabetic characters.
Definition: eqi.h:63
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi2()

static bool eqi2 ( const char *  a,
const char  b[2] 
)
inlinestatic

Compare two 2-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.

Parameters
aFirst string
bSecond string, must be lower case
Return values
trueStrings match

Definition at line 88 of file eqi.h.

89{
90 uint16_t a16, b16;
91 memcpy(&a16, a, sizeof(a16));
92 memcpy(&b16, b, sizeof(b16));
93 const uint16_t lowercase_mask = make_lowercase_mask(b16, 0) |
94 make_lowercase_mask(b16, 1);
95 return (a16 | lowercase_mask) == b16;
96}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi4()

static bool eqi4 ( const char *  a,
const char  b[4] 
)
inlinestatic

Compare two 4-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.

Parameters
aFirst string
bSecond string, must be lower case
Return values
trueStrings match

Definition at line 104 of file eqi.h.

105{
106 uint32_t a32, b32;
107 memcpy(&a32, a, sizeof(a32));
108 memcpy(&b32, b, sizeof(b32));
109 const uint32_t lowercase_mask = make_lowercase_mask(b32, 0) |
110 make_lowercase_mask(b32, 1) |
111 make_lowercase_mask(b32, 2) |
112 make_lowercase_mask(b32, 3);
113 return (a32 | lowercase_mask) == b32;
114}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi8()

static bool eqi8 ( const char *  a,
const char  b[8] 
)
inlinestatic

Compare two 8-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.

Parameters
aFirst string
bSecond string, must be lower case
Return values
trueStrings match

Definition at line 122 of file eqi.h.

123{
124 uint64_t a64, b64;
125 memcpy(&a64, a, sizeof(a64));
126 memcpy(&b64, b, sizeof(b64));
127 const uint64_t lowercase_mask = make_lowercase_mask(b64, 0) |
128 make_lowercase_mask(b64, 1) |
129 make_lowercase_mask(b64, 2) |
130 make_lowercase_mask(b64, 3) |
131 make_lowercase_mask(b64, 4) |
132 make_lowercase_mask(b64, 5) |
133 make_lowercase_mask(b64, 6) |
134 make_lowercase_mask(b64, 7);
135 return (a64 | lowercase_mask) == b64;
136}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi5()

static bool eqi5 ( const char *  a,
const char  b[5] 
)
inlinestatic

eqi5 - Compare two 5-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 143 of file eqi.h.

144{
145 return eqi4(a, b) && eqi1(a + 1, b + 1);
146}
static bool eqi4(const char *a, const char b[4])
Compare two 4-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
Definition: eqi.h:104
static bool eqi1(const char *a, const char b[1])
Compare two 1-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
Definition: eqi.h:76
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi6()

static bool eqi6 ( const char *  a,
const char  b[6] 
)
inlinestatic

eqi6 - Compare two 6-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 149 of file eqi.h.

150{
151 return eqi4(a, b) && eqi2(a + 4, b + 4);
152}
static bool eqi2(const char *a, const char b[2])
Compare two 2-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
Definition: eqi.h:88
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi9()

static bool eqi9 ( const char *  a,
const char  b[9] 
)
inlinestatic

eqi9 - Compare two 9-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 157 of file eqi.h.

158{
159 return eqi8(a, b) && eqi1(a + 8, b + 8);
160}
static bool eqi8(const char *a, const char b[8])
Compare two 8-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons.
Definition: eqi.h:122
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi10()

static bool eqi10 ( const char *  a,
const char  b[10] 
)
inlinestatic

eqi10 - Compare two 10-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 163 of file eqi.h.

164{
165 return eqi8(a, b) && eqi2(a + 8, b + 8);
166}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi11()

static bool eqi11 ( const char *  a,
const char  b[11] 
)
inlinestatic

eqi11 - Compare two 11-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 169 of file eqi.h.

170{
171 return eqi8(a, b) && eqi4(a + 7, b + 7);
172}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi12()

static bool eqi12 ( const char *  a,
const char  b[12] 
)
inlinestatic

eqi12 - Compare two 12-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 175 of file eqi.h.

176{
177 return eqi8(a, b) && eqi4(a + 8, b + 8);
178}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi13()

static bool eqi13 ( const char *  a,
const char  b[13] 
)
inlinestatic

eqi13 - Compare two 13-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 181 of file eqi.h.

182{
183 return eqi8(a, b) && eqi8(a + 5, b + 5);
184}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi14()

static bool eqi14 ( const char *  a,
const char  b[14] 
)
inlinestatic

eqi14 - Compare two 14-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 187 of file eqi.h.

188{
189 return eqi8(a, b) && eqi8(a + 6, b + 6);
190}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi15()

static bool eqi15 ( const char *  a,
const char  b[15] 
)
inlinestatic

eqi15 - Compare two 15-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 193 of file eqi.h.

194{
195 return eqi8(a, b) && eqi8(a + 7, b + 7);
196}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi16()

static bool eqi16 ( const char *  a,
const char  b[16] 
)
inlinestatic

eqi16 - Compare two 16-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 199 of file eqi.h.

200{
201 return eqi8(a, b) && eqi8(a + 8, b + 8);
202}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eqi17()

static bool eqi17 ( const char *  a,
const char  b[17] 
)
inlinestatic

eqi17 - Compare two 17-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons

Definition at line 205 of file eqi.h.

206{
207 return eqi16(a, b) && eqi1(a + 16, b + 16);
208}
static bool eqi16(const char *a, const char b[16])
eqi16 - Compare two 16-byte strings, ignoring case - See: Case-insensitive fixed-chunk comparisons
Definition: eqi.h:199
+ Here is the call graph for this function:
+ Here is the caller graph for this function: