summaryrefslogtreecommitdiffhomepage
path: root/ir/libcore
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2011-10-20 14:26:36 +0200
committerMatthias Braun <matze@braunis.de>2011-10-20 14:27:26 +0200
commit573f2284df8276913dfcf63c795cc6cfbe15462a (patch)
tree2d5c3b6211b3fbe750458948f106f66f6acf3a3b /ir/libcore
parent158da8a496e0d54ade008d0d3b6b0b82f0bf92d1 (diff)
cast ctype functions input to unsigned char
From the manpage: If c is not an unsigned char value, or EOF, the behavior of these functions is undefined. (So putting char into them directly is wrong)
Diffstat (limited to 'ir/libcore')
-rw-r--r--ir/libcore/lc_opts.c2
-rw-r--r--ir/libcore/lc_printf.c8
2 files changed, 5 insertions, 5 deletions
diff --git a/ir/libcore/lc_opts.c b/ir/libcore/lc_opts.c
index d68318f..3c33724 100644
--- a/ir/libcore/lc_opts.c
+++ b/ir/libcore/lc_opts.c
@@ -335,7 +335,7 @@ static char *strtolower(char *buf, size_t n, const char *str)
{
unsigned i;
for (i = 0; i < n; ++i)
- buf[i] = tolower(str[i]);
+ buf[i] = tolower((unsigned char)str[i]);
return buf;
}
diff --git a/ir/libcore/lc_printf.c b/ir/libcore/lc_printf.c
index 471f751..2e6cedf 100644
--- a/ir/libcore/lc_printf.c
+++ b/ir/libcore/lc_printf.c
@@ -104,11 +104,11 @@ int lc_arg_register(lc_arg_env_t *env, const char *name, char letter, const lc_a
arg.letter = letter;
arg.handler = handler;
- if (isupper(letter)) {
+ if (isupper((unsigned char)letter)) {
map = env->upper;
base = 'A';
}
- else if (islower(letter)) {
+ else if (islower((unsigned char)letter)) {
map = env->lower;
base = 'a';
}
@@ -462,12 +462,12 @@ int lc_evpprintf(const lc_arg_env_t *env, lc_appendable_t *app, const char *fmt,
const char *mod = s;
/* Read, as long there are letters */
- while (isalpha(ch) && !arg) {
+ while (isalpha((unsigned char)ch) && !arg) {
int base = 'a';
lc_arg_t * const *map = env->lower;
/* If uppercase, select the uppercase map from the environment */
- if (isupper(ch)) {
+ if (isupper((unsigned char)ch)) {
base = 'A';
map = env->upper;
}