summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Günther <tom@toms-cafe.de>2008-11-23 01:18:02 +0100
committerThomas Günther <tom@toms-cafe.de>2008-11-23 01:18:02 +0100
commitc174c43f7d9ca12ffab4f9d0a5a88af6537c69c1 (patch)
treebc19b3161f137b615e44c7cdfbd5fb1abfafecf1
parent4e267c94df295858d5cd07f103b3e1bab63272ff (diff)
downloadvdr-plugin-sudoku-c174c43f7d9ca12ffab4f9d0a5a88af6537c69c1.tar.gz
vdr-plugin-sudoku-c174c43f7d9ca12ffab4f9d0a5a88af6537c69c1.tar.bz2
Delete puzzles from the sudoku-list file with confirmation.v0.3.3
Added version option to sudoku_generator. Added manual page for sudoku_generator. Set version number and release date for version 0.3.3
-rw-r--r--HISTORY6
-rw-r--r--i18n.cpp24
-rw-r--r--list.cpp6
-rw-r--r--po/de_DE.po11
-rw-r--r--po/es_ES.po7
-rw-r--r--po/fi_FI.po8
-rw-r--r--po/fr_FR.po8
-rw-r--r--po/it_IT.po8
-rw-r--r--sudoku.cpp4
-rw-r--r--tools/Makefile24
-rw-r--r--tools/sudoku_generator.174
-rw-r--r--tools/sudoku_generator.cpp63
12 files changed, 203 insertions, 40 deletions
diff --git a/HISTORY b/HISTORY
index e059666..c226def 100644
--- a/HISTORY
+++ b/HISTORY
@@ -69,3 +69,9 @@ VDR plug-in 'Sudoku' Revision History
2008-09-28: Version 0.3.2
- Updated French language texts (thanks to NIVAL Michaël).
+
+2008-11-23: Version 0.3.3
+
+- Delete puzzles from the sudoku-list file with confirmation.
+- Added version option to sudoku_generator.
+- Added manual page for sudoku_generator.
diff --git a/i18n.cpp b/i18n.cpp
index f44ed66..fccbf5a 100644
--- a/i18n.cpp
+++ b/i18n.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: i18n.cpp 157 2008-09-28 00:13:23Z tom $
+ * $Id: i18n.cpp 161 2008-11-23 00:18:02Z tom $
*
*
* Translations provided by:
@@ -345,6 +345,28 @@ const tI18nPhrase SudokuPlugin::Phrases[] = {
"", // Dansk / Danish
"", // Èesky / Czech
},
+ { "Delete the puzzle?", // English
+ "Puzzle löschen?", // Deutsch / German
+ "", // Slovenski / Slovenian
+ "Eliminare partita?", // Italiano / Italian
+ "", // Nederlands / Dutch
+ "", // Português / Portuguese
+ "Supprimer le puzzle ?", // Français / French
+ "", // Norsk / Norwegian
+ "Poistetaanko ristikko?", // suomi / Finnish
+ "", // Polski / Polish
+ "", // Español / Spanish
+ "", // ÅëëçíéêÜ / Greek
+ "", // Svenska / Swedish
+ "", // Românã / Romanian
+ "", // Magyar / Hungarian
+ "", // Català / Catalanian
+ "", // ÀãááÚØÙ / Russian
+ "", // Hrvatski / Croatian
+ "", // Eesti / Estonian
+ "", // Dansk / Danish
+ "", // Èesky / Czech
+ },
{ "Button$Load", // English
"Laden", // Deutsch / German
"", // Slovenski / Slovenian
diff --git a/list.cpp b/list.cpp
index 37e6a71..81f3dcf 100644
--- a/list.cpp
+++ b/list.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: list.cpp 115 2008-03-19 00:38:58Z tom $
+ * $Id: list.cpp 161 2008-11-23 00:18:02Z tom $
*/
#include "list.h"
@@ -26,6 +26,7 @@
#include <vdr/osdbase.h>
#include <vdr/osd.h>
#include <vdr/menuitems.h>
+#include <vdr/interface.h>
#include <assert.h>
// Compatibility to older vdr versions
@@ -145,7 +146,8 @@ eOSState ListMenu::ProcessKey(eKeys key)
return AddSubMenu(new ListEdit(*list.Get(Current())));
break;
case kYellow:
- if (Current() >= 0 && Current() < list.Count())
+ if (Current() >= 0 && Current() < list.Count() &&
+ Interface->Confirm(tr("Delete the puzzle?")))
list.Del(list.Get(Current()));
refresh();
list.Save();
diff --git a/po/de_DE.po b/po/de_DE.po
index 508dfd5..97afd80 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -3,14 +3,14 @@
# This file is distributed under the same license as the vdr-sudoku package.
# Thomas Günther <tom@toms-cafe.de>, 2005, 2008.
#
-# $Id: de_DE.po 157 2008-09-28 00:13:23Z tom $
+# $Id: de_DE.po 161 2008-11-23 00:18:02Z tom $
#
msgid ""
msgstr ""
-"Project-Id-Version: vdr-sudoku 0.3.2\n"
+"Project-Id-Version: vdr-sudoku 0.3.3\n"
"Report-Msgid-Bugs-To: <tom@toms-cafe.de>\n"
-"POT-Creation-Date: 2008-08-28 23:32+0200\n"
-"PO-Revision-Date: 2008-08-28 23:32+0200\n"
+"POT-Creation-Date: 2008-11-21 00:36+0100\n"
+"PO-Revision-Date: 2008-11-21 00:36+0100\n"
"Last-Translator: Thomas Günther <tom@toms-cafe.de>\n"
"Language-Team: <vdr@linuxtv.org>\n"
"MIME-Version: 1.0\n"
@@ -53,6 +53,9 @@ msgstr "Beenden"
msgid "Sudoku list"
msgstr "Sudoku-Liste"
+msgid "Delete the puzzle?"
+msgstr "Puzzle löschen?"
+
msgid "Button$Load"
msgstr "Laden"
diff --git a/po/es_ES.po b/po/es_ES.po
index 7fb6f95..fc3b63b 100644
--- a/po/es_ES.po
+++ b/po/es_ES.po
@@ -3,13 +3,13 @@
# This file is distributed under the same license as the vdr-sudoku package.
# bittor from open7x0.org, 2007.
#
-# $Id: es_ES.po 151 2008-08-29 22:57:35Z tom $
+# $Id: es_ES.po 161 2008-11-23 00:18:02Z tom $
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-sudoku 0.1.3\n"
"Report-Msgid-Bugs-To: <tom@toms-cafe.de>\n"
-"POT-Creation-Date: 2008-08-28 23:32+0200\n"
+"POT-Creation-Date: 2008-11-21 00:36+0100\n"
"PO-Revision-Date: 2007-08-20 22:43+0200\n"
"Last-Translator: bittor from open7x0.org\n"
"Language-Team: <vdr@linuxtv.org>\n"
@@ -53,6 +53,9 @@ msgstr ""
msgid "Sudoku list"
msgstr ""
+msgid "Delete the puzzle?"
+msgstr ""
+
msgid "Button$Load"
msgstr ""
diff --git a/po/fi_FI.po b/po/fi_FI.po
index f1fcf2d..312b09f 100644
--- a/po/fi_FI.po
+++ b/po/fi_FI.po
@@ -3,13 +3,13 @@
# This file is distributed under the same license as the vdr-sudoku package.
# Ville Skyttä <ville.skytta@iki.fi>, 2005, 2008.
#
-# $Id: fi_FI.po 157 2008-09-28 00:13:23Z tom $
+# $Id: fi_FI.po 161 2008-11-23 00:18:02Z tom $
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-sudoku 0.3.2\n"
"Report-Msgid-Bugs-To: <tom@toms-cafe.de>\n"
-"POT-Creation-Date: 2008-08-28 23:32+0200\n"
+"POT-Creation-Date: 2008-11-21 00:36+0100\n"
"PO-Revision-Date: 2008-07-27 12:24+0300\n"
"Last-Translator: Ville Skyttä <ville.skytta@iki.fi>\n"
"Language-Team: <vdr@linuxtv.org>\n"
@@ -53,6 +53,10 @@ msgstr "Poistu"
msgid "Sudoku list"
msgstr "Tallennetut ristikot"
+#, fuzzy
+msgid "Delete the puzzle?"
+msgstr "Poistetaanko ristikko?"
+
msgid "Button$Load"
msgstr "Lataa"
diff --git a/po/fr_FR.po b/po/fr_FR.po
index 615128d..3c7ae0b 100644
--- a/po/fr_FR.po
+++ b/po/fr_FR.po
@@ -4,13 +4,13 @@
# Patrice Staudt <patr.staudt@laposte.net>, 2008.
# NIVAL Michaël <mnival@vdrbox.lautre.net>, 2008.
#
-# $Id: fr_FR.po 157 2008-09-28 00:13:23Z tom $
+# $Id: fr_FR.po 161 2008-11-23 00:18:02Z tom $
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-sudoku 0.3.2\n"
"Report-Msgid-Bugs-To: <tom@toms-cafe.de>\n"
-"POT-Creation-Date: 2008-08-28 23:32+0200\n"
+"POT-Creation-Date: 2008-11-21 00:36+0100\n"
"PO-Revision-Date: 2008-09-16 22:59+0100\n"
"Last-Translator: NIVAL Michaël <mnival@vdrbox.lautre.net>\n"
"Language-Team: <vdr@linuxtv.org>\n"
@@ -54,6 +54,10 @@ msgstr "Terminer"
msgid "Sudoku list"
msgstr "Liste Sudoku"
+#, fuzzy
+msgid "Delete the puzzle?"
+msgstr "Supprimer le puzzle ?"
+
msgid "Button$Load"
msgstr "Charger"
diff --git a/po/it_IT.po b/po/it_IT.po
index 808cef7..e2d0dfa 100644
--- a/po/it_IT.po
+++ b/po/it_IT.po
@@ -3,13 +3,13 @@
# This file is distributed under the same license as the vdr-sudoku package.
# Diego Pierotto <vdr-italian@tiscali.it>, 2007, 2008.
#
-# $Id: it_IT.po 157 2008-09-28 00:13:23Z tom $
+# $Id: it_IT.po 161 2008-11-23 00:18:02Z tom $
#
msgid ""
msgstr ""
"Project-Id-Version: vdr-sudoku 0.3.2\n"
"Report-Msgid-Bugs-To: <tom@toms-cafe.de>\n"
-"POT-Creation-Date: 2008-08-28 23:32+0200\n"
+"POT-Creation-Date: 2008-11-21 00:36+0100\n"
"PO-Revision-Date: 2008-07-27 20:28+0200\n"
"Last-Translator: Diego Pierotto <vdr-italian@tiscali.it>\n"
"Language-Team: <vdr@linuxtv.org>\n"
@@ -53,6 +53,10 @@ msgstr "Esci"
msgid "Sudoku list"
msgstr "Elenco Sudoku"
+#, fuzzy
+msgid "Delete the puzzle?"
+msgstr "Eliminare partita?"
+
msgid "Button$Load"
msgstr "Carica"
diff --git a/sudoku.cpp b/sudoku.cpp
index 5c131ae..5ad34d6 100644
--- a/sudoku.cpp
+++ b/sudoku.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: sudoku.cpp 157 2008-09-28 00:13:23Z tom $
+ * $Id: sudoku.cpp 161 2008-11-23 00:18:02Z tom $
*/
#include "sudoku.h"
@@ -34,7 +34,7 @@ namespace SudokuPlugin
{
/** Version number of the plugin */
- static const char* VERSION = "0.3.2";
+ static const char* VERSION = "0.3.3";
/** Short description of the plugin's purpose */
static const char* DESCRIPTION =
diff --git a/tools/Makefile b/tools/Makefile
index edd5432..eb5f63c 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -17,7 +17,7 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
-# $Id: Makefile 140 2008-06-30 22:10:38Z tom $
+# $Id: Makefile 161 2008-11-23 00:18:02Z tom $
# Define STATIC_LINK=1 to force static linking
#STATIC_LINK = 1
@@ -27,7 +27,8 @@
PROGRAM = sudoku_generator
-SRCS = ../puzzle.cpp ../generator.cpp ../solver.cpp ../backtrack.cpp ../history.cpp
+SRCS = ../puzzle.cpp ../generator.cpp ../solver.cpp ../backtrack.cpp \
+ ../history.cpp
VERSION = $(shell sed -ne '/static .* VERSION *=/s/^.*"\(.*\)".*$$/\1/p' \
../sudoku.cpp)
@@ -44,6 +45,20 @@ ifdef WITH_TEST
DEFINES += -DWITH_TEST
endif
+### Directories:
+
+prefix = /usr/local
+bindir = $(prefix)/bin
+mandir = $(prefix)/share/man
+man1dir = $(mandir)/man1
+
+### Tools:
+
+INSTALL = install
+INSTALL_DIRS = $(INSTALL) -d
+INSTALL_PROG = $(INSTALL)
+INSTALL_DATA = $(INSTALL) -m u=rw,g=r,o=r
+
### Targets:
all: $(PROGRAM)
@@ -51,5 +66,10 @@ all: $(PROGRAM)
$(PROGRAM): $(PROGRAM).cpp $(SRCS) $(SRCS:%.cpp=%.h)
$(CXX) $(CXXFLAGS) $(DEFINES) $(INCLUDES) -o $@ $(PROGRAM).cpp $(SRCS)
+install: all
+ $(INSTALL_DIRS) $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
+ $(INSTALL_PROG) $(PROGRAM) $(DESTDIR)$(bindir)/
+ $(INSTALL_DATA) $(PROGRAM).1 $(DESTDIR)$(man1dir)/
+
clean:
@-rm -f $(PROGRAM) core* *~
diff --git a/tools/sudoku_generator.1 b/tools/sudoku_generator.1
new file mode 100644
index 0000000..4bc9e50
--- /dev/null
+++ b/tools/sudoku_generator.1
@@ -0,0 +1,74 @@
+.\"
+.\" Sudoku: A plug-in for the Video Disk Recorder
+.\"
+.\" Copyright (C) 2008, Thomas Günther <tom@toms-cafe.de>
+.\"
+.\" This program is free software; you can redistribute it and/or modify
+.\" it under the terms of the GNU General Public License as published by
+.\" the Free Software Foundation; either version 2 of the License, or
+.\" (at your option) any later version.
+.\"
+.\" This program is distributed in the hope that it will be useful,
+.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
+.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+.\" GNU General Public License for more details.
+.\"
+.\" You should have received a copy of the GNU General Public License along
+.\" with this program; if not, write to the Free Software Foundation, Inc.,
+.\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+.\"
+.\" $Id: sudoku_generator.1 161 2008-11-23 00:18:02Z tom $
+.\"
+.TH sudoku_generator "1" "November 2008" "sudoku_generator 0.3.3" "User Commands"
+
+.SH NAME
+sudoku_generator \- generate and solve Sudoku puzzles
+
+.SH SYNOPSIS
+.B sudoku_generator
+[\fI-n|--non-sym\fR] [\fI-d|--dump\fR] [\fIgivens_count\fR]
+.br
+.B sudoku_generator
+\fI-s|--solve|-p|--print\fR \fIsudoku_dump\fR
+
+.SH DESCRIPTION
+.B sudoku_generator
+generates, solves and prints Number Place puzzles, so called Sudokus.
+A Sudoku puzzle consists of 9 x 9 cells subdivided into 9 regions with 3 x 3
+cells. The rules are simple. There have to be the numbers from 1 to 9 in every
+row, column and region.
+
+.TP
+\fBgivens_count\fR
+Number of givens (<= 81). Default is 36.
+Generation of Sudoku puzzles with less than 26 givens takes very long.
+.TP
+\fBsudoku_dump\fR
+String with 81 * 1\-9 or _ (+ ignored).
+
+.SH OPTIONS
+.TP
+\fB\-n\fR, \fB\-\-non\-sym\fR
+Generate a non\-symmetric Sudoku puzzle. Default is symmetric.
+.TP
+\fB\-d\fR, \fB\-\-dump\fR
+Dump the generated Sudoku puzzle (don't print).
+.TP
+\fB\-s\fR, \fB\-\-solve\fR \fIsudoku_dump\fR
+Solve a Sudoku puzzle.
+.TP
+\fB\-p\fR, \fB\-\-print\fR \fIsudoku_dump\fR
+Print a Sudoku puzzle.
+.TP
+\fB\-v\fR, \fB\-\-version\fR
+Print version information and exit.
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+Print help message and exit.
+
+.SH COPYRIGHT
+Copyright \(co 2005-2008, Thomas G\(:unther <tom@toms-cafe.de>
+.br
+This GPL program comes with ABSOLUTELY NO WARRANTY;
+this is free software, and you are welcome to redistribute it
+under certain conditions; see the source for details.
diff --git a/tools/sudoku_generator.cpp b/tools/sudoku_generator.cpp
index fdd3e30..8b563f5 100644
--- a/tools/sudoku_generator.cpp
+++ b/tools/sudoku_generator.cpp
@@ -17,7 +17,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * $Id: sudoku_generator.cpp 117 2008-03-21 17:57:50Z tom $
+ * $Id: sudoku_generator.cpp 161 2008-11-23 00:18:02Z tom $
*/
#include "../puzzle.h"
@@ -30,15 +30,24 @@
using namespace Sudoku;
-void print_copyleft(unsigned int givens_count)
+int print_version()
+{
+ printf("sudoku_generator %s\n"
+ "Copyright (C) 2005-2008, Thomas Günther <tom@toms-cafe.de>\n"
+ "This GPL program comes with ABSOLUTELY NO WARRANTY;\n"
+ "this is free software, and you are welcome to redistribute it\n"
+ "under certain conditions; see the source for details.\n", VERSION);
+ return 0;
+}
+
+void print_description(unsigned int givens_count)
{
printf("Sudoku with %d givens generated by sudoku_generator %s\n"
- " Copyright (C) 2005, Thomas Günther <tom@toms-cafe.de>\n"
- " This puzzle can be used without any limitations.\n"
+ " This puzzle can be used without any limitations.\n"
"\n", givens_count, VERSION);
}
-void print_usage()
+int print_usage()
{
printf("Usage: sudoku_generator [-n|--non-sym] [-d|--dump] [<givens_count>]\n"
" Generate a Sudoku puzzle.\n"
@@ -60,9 +69,13 @@ void print_usage()
" Perform some test procedures.\n"
"\n"
#endif
+ " sudoku_generator -v|--version\n"
+ " Print version information and exit.\n"
+ "\n"
" sudoku_generator -h|--help\n"
- " Print this help.\n"
+ " Print this help message and exit.\n"
"\n");
+ return 2;
}
void print_sudoku(const Numbers* sudoku_list[], unsigned int count,
@@ -108,7 +121,7 @@ void print_sudoku(const Numbers* sudoku_list[], unsigned int count,
}
printf("\n");
if (givens_count != 0)
- print_copyleft(givens_count);
+ print_description(givens_count);
}
void print_sudoku(const Numbers& sudoku, unsigned int givens_count = 0)
@@ -305,19 +318,21 @@ int main(int argc, char* argv[])
#ifdef WITH_TEST
{ "test", no_argument, NULL, 't' },
#endif
+ { "version", no_argument, NULL, 'v' },
{ "help", no_argument, NULL, 'h' },
{ NULL }
};
#ifdef WITH_TEST
- static const char* options = "ndspth";
+ static const char* options = "ndsptvh";
#else
- static const char* options = "ndsph";
+ static const char* options = "ndspvh";
#endif
bool non_sym = false;
bool dump = false;
bool solve = false;
bool print = false;
bool test = false;
+ bool version = false;
bool help = false;
bool error = false;
int c;
@@ -332,33 +347,39 @@ int main(int argc, char* argv[])
#ifdef WITH_TEST
case 't': test = true; break;
#endif
+ case 'v': version = true; break;
case 'h': help = true; break;
default: error = true;
}
}
int arg_count = argc - optind;
+ bool generate = non_sym || dump ||
+ (arg_count == 0 && !test && !version && !help);
unsigned int givens_count = 36;
- if ((arg_count == 0 ||
- (arg_count == 1 && sscanf(argv[optind], "%u", &givens_count) == 1)) &&
- givens_count > 0 && givens_count <= SDIM &&
- !solve && !print && !test && !help && !error)
+ if (arg_count == 1 && sscanf(argv[optind], "%u", &givens_count) == 1)
+ generate = true;
+
+ if ((generate ? 1 : 0) + (solve ? 1 : 0) + (print ? 1 : 0) + (test ? 1 : 0) +
+ (version ? 1 : 0) + (help ? 1 : 0) > 1 || error)
+ return print_usage();
+
+ if (generate && 0 < givens_count && givens_count <= SDIM)
return generate_puzzle(givens_count, non_sym, dump);
- if (solve && arg_count == 1 && strlen(argv[optind]) >= SDIM &&
- !non_sym && !dump && !test && !help && !error)
+ if (solve && arg_count == 1 && strlen(argv[optind]) >= SDIM)
return solve_puzzle(argv[optind]);
- if (print && arg_count == 1 && strlen(argv[optind]) >= SDIM &&
- !non_sym && !dump && !test && !help && !error)
+ if (print && arg_count == 1 && strlen(argv[optind]) >= SDIM)
return print_puzzle(argv[optind]);
#ifdef WITH_TEST
- if (test && arg_count == 0 &&
- !non_sym && !dump && !print && !help && !error)
+ if (test)
return test_sudoku();
#endif
- print_usage();
- return 2;
+ if (version)
+ return print_version();
+
+ return print_usage();
}