From 0effb866f9038dbf9a3bc7d01caad0231bc7f9d5 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sun, 2 Nov 2008 20:21:46 +0000 Subject: [PATCH] New upstream version. Change manual page generation to use upstream documentation as source. --- Makefile.doc | 5 +- Recipe | 9 +-- debian/changelog | 7 +++ debian/control | 3 + debian/mkmanpages.pl | 160 ------------------------------------------------ debian/rules | 3 +- debian/sgt-puzzles.menu | 3 + mines.c | 2 +- mkmanpages.pl | 131 +++++++++++++++++++++++++++++++++++++++ pegs.c | 2 +- puzzles.but | 11 ++++ 11 files changed, 167 insertions(+), 169 deletions(-) delete mode 100644 debian/mkmanpages.pl create mode 100644 mkmanpages.pl diff --git a/Makefile.doc b/Makefile.doc index d127e78..9e3a8f8 100644 --- a/Makefile.doc +++ b/Makefile.doc @@ -1,7 +1,10 @@ -all: puzzles.hlp puzzles.txt HACKING +all: puzzles.hlp puzzles.txt blackboxgame.6 cube.6 dominosa.6 fifteen.6 flipgame.6 guess.6 mines.6 netgame.6 netslide.6 pattern.6 pegs.6 rect.6 samegame.6 sixteen.6 solo.6 twiddle.6 untangle.6 HACKING puzzles.hlp puzzles.txt: puzzles.but halibut --winhelp=puzzles.hlp --text=puzzles.txt puzzles.but +blackboxgame.6 cube.6 dominosa.6 fifteen.6 flipgame.6 guess.6 mines.6 netgame.6 netslide.6 pattern.6 pegs.6 rect.6 samegame.6 sixteen.6 solo.6 twiddle.6 untangle.6: puzzles.but + perl mkmanpages.pl puzzles.but + HACKING: HACKING.but halibut --text=HACKING HACKING.but diff --git a/Recipe b/Recipe index e483e98..104cf70 100644 --- a/Recipe +++ b/Recipe @@ -25,8 +25,9 @@ UNTANGLE = untangle tree234 ALL = list NET NETSLIDE cube fifteen sixteen rect pattern solo twiddle + MINES samegame FLIP guess PEGS dominosa UNTANGLE blackbox -# Debian already has binaries called `flip' (in the flip package) and `net' (in -# the samba-common package) so we append `game' to their names +# Debian already has binaries called `blackbox' (in the blackbox package), +# `flip' (in the flip package) and `net' (in the samba-common package) so we +# append `game' to their names netgame : [X] gtk COMMON NET netslide : [X] gtk COMMON NETSLIDE cube : [X] gtk COMMON cube @@ -43,7 +44,7 @@ guess : [X] gtk COMMON guess pegs : [X] gtk COMMON PEGS dominosa : [X] gtk COMMON dominosa untangle : [X] gtk COMMON UNTANGLE -blackbox : [X] gtk COMMON blackbox +blackboxgame : [X] gtk COMMON blackbox # Auxiliary command-line programs. solosolver : [U] solo[STANDALONE_SOLVER] malloc @@ -163,7 +164,7 @@ FORCE: install: for i in cube netgame netslide fifteen sixteen twiddle \ pattern rect solo mines samegame flipgame guess \ - pegs dominosa untangle blackbox; do \ + pegs dominosa untangle blackboxgame; do \ $(INSTALL_PROGRAM) -m 755 $$i $(DESTDIR)$(gamesdir)/$$i; \ done !end diff --git a/debian/changelog b/debian/changelog index cb49bcb..7b5ca19 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +sgt-puzzles (6119-1) unstable; urgency=low + + * New upstream version + * Change manual page generation to use upstream documentation as source + + -- Ben Hutchings Wed, 20 Jul 2005 09:09:10 +0100 + sgt-puzzles (6085-2) unstable; urgency=low * Fix warning from gcc 4.0 treated as error diff --git a/debian/control b/debian/control index 6047185..8870e1b 100644 --- a/debian/control +++ b/debian/control @@ -22,5 +22,8 @@ Description: Simon Tatham's Portable Puzzle Collection - 1-player puzzle games * Same Game * Guess, based on Mastermind * Pegs, an implementation of several versions of peg solitaire + * Black Box + * Dominosa + * Untangle . Homepage: http://www.chiark.greenend.org.uk/~sgtatham/puzzles/ diff --git a/debian/mkmanpages.pl b/debian/mkmanpages.pl deleted file mode 100644 index 602cb72..0000000 --- a/debian/mkmanpages.pl +++ /dev/null @@ -1,160 +0,0 @@ -#!/usr/bin/perl -w - -# Generate manual pages for sgt-puzzles. All the games take the same options -# and are best described by puzzles.txt, so we generate a brief description -# of each game and the common options using a single template. - -use strict; - -my $date = "July 2005"; - -my $package = "sgt-puzzles"; - -my $section = "Games"; - -my %descriptions = (cube => -['tile manipulation puzzle game', - 'Cube', - 'is a game in which the player rolls a cube or other solid shape over a grid, -picking up or setting down coloured tiles. The object is to cover all faces -of the solid with tiles with as few rotations as possible.'], - fifteen => -['tile manipulation puzzle game', - 'Fifteen', - 'is a game in which the player slides numbered tiles around a grid with one -empty space. The object is to arrange the tiles into numerical order.'], - flipgame => -['tile manipulation puzzle game', - 'Flip', - 'is a game in which the player flips over sets of tiles, each having a dark -and a light side. The object is to light all the squares at the same time -using as few flips as possible.'], - guess => -['guessing game based on Mastermind', - 'Guess', - 'is a game in which the player attempts to guess a hidden sequence of -coloured pegs. The player makes a succession of guesses, each of which is -then marked with the number of pegs that are correctly positioned and the -number that are correctly coloured but wrongly positioned. A limited -number of guesses is allowed.'], - mines => -['puzzle game based on Minesweeper', - 'Mines', - 'is played on a grid of squares, all of which are initially covered, -and some of which contain mines. The object of the game is to uncover -all the squares that do not contain mines. When uncovered, each such -square will reveal how many mines are in the 8 neighbouring squares; -this can be used to deduce where the mines are. - -With the default game parameters, it is always possible to deduce -where mines are, rather than requiring guesswork.'], - netgame => -['tile manipulation puzzle game based on FreeNet', - 'Net', - 'is a game in which the player rotates electrical components arranged as tiles -on a grid. The object is to connect all components into a network without any -closed loops.'], - netslide => -['tile manipulation puzzle game', - 'Netslide', - 'is a game in which the player slides rows and columns of electrical -components arranged as tiles on a grid. The object is to connect all -components into a network without any closed loops.'], - pattern => -['nonogram puzzle game', - 'Pattern', - 'is played on a grid of squares which must each be marked either -black or white. At the left of each row and top of each column is a -sequence of numbers specifying the runs of black tiles that should -appear in that row or column.'], - pegs => -['peg solitaire puzzle game', - 'Pegs', - 'is an implementation of various peg solitaire games. It is played -on a shaped board with holes in it, all but one of which are initially -occupied by pegs. The player may remove a peg from the board by jumping -another peg over it. The object is to remove all but one peg from the -board.'], - rect => -['puzzle game based on Divide by Squares', - 'Rectangles', - 'is played on a grid of squares, some of which are numbered. The -object is to divide the grid into rectangles, each containing one -numbered square and having an area equal to that number.'], - samegame => -['tile manipulation puzzle game', - 'Same Game', - 'is played on a grid of squares, some of which are covered with -coloured tiles. A contiguous group of multiple same-coloured tiles -can be removed, with tiles dropping down and columns of tiles -shuffling left to fill gaps. The object is to remove all the tiles.'], - sixteen => -['tile manipulation puzzle game', - 'Sixteen', - 'is a game in which the player slides rows and columns of numbered -tiles around a grid. The object is to arrange the tiles into -numerical order.'], - solo => -['puzzle game based on Sudoku', - 'Solo', - 'is played on a grid of square or rectangular boxes subdivided into -numbered squares. Initially only some of the squares are numbered. -The object of the game is to assign numbers to the remaining squares -so that each number appears exactly once in each row, column or box.'], - twiddle => -['tile manipulation puzzle game', - 'Twiddle', - 'is a game in which the player rotates groups of numbered tiles within -a grid. The object is to arrange the tiles into numerical order.']); - -for my $command (keys %descriptions) { - my ($short_desc, $name, $long_desc) = @{$descriptions{$command}}; - open MANPAGE, ">$command.6" - or die "open: $!"; - print MANPAGE -".PU -.TH ".uc($command)." 6 \"$date\" \"$command ($package)\" \"$section\" -.SH NAME -$command \\- $short_desc -.SH SYNOPSIS -.B $command -[\\fIGAME-ID\\fR|\\fISEED\\fR|\\fIPARAMETERS\\fR] -.br -.B $command -\\fB--generate\\fR [\\fICOUNT\\fR [\\fIPARAMETERS\\fR]] -.br -.B $command -\\fB--version\\fR -.SH DESCRIPTION -.B $name -$long_desc -.SH OPTIONS -.TP -\\fIGAME-ID\\fR -A game ID, specifying the initial state of the game. This can be used -to recreate a specific game. The game ID for the current game can be -found by selecting 'Specific...' from the Game menu. -.TP -\\fISEED\\fR -A random seed from which the initial state of the game can be -generated. This can be used to recreate a specific game. The random -seed for the current game can be found by selecting 'Random Seed...' -from the Game menu. -.TP -\\fIPARAMETERS\\fR -Parameters of the game, as a string. This can be used to begin a -particular variant of the game quickly. The parameter string for the -current game can be found by selecting 'Random Seed...' from the Game -menu and discarding the '#' and following characters. -.TP -\\fB--generate\\fR [\\fICOUNT\\fR [\\fIPARAMETERS\\fR]] -Output one or \\fICOUNT\\fR random game IDs using \\fIPARAMETERS\\fR -or the default parameters, then exit. -.TP -\\fB--version\\fR -Output version information and exit. -.SH SEE ALSO -Original documentation in /usr/share/doc/sgt-puzzles/puzzles.txt.gz." - or die "print: $!"; - close MANPAGE; -} diff --git a/debian/rules b/debian/rules index 122166a..30c4b34 100755 --- a/debian/rules +++ b/debian/rules @@ -5,7 +5,6 @@ build : Makefile [ -n "$$DEBIAN_REVISION" ] && \ make "VER=$$(cat version.def) -DDEBIAN_REVISION=\"\\\"$$DEBIAN_REVISION\\\"\"" make -f Makefile.doc - perl debian/mkmanpages.pl # We patch these sources and so must rebuild the Makefile. Makefile : mkfiles.pl Recipe @@ -57,4 +56,4 @@ get-orig-source : source : clean dir=$$(basename $$PWD) && \ cd .. && \ - dpkg-source -b -i'Makefile|puzzles\.(cnt|hlp|txt)' $$dir + dpkg-source -b -i'(^|/)(Makefile|puzzles\.(cnt|hlp|txt))$$' $$dir diff --git a/debian/sgt-puzzles.menu b/debian/sgt-puzzles.menu index 135d9ce..2b117f4 100644 --- a/debian/sgt-puzzles.menu +++ b/debian/sgt-puzzles.menu @@ -1,4 +1,6 @@ +?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Black Box" command="/usr/games/blackboxgame" ?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Cube" command="/usr/games/cube" +?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Dominosa" command="/usr/games/dominosa" ?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Fifteen" command="/usr/games/fifteen" ?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Flip" command="/usr/games/flipgame" ?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Guess" command="/usr/games/guess" @@ -12,3 +14,4 @@ ?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Sixteen" command="/usr/games/sixteen" ?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Solo" command="/usr/games/solo" ?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Twiddle" command="/usr/games/twiddle" +?package(sgt-puzzles):needs="x11" section="Games/Puzzles" title="Untangle" command="/usr/games/untangle" diff --git a/mines.c b/mines.c index f962dd6..e991adb 100644 --- a/mines.c +++ b/mines.c @@ -2370,7 +2370,7 @@ static char *encode_ui(game_ui *ui) static void decode_ui(game_ui *ui, char *encoding) { - int p; + int p = 0; sscanf(encoding, "D%d%n", &ui->deaths, &p); if (encoding[p] == 'C') ui->completed = TRUE; diff --git a/mkmanpages.pl b/mkmanpages.pl new file mode 100644 index 0000000..0f7c455 --- /dev/null +++ b/mkmanpages.pl @@ -0,0 +1,131 @@ +#!/usr/bin/perl -w + +# Generate manual pages for sgt-puzzles by running extracts of puzzles.but +# through halibut. + +use strict; + +# Header information +my $date = "July 2005"; # this may be dynamically pulled from the file +my $package = "sgt-puzzles"; +my $section = "Games"; +my $section_no = "6"; + +# Name of command corresponding to each game-specific chapter name +my %commands = (blackbox => 'blackboxgame', + cube => 'cube', + dominosa => 'dominosa', + fifteen => 'fifteen', + flip => 'flipgame', + guess => 'guess', + mines => 'mines', + net => 'netgame', + netslide => 'netslide', + pattern => 'pattern', + pegs => 'pegs', + rectangles => 'rect', + samegame => 'samegame', + sixteen => 'sixteen', + solo => 'solo', + twiddle => 'twiddle', + untangle => 'untangle'); +my %short_descs = (blackboxgame => 'guessing game', + cube => 'tile manipulation puzzle game', + dominosa => 'puzzle game', + fifteen => 'tile manipulation puzzle game', + flipgame => 'tile manipulation puzzle game', + guess => 'guessing game based on Mastermind', + mines => 'game based on Minesweeper', + netgame => 'tile manipulation puzzle game based on FreeNet', + netslide => 'tile manipulation puzzle game', + pattern => 'nonogram puzzle game', + pegs => 'peg solitaire puzzle game', + rect => 'puzzle game based on Divide by Squares', + samegame => 'puzzle game', + sixteen => 'tile manipulation puzzle game', + solo => 'puzzle game based on Sudoku', + twiddle => 'tile manipulation puzzle game', + untangle => 'puzzle game'); + +my @MONTHS = qw(January February March April May June + July August September October November December); + +# Chapter name, initialised to dummy value to capture header +my $name = '__HEADER__'; + +# Contents of each chapter/appendix +my %contents; + +# Gather chapters from the original documentation +while (<>) { + # Look for chapter/appendix heading + if (/^\\[AC]{([^}]+)}\s*/) { + $name = $1; + } + # Look for version ID with date + if (/^\\versionid \$Id: [^ ]+ \d+ (\d{4})-(\d{2})-\d{2} /) { + $date = "${MONTHS[$2-1]} $1"; + } + $contents{$name} .= $_; +} + +# Remove all normal text from the header +$contents{__HEADER__} =~ s/^(?!\\(?:cfg|define|title){).*$//gm; + +# Remove introduction from "common features" chapter +$contents{common} =~ s/^.*?(?=\\H{)//s; + +for my $chapter (keys %commands) { + + my $command = $commands{$chapter}; + print "Generating $command.6\n"; + + my $contents = + "\\cfg{man-mindepth}{1}\n" # don't show original chapter headings + . "\\cfg{man-identity}{".uc($command)."}{$section_no}{$date}{$command ($package)}{$section}\n\n" + . $contents{__HEADER__} + . "\\C{man-$command} $command\n\n" # dummy chapter + . "\\H{man-$command-name} NAME\n\n" + . "\\c{$command} \\- $short_descs{$command}\n\n" + . "\\H{man-$command-synopsis} SYNOPSIS\n\n" + # Is there any way I can avoid the blank lines between these? + . "\\cw{$command} [\\e{GAME-ID}|\\e{SEED}|\\e{PARAMETERS}]\n\n" + . "\\cw{$command --generate} [\\e{COUNT} [\\e{PARAMETERS}]]\n\n" + . "\\cw{$command --version}\n\n" + . "\\H{man-$command-desc} DESCRIPTION\n\n" + . $contents{$chapter} + . $contents{common} + . "\\H{man-$command-see-also} SEE ALSO\n\n" + . "Full documentation in /usr/share/doc/$package/puzzles.txt.gz.\n"; + + # Kluge cross-references + sub replace_ref { + my ($contents, $target) = @_; + # If the target is a section in the current page, say it's above (FIXME) + if ($contents =~ m/\\(?:[CHA]|S\d*){$target}/) { + 'above'; + } + # Else if the target is a bibliographic entry, include the entry directly + elsif ($contents =~ m/\\B{$target} (.*)/) { + "($1)"; + } + # If it appears to refer to another game, convert to a customary + # cross-manual-page reference + elsif ($target =~ /(\w+)/ && exists $commands{$1}) { + "\\e{$1}($section_no)"; + } + # Otherwise (and this shouldn't happen), show the reference target + else { + $target; + } + } + $contents =~ s/\\[kK]{([^}]+)}/replace_ref($contents, $1)/eg; + + # Pipe through halibut --man, removing any erroneous .UC macro from the + # output + open HALIBUT, "| halibut --man=/dev/stdout /dev/stdin | grep -v '^\\.UC' > $command.6"; + print HALIBUT $contents; + close HALIBUT; +} + +exit; diff --git a/pegs.c b/pegs.c index 5bb5de2..4abe116 100644 --- a/pegs.c +++ b/pegs.c @@ -869,7 +869,7 @@ static game_state *execute_move(game_state *state, char *move) int sx, sy, tx, ty; game_state *ret; - if (sscanf(move, "%d,%d-%d,%d", &sx, &sy, &tx, &ty)) { + if (sscanf(move, "%d,%d-%d,%d", &sx, &sy, &tx, &ty) == 4) { int mx, my, dx, dy; if (sx < 0 || sx >= w || sy < 0 || sy >= h) diff --git a/puzzles.but b/puzzles.but index 0ad62ba..dd96778 100644 --- a/puzzles.but +++ b/puzzles.but @@ -294,6 +294,14 @@ than by pasting it into the game ID selection box. then some options, such as the difficulty level in Solo, will be missing. See \k{common-id} for more details on this.) +Alternately, one or more random game IDs may be generated for later +use by specifying the command line argument \cw{--generate}, +optionally followed by a count (defaulting to 1), optionally followed +by encoded game parameters to use. + +Finally, the version number can be shown by specifying the command +line argument \cw{--version}. + \C{net} \i{Net} \cfg{winhelp-topic}{games.net} @@ -1283,6 +1291,9 @@ points in the generated graph. \cfg{winhelp-topic}{games.blackbox} +(\e{Note:} the Debian version of this game is called \i\cw{blackboxgame} to +avoid clashing with the window manager \cw{blackbox}.) + A number of balls are hidden in a rectangular arena. You have to deduce the positions of the balls by firing lasers from positions on the edge of the arena and observing how they are deflected. -- 2.11.4.GIT