Package: bsdgames Version: 2.17-19 Severity: important Tags: upstream patch
Hi, First of all, thanks for maintaining the Debian package of bsdgames! As seen from the additional information, I'm using a Bulgarian locale and I have the Bulgarian wordlist installed; moreover, it is the one selected as default, the target of the /usr/share/dict/words symlink. A couple of days ago I started "hangman" for the first time on this particular installation - and to my astonishment, it did not do anything - or rather, it seemed to be doing something very, very disk-intensive for a long, long time. It turns out that hangman's getwords() routine does not have an exit condition for the "let's look for a suitable word" loop, and since the game is not locale-aware, islower() will always fail on a non-Latin dictionary, and thus getwords() will never really get a word. Steps to reproduce the problem: - install wbulgarian (maybe it would "work" with any non-Latin wordlist) - select it as the default wordlist - start hangman - watch it, well, "hang" :) Attached is a simple patch that weasels out of that problem by putting an upper limit on the number of words that get through to the islower() test. Yes, I know that a real solution would be to make hangman locale-aware, teach it about multibyte locales, and let it actually give me Cyrillic words from a Cyrillic dictionary, but I'm afraid this cannot be achieved without very intrusive changes; thus, this cop-out might have to serve for the present. Thanks again for maintaining bsdgames and your other Debian packages, and keep up the good work! G'luck, Peter -- System Information: Debian Release: 6.0 APT prefers testing APT policy: (990, 'testing'), (500, 'oldstable'), (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.32-5-686 (SMP w/2 CPU cores) Locale: LANG=bg_BG.UTF-8, LC_CTYPE=bg_BG.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages bsdgames depends on: ii libc6 2.11.2-7 Embedded GNU C Library: Shared lib ii libgcc1 1:4.4.5-8 GCC support library ii libncurses5 5.7+20100313-5 shared libraries for terminal hand ii libstdc++6 4.4.5-8 The GNU Standard C++ Library v3 ii wamerican [wordlist] 6-3 American English dictionary words ii wbritish [wordlist] 6-3 British English dictionary words f ii wbulgarian [wordlist] 3.0-12 The Bulgarian dictionary words for bsdgames recommends no packages. bsdgames suggests no packages. -- no debconf information
From 777c39983183fe0acd638b4349e9cd7fa64b9ce4 Mon Sep 17 00:00:00 2001 From: Peter Pentchev <r...@ringlet.net> Date: Mon, 17 Jan 2011 00:42:54 +0200 Subject: [PATCH] Error out on 1000 unsuitable words. This fixes an endless loop in getword() on non-Latin dictionaries. --- debian/patches/hangman-words.diff | 41 +++++++++++++++++++++++++++++++++++++ debian/patches/series | 1 + 2 files changed, 42 insertions(+), 0 deletions(-) create mode 100644 debian/patches/hangman-words.diff diff --git a/debian/patches/hangman-words.diff b/debian/patches/hangman-words.diff new file mode 100644 index 0000000..907f597 --- /dev/null +++ b/debian/patches/hangman-words.diff @@ -0,0 +1,41 @@ +Description: Error out on 1000 unsuitable words. +Forwarded: no +Author: Peter Pentchev <r...@ringlet.net> +Last-Update: 2011-01-17 + +--- a/hangman/getword.c ++++ b/hangman/getword.c +@@ -50,8 +50,10 @@ + FILE *inf; + char *wp, *gp; + long pos; ++ int tries; + + inf = Dict; ++ tries = 0; + for (;;) { + pos = (double) rand() / (RAND_MAX + 1.0) * (double) Dict_size; + fseek(inf, pos, SEEK_SET); +@@ -66,7 +68,21 @@ + if (!islower((unsigned char)*wp)) + goto cont; + break; +-cont: ; ++cont: ++ if (++tries >= 1000) { ++ move(MESGY, MESGX); ++ deleteln(); ++ deleteln(); ++ deleteln(); ++ move(MESGY, MESGX); ++ printw("No suitable word found, try using " ++ "another dictionary!"); ++ leaveok(stdscr, FALSE); ++ refresh(); ++ readch(); ++ leaveok(stdscr, TRUE); ++ die(0); ++ } + } + gp = Known; + wp = Word; diff --git a/debian/patches/series b/debian/patches/series index 21a10ef..6a59734 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -8,3 +8,4 @@ capitals.diff define-dead.diff wump-update.diff debian-changes-2.17-19 +hangman-words.diff -- 1.7.2.3
signature.asc
Description: Digital signature