commit aa92618c62effae7cecaf71354270ecf681d04d7 Author: Raphaƫl Pinson Date: Tue Mar 26 13:37:14 2013 +0100 Add options to diatheke: * --no-refs suppresses reference printing in output * --no-mod-name suppresses the module name in output * --no-newlines replaces new lines with a space in output diff --git a/utilities/diatheke/corediatheke.cpp b/utilities/diatheke/corediatheke.cpp index 70dea95..12e3f45 100644 --- a/utilities/diatheke/corediatheke.cpp +++ b/utilities/diatheke/corediatheke.cpp @@ -342,17 +342,19 @@ void doquery(unsigned long maxverses = -1, unsigned char outputformat = FMT_PLAI } if (strlen(text)) { - *output << (char*)target->getKeyText(); - if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { - *output << ": "; - } - else if (outputformat == FMT_RTF) { - *output << ": {\\f1 "; - } - else { - *output << ": "; + if (!(optionfilters & OP_NOPRINTREFS)) { + *output << (char*)target->getKeyText(); + if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { + *output << ": "; + } + else if (outputformat == FMT_RTF) { + *output << ": {\\f1 "; + } + else { + *output << ": "; + } } *output << text; if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { @@ -362,9 +364,11 @@ void doquery(unsigned long maxverses = -1, unsigned char outputformat = FMT_PLAI *output << "}"; } - *output << "("; - *output << target->getName(); - *output << ")\n"; + if (!(optionfilters & OP_NOPRINTMODNAME)) { + *output << "("; + *output << target->getName(); + *output << ")\n"; + } } if (outputformat == FMT_RTF) { @@ -404,17 +408,19 @@ void doquery(unsigned long maxverses = -1, unsigned char outputformat = FMT_PLAI target->setKey(element->getLowerBound()); *parser = element->getUpperBound(); while (maxverses && *target->getKey() <= *parser) { - *output << (char*)target->getKeyText(); - if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { - *output << ": "; - } - else if (outputformat == FMT_RTF) { - *output << ": {\\f1 "; - } - else { - *output << ": "; + if (!(optionfilters & OP_NOPRINTREFS)) { + *output << (char*)target->getKeyText(); + if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { + *output << ": "; + } + else if (outputformat == FMT_RTF) { + *output << ": {\\f1 "; + } + else { + *output << ": "; + } } *output << (const char*)*target; if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { @@ -433,7 +439,11 @@ void doquery(unsigned long maxverses = -1, unsigned char outputformat = FMT_PLAI else if (outputformat == FMT_GBF) *output << ""; - *output << "\n"; + if (optionfilters & OP_NOPRINTNEWLINES) { + *output << " "; + } else { + *output << "\n"; + } if (*target->getKey() == *parser) break; @@ -443,17 +453,19 @@ void doquery(unsigned long maxverses = -1, unsigned char outputformat = FMT_PLAI } else { target->setKey(*listkey.GetElement(i)); - *output << (char*)target->getKeyText(); - if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { - *output << ": "; - } - else if (outputformat == FMT_RTF) { - *output << ": {\\f1 "; - } - else { - *output << ": "; + if (!(optionfilters & OP_NOPRINTREFS)) { + *output << (char*)target->getKeyText(); + if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { + *output << ": "; + } + else if (outputformat == FMT_RTF) { + *output << ": {\\f1 "; + } + else { + *output << ": "; + } } *output << (const char*)*target; if (font && (outputformat == FMT_HTML || outputformat == FMT_THML || outputformat == FMT_CGI)) { @@ -472,14 +484,21 @@ void doquery(unsigned long maxverses = -1, unsigned char outputformat = FMT_PLAI else if (outputformat == FMT_GBF) *output << ""; - *output << "\n"; + if (optionfilters & OP_NOPRINTNEWLINES) { + *output << " "; + } else { + *output << "\n"; + } maxverses--; } } - *output << "("; - *output << target->getName(); - *output << ")\n"; + if (!(optionfilters & OP_NOPRINTMODNAME)) { + *output << "("; + *output << target->getName(); + *output << ")"; + } + *output << "\n"; if (outputformat == FMT_RTF) { *output << "}"; diff --git a/utilities/diatheke/corediatheke.h b/utilities/diatheke/corediatheke.h index 2ad4801..8cf766e 100644 --- a/utilities/diatheke/corediatheke.h +++ b/utilities/diatheke/corediatheke.h @@ -48,6 +48,9 @@ #define OP_VARIANTS 4096 #define OP_RED 8192 #define OP_ARABICPOINTS 16384 +#define OP_NOPRINTMODNAME 32768 +#define OP_NOPRINTREFS 65536 +#define OP_NOPRINTNEWLINES 131072 #define ST_NONE 0 #define ST_REGEX 1 //0 #define ST_PHRASE 2 // -1 diff --git a/utilities/diatheke/diatheke.cpp b/utilities/diatheke/diatheke.cpp index 030ca00..b64688a 100644 --- a/utilities/diatheke/diatheke.cpp +++ b/utilities/diatheke/diatheke.cpp @@ -38,7 +38,7 @@ void printsyntax() { fprintf (stderr, "diatheke <-b module_name> [-s search_type] [-r search_range]\n"); fprintf (stderr, "[-o option_filters] [-m maximum_verses] [-f output_format]\n"); fprintf (stderr, "[-e output_encoding] [-t script] [-v variant#(-1=all|0|1)]\n"); - fprintf (stderr, "[-l locale] <-k query_key>\n"); + fprintf (stderr, "[-l locale] [--no-refs] [--no-mod-name] [--no-newlines] <-k query_key>\n"); fprintf (stderr, "\n"); fprintf (stderr, "If is \"system\" you may use these system keys: \"modulelist\",\n"); fprintf (stderr, "\"modulelistnames\", and \"localelist\"."); @@ -54,6 +54,9 @@ void printsyntax() { fprintf (stderr, "Valid output_format values are: GBF, ThML, RTF, HTML, HTMLHREF, XHTML, OSIS, CGI, and plain (def)\n"); fprintf (stderr, "Valid output_encoding values are: Latin1, UTF8 (def), UTF16, HTML, and RTF\n"); fprintf (stderr, "Valid locale values depend on installed locales. en is default.\n"); + fprintf (stderr, "--no-refs suppresses reference printing in output\n"); + fprintf (stderr, "--no-mod-name suppresses the module name in output\n"); + fprintf (stderr, "--no-newlines replaces new lines with a space in output\n"); fprintf (stderr, "The query_key must be the last argument because all following\n"); fprintf (stderr, " arguments are added to the key.\n\n"); @@ -237,6 +240,18 @@ int main(int argc, char **argv) i++; } } + else if (!::stricmp("--no-mod-name", argv[i])) { + if (i+1 <= argc) + optionfilters |= OP_NOPRINTMODNAME; + } + else if (!::stricmp("--no-refs", argv[i])) { + if (i+1 <= argc) + optionfilters |= OP_NOPRINTREFS; + } + else if (!::stricmp("--no-newlines", argv[i])) { + if (i+1 <= argc) + optionfilters |= OP_NOPRINTNEWLINES; + } }