arp242 / find-cursor

Highlight the cursor position in X11

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

-o isn't optional

luebking opened this issue · comments

The parameter wasn't set optional so "-o -f" would fail for "-f" not being an integer.
I took the "2" from the comments.
(Stumbled over that when writing the bool parser ;)

diff --git a/find-cursor.c b/find-cursor.c
index 2caaf51..bce509e 100644
--- a/find-cursor.c
+++ b/find-cursor.c
@@ -157,7 +157,7 @@ int main(int argc, char* argv[]) {
 
 	extern int optopt;
 	int ch;
-	while ((ch = getopt_long(argc, argv, ":hs:d:w:l:c:r:ft::go:O:", longopts, NULL)) != -1)
+	while ((ch = getopt_long(argc, argv, ":hs:d:w:l:c:r:ft::go::O:", longopts, NULL)) != -1)
 		switch (ch) {
 		case 's':
 			size = parse_num(ch, optarg, argv[0]);
@@ -187,7 +187,7 @@ int main(int argc, char* argv[]) {
 			grow = 1;
 			break;
 		case 'o':
-			outline = parse_num(ch, optarg, argv[0]);
+			outline = optarg ? parse_num(ch, optarg, argv[0]) : 2;
 			break;
 		case 'O':
 			strncpy(ocolor_name, optarg, sizeof(ocolor_name));