summaryrefslogtreecommitdiff
path: root/src/u8c/u32fndchr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/u8c/u32fndchr.c')
-rw-r--r--src/u8c/u32fndchr.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/u8c/u32fndchr.c b/src/u8c/u32fndchr.c
index ca83998..ab4b5e1 100644
--- a/src/u8c/u32fndchr.c
+++ b/src/u8c/u32fndchr.c
@@ -18,6 +18,7 @@
# include <stddef.h>
# include <stdint.h>
# include <u8c/SIZE_C.h>
+# include <u8c/errtyp.h>
# include <u8c/seterr.h>
# include <u8c/u32fndchr.h>
# include <u8c/u32sz.h>
@@ -25,16 +26,21 @@ bool u8c_u32fndchr(size_t * const _pos,char32_t const * const _in,char32_t const
assert(_pos != NULL);
assert(_in != NULL);
for(register size_t n = SIZE_C(0x0);n <= SIZE_MAX;n += SIZE_C(0x1)) {
- if(_in[n] == UINT32_C(0x0) && _chr != UINT32_C(0x0)) {
+ register uint_least32_t const tmp = _in[n];
+ if(tmp == UINT32_C(0x0)) {
+ if(_chr == UINT32_C(0x0)) {
+ *_pos = n;
+ return false;
+ }
*_pos = SIZE_C(-0x1);
return true;
}
- if(_in[n] == _chr) {
+ if(tmp == _chr) {
*_pos = n;
return false;
}
}
- u8c_seterr(U"u8c_u32fndchr: Unterminated input.");
+ u8c_seterr(U"u8c_u32fndchr: Unterminated input.",u8c_errtyp_badio);
*_pos = SIZE_C(-0x1);
return true;
}