← easystroke

main: Use type int for getopt return value

161a59b1de6914857ec73ff5210fc05313b07e8c · Ulrik Sverdrup · May 15, 2010 15:22

The signedness of char differs from platform to platform; to portably
compare the return value from getopt_long to -1, we have to store it
in an int.

This fixes an infinite loop on powerpc where char is an unsigned
char.

+1 −1 · 1 file changed

  • main.cc +1 −1
diff --git a/main.cc b/main.cc
index 8d53440..1a536e8 100644
--- a/main.cc
+++ b/main.cc
@@ -1145,7 +1145,7 @@ std::string Main::parse_args_and_init_gtk() {
 		{0,0,0,0}
 	};
 	std::string display;
-	char opt;
+	int opt;
 	// parse --display here, before Gtk::Main(...) takes it away from us
 	opterr = 0;
 	while ((opt = getopt_long(argc, argv, "gh", long_opts1, 0)) != -1)