--- sudoku-1.0.1.orig/sudoku.6 +++ sudoku-1.0.1/sudoku.6 @@ -14,20 +14,20 @@ .PP (generate boards) .RS -.B sudoku -g +.B sudoku \-g .RI [ ] .RI [ options "] ..." .RE .PP (solve boards) .RS -.B sudoku -v +.B sudoku \-v .RI [ options "] ..." .RE .PP (calculate statistics) .RS -.B sudoku -s +.B sudoku \-s .RI [ options "] ..." .RE .SH DESCRIPTION @@ -101,7 +101,7 @@ .SS "Generating a New Board" A new board can be generated at any time by pressing the `\fIn\fR' key, and either a \fIprecanned\fR or randomly generated board will be displayed. -If the \fB-n\fR command line option is set, then only \fIprecanned\fR boards +If the \fB\-n\fR command line option is set, then only \fIprecanned\fR boards will be displayed. .SS "Entering a Custom Board" A custom board (e.g. found on the internet, or published in a newspaper) @@ -140,14 +140,18 @@ .SH OPTIONS .TP -.BI -d +.BI \-c +Generate a board until it finds a board of the specified class. +Supported classes are: very easy, easy, medium, hard, and fiendish. +.TP +.BI \-d Describe the moves needed to solve the board. Can only be used with the -.B -v +.B \-v option for solving .I precanned boards. .TP -.BI -f +.BI \-f Set output format. The supported formats are: .ta 0.25i 1.25i .nf @@ -159,31 +163,31 @@ \fBhtml\fR Simple HTML. .fi .TP -.BI -g "[]" +.BI \-g "[]" Generate .I boards (or just 1 board, if not specified) and write them to standard output. .TP -.BI -n +.BI \-n No random boards generated in the interactive game. Requires the optional file of \fIprecanned\fR boards to be specified. .TP -.BI -r +.BI \-r Run in restricted mode, disallowing any games to be saved. .TP -.BI -s +.BI \-s Calculate statistics for the .I precanned boards, and attempt to classify the difficulty of solving the boards. Can be used with the -.B -v +.B \-v option. .TP -.BI -t "" +.BI \-t "" Set the template file. The file set on the command line will be used instead of the default template file. .TP -.BI -v +.BI \-v Solve .I precanned boards, writing the solution to standard output. @@ -198,13 +202,13 @@ program. .SH FILES .TP -.BI /usr/lib/sudoku/template +.BI /usr/share/sudoku/template Template file for generating new sudoku boards. .TP -.BI /usr/lib/sudoku/precanned +.BI /usr/share/sudoku/precanned Optional file, containing `precanned' sudoku boards. .SH "FILE FORMATS" -.SS /usr/lib/sudoku/template +.SS /usr/share/sudoku/template The template file contains a sequence of patterns that are used for generating new .B sudoku @@ -223,7 +227,7 @@ .B sudoku program can read precanned files in this format, and will write them when the -.B -fcompact +.B \-fcompact option is set. .SS "Standard text format" This format is very similar to the compact text format, but includes @@ -231,7 +235,7 @@ .B sudoku program can read precanned files in this format, and writes them by default, unless another output format is set by the -.B -f +.B \-f option. .SS "Comma separated text format" This format is useful for importing @@ -242,7 +246,7 @@ .B sudoku program cannot read precanned files in this format, and writes them when the -.B -fcsv +.B \-fcsv option is set. Unlike the standard or compact text formats, there are no lines separating boards, and hence, it is really only feasible to store one board per file. @@ -253,7 +257,7 @@ .B sudoku program cannot read boards stored in this format, and writes them when the -.B -fpostscript +.B \-fpostscript option is set. Unlike the standard or compact text formats, it is not possible to store multiple boards in the same file. .SS "HTML format" @@ -263,7 +267,7 @@ .B sudoku program cannot read boards stored in this format, and writes them when the -.B -fhtml +.B \-fhtml option is set. Unlike the standard or compact text formats, it is not possible to store multiple boards in the same file. .SH "SEE ALSO" --- sudoku-1.0.1.orig/sudoku.html +++ sudoku-1.0.1/sudoku.html @@ -133,6 +133,10 @@

OPTIONS

+       -c<class>
+	      Generate a board until it finds a board of the specified class.
+	      Supported classes are: very easy, easy, medium, hard, and fiendish.
+
        -d     Describe the moves needed to solve the board. Can only  be  used
 	      with the -v option for solving precanned boards.
 
--- sudoku-1.0.1.orig/Makefile
+++ sudoku-1.0.1/Makefile
@@ -4,32 +4,19 @@
 # the public domain by Michael Kennett (July 2005), and can be
 # used freely by anybody for any purpose.
 
-OWN=-o bin
-GRP=-g operator
+OWN=-o root
+GRP=-g root
+DESTDIR=/
 
-# Minix requires compilation flags for a clean compile
 sudoku: sudoku.c
-	if [ -x /usr/bin/uname -a `/usr/bin/uname` = Minix ] ; then \
-	DEFS="-D_MINIX -D_POSIX_SOURCE" ; fi ; \
-	$(CC) -o sudoku $$DEFS sudoku.c -lcurses
+	$(CC) -o sudoku $(LDFLAGS) $(CPPFLAGS) $(CFLAGS) sudoku.c -lcurses
 
 clean:
 	rm -f sudoku
 
-# Simple support for alternate systems
 install: sudoku sudoku.6
-	if [ -x /usr/bin/uname -a `/usr/bin/uname` = Minix ] ; then \
-	install -s -S 8kw $(OWN) $(GRP) -m 755 sudoku /usr/bin/sudoku ; \
-	else \
-	install -s $(OWN) $(GRP) -m 755 sudoku /usr/bin/sudoku ; \
-	fi
-	install -d $(OWN) $(GRP) -m 755 /usr/lib/sudoku
-	install $(OWN) $(GRP) -m 644 template /usr/lib/sudoku/template
-	if [ -d /usr/man/man6 ] ; then \
-	install $(OWN) $(GRP) -m 644 sudoku.6 /usr/man/man6/sudoku.6 ; \
-	elif [ -d /usr/share/man/man6 ] ; then \
-	install $(OWN) $(GRP) -m 644 sudoku.6 /usr/share/man/man6/sudoku.6 ; \
-	else \
-	echo Warning: Manual page not installed ; \
-	fi
+	install $(OWN) $(GRP) -m 755 sudoku $(DESTDIR)/usr/games/sudoku
+	install -d $(OWN) $(GRP) -m 755 $(DESTDIR)/usr/share/sudoku
+	install $(OWN) $(GRP) -m 644 template $(DESTDIR)/usr/share/sudoku/template
+	install $(OWN) $(GRP) -m 644 sudoku.6 $(DESTDIR)/usr/share/man/man6/sudoku.6
 
--- sudoku-1.0.1.orig/sudoku.c
+++ sudoku-1.0.1/sudoku.c
@@ -44,14 +44,17 @@
 
 /* Default file locations */
 #ifndef TEMPLATE
-#define TEMPLATE "/usr/lib/sudoku/template"
+#define TEMPLATE "/usr/share/sudoku/template"
 #endif
 #ifndef PRECANNED
-#define PRECANNED "/usr/lib/sudoku/precanned"
+#define PRECANNED "/usr/share/sudoku/precanned"
 #endif
 
 static const char * program;        /* argv[0] */
 
+static const char * class = NULL;
+static time_t start_time;
+
 /* Common state encoding in a 32-bit integer:
  *   bits  0-6    index
  *         7-15   state  [bit high signals digits not possible]
@@ -1301,12 +1304,14 @@
     mvaddstr( TOP + 3, RIGHT + 7, "1-9  place digit" );
     mvaddstr( TOP + 4, RIGHT + 7, "0 .  clear digit" );
     mvaddstr( TOP + 5, RIGHT + 8, "c   clear board" );
-    mvaddstr( TOP + 6, RIGHT + 8, "f   fix squares" );
-    mvaddstr( TOP + 7, RIGHT + 8, "n   new board" );
-    mvaddstr( TOP + 8, RIGHT + 8, "q   quit game" );
-    i = TOP + 8;
+    mvaddstr( TOP + 6, RIGHT + 8, "d   redraw the board" );
+    mvaddstr( TOP + 7, RIGHT + 8, "f   fix squares" );
+    mvaddstr( TOP + 8, RIGHT + 8, "n   new board" );
+    mvaddstr( TOP + 9, RIGHT + 8, "q   quit game" );
+    i = TOP + 9;
     if( 0 == opt_restrict )
         mvaddstr( ++i, RIGHT + 8, "s   save" );
+    mvaddstr( ++i, RIGHT + 8, "r   restart" );
     mvaddstr( ++i, RIGHT + 8, "u   undo last move" );
     mvaddstr( ++i, RIGHT + 8, "v   solve" );
     mvaddstr( ++i, RIGHT + 8, "?   request hint" );
@@ -1696,10 +1701,21 @@
     if( -1 != backtrack( ) && 0 == solve( ) )
         goto start;
 
+    if( NULL != class )
+    {
+        const char * generated_class = classify();
+        sprintf( title, "randomly generated - %s", generated_class);
+        write_title( title );
+        wrefresh( stdscr );
+        if (0 != strcmp( class, generated_class ) )
+            goto start;
+    }
+
     strcpy( title, "randomly generated - " );
     strcat( title, classify( ) );
 
     clear_moves( );
+    time( &start_time );
 }
 
 /* Support for precanned board (optional) */
@@ -1797,8 +1813,11 @@
             case 'C': ch = VKEY_RIGHT; break;
             case 'D': ch = VKEY_LEFT; break;
             case 'H': ch = VKEY_HOME; break;
+            default: ch = 256;
             }
         }
+        else
+            ch = 256;
     }
     return ch;
 }
@@ -1837,9 +1856,9 @@
 
     /* Read character input (raw processing mode) */
     i = strlen( userfile );
-    while( '\r' != ( ch = getkey( ) ) )
+    while( '\r' != ( ch = getkey( ) ) && ch != '\n')
     {
-        if( 0x08 == ch || VKEY_LEFT == ch ) /* destructive backspace */
+        if( 0x08 == ch || VKEY_LEFT == ch || 0x7F == ch) /* destructive backspace */
         {
             if( 0 < i )
             {
@@ -2021,6 +2040,9 @@
     fprintf( stderr,
 "Usage: %s [options] []\n"
 "Supported options:\n"
+"    -c    generate a board until it finds a board of the specified\n"
+"                 class. Supported classes are:\n"
+"                    very easy, easy, medium, hard, and fiendish\n"
 "    -d           describe solution steps (with -v)\n"
 "    -f   set output format; supported formats are:\n"
 "                    standard   (std)    \n"
@@ -2072,12 +2094,38 @@
                 while( '\0' != *++arg )
                     switch( *arg )
                     {
+                    case 'c':
+                        class = strdup( &arg[ 1 ] );
+                        if( 0 != strcmp( class, "very easy" ) &&
+                            0 != strcmp( class, "easy" ) &&
+                            0 != strcmp( class, "medium" ) &&
+                            0 != strcmp( class, "hard" ) &&
+                            0 != strcmp( class, "fiendish" ) )
+                        {
+                            fprintf( stderr,
+                                     "Error: the class must be one of 'very easy', 'easy', 'medium', 'hard' and 'fiendish'\n" );
+                            exit( 1 );
+                        }
+                        arg = "x"; /* dummy to force termination */
+                        break;
+
                     case 'd': opt_describe = 1; break;
                     case 'f':
                         if( '\0' == arg[ 1 ] )
                         {
-                            arg = *++argv;
-                            --argc;
+                            if(    (NULL != argv[1])
+                                && ('-'  != argv[1][0]))
+                            {
+                                arg = *++argv;
+                                --argc;
+                            }
+                            else
+                            {
+                                fprintf( stderr,
+                                         "Error: missing format with option -f\n" );
+                                exit( 1 );
+                            }
+
                         }
                         else
                             ++arg;
@@ -2240,7 +2288,7 @@
 
     draw_screen( );
     noecho( );
-    raw( );
+    cbreak( );
 
     load_board( );
 
@@ -2329,8 +2377,8 @@
                     move_next( );
                 }
                 else
-                    move_to( ROW( GET_INDEX( history[ idx_history ] ) ),
-                             COLUMN( GET_INDEX( history[ idx_history ] ) ) );
+                    move_to( COLUMN( GET_INDEX( history[ idx_history ] ) ),
+                             ROW( GET_INDEX( history[ idx_history ] ) ) );
             }
             break;
         case 'c': /* clear board */
@@ -2343,6 +2391,10 @@
             write_title( 0 );
             move_to( 0, 0 );
             break;
+        case 'd': /* refresh screen */
+            wrefresh( stdscr );
+            redrawwin( stdscr );
+            break;
         case 'f': /* fix squares (if possible) */
             if( 0 == idx_history || 0 != ( history[ 0 ] & FIXED ) )
                 break;
@@ -2374,6 +2426,13 @@
             move_to( curx, cury );
             break;
 
+        case 'r': /* restart the same board */
+            clear_moves( );
+            render( );
+            curx = cury = 8;    /* move_next() takes care of this... */
+            move_next( );
+            break;
+
         /* The main difficulty with saving a board is managing the
          * user interface.
          */
@@ -2455,8 +2514,15 @@
                 ;
             if( 81 == i && 0 == fix( ) )
             {
+                time_t end_time;
+                time( &end_time );
+                end_time -= start_time;
+                sprintf(statusline, "Well done - you've completed the puzzle! (%02d:%02d:%02d)",
+                                    (int) (end_time/60/60),
+                                    (int) (end_time/60)%60,
+                                    (int) (end_time%60));
                 beep( );
-                set_status( "Well done - you've completed the puzzle!" );
+                set_status( statusline );
                 completed = 1;
             }
         }
--- sudoku-1.0.1.orig/debian/compat
+++ sudoku-1.0.1/debian/compat
@@ -0,0 +1 @@
+9
--- sudoku-1.0.1.orig/debian/copyright
+++ sudoku-1.0.1/debian/copyright
@@ -0,0 +1,13 @@
+This package was debianized by Nicolas FRANCOIS (Nekral)
+ on Mon, 26 Dec 2005 22:40:39 +0100.
+
+It was downloaded from http://www.laurasia.com.au/sudoku/
+which as of 2008-03-13 is no longer available.
+
+Upstream author: Michael Kennett
+
+License:
+
+LICENSE: This work has been placed into the Public Domain by Michael
+Kennett (July 2005), and may be freely used by anybody for any purpose
+whatsoever. No warranty, of any kind, applies to this work.
--- sudoku-1.0.1.orig/debian/dirs
+++ sudoku-1.0.1/debian/dirs
@@ -0,0 +1,2 @@
+usr/games
+usr/share/man/man6
--- sudoku-1.0.1.orig/debian/docs
+++ sudoku-1.0.1/debian/docs
@@ -0,0 +1 @@
+README
--- sudoku-1.0.1.orig/debian/rules
+++ sudoku-1.0.1/debian/rules
@@ -0,0 +1,3 @@
+#!/usr/bin/make -f
+%:
+	dh $@
--- sudoku-1.0.1.orig/debian/control
+++ sudoku-1.0.1/debian/control
@@ -0,0 +1,22 @@
+Source: sudoku
+Section: games
+Priority: optional
+Maintainer: Nicolas FRANCOIS (Nekral) 
+Build-Depends: debhelper (>= 9), libncurses-dev
+Standards-Version: 3.9.4.0
+#The Homepage used to be:
+#Homepage: http://www.laurasia.com.au/sudoku/
+
+Package: sudoku
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: console based sudoku
+ This sudoku puzzle generator/solver features:
+  * character based (curses) interface;
+  * cross-platform (Minix, Unix, Windows) with full source code (ANSI C);
+  * generates hints upon request;
+  * classification of board difficulty (very easy, easy, medium, hard or
+    fiendish);
+  * generation of new boards;
+  * easy entry of boards published in newspapers, Internet, ...;
+  * multiple output formats (text, csv, HTML, PostScript).
--- sudoku-1.0.1.orig/debian/changelog
+++ sudoku-1.0.1/debian/changelog
@@ -0,0 +1,71 @@
+sudoku (1.0.1-5) unstable; urgency=low
+
+  * sudoku.c: Report error whan no formatsare provided to -f
+  * debian/control: Update description: spell HTML in upper case and remove
+    etc redundant with ellipsis. Closes: #673692
+  * debian/control: Bump Standards-Version to 3.9.4.0 No changes.
+
+ -- Nicolas FRANCOIS (Nekral)   Sun, 30 Jun 2013 15:33:07 +0200
+
+sudoku (1.0.1-4) unstable; urgency=low
+
+  * debian/compat, debian/control: Use compatibility level 9.
+  * debian/rules: Use minimal dh Makefile
+  * debian/control: Bump Standards-Version to 3.9.3. No changes.
+  * debian/control: Remove dependency on cdbs.
+  * Makefile: Install in /usr per default.
+  * Makefile: Add LDFLAGS.
+  * sudoku.c: Added keystroke to redraw the board in case of screen corruption.
+    Closes: #673288
+  * debian/control: Fix PostScript spelling in description. Closes: #600011
+
+ -- Nicolas FRANCOIS (Nekral)   Sat, 19 May 2012 20:44:59 +0200
+
+sudoku (1.0.1-3) unstable; urgency=low
+
+  * debian/copyright: Indicate that upstream homepage is no more available.
+    Closes: #470744
+  * Makefile, debian/dirs: Install the binary in /usr/games instead of
+    /usr/bin.
+  * debian/control: Do not mention the Homepage anymore.
+  * debian/control: Bump Standards-Version to 3.7.3. No changes.
+
+ -- Nicolas FRANCOIS (Nekral)   Sat, 26 Apr 2008 23:40:09 +0200
+
+sudoku (1.0.1-2) unstable; urgency=low
+
+  * Makefile: Do not strip sudoku when it is installed. This fixes the
+    handling of the nostrip build option. Closes: #438072
+
+ -- Nicolas FRANCOIS (Nekral)   Sat, 25 Aug 2007 22:45:49 +0200
+
+sudoku (1.0.1-1) unstable; urgency=low
+
+  * Initial release Closes: #378167
+
+  * Fix the "save" command (accept \n as \r)
+
+  * rework the Makefile to support DESTDIR.
+
+  * Add a "restart" command to restore a blanked sudoku, with the original
+    digits ("clear" remove all the digits)
+
+  * Fix the "undo" command (the cursor was not going back to the changed
+    digit).
+
+  * change the location of the data files from /usr/lib to /usr/share (and fix
+    the Makefile and man page accordingly).
+
+  * Add a -c option to specify the complexity of the generated board.
+
+  * Use the cbreak mode instead of raw mode to allow signals.
+
+  * Use minus signs instead of hyphens in the man page.
+
+  * Display the time spent for solving the puzzle.
+
+  * Avoid special keys to have be interpreted like another key (e.g. PAGE_UP
+    was 5 and PAGE_DOWN was 6).
+
+ -- Nicolas FRANCOIS (Nekral)   Mon, 26 Dec 2005 22:40:39 +0100
+