diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-02-22 18:53:21 +0100 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-02-22 18:53:21 +0100 |
commit | 6ed576974dec969ad2745a451a6f680a3cdbcfc4 (patch) | |
tree | a6ab07dc60f1a1cb3f9a08f1e0bea835103dc1c5 | |
parent | f2200e22b05c3801b722cd46617e7bcf64538d17 (diff) | |
download | dict-6ed576974dec969ad2745a451a6f680a3cdbcfc4.tar.gz dict-6ed576974dec969ad2745a451a6f680a3cdbcfc4.tar.bz2 dict-6ed576974dec969ad2745a451a6f680a3cdbcfc4.zip |
feat: Sync
-rw-r--r-- | dict/main.c | 4 | ||||
-rw-r--r-- | lib/data.c | 4 | ||||
-rw-r--r-- | lib/list.c | 3 |
3 files changed, 3 insertions, 8 deletions
diff --git a/dict/main.c b/dict/main.c index 98608cc..18aeb63 100644 --- a/dict/main.c +++ b/dict/main.c @@ -72,11 +72,9 @@ int run(const char *db) void search(char *sch, int len) { - char s[len+2]; - sprintf(s, "%%%*s%%", len, sch); - LIST* l = data_select(data, s, len+2, LINES-5); + LIST* l = data_select(data, sch, len, LINES-5); for (int y = 0; y < (LINES-5); y++) { move(y, 0); @@ -6,8 +6,8 @@ #include "../lib/util.h" const char *insert_into = "INSERT INTO words (LINE) VALUES($VVV);"; -const char *select_words = "SELECT Id, Line FROM words WHERE line like $VVV LIMIT $NNN;"; -const char *create_table = "CREATE TABLE IF NOT EXISTS words (ID INTEGER PRIMARY KEY AUTOINCREMENT, LINE TEXT NOT NULL);"; +const char *select_words = "SELECT Id, Line FROM words WHERE line MATCH $VVV LIMIT $NNN;"; +const char *create_table = "CREATE VIRTUAL TABLE IF NOT EXISTS words USING fts4 (ID INTEGER PRIMARY KEY AUTOINCREMENT, LINE TEXT NOT NULL);"; Data* new_data(const char* con) { @@ -36,9 +36,6 @@ LIST* list_remove(LIST* list, unsigned int pos) void list_free(LIST* list) { - for (unsigned int x = 0; x < list->size; x++) - free(list->list[x]); - free(list->list); free(list); } |