summaryrefslogtreecommitdiffhomepage
path: root/src/build/codegen.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2023-06-20 21:00:00 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2023-06-20 21:00:00 +0100
commita86be4b76d96464e4bb9aa108d2c01198125084e (patch)
treeacc66325dd342582b15233ea30794378d68c7e5b /src/build/codegen.c
parent9c2bb3af4358a44d71d45d05278b2f34313de0e2 (diff)
Tweak feature sorting and fix a chibicc bug
That sorting function was a bit wonky, so make it just a little bit wonky instead. chibicc would produce confusing lex errors if given a stray single quote somewhere, so make it give non-confusing errors. Also get rid of canonicalize_newline() because it's unnecessary for SST so long as Windows Git isn't left in its default misconfigured state.
Diffstat (limited to 'src/build/codegen.c')
-rw-r--r--src/build/codegen.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/build/codegen.c b/src/build/codegen.c
index bf3ae1e..e24a096 100644
--- a/src/build/codegen.c
+++ b/src/build/codegen.c
@@ -81,14 +81,14 @@ static inline int cmp_feature(struct feature *e, const char *s) {
}
static inline int cmp_feature_bydesc(struct feature *e, const char *s) {
for (const char *p = e->desc; ; ++p, ++s) {
- // longer string first
- if (!*s) return !!*p; else if (!*p) return -1;
+ // shortest string first
+ if (!*p) return !!*s; if (!*s) return -1;
// case insensitive sort where possible
- if (tolower(*p) > tolower(*s)) return 1;
- if (tolower(*p) < tolower(*s)) return -1;
+ if (tolower((uchar)*p) > tolower((uchar)*s)) return 1;
+ if (tolower((uchar)*p) < tolower((uchar)*s)) return -1;
// prioritise upper-case if same letter
- if (isupper(*p) && islower(*s)) return 1;
- if (islower(*p) && isupper(*s)) return -1;
+ if (isupper((uchar)*p) && islower((uchar)*s)) return 1;
+ if (islower((uchar)*p) && isupper((uchar)*s)) return -1;
}
return 0;
}