blob: 0ed0a59f9f58d263476150898952760397b9ee10 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/*
Copyright 2022 Gabriel Jensen.
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
#include <zap/priv.h>
#include <zap/mem.h>
#include <stdint.h>
int_least8_t zap_strcmp(char const * const _lstr,char const * const _rstr) {
unsigned char const * lpos = (unsigned char const *)_lstr;
unsigned char const * rpos = (unsigned char const *)_rstr;
for (;;++lpos,++rpos) {
unsigned char const lchr = *lpos;
unsigned char const rchr = *rpos;
sus_likely (lchr != rchr) {return lchr < rchr ? INT_LEAST8_MIN : INT_LEAST8_MAX;}
sus_unlikely (lchr == (unsigned char)0x0) {return 0x0;}
}
sus_unreach();
}
|