commit d2fe0fa3511539dcb36fe6c678bd14f92d0909d1
Author: Laslo Hunhold <[email protected]>
AuthorDate: Sat Jan 8 16:49:09 2022 +0100
Commit: Laslo Hunhold <[email protected]>
CommitDate: Sat Jan 8 16:49:09 2022 +0100
Consistently use least-types
The fixed-size-types are not guaranteed by the standard to exist.
Signed-off-by: Laslo Hunhold <[email protected]>
diff --git a/benchmark/utf8-decode.c b/benchmark/utf8-decode.c
index ae4d275..03722e5 100644
--- a/benchmark/utf8-decode.c
+++ b/benchmark/utf8-decode.c
@@ -67,7 +67,7 @@ main(int argc, char *argv[])
{
struct payload p;
size_t cpbufsiz, i, off, ret;
- uint32_t *cpbuf;
+ uint_least32_t *cpbuf;
double baseline = (double)NAN;
(void)argc;
diff --git a/benchmark/util.c b/benchmark/util.c
index dbf5ccb..b1f74e1 100644
--- a/benchmark/util.c
+++ b/benchmark/util.c
@@ -6,11 +6,11 @@
#include "util.h"
-uint32_t *
+uint_least32_t *
generate_test_buffer(const struct test *t, size_t tlen, size_t *bufsiz)
{
size_t i, j, off;
- uint32_t *buf;
+ uint_least32_t *buf;
/* allocate and generate buffer */
for (i = 0, *bufsiz = 0; i < tlen; i++) {
diff --git a/benchmark/util.h b/benchmark/util.h
index 3b3f238..7da388b 100644
--- a/benchmark/util.h
+++ b/benchmark/util.h
@@ -6,7 +6,7 @@
#define LEN(x) (sizeof(x) / sizeof(*(x)))
-uint32_t *generate_test_buffer(const struct test *, size_t, size_t *);
+uint_least32_t *generate_test_buffer(const struct test *, size_t, size_t *);
void run_benchmark(void (*func)(const void *), const void *, const char *,
const char *, double *, size_t, size_t);
diff --git a/src/utf8.c b/src/utf8.c
index e01fa37..f386edf 100644
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -8,8 +8,8 @@
/* lookup-table for the types of sequence first bytes */
static const struct {
- uint8_t lower; /* lower bound of sequence first byte */
- uint8_t upper; /* upper bound of sequence first byte */
+ uint_least8_t lower; /* lower bound of sequence first byte */
+ uint_least8_t upper; /* upper bound of sequence first byte */
uint_least32_t mincp; /* smallest non-overlong encoded codepoint */
uint_least32_t maxcp; /* largest encodable codepoint */
/*
@@ -191,7 +191,8 @@ grapheme_encode_utf8(uint_least32_t cp, char *str, size_t
len)
* We do not overwrite the mask because we guaranteed earlier
* that there are no bits higher than the mask allows.
*/
- ((unsigned char *)str)[0] = lut[off].lower | (uint8_t)(cp >> (6 * off));
+ ((unsigned char *)str)[0] = lut[off].lower |
+ (uint_least8_t)(cp >> (6 * off));
for (i = 1; i <= off; i++) {
/*