qqwing: fix an infinite loop on unsigned char archs

Using the `--solve` option on powerpc made qqwing freeze. A looped
getchar(3) call never reached EOF, since the return value was stored
as a char, that is unsigned on powerpc and arm*, instead of int.

OK jca@
This commit is contained in:
cwen 2021-07-24 19:35:41 +00:00
parent cd0438c481
commit 66ff0692ae
2 changed files with 19 additions and 2 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.3 2019/07/12 20:46:23 sthen Exp $
# $OpenBSD: Makefile,v 1.4 2021/07/24 19:35:41 cwen Exp $
COMMENT = Sudoku generator and solver
DISTNAME = qqwing-1.3.4
SHARED_LIBS += qqwing 0.0 # 3.0
REVISION = 0
REVISION = 1
CATEGORIES = games

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-main_cpp,v 1.1 2021/07/24 19:35:41 cwen Exp $
Fix infinite loop while using `qqwing --solve` on unsigned char archs (powerpc
and arm)
Index: main.cpp
--- main.cpp.orig
+++ main.cpp
@@ -488,7 +488,7 @@ void printHelp(){
bool readPuzzleFromStdIn(int* puzzle){
int read = 0;
while (read < BOARD_SIZE){
- char c = getchar();
+ int c = getchar();
if (c == EOF) return false;
if (c >= '1' && c <='9'){
puzzle[read] = c-'0';