aboutsummaryrefslogtreecommitdiffstats
path: root/memptoupper.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-06-11 16:37:09 +0200
committerMattias Andrée <maandree@kth.se>2022-06-11 16:37:09 +0200
commitfcfe59c1f2219408ac2a9cd84b386816ff252221 (patch)
tree0f46c009babfba2d0200ece3ecce067c548a66b6 /memptoupper.c
parentRemove `static` from some `static inline` (diff)
downloadlibsimple-fcfe59c1f2219408ac2a9cd84b386816ff252221.tar.gz
libsimple-fcfe59c1f2219408ac2a9cd84b386816ff252221.tar.bz2
libsimple-fcfe59c1f2219408ac2a9cd84b386816ff252221.tar.xz
Fix warnings, replace some static inline with inline + extern inline, and fix glibc support
Diffstat (limited to 'memptoupper.c')
-rw-r--r--memptoupper.c15
1 files changed, 3 insertions, 12 deletions
diff --git a/memptoupper.c b/memptoupper.c
index f9798f4..c02cb3c 100644
--- a/memptoupper.c
+++ b/memptoupper.c
@@ -10,17 +10,17 @@ libsimple_memptoupper(void *d_, const void *s_, size_t n)
const char *s = s_;
if (d == s) {
for (; n; d++, n--)
- *d = toupper(*d);
+ *d = (char)toupper(*d);
return d;
} else if (d < s) {
for (; n; d++, s++, n--)
- *d = toupper(*s);
+ *d = (char)toupper(*s);
return d;
} else {
ret = &d[n];
while (n) {
n--;
- d[n] = toupper(s[n]);
+ d[n] = (char)toupper(s[n]);
}
return ret;
}
@@ -44,15 +44,6 @@ main(void)
stpcpy(buf, "abcdeABCDE12345");
assert(libsimple_memptoupper(&buf[0], &buf[0], 16) == &buf[16]);
assert(!strcmp(buf, "ABCDEABCDE12345"));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_memtoupper(&buf[3], &buf[0], 16), "ABCDEABCDE12345"));
- assert(!strcmp(buf, "abcABCDEABCDE12345"));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_memtoupper(&buf[0], &buf[3], 13), "DEABCDE12345"));
- assert(!strcmp(buf, "DEABCDE12345"));
- stpcpy(buf, "abcdeABCDE12345");
- assert(!strcmpnul(libsimple_memtoupper(&buf[0], &buf[0], 16), "ABCDEABCDE12345"));
- assert(!strcmp(buf, "ABCDEABCDE12345"));
return 0;
}