From d9af4a2b674e5ab91df0f9af236283b617bb81c7 Mon Sep 17 00:00:00 2001 From: mdw Date: Sat, 29 Nov 2003 23:47:33 +0000 Subject: [PATCH] Debianization. --- .cvsignore | 1 + AnagGUI.java | 19 +++++++- Makefile.am | 17 +++++-- acconfig.h | 9 +++- anag-gui.in | 1 + anag.c | 20 +++++++-- anag.h | 6 ++- configure.in | 18 ++++++-- debian/.cvsignore | 2 + debian/anag-gui-java.postinst | 5 +++ debian/anag-gui-java.prerm | 4 ++ debian/anag-gui-java.sh | 3 ++ debian/anag-gui-tk.postinst | 5 +++ debian/anag-gui-tk.prerm | 4 ++ debian/changelog | 5 +++ debian/control | 40 +++++++++++++++++ debian/copyright | 16 +++++++ debian/rules | 65 +++++++++++++++++++++++++++ pcre.c | 102 ++++++++++++++++++++++++++++++++++++++++++ 19 files changed, 327 insertions(+), 15 deletions(-) create mode 100644 debian/.cvsignore create mode 100644 debian/anag-gui-java.postinst create mode 100644 debian/anag-gui-java.prerm create mode 100644 debian/anag-gui-java.sh create mode 100644 debian/anag-gui-tk.postinst create mode 100644 debian/anag-gui-tk.prerm create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100644 pcre.c diff --git a/.cvsignore b/.cvsignore index f1487c7..a9331f6 100644 --- a/.cvsignore +++ b/.cvsignore @@ -4,3 +4,4 @@ aclocal.m4 build stamp-h.in config.h.in +deb-build diff --git a/AnagGUI.java b/AnagGUI.java index bf51835..ac4d279 100644 --- a/AnagGUI.java +++ b/AnagGUI.java @@ -1,6 +1,6 @@ /* -*-java-*- * - * $Id: AnagGUI.java,v 1.5 2002/08/11 12:58:09 mdw Exp $ + * $Id: AnagGUI.java,v 1.6 2003/11/29 23:38:37 mdw Exp $ * * Front-end GUI * @@ -29,6 +29,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: AnagGUI.java,v $ + * Revision 1.6 2003/11/29 23:38:37 mdw + * Debianization. + * * Revision 1.5 2002/08/11 12:58:09 mdw * Added support for regular expression matching, if supported by the C * library. @@ -262,12 +265,24 @@ class AnagPanel extends Panel { }); add(b, g); - b = new Button("Regexp"); + b = new Button("Regular expression"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getlist("-regexp"); } }); add(b, g); + b = new Button("Perl regexp"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { getlist("-pcre"); } + }); + add(b, g); + + b = new Button("Monoalphabetic"); + b.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { getlist("-mono"); } + }); + add(b, g); + b = new Button("Trackword"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getlist("-trackword"); } diff --git a/Makefile.am b/Makefile.am index f3c4ee3..60a4fde 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ## -*-makefile-*- ## -## $Id: Makefile.am,v 1.9 2003/09/15 02:48:55 mdw Exp $ +## $Id: Makefile.am,v 1.10 2003/11/29 23:38:37 mdw Exp $ ## ## Makefile for Anag ## @@ -28,6 +28,9 @@ ##----- Revision history ---------------------------------------------------- ## ## $Log: Makefile.am,v $ +## Revision 1.10 2003/11/29 23:38:37 mdw +## Debianization. +## ## Revision 1.9 2003/09/15 02:48:55 mdw ## Monoalphabetic match filter. ## @@ -71,17 +74,23 @@ EXTRA_SCRIPTS = anag-gui java_DATA = @JARFILES@ anag_SOURCES = \ - anag.c anag.h wildcard.c anagram.c mono.c trackword.c regexp.c util.c + anag.c anag.h util.c \ + wildcard.c anagram.c mono.c trackword.c regexp.c pcre.c EXTRA_anag_SOURCES = regexp.c anag.jar: AnagGUI.class - jar cf anag.jar Anag*.class + jar cfm anag.jar $(srcdir)/anag.manifest Anag*.class Whinge*.class doszip: distdir rm -f $(PACKAGE).zip zip -qlr $(PACKAGE).zip $(distdir) rm -rf $(distdir) -EXTRA_DIST = AnagGUI.java anag-gui +EXTRA_DIST = \ + AnagGUI.java anag-gui.in \ + debian/control debian/changelog debian/copyright debian/rules \ + debian/anag-gui-java.postinst debian/anag-gui-java.prerm \ + debian/anag-gui-tk.postinst debian/anag-gui-tk.prerm + CLEANFILES = *.class *.jar ##----- That's all, folks --------------------------------------------------- diff --git a/acconfig.h b/acconfig.h index 86765be..7bce8b1 100644 --- a/acconfig.h +++ b/acconfig.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: acconfig.h,v 1.1 2001/02/04 17:14:42 mdw Exp $ + * $Id: acconfig.h,v 1.2 2003/11/29 23:38:37 mdw Exp $ * * Configuration header for Anag * @@ -29,6 +29,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: acconfig.h,v $ + * Revision 1.2 2003/11/29 23:38:37 mdw + * Debianization. + * * Revision 1.1 2001/02/04 17:14:42 mdw * Initial checkin * @@ -51,6 +54,10 @@ /* Define this to be your default wordlist location. */ #define DICTIONARY "/usr/dict/words" +/* Define this if you have (and want to use) the Perl-Compatible Regular + * Expression (PCRE) library. */ +#define HAVE_PCRE + @BOTTOM@ /*----- That's all, folks -------------------------------------------------*/ diff --git a/anag-gui.in b/anag-gui.in index 317f304..3f30753 100644 --- a/anag-gui.in +++ b/anag-gui.in @@ -183,6 +183,7 @@ foreach {opt text mnem} { trackword Trackword t mono Monoalphabetic m regexp "Regular expression" r + pcre "Perl regexp" p } { button .b-$opt -text $text \ -underline [string first $mnem [string tolower $text]] \ diff --git a/anag.c b/anag.c index 56aa565..e15fb6d 100644 --- a/anag.c +++ b/anag.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: anag.c,v 1.6 2003/09/15 02:48:54 mdw Exp $ + * $Id: anag.c,v 1.7 2003/11/29 23:38:37 mdw Exp $ * * Main driver for anag * @@ -29,6 +29,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: anag.c,v $ + * Revision 1.7 2003/11/29 23:38:37 mdw + * Debianization. + * * Revision 1.6 2003/09/15 02:48:54 mdw * Monoalphabetic match filter. * @@ -99,12 +102,17 @@ The basic tests in the expression are:\n\ -regexp REGEXP matches with an (extended) regular expression\n\ " #endif +#ifdef HAVE_PCRE +"\ +-pcre REGEXP matches with a Perl-like regular expression\n\ +" +#endif "\ \n\ These simple tests can be combined using the operators `-a', `-o' and `-n'\n\ (for `and', `or' and `not'; they may also be written `&', `|' and `!' if\n\ you like), and grouped using parentheses `(' and `)'.\n\ -", fp); +", fp); /*"*/ } /*----- The options parser ------------------------------------------------*/ @@ -122,7 +130,7 @@ enum { O_HELP, O_VERSION, O_USAGE, O_FILE, O_AND, O_OR, O_NOT, O_LPAREN, O_RPAREN, - O_ANAG, O_SUBG, O_WILD, O_TRACK, O_REGEXP, O_MONO, + O_ANAG, O_SUBG, O_WILD, O_TRACK, O_REGEXP, O_PCRE, O_MONO, O_EOF }; @@ -156,6 +164,9 @@ static const struct opt opttab[] = { #ifdef HAVE_REGCOMP { "regexp", 1, 0, O_REGEXP }, #endif +#ifdef HAVE_PCRE + { "pcre", 1, 0, O_PCRE }, +#endif /* --- End marker --- */ @@ -359,6 +370,9 @@ static void p_factor(p_ctx *p, node **nn) #ifdef HAVE_REGCOMP case O_REGEXP: *nn = regexp(p->a + 1); break; #endif +#ifdef HAVE_PCRE + case O_PCRE: *nn = pcrenode(p->a + 1); break; +#endif case O_MONO: *nn = mono(p->a + 1); break; default: die("syntax error near `%s': unexpected token", *p->a); } diff --git a/anag.h b/anag.h index 5c9822c..eca5091 100644 --- a/anag.h +++ b/anag.h @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: anag.h,v 1.3 2003/09/15 02:48:55 mdw Exp $ + * $Id: anag.h,v 1.4 2003/11/29 23:38:37 mdw Exp $ * * External definitions for Anag * @@ -29,6 +29,9 @@ /*----- Revision history --------------------------------------------------* * * $Log: anag.h,v $ + * Revision 1.4 2003/11/29 23:38:37 mdw + * Debianization. + * * Revision 1.3 2003/09/15 02:48:55 mdw * Monoalphabetic match filter. * @@ -83,6 +86,7 @@ extern node *wildcard(const char *const */*av*/); extern node *trackword(const char *const */*av*/); extern node *mono(const char *const */*av*/); extern node *regexp(const char *const */*av*/); +extern node *pcrenode(const char *const */*av*/); /*----- Error reporting ---------------------------------------------------*/ diff --git a/configure.in b/configure.in index b90e4ee..a9dbcc5 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ -dnl -*-fundamental-*- +dnl -*-m4-*- dnl -dnl $Id: configure.in,v 1.3 2002/08/11 12:59:00 mdw Exp $ +dnl $Id: configure.in,v 1.4 2003/11/29 23:38:37 mdw Exp $ dnl dnl Configuration script dnl @@ -28,6 +28,9 @@ dnl Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. dnl ----- Revision history -------------------------------------------------- dnl dnl $Log: configure.in,v $ +dnl Revision 1.4 2003/11/29 23:38:37 mdw +dnl Debianization. +dnl dnl Revision 1.3 2002/08/11 12:59:00 mdw dnl New Tcl/Tk interface; regular expression support. dnl @@ -44,6 +47,7 @@ AM_INIT_AUTOMAKE(anag, 1.1.0) AM_CONFIG_HEADER(config.h) AC_PROG_CC mdw_GCC_FLAGS + AC_CHECK_PROGS([JAVAC], [jikes javac], [none]) if test "$JAVAC" = "none"; then AC_MSG_WARN([No Java compiler found]) @@ -51,6 +55,8 @@ if test "$JAVAC" = "none"; then else JARFILES="anag.jar" fi +AC_SUBST([JARFILES]) + AC_CHECK_PROGS([WISH], [wish wish8], [none]) if test "$WISH" = "none"; then AC_MSG_WARN([No Tcl/Tk interpreter found]) @@ -58,19 +64,23 @@ if test "$WISH" = "none"; then else TKPROGS="anag-gui" fi +AC_SUBST([TKPROGS]) + EXTNODE="" AC_CHECK_FUNCS([regcomp]) -AC_SUBST([JARFILES]) -AC_SUBST([TKPROGS]) +mdw_CHECK_MANYLIBS([pcre_fullinfo], [pcre], [AC_DEFINE([HAVE_PCRE])]) + AC_ARG_WITH(dictionary, [ --with-dictionary=DICT set default word list to be DICT], [DICTIONARY=$withval], [DICTIONARY="/usr/dict/words"]) AC_DEFINE_UNQUOTED([DICTIONARY], ["$DICTIONARY"]) AC_SUBST([DICTIONARY]) + mdw_DEFINE_PATHS([ ANAG=mdw_PATH([${bindir}])/mdw_PROG([anag]) ]) + AC_SUBST([ANAG]) AC_OUTPUT(Makefile anag-gui) diff --git a/debian/.cvsignore b/debian/.cvsignore new file mode 100644 index 0000000..9db7be3 --- /dev/null +++ b/debian/.cvsignore @@ -0,0 +1,2 @@ +files tmp substvars *.substvars *.debhelper +anag anag-gui-tk anag-gui-java diff --git a/debian/anag-gui-java.postinst b/debian/anag-gui-java.postinst new file mode 100644 index 0000000..f3e1dcf --- /dev/null +++ b/debian/anag-gui-java.postinst @@ -0,0 +1,5 @@ +#! /bin/sh +set -e +update-alternatives --install \ + /usr/bin/anag-gui anag-gui /usr/bin/anag-gui-java 10 +#DEBHELPER# diff --git a/debian/anag-gui-java.prerm b/debian/anag-gui-java.prerm new file mode 100644 index 0000000..dda2d3e --- /dev/null +++ b/debian/anag-gui-java.prerm @@ -0,0 +1,4 @@ +#! /bin/sh +set -e +update-alternatives --remove anag-gui /usr/bin/anag-gui-java +#DEBHELPER# \ No newline at end of file diff --git a/debian/anag-gui-java.sh b/debian/anag-gui-java.sh new file mode 100644 index 0000000..f964810 --- /dev/null +++ b/debian/anag-gui-java.sh @@ -0,0 +1,3 @@ +#! /bin/sh +set -e +/usr/bin/java -jar /usr/share/anag-gui-java/anag.jar "$@" diff --git a/debian/anag-gui-tk.postinst b/debian/anag-gui-tk.postinst new file mode 100644 index 0000000..f55c72d --- /dev/null +++ b/debian/anag-gui-tk.postinst @@ -0,0 +1,5 @@ +#! /bin/sh +set -e +update-alternatives --install \ + /usr/bin/anag-gui anag-gui /usr/bin/anag-gui-tk 20 +#DEBHELPER# diff --git a/debian/anag-gui-tk.prerm b/debian/anag-gui-tk.prerm new file mode 100644 index 0000000..76cfdef --- /dev/null +++ b/debian/anag-gui-tk.prerm @@ -0,0 +1,4 @@ +#! /bin/sh +set -e +update-alternatives --remove anag-gui /usr/bin/anag-gui-tk +#DEBHELPER# diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..b373a62 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +anag (1.1.0) experimental; urgency=low + + * Debianization! + + -- Mark Wooding Wed, 12 Nov 2003 00:02:31 +0000 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..8c97ad1 --- /dev/null +++ b/debian/control @@ -0,0 +1,40 @@ +Source: anag +Section: text +Priority: extra +Maintainer: Mark Wooding +Standards-Version: 3.1.1 + +Package: anag +Architecture: any +Depends: ${shlibs:Depends} +Recommends: wordlist +Suggests: anag-gui +Description: A simple wordgame tool + Anag can solve simple wordgame puzzles, such as anagrams, crosswords, + and trackwords. It has a powerful command-line syntax, reminiscent of + `find'. + . + This is just the command-line program. There are graphical user + interfaces for it. + +Package: anag-gui-tk +Architecture: all +Depends: anag, wish +Provides: anag-gui +Description: A simple wordgame tool + Anag can solve simple wordgame puzzles, such as anagrams, crosswords, + and trackwords. It has a powerful command-line syntax, reminiscent of + `find'. + . + This is the Tcl/Tk graphical interface. + +Package: anag-gui-java +Architecture: all +Depends: anag, java-virtual-machine +Provides: anag-gui +Description: A simple wordgame tool + Anag can solve simple wordgame puzzles, such as anagrams, crosswords, + and trackwords. It has a powerful command-line syntax, reminiscent of + `find'. + . + This is the Java graphical interface. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..d5d5213 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,16 @@ +anag is copyright (c) 2003 Straylight/Edgeware. + +anag 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. + +anag 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 a copy of the GNU General Public License in +/usr/share/common-licenses/GPL; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +USA. diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..76191ab --- /dev/null +++ b/debian/rules @@ -0,0 +1,65 @@ +#! /usr/bin/make -f + +export DH_COMPAT = 4 + +build: + rm -rf build deb-build + mkdir deb-build + cd deb-build; ../configure \ + --prefix=/usr \ + --with-dictionary=/usr/share/dict/words + make -C deb-build JAVAC=jikes-kaffe + touch build + +clean: + dh_clean + rm -rf deb-build build + +install: build + dh_clean + make -C deb-build install DESTDIR=`pwd`/debian/anag + mkdir -p debian/anag-gui-java/usr/share/anag-gui-java + mv debian/anag/usr/share/java/anag.jar \ + debian/anag-gui-java/usr/share/anag-gui-java + rmdir debian/anag/usr/share/java + mkdir -p debian/anag-gui-java/usr/bin + cp debian/anag-gui-java.sh debian/anag-gui-java/usr/bin/anag-gui-java + mkdir -p debian/anag-gui-tk/usr/bin + mv debian/anag/usr/bin/anag-gui \ + debian/anag-gui-tk/usr/bin/anag-gui-tk + +binary-indep: + dh_testdir -i + dh_testroot -i + dh_compress -i + dh_installdocs -i + dh_gencontrol -i + dh_fixperms -i + dh_installdeb -i + dh_md5sums -i + dh_builddeb -i + +binary-arch: + dh_testdir -a + dh_testroot -a + dh_compress -a + dh_installdocs -a + dh_strip -a + dh_shlibdeps -a + dh_gencontrol -a + dh_fixperms -a + dh_installdeb -a + dh_md5sums -a + dh_builddeb -a + +binary: install binary-indep binary-arch + +source: + rm -rf deb-build/*.tar.gz deb-build/=deb= + make -C deb-build dist + mkdir deb-build/=deb= + cd deb-build/=deb=; tar xvfz ../*.tar.gz + d=`pwd`; cd ..; dpkg-source -i -b $$d/deb-build/=deb=/* + rm -rf deb-build/=deb= + +.PHONY: binary binary-arch binary-indep clean install source diff --git a/pcre.c b/pcre.c new file mode 100644 index 0000000..89ae8b4 --- /dev/null +++ b/pcre.c @@ -0,0 +1,102 @@ +/* -*-c-*- + * + * $Id: pcre.c,v 1.1 2003/11/29 23:38:37 mdw Exp $ + * + * Matches Perl-compatible regular expressions + * + * (c) 2002 Mark Wooding + */ + +/*----- Licensing notice --------------------------------------------------* + * + * This file is part of Anag: a simple wordgame helper. + * + * Anag 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. + * + * Anag 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 Anag; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/*----- Revision history --------------------------------------------------* + * + * $Log: pcre.c,v $ + * Revision 1.1 2003/11/29 23:38:37 mdw + * Debianization. + * + */ + +/*----- Header files ------------------------------------------------------*/ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#ifndef HAVE_PCRE + extern int dummy; +#else + +#include "anag.h" +#include + +/*----- Data structures ---------------------------------------------------*/ + +typedef struct node_pcre { + node n; + const char *s; + pcre *rx; + pcre_extra *rx_study; + int *ovec; + int ovecsz; +} node_pcre; + +/*----- Main code ---------------------------------------------------------*/ + +/* --- Node matcher --- */ + +static int n_pcre(node *nn, const char *p, size_t sz) +{ + node_pcre *n = (node_pcre *)nn; + int e; + + e = pcre_exec(n->rx, n->rx_study, p, sz, 0, 0, n->ovec, n->ovecsz); + if (e >= 0) + return (1); + if (e == PCRE_ERROR_NOMATCH) + return (0); + die("unexpected PCRE error code %d", e); + return (-1); +} + +/* --- Node creation --- */ + +node *pcrenode(const char *const *av) +{ + node_pcre *n = xmalloc(sizeof(*n)); + const char *e; + int eo; + int c; + + n->n.func = n_pcre; + if ((n->rx = pcre_compile(av[0], PCRE_CASELESS, &e, &eo, 0)) == 0) + die("bad regular expression `%s': %s", av[0], e); + n->rx_study = pcre_study(n->rx, 0, &e); + if (e) + die("error studying pattern `%s': %s", av[0], e); + pcre_fullinfo(n->rx, n->rx_study, PCRE_INFO_BACKREFMAX, &c); + n->ovecsz = c * 2; + n->ovec = xmalloc(n->ovecsz * sizeof(*n->ovec)); + return (&n->n); +} + +/*----- That's all, folks -------------------------------------------------*/ + +#endif -- 2.11.0