Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 42 additions & 39 deletions src/org/joni/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,54 +22,57 @@
import java.io.PrintStream;

public interface Config extends org.jcodings.Config {
final int CHAR_TABLE_SIZE = 256;
final boolean USE_NO_INVALID_QUANTIFIER = true;
final int SCANENV_MEMNODES_SIZE = 8;

final boolean USE_NAMED_GROUP = true;
final boolean USE_SUBEXP_CALL = true;
final boolean USE_PERL_SUBEXP_CALL = true;
final boolean USE_BACKREF_WITH_LEVEL = true; /* \k<name+n>, \k<name-n> */

final boolean USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT = true; /* /(?:()|())*\2/ */
final boolean USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE = true; /* /\n$/ =~ "\n" */
final boolean USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR = true;

final boolean CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS = true;

final boolean USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE = false;
final boolean USE_CAPTURE_HISTORY = false;
final boolean USE_VARIABLE_META_CHARS = true;
final boolean USE_WORD_BEGIN_END = true; /* "\<": word-begin, "\>": word-end */
final boolean USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE = true;
final boolean USE_SUNDAY_QUICK_SEARCH = true;
final boolean USE_CEC = false;
final boolean USE_DYNAMIC_OPTION = false;
final boolean USE_BYTE_MAP = OptExactInfo.OPT_EXACT_MAXLEN <= CHAR_TABLE_SIZE;
final boolean USE_INT_MAP_BACKWARD = false;

final int NREGION = 10;
final int MAX_BACKREF_NUM = 1000;
final int MAX_CAPTURE_GROUP_NUM = 32767;
final int MAX_REPEAT_NUM = 100000;
final int MAX_MULTI_BYTE_RANGES_NUM = 10000;
final int CHAR_TABLE_SIZE = ConfigSupport.getInt("joni.char_table_size", 256);
final boolean USE_NO_INVALID_QUANTIFIER = ConfigSupport.getBoolean("joni.use_no_invalid_quantifier", true);
final int SCANENV_MEMNODES_SIZE = ConfigSupport.getInt("joni.scanenv_memnodes_size", 8);

final boolean USE_NAMED_GROUP = ConfigSupport.getBoolean("joni.use_named_group", true);
final boolean USE_SUBEXP_CALL = ConfigSupport.getBoolean("joni.use_subexp_call", true);
final boolean USE_PERL_SUBEXP_CALL = ConfigSupport.getBoolean("joni.use_perl_subexp_call", true);
final boolean USE_BACKREF_WITH_LEVEL = ConfigSupport.getBoolean("joni.use_backref_with_level", true); /* \k<name+n>, \k<name-n> */

final boolean USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT = ConfigSupport.getBoolean("joni.use_monomaniac_check_captures_in_endless_repeat", true); /* /(?:()|())*\2/ */
final boolean USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE = ConfigSupport.getBoolean("joni.use_newline_at_end_of_string_has_empty_line", true); /* /\n$/ =~ "\n" */
final boolean USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR = ConfigSupport.getBoolean("joni.use_warning_redundant_nested_repeat_operator", true);

final boolean CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS = ConfigSupport.getBoolean("joni.case_fold_is_applied_inside_negative_cclass", true);

final boolean USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE = ConfigSupport.getBoolean("joni.use_match_range_must_be_inside_of_specified_range", false);
final boolean USE_CAPTURE_HISTORY = ConfigSupport.getBoolean("joni.use_capture_history", false);
final boolean USE_VARIABLE_META_CHARS = ConfigSupport.getBoolean("joni.use_variable_meta_chars", true);
final boolean USE_WORD_BEGIN_END = ConfigSupport.getBoolean("joni.use_word_begin_end", true); /* "\<": word-begin, "\>": word-end */
final boolean USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE = ConfigSupport.getBoolean("joni.use_find_longest_search_all_of_range", true);
final boolean USE_SUNDAY_QUICK_SEARCH = ConfigSupport.getBoolean("joni.use_sunday_quick_search", true);
final boolean USE_CEC = ConfigSupport.getBoolean("joni.use_cec", false);
final boolean USE_DYNAMIC_OPTION = ConfigSupport.getBoolean("joni.use_dynamic_option", false);
final boolean USE_BYTE_MAP = ConfigSupport.getBoolean("joni.use_byte_map", OptExactInfo.OPT_EXACT_MAXLEN <= CHAR_TABLE_SIZE);
final boolean USE_INT_MAP_BACKWARD = ConfigSupport.getBoolean("joni.use_int_map_backward", false);

final int NREGION = ConfigSupport.getInt("joni.nregion", 10);
final int MAX_BACKREF_NUM = ConfigSupport.getInt("joni.max_backref_num", 1000);
final int MAX_CAPTURE_GROUP_NUM = ConfigSupport.getInt("joni.max_capture_group_num", 32767);
final int MAX_REPEAT_NUM = ConfigSupport.getInt("joni.max_multi_byte_ranges_num", 100000);
final int MAX_MULTI_BYTE_RANGES_NUM = ConfigSupport.getInt("joni.max_multi_byte_ranges_num", 10000);

// internal config
final boolean USE_OP_PUSH_OR_JUMP_EXACT = true;
final boolean USE_QTFR_PEEK_NEXT = true;
final boolean USE_OP_PUSH_OR_JUMP_EXACT = ConfigSupport.getBoolean("joni.use_op_push_or_jump_exact", true);
final boolean USE_QTFR_PEEK_NEXT = ConfigSupport.getBoolean("joni.use_qtfr_peek_next", true);

final int INIT_MATCH_STACK_SIZE = 64;
final int INIT_MATCH_STACK_SIZE = ConfigSupport.getInt("joni.init_match_stack_size", 64);

final boolean DONT_OPTIMIZE = false;
final boolean OPTIMIZE = ConfigSupport.getBoolean("joni.optimize", true);
@Deprecated
final boolean DONT_OPTIMIZE = !OPTIMIZE;

final boolean USE_STRING_TEMPLATES = true; // use embedded string templates in Regex object as byte arrays instead of compiling them into int bytecode array
// use embedded string templates in Regex object as byte arrays instead of compiling them into int bytecode array
final boolean USE_STRING_TEMPLATES = ConfigSupport.getBoolean("joni.use_string_templates", true);


final int MAX_CAPTURE_HISTORY_GROUP = 31;
final int MAX_CAPTURE_HISTORY_GROUP = ConfigSupport.getInt("joni.max_capture_history_group", 31);


final int CHECK_STRING_THRESHOLD_LEN = 7;
final int CHECK_BUFF_MAX_SIZE = 0x4000;
final int CHECK_STRING_THRESHOLD_LEN = ConfigSupport.getInt("joni.check_string_threshold_len", 7);
final int CHECK_BUFF_MAX_SIZE = ConfigSupport.getInt("joni.check_buff_max_size", 0x4000);

final PrintStream log = System.out;
final PrintStream err = System.err;
Expand Down
5 changes: 5 additions & 0 deletions src/org/joni/ConfigSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ static boolean getBoolean(String property, boolean def) {
String value = System.getProperty(property, def ? "true" : "false");
return !value.equals("false");
}

static int getInt(String property, int def) {
String value = System.getProperty(property);
return value != null ? Integer.parseInt(value) : def;
}
}
4 changes: 2 additions & 2 deletions src/org/joni/Search.java
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,10 @@ final int search(Matcher matcher, byte[]text, int textP, int textEnd, int textRa
int targetP = regex.exactP;
int targetEnd = regex.exactEnd;

int end, s, tlen1;
int end, s;
int tail = targetEnd - 1;
int tlen1 = tail - targetP;
if (USE_SUNDAY_QUICK_SEARCH) {
tlen1 = tail - targetP;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this fixing a separate bug? If so we should move it to another PR because it's not config-related.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I changed USE_SUNDAY_QUICK_SEARCH to be initialized from system property it no longer compiled

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile (default-compile) on project joni: Compilation failure: Compilation failure:
[ERROR] /Users/nezda/code/joni.git/src/org/joni/Search.java:[438,59] variable tlen1 might not have been initialized
[ERROR] /Users/nezda/code/joni.git/src/org/joni/Search.java:[446,59] variable tlen1 might not have been initialized

so I tried to fix.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pinged @enebo to look at this too.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, it was constant propagated since those interface fields are essentially static finals

end = textRange + tlen1;
s = textP + tlen1;
} else {
Expand Down