--- a/src/smallut.cpp
+++ b/src/smallut.cpp
@@ -14,8 +14,6 @@
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-
-#ifndef TEST_SMALLUT
#ifdef BUILDING_RECOLL
#include "autoconfig.h"
#else
@@ -1332,242 +1330,3 @@
// Init langtocode() static table
langtocode("");
}
-
-#else // TEST_SMALLUT
-
-#include <string>
-using namespace std;
-#include <iostream>
-
-#include "smallut.h"
-
-struct spair {
- const char *s1;
- const char *s2;
-};
-struct spair pairs[] = {
- {"", ""},
- {"", "a"},
- {"a", ""},
- {"a", "a"},
- {"A", "a"},
- {"a", "A"},
- {"A", "A"},
- {"12", "12"},
- {"a", "ab"},
- {"ab", "a"},
- {"A", "Ab"},
- {"a", "Ab"},
-};
-int npairs = sizeof(pairs) / sizeof(struct spair);
-struct spair suffpairs[] = {
- {"", ""},
- {"", "a"},
- {"a", ""},
- {"a", "a"},
- {"toto.txt", ".txt"},
- {"TXT", "toto.txt"},
- {"toto.txt", ".txt1"},
- {"toto.txt1", ".txt"},
-};
-int nsuffpairs = sizeof(suffpairs) / sizeof(struct spair);
-
-
-// Periods test strings
-const char* periods[] = {
- "2001", // Year 2001
- "2001/", // 2001 or later
- "2001/P3Y", // 2001 -> 2004 or 2005, ambiguous
- "2001-01-01/P3Y", // 01-2001 -> 01 2004
- "2001-03-03/2001-05-01", // Explicit one
- "P3M/", // 3 months ago to now
- "P1Y1M/2001-03-01", // 2000-02-01/2001-03-01
- "/2001", // From the epoch to the end of 2001
-};
-const int nperiods = sizeof(periods) / sizeof(char*);
-
-const char *thisprog;
-static void cerrdip(const string& s, DateInterval *dip)
-{
- cerr << s << dip->y1 << "-" << dip->m1 << "-" << dip->d1 << "/"
- << dip->y2 << "-" << dip->m2 << "-" << dip->d2
- << endl;
-}
-
-int main(int argc, char **argv)
-{
- thisprog = *argv++;
- argc--;
-
-#if 0
- if (argc <= 0) {
- cerr << "Usage: smallut <stringtosplit>" << endl;
- exit(1);
- }
- string s = *argv++;
- argc--;
- vector<string> vs;
- stringToTokens(s, vs, "/");
- for (vector<string>::const_iterator it = vs.begin(); it != vs.end(); it++) {
- cerr << "[" << *it << "] ";
- }
- cerr << endl;
- exit(0);
-#elif 0
- if (argc <= 0) {
- cerr << "Usage: smallut <stringtosplit>" << endl;
- exit(1);
- }
- string s = *argv++;
- argc--;
- vector<string> vs;
- if (!stringToStrings(s, vs, ":-()")) {
- cerr << "Bad entry" << endl;
- exit(1);
- }
- for (vector<string>::const_iterator it = vs.begin(); it != vs.end(); it++) {
- cerr << "[" << *it << "] ";
- }
- cerr << endl;
- exit(0);
-#elif 0
- if (argc <= 0) {
- cerr << "Usage: smallut <dateinterval>" << endl;
- exit(1);
- }
- string s = *argv++;
- argc--;
- DateInterval di;
- if (!parsedateinterval(s, &di)) {
- cerr << "Parse failed" << endl;
- exit(1);
- }
- cerrdip("", &di);
- exit(0);
-#elif 0
- DateInterval di;
- for (int i = 0; i < nperiods; i++) {
- if (!parsedateinterval(periods[i], &di)) {
- cerr << "Parsing failed for [" << periods[i] << "]" << endl;
- } else {
- cerrdip(string(periods[i]).append(" : "), &di);
- }
- }
- exit(0);
-#elif 0
- for (int i = 0; i < npairs; i++) {
- {
- int c = stringicmp(pairs[i].s1, pairs[i].s2);
- printf("'%s' %s '%s' ", pairs[i].s1,
- c == 0 ? "==" : c < 0 ? "<" : ">", pairs[i].s2);
- }
- {
- int cl = stringlowercmp(pairs[i].s1, pairs[i].s2);
- printf("L '%s' %s '%s' ", pairs[i].s1,
- cl == 0 ? "==" : cl < 0 ? "<" : ">", pairs[i].s2);
- }
- {
- int cu = stringuppercmp(pairs[i].s1, pairs[i].s2);
- printf("U '%s' %s '%s' ", pairs[i].s1,
- cu == 0 ? "==" : cu < 0 ? "<" : ">", pairs[i].s2);
- }
- printf("\n");
- }
-#elif 0
- for (int i = 0; i < nsuffpairs; i++) {
- int c = stringisuffcmp(suffpairs[i].s1, suffpairs[i].s2);
- printf("[%s] %s [%s] \n", suffpairs[i].s1,
- c == 0 ? "matches" : c < 0 ? "<" : ">", suffpairs[i].s2);
- }
-#elif 0
- std::string testit("\303\251l\303\251gant");
- for (int sz = 10; sz >= 0; sz--) {
- utf8truncate(testit, sz);
- cout << testit << endl;
- }
-#elif 0
- std::string testit("ligne\ndeuxieme ligne\r3eme ligne\r\n");
- cout << "[" << neutchars(testit, "\r\n") << "]" << endl;
- string i, o;
- cout << "neutchars(null) is [" << neutchars(i, "\r\n") << "]" << endl;
-#elif 0
- map<string, string> substs;
- substs["a"] = "A_SUBST";
- substs["title"] = "TITLE_SUBST";
- string in = "a: %a title: %(title) pcpc: %% %";
- string out;
- pcSubst(in, out, substs);
- cout << in << " => " << out << endl;
-
- in = "unfinished: %(unfinished";
- pcSubst(in, out, substs);
- cout << in << " => " << out << endl;
- in = "unfinished: %(";
- pcSubst(in, out, substs);
- cout << in << " => " << out << endl;
- in = "empty: %()";
- pcSubst(in, out, substs);
- cout << in << " => " << out << endl;
- substs.clear();
- in = "a: %a title: %(title) pcpc: %% %";
- pcSubst(in, out, substs);
- cout << "After map clear: " << in << " => " << out << endl;
-#elif 0
- list<string> tokens;
- tokens.push_back("");
- tokens.push_back("a,b");
- tokens.push_back("simple value");
- tokens.push_back("with \"quotes\"");
- string out;
- stringsToCSV(tokens, out);
- cout << "CSV line: [" << out << "]" << endl;
-#elif 0
- string sshort("ABC");
- string slong("ABCD");
- string sshortsmaller("ABB");
-
- vector<pair<string, string> > cmps;
- cmps.push_back(pair<string, string>(sshort, sshort));
- cmps.push_back(pair<string, string>(sshort, slong));
- cmps.push_back(pair<string, string>(slong, sshort));
- cmps.push_back(pair<string, string>(sshortsmaller, sshort));
- cmps.push_back(pair<string, string>(sshort, sshortsmaller));
-
- for (vector<pair<string, string> >::const_iterator it = cmps.begin();
- it != cmps.end(); it++) {
- cout << it->first << " " << it->second << " " <<
- stringicmp(it->first, it->second) << endl;
- }
- cout << endl;
- for (vector<pair<string, string> >::const_iterator it = cmps.begin();
- it != cmps.end(); it++) {
- cout << it->first << " " << it->second << " " <<
- stringlowercmp(stringtolower(it->first), it->second) << endl;
- }
- cout << endl;
- for (vector<pair<string, string> >::const_iterator it = cmps.begin();
- it != cmps.end(); it++) {
- cout << it->first << " " << it->second << " " <<
- stringuppercmp(it->first, it->second) << endl;
- }
-#elif 0
- SimpleRegexp exp("[ \t]*#[ \t]*([a-zA-Z0-9]+)[ \t]*=.*", 0, 1);
- //SimpleRegexp exp(" # ([a-zA-Z0-9]+) =.*", 0, 10);
- //SimpleRegexp exp(" # (varnm) = sdf sdf sdf ", 0, 10);
- //SimpleRegexp exp(".*", 0);
- string tomatch(" # varnm = sdf sdf sdf ");
- if (exp.simpleMatch(tomatch)) {
- cout << "Match !\n";
- cout << "Submatch[0]: [" << exp.getMatch(tomatch, 0) << "]\n";
- cout << "Submatch[1]: [" << exp.getMatch(tomatch, 1) << "]\n";
- return 0;
- } else {
- cerr << "No match\n";
- return 1;
- }
-#elif 1
- cout << makeCString("\"hello\" world\n2nd line") << endl;
-#endif
-}
-
-#endif