Package: goplay Version: 0.10 Severity: minor Tags: patch Hello,
I've uploaded libept 1.1 to experimental, with more unused code removed and no more dependencies on tagcoll and wibble. I'm attaching a patch that makes goplay work with that new libept, and also removes the custom wibble command line parser in favour of a more standard getopt. Thank you, Enrico -- System Information: Debian Release: stretch/sid APT prefers testing APT policy: (500, 'testing') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 4.1.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages goplay depends on: ii apt-xapian-index 0.47 ii debtags 2.0+nmu1 ii libapt-pkg4.16 1.0.10.2 ii libc6 2.19-19 ii libcurl3-gnutls 7.44.0-1 ii libept1.4.16 1.1 ii libfltk-images1.3 1.3.3-4 ii libfltk1.3 1.3.3-4 ii libgcc1 1:5.2.1-16 ii libstdc++6 5.2.1-16 ii libx11-6 2:1.6.3-1 ii libxapian22v5 1.2.21-1.2 ii zlib1g 1:1.2.8.dfsg-2+b1 Versions of packages goplay recommends: ii games-thumbnails 20120227 goplay suggests no packages. -- no debconf information
commit 8a87187763ddf0c05f8a5e54a5e8f5d947d7a368 Author: Enrico Zini <enr...@enricozini.org> Date: Thu Sep 10 20:16:38 2015 +0200 Ported to new libept, removed tagcoll and wibble deps diff --git a/Makefile.am b/Makefile.am index d5975bf..21cb2b9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,4 @@ SUBDIRS = libxdgutils src . man_MANS = goplay.1 -goplay.1: src/manpage - src/manpage goplay > $@ || rm $@ - EXTRA_DIST = $(man_MANS) FAQ LICENSE README data autogen.sh diff --git a/configure.ac b/configure.ac index 1c58d49..9779e8a 100644 --- a/configure.ac +++ b/configure.ac @@ -3,6 +3,7 @@ AC_INIT(goplay, 0.5, [Miriam Ruiz <little_m...@yahoo.es>, Enrico Zini <enrico@de AC_CONFIG_SRCDIR([configure.ac]) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE([foreign]) +AC_CONFIG_MACRO_DIR([m4]) m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) dnl To use subdirs @@ -18,13 +19,14 @@ AM_PROG_CC_STDC AC_HEADER_STDC AC_PROG_RANLIB +dnl Use c++11 +AX_CXX_COMPILE_STDCXX_11 + dnl Use libtool AM_PROG_LIBTOOL -dnl Use wibble, tagcoll2 and pkg -PKG_CHECK_MODULES([LIBWIBBLE], [libwibble]) +dnl Use libept PKG_CHECK_MODULES([LIBEPT], [libept]) -PKG_CHECK_MODULES([LIBTAGCOLL2], [libtagcoll2]) dnl Look for apt-get AC_PATH_PROG(APTGET, apt-get, /usr/bin/apt-get) diff --git a/debian/changelog b/debian/changelog index bfd04bb..ceff88e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +goplay (0.10) UNRELEASED; urgency=medium + + * Build using new libept and C++11, dropping libwibble and libtagcoll + dependencies. + + -- Enrico Zini <enr...@debian.org> Thu, 10 Sep 2015 18:24:03 +0200 + goplay (0.9) unstable; urgency=low * Update Standards-Version from 3.9.4 to 3.9.6. diff --git a/debian/control b/debian/control index 4f59136..412b96a 100644 --- a/debian/control +++ b/debian/control @@ -7,7 +7,7 @@ Uploaders: Enrico Zini <enr...@debian.org>, Petter Reinholdtsen <p...@debian.org> Build-Depends: debhelper (>= 8), pkg-config, dh-autoreconf, - libept-dev, libwibble-dev, libfltk1.3-dev, libtagcoll2-dev + libept-dev (>= 1.1), libfltk1.3-dev ,imagemagick ,libcurl4-gnutls-dev ,fluid diff --git a/libxdgutils/XDGDesktopEntry.cpp b/libxdgutils/XDGDesktopEntry.cpp index 14329eb..34e3ad0 100644 --- a/libxdgutils/XDGDesktopEntry.cpp +++ b/libxdgutils/XDGDesktopEntry.cpp @@ -468,7 +468,7 @@ void XDGDesktopEntry::validateEntries() // Now find missing required keys for(i = 0; registeredEntries[i].name != NULL; i++) { - if (!registeredEntries[i].type & type) + if (~registeredEntries[i].type & type) continue; if (registeredEntries[i].required) { diff --git a/m4/m4_ax_cxx_compile_stdcxx_11.m4 b/m4/m4_ax_cxx_compile_stdcxx_11.m4 new file mode 100644 index 0000000..3f67053 --- /dev/null +++ b/m4/m4_ax_cxx_compile_stdcxx_11.m4 @@ -0,0 +1,133 @@ +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the C++11 +# standard; if necessary, add switches to CXXFLAGS to enable support. +# +# The first argument, if specified, indicates whether you insist on an +# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. +# -std=c++11). If neither is specified, you get whatever works, with +# preference for an extended mode. +# +# The second argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline C++11 support is required and that the macro +# should error out if no mode with that support is found. If specified +# 'optional', then configuration proceeds regardless, after defining +# HAVE_CXX11 if and only if a supporting mode is found. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik <b...@redhat.com> +# Copyright (c) 2012 Zack Weinberg <za...@panix.com> +# Copyright (c) 2013 Roy Stogner <royst...@ices.utexas.edu> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 3 + +m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [ + template <typename T> + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + typedef check<check<bool>> right_angle_brackets; + + int a; + decltype(a) b; + + typedef check<int> check_type; + check_type c; + check_type&& cr = static_cast<check_type&&>(c); + + auto d = a; +]) + +AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl + m4_if([$1], [], [], + [$1], [ext], [], + [$1], [noext], [], + [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl + m4_if([$2], [], [ax_cxx_compile_cxx11_required=true], + [$2], [mandatory], [ax_cxx_compile_cxx11_required=true], + [$2], [optional], [ax_cxx_compile_cxx11_required=false], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])dnl + AC_LANG_PUSH([C++])dnl + ac_success=no + AC_CACHE_CHECK(whether $CXX supports C++11 features by default, + ax_cv_cxx_compile_cxx11, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], + [ax_cv_cxx_compile_cxx11=yes], + [ax_cv_cxx_compile_cxx11=no])]) + if test x$ax_cv_cxx_compile_cxx11 = xyes; then + ac_success=yes + fi + + m4_if([$1], [noext], [], [dnl + if test x$ac_success = xno; then + for switch in -std=gnu++11; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, + $cachevar, + [ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXXFLAGS="$ac_save_CXXFLAGS"]) + if eval test x\$$cachevar = xyes; then + CXXFLAGS="$CXXFLAGS $switch" + ac_success=yes + break + fi + done + fi]) + + m4_if([$1], [ext], [], [dnl + if test x$ac_success = xno; then + for switch in -std=c++11; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch, + $cachevar, + [ac_save_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$CXXFLAGS $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXXFLAGS="$ac_save_CXXFLAGS"]) + if eval test x\$$cachevar = xyes; then + CXXFLAGS="$CXXFLAGS $switch" + ac_success=yes + break + fi + done + fi]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx11_required = xtrue; then + if test x$ac_success = xno; then + AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.]) + fi + else + if test x$ac_success = xno; then + HAVE_CXX11=0 + AC_MSG_NOTICE([No compiler with C++11 support was found]) + else + HAVE_CXX11=1 + AC_DEFINE(HAVE_CXX11,1, + [define if the compiler supports basic C++11 syntax]) + fi + + AC_SUBST(HAVE_CXX11) + fi +]) diff --git a/src/Engine.cpp b/src/Engine.cpp index 1a6693d..d91d33b 100644 --- a/src/Engine.cpp +++ b/src/Engine.cpp @@ -19,14 +19,13 @@ */ #include "Engine.h" - -#include <wibble/string.h> -#include <wibble/regexp.h> +#include <ept/utils/string.h> +#include <regex> #include <iostream> #include <fstream> using namespace std; -using namespace wibble; +using namespace ept; using namespace ept::apt; using namespace ept::debtags; @@ -46,16 +45,17 @@ Engine::Engine() in.open("/var/lib/apt-xapian-index/values", ios::in); if (!in.is_open() || in.fail()) m_popcon_validx = -1; - ERegexp match_line("^app-popcon[ \t]+([0-9]+)", 2); + std::regex match_line(R"(^app-popcon\S+(\d+))", 2); string line; while (true) { getline(in, line); if (in.fail()) break; if (in.eof()) break; - if (match_line.match(line)) + std::smatch match; + if (std::regex_search(line, match, match_line)) { - m_popcon_validx = strtoul(match_line[1].c_str(), 0, 10); + m_popcon_validx = strtoul(match[1].str().c_str(), 0, 10); break; } } @@ -106,19 +106,19 @@ Xapian::Query Engine::makeQuery() if (!m_filter_keywords.empty()) { // Add prefixes to tag names - Splitter splitter("[ \t]*,[ \t]*", REG_EXTENDED); + std::regex splitter(R"([ \t]*,[ \t]*)"); vector<string> kw; - for (Splitter::const_iterator i = splitter.begin(m_filter_keywords); - i != splitter.end(); ++i) + for (auto i = std::sregex_token_iterator(m_filter_keywords.begin(), m_filter_keywords.end(), splitter, -1); + i != std::sregex_token_iterator(); ++i) { if (m_vocabulary.hasTag(*i)) - kw.push_back("tag:" + *i); + kw.push_back("tag:" + i->str()); else kw.push_back(*i); } bool do_partial = not (kw.size() == 1 and kw[0].size() < 3); - kwquery = m_qp.parse_query(str::join(kw.begin(), kw.end(), " "), + kwquery = m_qp.parse_query(str::join(" ", kw.begin(), kw.end()), Xapian::QueryParser::FLAG_BOOLEAN | Xapian::QueryParser::FLAG_LOVEHATE | Xapian::QueryParser::FLAG_BOOLEAN_ANY_CASE | @@ -365,7 +365,3 @@ void Engine::setInstalledFilter(State state) m_filter_state = state; m_dirty = true; } - -#include <ept/debtags/debtags.tcc> - -// vim:set ts=4 sw=4: diff --git a/src/GamesOptions.h b/src/GamesOptions.h deleted file mode 100644 index de4e052..0000000 --- a/src/GamesOptions.h +++ /dev/null @@ -1,69 +0,0 @@ -#ifndef GAMES_OPTIONS_H -#define GAMES_OPTIONS_H - -/* - * Commandline parser for the game viewer - * - * Copyright (C) 2003,2004,2005,2006,2007 Enrico Zini - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <wibble/commandline/parser.h> - -namespace wibble { -namespace commandline { - -struct GamesOptions : public StandardParserWithManpage -{ -public: - BoolOption* out_debug; - BoolOption* out_verbose; - StringOption* gowhere; - StringOption* mainFacet; - StringOption* secondaryFacet; - StringOption* ftags; - - GamesOptions() - : StandardParserWithManpage("goplay", VERSION, 1, "Enrico Zini <enr...@enricozini.org> and Miriam Ruiz <little_m...@yahoo.es>") - { - usage = "[options and arguments]"; - description = "Debian game browser"; - longDescription = - "GoPlay! is a Graphical User Interface (GUI) that uses DebTags" - " for finding games in Debian easily.\n"; - - out_verbose = add<BoolOption>("verbose", 'v', "verbose", "", - "enable verbose output"); - out_debug = add<BoolOption>("debug", 0, "debug", "", - "enable debugging output (including verbose output)"); - gowhere = add<StringOption>("go", 0, "go", "where", - "change the interface flavour. " - "Available flavours are: play, learn, admin, net, office, safe, web, science"); - mainFacet = add<StringOption>("primary", 0, "primary", "facet", - "use the given facet instead of 'games'"); - secondaryFacet = add<StringOption>("secondary", 0, "secondary", "facet", - "use the given facet instead of 'interface'"); - ftags = add<StringOption>("ftags", 0, "ftags", "tags", - "comma-separated list of tags that are always " - "required in search results (default: role::program)"); - } -}; - -} -} - -// vim:set ts=4 sw=4: -#endif diff --git a/src/Makefile.am b/src/Makefile.am index 7174229..f7c0bc0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,7 +1,6 @@ ## Process this file with automake to produce Makefile.in bin_PROGRAMS = goplay -noinst_PROGRAMS = manpage BUILT_SOURCES = goweb gonet goadmin gooffice golearn gosafe goscience CLEANFILES = $(BUILT_SOURCES) @@ -16,7 +15,6 @@ dist_noinst_HEADERS = \ Environment.h \ URLFetcher.h \ filter.h \ - GamesOptions.h \ pkgbrowser.h \ taghandler.h \ windows.h @@ -39,9 +37,6 @@ goplay_LDADD = \ ../libxdgutils/libxdgutils.a \ $(LIBEPT_LIBS) -manpage_SOURCES = manpage.cpp -manpage_LDADD = $(LIBEPT_LIBS) - ui.h ui.cpp: ui.fld fluid -c -o ui.cpp -h ui.h ui.fld @@ -56,9 +51,9 @@ WARNFLAGS = \ -Wformat \ -Werror=format-security -INCLUDES = -I.. $(LIBEPT_CFLAGS) `fltk-config --cxxflags --use-images` `curl-config --cflags` $(WARNFLAGS) -ggdb +INCLUDES = -I.. --std=c++11 $(LIBEPT_CFLAGS) `fltk-config --cxxflags --use-images` `curl-config --cflags` $(WARNFLAGS) -ggdb -EXTRA_DIST = GamesOptions.h Environment.h Engine.h ui.fld ui.h ui.cpp pkgbrowser.h LICENSE \ +EXTRA_DIST = Environment.h Engine.h ui.fld ui.h ui.cpp pkgbrowser.h LICENSE \ Makefile.test CuTest.h CuTest.c CuTest.sh CuTest.txt \ CuTest.example/example.c \ CuTest.example/Makefile \ diff --git a/src/Makefile.test b/src/Makefile.test index 4b5250d..6b50122 100644 --- a/src/Makefile.test +++ b/src/Makefile.test @@ -2,8 +2,8 @@ OBJS= test_aux.o test_Engine.o test_Environment.o test_filter.o \ test_goplay.o test_pkgbrowser.o test_taghandler.o \ test_ui.o test_windows.o CuTest.o test_main.o -CFLAGS= -O2 -g -I.. -I/usr/include/tagcoll-2.0.7 `fltk-config --cxxflags --use-images` -Wall -LDFLAGS= -lept -lept-core -lapt-pkg -lxapian -ltagcoll2 -lz -lwibble `fltk-config --ldflags --use-images` +CFLAGS= -O2 -g -I.. `fltk-config --cxxflags --use-images` -Wall +LDFLAGS= -lept -lept-core -lapt-pkg -lxapian -lz `fltk-config --ldflags --use-images` test: $(OBJS) g++ -o $@ $(LDFLAGS) $+ diff --git a/src/goplay.cpp b/src/goplay.cpp index 603211e..67323eb 100644 --- a/src/goplay.cpp +++ b/src/goplay.cpp @@ -29,7 +29,6 @@ #endif #include "Environment.h" -#include "GamesOptions.h" #include "Engine.h" #include "common.h" @@ -37,10 +36,10 @@ #include "filter.h" #include <ept/apt/packagerecord.h> -#include <wibble/regexp.h> -#include <wibble/string.h> +#include <ept/utils/string.h> #include <xapian.h> +#include <regex> #include <iostream> #include <fstream> #include <cmath> @@ -53,6 +52,8 @@ #define gettext(a) (a) #endif +#include <getopt.h> + #include <FL/Fl.H> #include <FL/Fl_PNG_Image.H> #include <FL/fl_ask.H> @@ -75,19 +76,6 @@ basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& out, cons return out; } -template<typename TAG, typename _Traits> -basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& out, const wibble::Singleton<TAG>& tags) -{ - out << *tags.begin(); - return out; -} - -template<typename TAG, typename _Traits> -basic_ostream<char, _Traits>& operator<<(basic_ostream<char, _Traits>& out, const wibble::Empty<TAG>&) -{ - return out; -} - } using namespace std; @@ -384,8 +372,34 @@ static void OnResultsBrowserClick(Fl_Browser*, void *data) } #endif +static void do_usage(const char* argv0, FILE* out) +{ + fprintf(out, "Usage: %s [options]\n", argv0); +} + +static void do_help(const char* argv0, FILE* out) +{ + do_usage(argv0, out); + fprintf(out, R"(Debian game browser + +GoPlay! is a Graphical User Interface (GUI) that uses DebTags for finding games +in Debian easily. + +Options: + -h,--help this help text + -v,--verbose enable verbose output + --debug enable debugging output (including verbose output) + --go <where> change the interface flavour. Available flavours are: + play, learn, admin, net, office, safe, web, science + --primary <facet> use the given facet instead of 'games' + --secondary <facet> use the given facet instead of 'interface' + --ftags <tags> comma-separated list of tags that are always + required in search results (default: role::program) +)"); +} + #ifndef UNIT_TEST -int main(int argc, const char* argv[]) +int main(int argc, char* argv[]) { #ifdef USE_GETTEXT setlocale (LC_MESSAGES, ""); @@ -395,25 +409,56 @@ int main(int argc, const char* argv[]) bindtextdomain ("gamesui", NULL); #endif - wibble::commandline::GamesOptions opts; - - try { - // Install the handler for unexpected exceptions - wibble::exception::InstallUnexpected installUnexpected; - - if (opts.parse(argc, argv)) - return 0; - - if (opts.out_verbose->boolValue()) - ::Environment::get().verbose(true); - - if (opts.out_debug->boolValue()) - ::Environment::get().debug(true); - - Engine engine; - - if (wibble::str::endsWith(argv[0], "learn") || opts.gowhere->stringValue() == "learn") - { + static struct option long_options[] = + { + /* These options set a flag. */ + {"verbose", no_argument, NULL, 'v'}, + {"debug", no_argument, NULL, 'D'}, + {"go", required_argument, NULL, 'G'}, + {"primary", required_argument, NULL, 'P'}, + {"seconday", required_argument, NULL, 'S'}, + {"ftags", required_argument, NULL, 'F'}, + {"help", no_argument, NULL, 'h'}, + {0, 0, 0, 0} + }; + + try { + string gowhere; + string primary; + string secondary; + string ftags; + + while (1) + { + // getopt_long stores the option index here + int option_index = 0; + + int c = getopt_long(argc, argv, "vDG:P:S:F:h", long_options, &option_index); + + // Detect the end of the options + if (c == -1) + break; + + switch (c) + { + case 'v': ::Environment::get().verbose(true); break; + case 'D': ::Environment::get().debug(true); break; + case 'G': gowhere = optarg; break; + case 'P': primary = optarg; break; + case 'S': secondary = optarg; break; + case 'F': ftags = optarg; break; + case 'h': do_help(argv[0], stdout); return 0; + default: + fprintf(stderr, "unknown option character %c (%d)\n", c, c); + do_help(argv[0], stderr); + return 1; + } + } + + Engine engine; + + if (str::endswith(argv[0], "learn") || gowhere == "learn") + { engine.mainFacet = "field"; engine.secondaryFacet = "interface"; engine.globalFilter = Xapian::Query(Xapian::Query::OP_AND, @@ -421,37 +466,37 @@ int main(int argc, const char* argv[]) Xapian::Query("XTrole::documentation"), Xapian::Query("XTrole::program")), Xapian::Query("XTuse::learning")); - } else if (wibble::str::endsWith(argv[0], "admin") || opts.gowhere->stringValue() == "admin") { + } else if (str::endswith(argv[0], "admin") || gowhere == "admin") { engine.mainFacet = "admin"; engine.secondaryFacet = "interface"; engine.globalFilter = Xapian::Query(Xapian::Query::OP_OR, Xapian::Query("XTrole::documentation"), Xapian::Query("XTrole::program")); - } else if (wibble::str::endsWith(argv[0], "net") || opts.gowhere->stringValue() == "net") { + } else if (str::endswith(argv[0], "net") || gowhere == "net") { engine.mainFacet = "network"; engine.secondaryFacet = "interface"; engine.globalFilter = Xapian::Query(Xapian::Query::OP_OR, Xapian::Query("XTrole::documentation"), Xapian::Query("XTrole::program")); - } else if (wibble::str::endsWith(argv[0], "office") || opts.gowhere->stringValue() == "office") { + } else if (str::endswith(argv[0], "office") || gowhere == "office") { engine.mainFacet = "office"; engine.secondaryFacet = "interface"; engine.globalFilter = Xapian::Query(Xapian::Query::OP_OR, Xapian::Query("XTrole::documentation"), Xapian::Query("XTrole::program")); - } else if (wibble::str::endsWith(argv[0], "safe") || opts.gowhere->stringValue() == "safe") { + } else if (str::endswith(argv[0], "safe") || gowhere == "safe") { engine.mainFacet = "security"; engine.secondaryFacet = "interface"; engine.globalFilter = Xapian::Query(Xapian::Query::OP_OR, Xapian::Query("XTrole::documentation"), Xapian::Query("XTrole::program")); - } else if (wibble::str::endsWith(argv[0], "web") || opts.gowhere->stringValue() == "web") { + } else if (str::endswith(argv[0], "web") || gowhere == "web") { engine.mainFacet = "web"; engine.secondaryFacet = "interface"; engine.globalFilter = Xapian::Query(Xapian::Query::OP_OR, Xapian::Query("XTrole::documentation"), Xapian::Query("XTrole::program")); - } else if (wibble::str::endsWith(argv[0], "science") || opts.gowhere->stringValue() == "science") { + } else if (str::endswith(argv[0], "science") || gowhere == "science") { engine.mainFacet = "field"; engine.secondaryFacet = "interface"; engine.globalFilter = Xapian::Query(Xapian::Query::OP_OR, @@ -463,28 +508,28 @@ int main(int argc, const char* argv[]) engine.globalFilter = Xapian::Query("XTrole::program"); } - if (opts.mainFacet->isSet()) - engine.mainFacet = opts.mainFacet->stringValue(); - - if (opts.secondaryFacet->isSet()) - engine.secondaryFacet = opts.secondaryFacet->stringValue(); - - if (opts.ftags->isSet()) - { - Xapian::Query fquery; - wibble::Splitter tags(", *", REG_EXTENDED); - bool first = true; - for (wibble::Splitter::const_iterator i = tags.begin(opts.ftags->stringValue()); - i != tags.end(); ++i) - { - if (first) - { - fquery = Xapian::Query("XT"+*i); - first = false; - } - else - fquery = Xapian::Query(Xapian::Query::OP_AND, fquery, Xapian::Query("XT"+*i)); - } + if (!primary.empty()) + engine.mainFacet = primary; + + if (!secondary.empty()) + engine.secondaryFacet = secondary; + + if (!ftags.empty()) + { + Xapian::Query fquery; + std::regex tags(R"(, *)"); + bool first = true; + for (auto i = std::sregex_token_iterator(ftags.begin(), ftags.end(), tags, -1); + i != std::sregex_token_iterator(); ++i) + { + if (first) + { + fquery = Xapian::Query("XT" + i->str()); + first = false; + } + else + fquery = Xapian::Query(Xapian::Query::OP_AND, fquery, Xapian::Query("XT" + i->str())); + } engine.globalFilter = fquery; } @@ -535,10 +580,6 @@ int main(int argc, const char* argv[]) window->show(argc, (char**)argv); while (Fl::wait()); return 0; - } catch (wibble::exception::BadOption& e) { - cerr << e.desc() << endl; - opts.outputHelp(cerr); - return 1; } catch (std::exception& e) { cerr << e.what() << endl; return 1; @@ -568,7 +609,3 @@ int main(int argc, const char* argv[]) } #endif - -#include <ept/debtags/debtags.tcc> - -// vim:set ts=4 sw=4: diff --git a/src/manpage.cpp b/src/manpage.cpp deleted file mode 100644 index f1861fb..0000000 --- a/src/manpage.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * tagged collection - Experimental programs to test and study tagged collections - * - * Copyright (C) 2003,2004,2005,2006 Enrico Zini - * - * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include <config.h> -#include <wibble/commandline/doc.h> -#include "GamesOptions.h" -#include <iostream> - -using namespace std; - -int main(int argc, const char* argv[]) -{ - try { - if (argc == 1) - throw wibble::exception::BadOption("no arguments provided"); - - string cmd(argv[1]); - string hooks(argc > 2 ? argv[2] : ""); - - if (cmd == "goplay") - { - wibble::commandline::GamesOptions opts; - wibble::commandline::Manpage help("goplay", VERSION, 1, "Enrico Zini <enr...@enricozini.org> and Miriam Ruiz <little_m...@yahoo.es>"); - if (!hooks.empty()) - help.readHooks(hooks); - help.output(cout, opts); - } - else - throw wibble::exception::BadOption("unknown command " + cmd); - - return 0; - } catch (wibble::exception::BadOption& e) { - cerr << e.desc() << endl << endl; - cerr << "Usage: manpage <command>" << endl << endl; - cerr << "Supported commands are: goplay" << endl; - return 1; - } catch (std::exception& e) { - cerr << e.what() << endl; - return 1; - } -} - -// vim:set ts=4 sw=4: diff --git a/src/pkgbrowser.cpp b/src/pkgbrowser.cpp index 16f968b..dd9b417 100644 --- a/src/pkgbrowser.cpp +++ b/src/pkgbrowser.cpp @@ -33,7 +33,6 @@ #endif #include "Environment.h" -#include "GamesOptions.h" #include "Engine.h" #include "URLFetcher.h"