Skip to content

Commit 6109041

Browse files
authored
Fix alias insertion (#181)
SQLite LIKE operator is case-insensitive. Hence the replacement must be case-insensitive too. If it is not, the keyword found by LIKE might not be replaced and will be found again and again. That will cause unlimited growth of sql_results. Example: https://en.cppreference.com/w/cpp/memory/allocator and Allocator template argument Another option would be using GLOB instead of LIKE for case-sensitive search. Whether it is better or not and search pattern selection is out of scope of this commit.
1 parent ff8a77e commit 6109041

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cppman/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def rebuild_index(self):
198198
% (table, k, k, k, k, k, k)).fetchall()
199199

200200
for id, keyword in sql_results:
201-
keyword = keyword.replace("%s" % k, "%s" % a)
201+
keyword = re.sub(re.escape("%s" % k), "%s" % a, keyword, flags=re.IGNORECASE)
202202

203203
self.db_cursor.execute(
204204
'INSERT INTO "%s_keywords" (id, keyword) '

0 commit comments

Comments
 (0)