diff --git a/TODO b/TODO index a9d7f01..fda6f13 100644 --- a/TODO +++ b/TODO @@ -1,13 +1,10 @@ 1. Approximate query matching (potentially use soundex and/or expose another search URL) -2. Detect if input file is sorted and sort of not sorted (eliminates -the -s switch) - -3. Show upper bound on time saved if input file were sorted (in case +2. Show upper bound on time saved if input file were sorted (in case of unsorted input file) -4. Vulnerable to long bodies being sent by attacker. Does not cause +3. Vulnerable to long bodies being sent by attacker. Does not cause memory blow-up but causes data to be continuously read. There is nothing we can do about it since the attacker could very well just create many connections and do the same thing even if we limit the # diff --git a/src/main.cpp b/src/main.cpp index 6d4a133..5e89096 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -56,7 +56,6 @@ volatile bool building = false; // TRUE if the structure is being built unsigned long nreq = 0; // The total number of requests served till now int line_limit = -1; // The number of lines to import from the input file time_t started_at; // When was the server started -bool ac_sorted = false; // Is the input sorted bool opt_show_help = false; // Was --help requested? const char *ac_file = NULL; // Path to the input file int port = 6767; // The port number on which to start the HTTP server @@ -409,12 +408,6 @@ get_uptime() { return humanized_time_difference(started_at, time(NULL)); } -bool -is_valid_cb(std::string const& cb) { - // We don't check since this could be any valid javascript expression - return true; -} - bool is_EOF(FILE *pf) { return feof(pf); } bool is_EOF(std::ifstream fin) { return !!fin; } @@ -438,8 +431,9 @@ void get_line(std::ifstream fin, char *buff, int buff_len, int &read_len) { int -do_import(std::string file, int sorted, uint_t limit, +do_import(std::string file, uint_t limit, int &rnadded, int &rnlines) { + bool is_input_sorted = true; #if defined USE_CXX_IO std::ifstream fin(file.c_str()); #else @@ -484,6 +478,7 @@ do_import(std::string file, int sorted, uint_t limit, pm.repr.clear(); char buff[INPUT_LINE_SIZE]; + std::string prev_phrase; while (!is_EOF(fin) && limit--) { buff[0] = '\0'; @@ -505,13 +500,20 @@ do_import(std::string file, int sorted, uint_t limit, if (!phrase.empty()) { str_lowercase(phrase); - DCERR("Adding: "<