Mercurial Hosting > luan
changeset 1622:b7f8418fb7ba
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 26 Jul 2021 11:51:56 -0600 |
parents | a9591906e608 |
children | 582384548a69 |
files | src/goodjava/lucene/queryparser/GoodQueryParser.java src/luan/modules/lucene/Lucene.luan |
diffstat | 2 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/goodjava/lucene/queryparser/GoodQueryParser.java Sun Jul 25 23:14:59 2021 -0600 +++ b/src/goodjava/lucene/queryparser/GoodQueryParser.java Mon Jul 26 11:51:56 2021 -0600 @@ -19,6 +19,17 @@ return new GoodQueryParser(fieldParser,query).parseQuery(); } + public static String quote(String s) { + s = s.replace("\\","\\\\"); + s = s.replace("\b","\\b"); + s = s.replace("\f","\\f"); + s = s.replace("\n","\\n"); + s = s.replace("\r","\\r"); + s = s.replace("\t","\\t"); + s = s.replace("\"","\\\""); + return '"'+s+'"'; + } + public static String escape(String s) { s = s.replace("\\","\\\\"); s = s.replace("\b","\\b");
--- a/src/luan/modules/lucene/Lucene.luan Sun Jul 25 23:14:59 2021 -0600 +++ b/src/luan/modules/lucene/Lucene.luan Mon Jul 26 11:51:56 2021 -0600 @@ -59,11 +59,8 @@ double = NumberFieldParser.DOUBLE } -local escape = GoodQueryParser.escape -Lucene.escape = escape -function Lucene.quote(s) - return [["]]..escape(s)..[["]] -end +Lucene.quote = GoodQueryParser.quote +Lucene.escape = GoodQueryParser.escape local function get_file(f,name) type(f)=="table" or error(name.." must be table")