aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarry Jeffery <harry@exec64.co.uk>2015-11-16 10:23:42 +0000
committerHarry Jeffery <harry@exec64.co.uk>2015-11-16 10:23:42 +0000
commita5597a9587e8240cccc0a263db69b329fe854d2b (patch)
tree499e89b5b69a4ef87842ef8217c037a16adf552d
parent450c3daa4a179e9c74e14614870e5de1c5909e2c (diff)
downloadimv-a5597a9587e8240cccc0a263db69b329fe854d2b.tar.gz
Support upper-case hex
Fixes #32
-rw-r--r--src/main.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 7f4b415..4de5fb1 100644
--- a/src/main.c
+++ b/src/main.c
@@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <SDL2/SDL.h>
#include <FreeImage.h>
#include <getopt.h>
+#include <ctype.h>
#include "image.h"
#include "texture.h"
@@ -407,6 +408,8 @@ int parse_hex(char c) {
return c - '0';
} else if (c >= 'a' && c <= 'f') {
return c - 'a' + 10;
+ } else if (c >= 'A' && c <= 'F') {
+ return c - 'A' + 10;
}
return -1;
}
@@ -423,7 +426,7 @@ int parse_hex_color(const char* str,
}
for(int i = 0; i < 6; ++i) {
- if(parse_hex(str[i]) == -1) {
+ if(!isxdigit(str[i])) {
return 1;
}
}