aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <m@maandree.se>2026-06-07 14:15:56 +0200
committerMattias Andrée <m@maandree.se>2026-06-07 14:15:56 +0200
commit6139ee872d09d34618a3ab590a6da03fdc590837 (patch)
tree68e3e363d3c96c83aa52be1d42e332c586c0d24e
parentFix whitespace typo (diff)
downloadlibcmap-6139ee872d09d34618a3ab590a6da03fdc590837.tar.gz
libcmap-6139ee872d09d34618a3ab590a6da03fdc590837.tar.bz2
libcmap-6139ee872d09d34618a3ab590a6da03fdc590837.tar.xz
Style improvementHEADmaster
Signed-off-by: Mattias Andrée <m@maandree.se>
-rw-r--r--Blocks.parse.c18
-rw-r--r--LICENSE2
-rw-r--r--Scripts.parse.c36
-rw-r--r--libcmap.h6
-rw-r--r--parse-common.c6
5 files changed, 34 insertions, 34 deletions
diff --git a/Blocks.parse.c b/Blocks.parse.c
index 3f93764..a5a626a 100644
--- a/Blocks.parse.c
+++ b/Blocks.parse.c
@@ -48,7 +48,7 @@ parse_line(char *text, size_t lineno)
name = text;
while (*text && *text != ';')
text++;
- for (i = 1U; isspace(text[-i]); i++)
+ for (i = 1u; isspace(text[-i]); i++)
text[-i] = '\0';
if (*text == ';') {
@@ -113,19 +113,19 @@ output(void)
qsort(blocks, nblocks, sizeof(*blocks), &blockcmp_range);
if (!nblocks || blocks[0].low)
abort();
- for (i = 1U; i < nblocks; i++)
- if (blocks[i].low > blocks[i - 1U].high + 1U)
+ for (i = 1u; i < nblocks; i++)
+ if (blocks[i].low > blocks[i - 1u].high + 1u)
break;
- if (i == nblocks && blocks[i - 1U].high == ULTIMATE_CODEPOINT) {
+ if (i == nblocks && blocks[i - 1u].high == ULTIMATE_CODEPOINT) {
x |= printf("const struct libcmap_script libcmap_no_block = {\"No Block\", NULL, 0};\n");
} else {
x |= printf("static const struct libcmap_range No_Block[] = {\n");
- x |= printf("\t{0x%04lX, 0x%04lX}", blocks[i - 1U].high + 1U, blocks[i].low - 1U);
+ x |= printf("\t{0x%04lX, 0x%04lX}", blocks[i - 1u].high + 1u, blocks[i].low - 1u);
for (i++; i < nblocks; i++)
- if (blocks[i].low > blocks[i - 1U].high + 1)
- x |= printf(",\n\t{0x%04lX, 0x%04lX}", blocks[i - 1U].high + 1U, blocks[i].low - 1U);
- if (blocks[i - 1U].high < ULTIMATE_CODEPOINT)
- x |= printf(",\n\t{0x%04lX, LIBCMAP_ULTIMATE_CODEPOINT}", blocks[i - 1U].high + 1U);
+ if (blocks[i].low > blocks[i - 1u].high + 1u)
+ x |= printf(",\n\t{0x%04lX, 0x%04lX}", blocks[i - 1u].high + 1u, blocks[i].low - 1u);
+ if (blocks[i - 1u].high < ULTIMATE_CODEPOINT)
+ x |= printf(",\n\t{0x%04lX, LIBCMAP_ULTIMATE_CODEPOINT}", blocks[i - 1u].high + 1u);
x |= printf("\n};\n");
x |= printf("const struct libcmap_script libcmap_no_block = ");
x |= printf("{\"No Block\", No_Block, sizeof(No_Block) / sizeof(*No_Block)};\n");
diff --git a/LICENSE b/LICENSE
index 0e6be1c..6c7f02b 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
ISC License
-© 2025 Mattias Andrée <m@maandree.se>
+© 2025, 2026 Mattias Andrée <m@maandree.se>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
diff --git a/Scripts.parse.c b/Scripts.parse.c
index 60ddfe9..6f90bd7 100644
--- a/Scripts.parse.c
+++ b/Scripts.parse.c
@@ -150,11 +150,11 @@ join_ranges(struct range *ranges, size_t n)
abort();
qsort(ranges, n, sizeof(*ranges), &rangecmp);
- for (r = w = 1U; r < n; r++) {
- if (ranges[r].low == ranges[w - 1U].low)
- ranges[w - 1U].high = ranges[r].high;
- else if (ranges[r].low <= ranges[w - 1U].high + 1U)
- ranges[w - 1U].high = ranges[r].high;
+ for (r = w = 1u; r < n; r++) {
+ if (ranges[r].low == ranges[w - 1u].low)
+ ranges[w - 1u].high = ranges[r].high;
+ else if (ranges[r].low <= ranges[w - 1u].high + 1u)
+ ranges[w - 1u].high = ranges[r].high;
else
ranges[w++] = ranges[r];
}
@@ -175,21 +175,21 @@ range_minus(struct range **rangesp, size_t *np, const struct range *xranges, siz
} else if (xranges[j].low > ranges[i].high) {
i++;
} else if (xranges[j].low <= ranges[i].low && xranges[j].high >= ranges[i].high) {
- memmove(&ranges[i], &ranges[i + 1U], (--n - i) * sizeof(*ranges));
+ memmove(&ranges[i], &ranges[i + 1u], (--n - i) * sizeof(*ranges));
} else if (xranges[j].low <= ranges[i].low && xranges[j].high < ranges[i].high) {
- ranges[i].low = xranges[j++].high + 1U;
+ ranges[i].low = xranges[j++].high + 1u;
} else if (xranges[j].high >= ranges[i].high && xranges[j].low > ranges[i].low) {
- ranges[i++].high = xranges[j].low - 1U;
+ ranges[i++].high = xranges[j].low - 1u;
} else if (xranges[j].low > ranges[i].low && xranges[j].high < ranges[i].high) {
- ranges = realloc(ranges, (n + 1U) * sizeof(*ranges));
+ ranges = realloc(ranges, (n + 1u) * sizeof(*ranges));
if (!ranges) {
- fprintf(stderr, "%s: realloc %zu: %s\n", argv0, (n + 1U) * sizeof(*ranges), strerror(errno));
+ fprintf(stderr, "%s: realloc %zu: %s\n", argv0, (n + 1u) * sizeof(*ranges), strerror(errno));
exit(1);
}
- memmove(&ranges[i + 1U], &ranges[i], (n++ - i) * sizeof(*ranges));
- ranges[i].low = ranges[i + 1U].low;
- ranges[i].high = xranges[j].low - 1U;
- ranges[i + 1U].low = xranges[j].high + 1U;
+ memmove(&ranges[i + 1u], &ranges[i], (n++ - i) * sizeof(*ranges));
+ ranges[i].low = ranges[i + 1u].low;
+ ranges[i].high = xranges[j].low - 1u;
+ ranges[i + 1u].low = xranges[j].high + 1u;
i++;
} else {
abort();
@@ -216,9 +216,9 @@ output(void)
fprintf(stderr, "%s: malloc %zu: %s\n", argv0, sizeof(*unknown->ranges), strerror(errno));
exit(1);
}
- nranges = 1U;
- ranges[0].low = 0;
- ranges[0].high = ULTIMATE_CODEPOINT;
+ nranges = 1u;
+ ranges[0u].low = 0;
+ ranges[0u].high = ULTIMATE_CODEPOINT;
for (i = 0; i < nscripts; i++) {
scripts[i].nranges = join_ranges(scripts[i].ranges, scripts[i].nranges);
@@ -238,7 +238,7 @@ output(void)
for (i = 0; i < nscripts; i++) {
x |= printf("static const struct libcmap_range %s[] = {", scripts[i].cname);
for (j = 0; j < scripts[i].nranges;) {
- prefix = j % 5U /* no more than 93!! */ == 0U ? "\n\t" : " ";
+ prefix = j % 5u /* no more than 93!! */ == 0u ? "\n\t" : " ";
x |= printf("%s{0x%04lX, 0x%04lX}", prefix, scripts[i].ranges[j].low, scripts[i].ranges[j].high);
if (++j < scripts[i].nranges)
x |= printf(",");
diff --git a/libcmap.h b/libcmap.h
index 6980daa..a62ddee 100644
--- a/libcmap.h
+++ b/libcmap.h
@@ -33,7 +33,7 @@
* @param RANGE:const libcmap_range * The codepoint range
* @return :size_t The number of covered codepoints
*/
-#define LIBCMAP_RANGE_SIZE(RANGE) ((size_t)((RANGE)->last - (RANGE)->first + 1U))
+#define LIBCMAP_RANGE_SIZE(RANGE) ((size_t)((RANGE)->last - (RANGE)->first + 1u))
/**
@@ -272,8 +272,8 @@ int libcmap_sprint_range(char *buf, const struct libcmap_range *range, const cha
* will not be counted in the return value
*
* If `bufsize` is not sufficiently large, string printed to
- * `buf` will be truncated to `bufsize - 1U` bytes, a NUL
- * byte will be added to the end (at `buf[bufsize - 1U`);
+ * `buf` will be truncated to `bufsize - 1u` bytes, a NUL
+ * byte will be added to the end (at `buf[bufsize - 1u`);
* however if `bufsize` is 0, nothing is written to `buf`.
* The function will always return the size the full string,
* even if it was truncated; therefore the return value can
diff --git a/parse-common.c b/parse-common.c
index 4e271c6..899debb 100644
--- a/parse-common.c
+++ b/parse-common.c
@@ -7,7 +7,7 @@
#include <unistd.h>
-#define ULTIMATE_CODEPOINT 0x10FFFFUL
+#define ULTIMATE_CODEPOINT 0x10FFFFul
static const char *argv0;
@@ -21,7 +21,7 @@ static size_t
parse(char *buf, size_t len)
{
static int prev_was_cr = 0;
- static size_t lineno = 1U;
+ static size_t lineno = 1u;
size_t ret = 0;
size_t off = 0;
size_t she;
@@ -94,7 +94,7 @@ main(int argc, char *argv[])
for (;;) {
if (len == bufsize) {
- buf = realloc(buf, bufsize += 8192U);
+ buf = realloc(buf, bufsize += 8192u);
if (!buf) {
fprintf(stderr, "%s: realloc %zu: %s\n", argv0, bufsize, strerror(errno));
exit(1);