summary refs log tree commit diff
path: root/swipeGuess.c
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2022-01-24 10:51:00 -0500
committerZach DeCook <zachdecook@librem.one>2022-01-24 20:18:02 -0500
commita8cb10f119b8f3244d003c6733cdd16c2079ab55 (patch)
tree6ef807b5a4a7ab0296625a8d39f90d9b67bfd587 /swipeGuess.c
parente355818da465782b7ce1c7e24b79bd817af90bf1 (diff)
downloadswipeGuess-a8cb10f119b8f3244d003c6733cdd16c2079ab55.tar.gz
swipeGuess: insensitive comparison
Diffstat (limited to 'swipeGuess.c')
-rw-r--r--swipeGuess.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/swipeGuess.c b/swipeGuess.c
index dad4548..41fb29c 100644
--- a/swipeGuess.c
+++ b/swipeGuess.c
@@ -1,6 +1,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <ctype.h>
 
 #define BUFSIZE 1024
 char wordBuff[BUFSIZE];
@@ -20,15 +21,21 @@ char *fgetst(char *restrict s, int size, FILE *restrict stream) {
 	return r;
 }
 
+bool charcmp(char a, char b) {
+	return tolower(a) == tolower(b);
+}
+
 bool swipeCompare(char *swipe, char *word) {
-	if (swipe[0] != word[0]) return false;
+	if (! charcmp(swipe[0], word[0])) {
+		return false;
+	}
 	char *swipeP = swipe;
 	char *wordP = word;
 	wordP++;
 	bool lastMatch = false;
 	for(swipeP++; swipeP[0]; swipeP++) {
 		lastMatch = false;
-		while (swipeP[0] == wordP[0]) {
+		while (charcmp(swipeP[0], wordP[0])) {
 			wordP++;
 			lastMatch = true;
 		}