commit f6ab5a6edf5eae9470f7eb6ee3062fd9a7865ead
Author: Laslo Hunhold <[email protected]>
AuthorDate: Thu Oct 6 00:02:29 2022 +0200
Commit: Laslo Hunhold <[email protected]>
CommitDate: Thu Oct 6 00:02:29 2022 +0200
Fix up smaller notational and type aspects for constants
Signed-off-by: Laslo Hunhold <[email protected]>
diff --git a/gen/util.c b/gen/util.c
index 012b04a..8f37bfd 100644
--- a/gen/util.c
+++ b/gen/util.c
@@ -76,7 +76,7 @@ hextocp(const char *str, size_t len, uint_least32_t *cp)
(uint_least32_t)(str[i] - relative + off);
}
- if (*cp > 0x10ffff) {
+ if (*cp > UINT32_C(0x10FFFF)) {
fprintf(stderr, "hextocp: '%.*s' is too large.\n",
(int)len, str);
return 1;
@@ -251,14 +251,14 @@ properties_compress(const struct properties *prop,
uint_least32_t cp, i;
/* initialization */
- if (!(comp->offset = malloc((size_t)0x110000 *
sizeof(*(comp->offset))))) {
+ if (!(comp->offset = malloc((size_t)UINT32_C(0x110000) *
sizeof(*(comp->offset))))) {
fprintf(stderr, "malloc: %s\n", strerror(errno));
exit(1);
}
comp->data = NULL;
comp->datalen = 0;
- for (cp = 0; cp < 0x110000; cp++) {
+ for (cp = 0; cp < UINT32_C(0x110000); cp++) {
for (i = 0; i < comp->datalen; i++) {
if (!memcmp(&(prop[cp]), &(comp->data[i]),
sizeof(*prop))) {
/* found a match! */
diff --git a/src/case.c b/src/case.c
index ac24f71..4d289fd 100644
--- a/src/case.c
+++ b/src/case.c
@@ -9,9 +9,9 @@
static inline enum case_property
get_case_property(uint_least32_t cp)
{
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
return (enum case_property)
- case_minor[case_major[cp >> 8] + (cp & 0xff)];
+ case_minor[case_major[cp >> 8] + (cp & 0xFF)];
} else {
return CASE_PROP_OTHER;
}
@@ -21,13 +21,13 @@ static inline int_least32_t
get_case_offset(uint_least32_t cp, const uint_least16_t *major,
const int_least32_t *minor)
{
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
/*
* this value might be larger than or equal to 0x110000
* for the special-case-mapping. This needs to be handled
* separately
*/
- return minor[major[cp >> 8] + (cp & 0xff)];
+ return minor[major[cp >> 8] + (cp & 0xFF)];
} else {
return 0;
}
diff --git a/src/character.c b/src/character.c
index 7bcc72f..33d2162 100644
--- a/src/character.c
+++ b/src/character.c
@@ -111,7 +111,7 @@ static const uint_least16_t dont_break_gb12_13[2 *
NUM_CHAR_BREAK_PROPS] = {
static inline enum char_break_property
get_break_prop(uint_least32_t cp)
{
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
return (enum char_break_property)
char_break_minor[char_break_major[cp >> 8] + (cp &
0xFF)];
} else {
diff --git a/src/line.c b/src/line.c
index e010cb3..233e80c 100644
--- a/src/line.c
+++ b/src/line.c
@@ -9,7 +9,7 @@
static inline enum line_break_property
get_break_prop(uint_least32_t cp)
{
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
return (enum line_break_property)
line_break_minor[line_break_major[cp >> 8] + (cp &
0xff)];
} else {
diff --git a/src/sentence.c b/src/sentence.c
index 88c21de..8a242c0 100644
--- a/src/sentence.c
+++ b/src/sentence.c
@@ -15,7 +15,7 @@ struct sentence_break_state
static inline uint_least8_t
get_sentence_break_prop(uint_least32_t cp)
{
- if (likely(cp <= 0x10FFFF)) {
+ if (likely(cp <= UINT32_C(0x10FFFF))) {
return (uint_least8_t)
sentence_break_minor[sentence_break_major[cp >> 8] +
(cp & 0xff)];