"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "query.cc" between
xapian-omega-1.4.18.tar.xz and xapian-omega-1.4.19.tar.xz

About: Xapian Omega is an application built on Xapian, consisting of indexers and a CGI search frontend.

query.cc  (xapian-omega-1.4.18.tar.xz):query.cc  (xapian-omega-1.4.19.tar.xz)
/** @file /** @file
* @brief query executor for omega * @brief query executor for omega
*/ */
/* Copyright 1999,2000,2001 BrightStation PLC /* Copyright 1999,2000,2001 BrightStation PLC
* Copyright 2001 James Aylett * Copyright 2001 James Aylett
* Copyright 2001,2002 Ananova Ltd * Copyright 2001,2002 Ananova Ltd
* Copyright 2002 Intercede 1749 Ltd * Copyright 2002 Intercede 1749 Ltd
* Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2013,2014,2015,20 16,2017,2018,2019,2020 Olly Betts * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2013,2014,2015,20 16,2017,2018,2019,2020,2021 Olly Betts
* Copyright 2008 Thomas Viehmann * Copyright 2008 Thomas Viehmann
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as * modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the * published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version. * License, or (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
skipping to change at line 110 skipping to change at line 110
#else #else
#define my_snprintf SNPRINTF #define my_snprintf SNPRINTF
#endif #endif
/// Map shard to DB parameter value and stats to allow docid mapping. /// Map shard to DB parameter value and stats to allow docid mapping.
vector<SubDB> subdbs; vector<SubDB> subdbs;
static bool query_parsed = false; static bool query_parsed = false;
static bool done_query = false; static bool done_query = false;
static Xapian::docid last = 0; static Xapian::docid last = 0;
static Xapian::docid topdoc = 0;
static Xapian::MSet mset; static Xapian::MSet mset;
static Xapian::RSet rset;
static map<Xapian::docid, bool> ticked; static map<Xapian::docid, bool> ticked;
static void ensure_query_parsed(); static void ensure_query_parsed();
static void ensure_match(); static void ensure_match();
static Xapian::Query query; static Xapian::Query query;
//static string url_query_string; //static string url_query_string;
Xapian::Query::op default_op = Xapian::Query::OP_AND; // default matching mode Xapian::Query::op default_op = Xapian::Query::OP_AND; // default matching mode
skipping to change at line 258 skipping to change at line 260
static unsigned static unsigned
read_qp_flags(const string & opt_pfx, unsigned f) read_qp_flags(const string & opt_pfx, unsigned f)
{ {
map<string, string>::const_iterator i = option.lower_bound(opt_pfx); map<string, string>::const_iterator i = option.lower_bound(opt_pfx);
for (; i != option.end() && startswith(i->first, opt_pfx); ++i) { for (; i != option.end() && startswith(i->first, opt_pfx); ++i) {
unsigned mask = 0; unsigned mask = 0;
const char * s = i->first.c_str() + opt_pfx.size(); const char * s = i->first.c_str() + opt_pfx.size();
switch (s[0]) { switch (s[0]) {
case 'a': case 'a':
// Note that the ``Xapian::QueryParser::FLAG_ACCUMULATE`` flag
// is or-ed in below because it's needed for ``$stoplist`` and
// ``$unstem`` to work correctly, and so is deliberately not
// available to specify here.
if (strcmp(s, "auto_multiword_synonyms") == 0) { if (strcmp(s, "auto_multiword_synonyms") == 0) {
mask = Xapian::QueryParser::FLAG_AUTO_MULTIWORD_SYNONYMS; mask = Xapian::QueryParser::FLAG_AUTO_MULTIWORD_SYNONYMS;
break; break;
} }
if (strcmp(s, "auto_synonyms") == 0) { if (strcmp(s, "auto_synonyms") == 0) {
mask = Xapian::QueryParser::FLAG_AUTO_SYNONYMS; mask = Xapian::QueryParser::FLAG_AUTO_SYNONYMS;
break; break;
} }
break; break;
case 'b': case 'b':
skipping to change at line 295 skipping to change at line 301
mask = Xapian::QueryParser::FLAG_DEFAULT; mask = Xapian::QueryParser::FLAG_DEFAULT;
break; break;
} }
break; break;
case 'l': case 'l':
if (strcmp(s, "lovehate") == 0) { if (strcmp(s, "lovehate") == 0) {
mask = Xapian::QueryParser::FLAG_LOVEHATE; mask = Xapian::QueryParser::FLAG_LOVEHATE;
break; break;
} }
break; break;
case 'n':
if (strcmp(s, "no_positions") == 0) {
mask = Xapian::QueryParser::FLAG_NO_POSITIONS;
break;
}
break;
case 'p': case 'p':
if (strcmp(s, "partial") == 0) { if (strcmp(s, "partial") == 0) {
mask = Xapian::QueryParser::FLAG_PARTIAL; mask = Xapian::QueryParser::FLAG_PARTIAL;
break; break;
} }
if (strcmp(s, "phrase") == 0) { if (strcmp(s, "phrase") == 0) {
mask = Xapian::QueryParser::FLAG_PHRASE; mask = Xapian::QueryParser::FLAG_PHRASE;
break; break;
} }
if (strcmp(s, "pure_not") == 0) { if (strcmp(s, "pure_not") == 0) {
skipping to change at line 923 skipping to change at line 935
static Xapian::doccount collapsed; static Xapian::doccount collapsed;
static string print_caption(const string& fmt, vector<string>& param); static string print_caption(const string& fmt, vector<string>& param);
enum tagval { enum tagval {
CMD_, CMD_,
CMD_add, CMD_add,
CMD_addfilter, CMD_addfilter,
CMD_allterms, CMD_allterms,
CMD_and, CMD_and,
CMD_base64,
CMD_cgi, CMD_cgi,
CMD_cgilist, CMD_cgilist,
CMD_cgiparams, CMD_cgiparams,
CMD_chr, CMD_chr,
CMD_collapsed, CMD_collapsed,
CMD_cond, CMD_cond,
CMD_contains, CMD_contains,
CMD_csv, CMD_csv,
CMD_date, CMD_date,
CMD_dbname, CMD_dbname,
skipping to change at line 1066 skipping to change at line 1079
#define Q 'Q' #define Q 'Q'
// NB when adding a new command which ensures M or Q, update the list in // NB when adding a new command which ensures M or Q, update the list in
// docs/omegascript.rst // docs/omegascript.rst
static const struct func_desc func_tab[] = { static const struct func_desc func_tab[] = {
//name minargs maxargs evalargs ensure //name minargs maxargs evalargs ensure
{"",{CMD_, N, N, 0, 0}},// commented out code {"",{CMD_, N, N, 0, 0}},// commented out code
T(add, 0, N, N, 0), // add a list of numbers T(add, 0, N, N, 0), // add a list of numbers
T(addfilter, 1, 2, N, 0), // add filter term T(addfilter, 1, 2, N, 0), // add filter term
T(allterms, 0, 1, N, 0), // list of all terms matching document T(allterms, 0, 1, N, 0), // list of all terms matching document
T(and, 1, N, 0, 0), // logical shortcutting and of a list of values T(and, 1, N, 0, 0), // logical shortcutting and of a list of values
T(base64, 1, 1, N, 0), // base64 encode
T(cgi, 1, 1, N, 0), // return cgi parameter value T(cgi, 1, 1, N, 0), // return cgi parameter value
T(cgilist, 1, 1, N, 0), // return list of values for cgi parameter T(cgilist, 1, 1, N, 0), // return list of values for cgi parameter
T(cgiparams, 0, 0, N, 0), // return list of cgi parameter names T(cgiparams, 0, 0, N, 0), // return list of cgi parameter names
T(chr, 1, 1, N, 0), // return UTF-8 for given Unicode codepoint T(chr, 1, 1, N, 0), // return UTF-8 for given Unicode codepoint
T(collapsed, 0, 0, N, 0), // return number of hits collapsed into this T(collapsed, 0, 0, N, 0), // return number of hits collapsed into this
T(cond, 2, N, 0, 0), // cascaded conditionals T(cond, 2, N, 0, 0), // cascaded conditionals
T(contains, 2, 2, N, 0), // return position of substring, or empty string T(contains, 2, 2, N, 0), // return position of substring, or empty string
T(csv, 1, 2, N, 0), // CSV string escaping T(csv, 1, 2, N, 0), // CSV string escaping
T(date, 1, 2, N, 0), // convert time_t to strftime format T(date, 1, 2, N, 0), // convert time_t to strftime format
// (default: YYYY-MM-DD) // (default: YYYY-MM-DD)
skipping to change at line 1394 skipping to change at line 1408
case CMD_and: { case CMD_and: {
value = "true"; value = "true";
for (auto&& arg : args) { for (auto&& arg : args) {
if (eval(arg, param).empty()) { if (eval(arg, param).empty()) {
value.resize(0); value.resize(0);
break; break;
} }
} }
break; break;
} }
case CMD_base64: {
const static char encode[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdef"
"ghijklmnopqrstuvwxyz0123456789+/";
const char pad = '=';
const string& input = args[0];
value.reserve((input.size() + 2) / 3 * 4);
auto it = input.begin();
auto n = input.size() / 3;
while (n--) {
uint32_t v = uint8_t(*it++);
v = (v << 8) | uint8_t(*it++);
v = (v << 8) | uint8_t(*it++);
value += encode[v >> 18];
value += encode[(v >> 12) & 63];
value += encode[(v >> 6) & 63];
value += encode[v & 63];
}
switch (input.size() % 3) {
case 2: {
uint32_t v = uint8_t(*it++);
v = (v << 8) | uint8_t(*it++);
value += encode[v >> 10];
value += encode[(v >> 4) & 63];
value += encode[(v << 2) & 63];
value += pad;
break;
}
case 1: {
uint32_t v = uint8_t(*it++);
value += encode[v >> 2];
value += encode[(v << 4) & 63];
value += pad;
value += pad;
break;
}
}
break;
}
case CMD_cgi: { case CMD_cgi: {
auto i = cgi_params.find(args[0]); auto i = cgi_params.find(args[0]);
if (i != cgi_params.end()) value = i->second; if (i != cgi_params.end()) value = i->second;
break; break;
} }
case CMD_cgilist: { case CMD_cgilist: {
auto g = cgi_params.equal_range(args[0]); auto g = cgi_params.equal_range(args[0]);
for (auto i = g.first; i != g.second; ++i) { for (auto i = g.first; i != g.second; ++i) {
value += i->second; value += i->second;
value += '\t'; value += '\t';
 End of changes. 8 change blocks. 
1 lines changed or deleted 53 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)