[misc] misc bugs

This commit is contained in:
Timothy Stack 2020-12-24 22:29:38 -08:00
parent bfa2c7f38c
commit 7476dd5bb9
5 changed files with 53 additions and 43 deletions

3
NEWS
View File

@ -34,6 +34,9 @@ lnav v0.9.1:
in the copy if they are enabled. in the copy if they are enabled.
* Log messages that cannot be parsed properly will be given an "invalid" * Log messages that cannot be parsed properly will be given an "invalid"
log level and the invalid portions colored yellow. log level and the invalid portions colored yellow.
* The range_start and range_stop values of the regexp_capture() results
now start at 1 instead of zero to match with what the other SQL string
functions expect.
Fixes: Fixes:
* Unicode text can now be entered in prompts. * Unicode text can now be entered in prompts.

View File

@ -2683,12 +2683,12 @@ regexp_capture(*string*, *pattern*)
;SELECT * FROM regexp_capture('a=1; b=2', '(\w+)=(\d+)') ;SELECT * FROM regexp_capture('a=1; b=2', '(\w+)=(\d+)')
match_index capture_index capture_name capture_count range_start range_stop content match_index capture_index capture_name capture_count range_start range_stop content
0 0 <NULL> 3 0 3 a=1 0 0 <NULL> 3 1 4 a=1
0 1 3 0 1 a 0 1 3 1 2 a
0 2 3 2 3 1 0 2 3 3 4 1
1 0 <NULL> 3 5 8 b=2 1 0 <NULL> 3 6 9 b=2
1 1 3 5 6 b 1 1 3 6 7 b
1 2 3 7 8 2 1 2 3 8 9 2
**See Also:** **See Also:**

View File

@ -141,10 +141,10 @@ CREATE TABLE regexp_capture (
sqlite3_result_int64(ctx, vc.c_context.get_count()); sqlite3_result_int64(ctx, vc.c_context.get_count());
break; break;
case RC_COL_RANGE_START: case RC_COL_RANGE_START:
sqlite3_result_int64(ctx, cap.c_begin); sqlite3_result_int64(ctx, cap.c_begin + 1);
break; break;
case RC_COL_RANGE_STOP: case RC_COL_RANGE_STOP:
sqlite3_result_int64(ctx, cap.c_end); sqlite3_result_int64(ctx, cap.c_end + 1);
break; break;
case RC_COL_CONTENT: case RC_COL_CONTENT:
if (cap.is_valid()) { if (cap.is_valid()) {

View File

@ -235,7 +235,7 @@ void view_curses::mvwattrline(WINDOW *window,
} }
if (attr_range.lr_end == -1) { if (attr_range.lr_end == -1) {
attr_range.lr_end = line_width_chars; attr_range.lr_end = lr_chars.lr_start + line_width_chars;
} }
if (attr_range.lr_end < lr_chars.lr_start) { if (attr_range.lr_end < lr_chars.lr_start) {
continue; continue;

View File

@ -174,6 +174,13 @@ Row 0:
EOF EOF
run_test ./drive_sql "SELECT substr('#foo', range_start) AS value FROM regexp_capture('#foo', '(\w+)') WHERE capture_index = 1"
check_output "" <<EOF
Row 0:
Column value: foo
EOF
run_test ./drive_sql "SELECT * FROM regexp_capture('foo bar', '\w+ (\w+)')" run_test ./drive_sql "SELECT * FROM regexp_capture('foo bar', '\w+ (\w+)')"
check_output "" <<EOF check_output "" <<EOF
@ -182,16 +189,16 @@ Row 0:
Column capture_index: 0 Column capture_index: 0
Column capture_name: (null) Column capture_name: (null)
Column capture_count: 2 Column capture_count: 2
Column range_start: 0 Column range_start: 1
Column range_stop: 7 Column range_stop: 8
Column content: foo bar Column content: foo bar
Row 1: Row 1:
Column match_index: 0 Column match_index: 0
Column capture_index: 1 Column capture_index: 1
Column capture_name: Column capture_name:
Column capture_count: 2 Column capture_count: 2
Column range_start: 4 Column range_start: 5
Column range_stop: 7 Column range_stop: 8
Column content: bar Column content: bar
EOF EOF
@ -203,8 +210,8 @@ Row 0:
Column capture_index: 0 Column capture_index: 0
Column capture_name: (null) Column capture_name: (null)
Column capture_count: 1 Column capture_count: 1
Column range_start: 0 Column range_start: 1
Column range_stop: 7 Column range_stop: 8
Column content: foo bar Column content: foo bar
EOF EOF
@ -216,16 +223,16 @@ Row 0:
Column capture_index: 0 Column capture_index: 0
Column capture_name: (null) Column capture_name: (null)
Column capture_count: 2 Column capture_count: 2
Column range_start: 0 Column range_start: 1
Column range_stop: 7 Column range_stop: 8
Column content: foo bar Column content: foo bar
Row 1: Row 1:
Column match_index: 0 Column match_index: 0
Column capture_index: 1 Column capture_index: 1
Column capture_name: word Column capture_name: word
Column capture_count: 2 Column capture_count: 2
Column range_start: 4 Column range_start: 5
Column range_stop: 7 Column range_stop: 8
Column content: bar Column content: bar
EOF EOF
@ -237,24 +244,24 @@ Row 0:
Column capture_index: 0 Column capture_index: 0
Column capture_name: (null) Column capture_name: (null)
Column capture_count: 3 Column capture_count: 3
Column range_start: 0 Column range_start: 1
Column range_stop: 7 Column range_stop: 8
Column content: foo bar Column content: foo bar
Row 1: Row 1:
Column match_index: 0 Column match_index: 0
Column capture_index: 1 Column capture_index: 1
Column capture_name: Column capture_name:
Column capture_count: 3 Column capture_count: 3
Column range_start: -1 Column range_start: 0
Column range_stop: -1 Column range_stop: 0
Column content: (null) Column content: (null)
Row 2: Row 2:
Column match_index: 0 Column match_index: 0
Column capture_index: 2 Column capture_index: 2
Column capture_name: word Column capture_name: word
Column capture_count: 3 Column capture_count: 3
Column range_start: 4 Column range_start: 5
Column range_stop: 7 Column range_stop: 8
Column content: bar Column content: bar
EOF EOF
@ -282,64 +289,64 @@ Row 0:
Column capture_index: 0 Column capture_index: 0
Column capture_name: (null) Column capture_name: (null)
Column capture_count: 2 Column capture_count: 2
Column range_start: 0 Column range_start: 1
Column range_stop: 1 Column range_stop: 2
Column content: 1 Column content: 1
Row 1: Row 1:
Column match_index: 0 Column match_index: 0
Column capture_index: 1 Column capture_index: 1
Column capture_name: Column capture_name:
Column capture_count: 2 Column capture_count: 2
Column range_start: 0 Column range_start: 1
Column range_stop: 1 Column range_stop: 2
Column content: 1 Column content: 1
Row 2: Row 2:
Column match_index: 1 Column match_index: 1
Column capture_index: 0 Column capture_index: 0
Column capture_name: (null) Column capture_name: (null)
Column capture_count: 2 Column capture_count: 2
Column range_start: 2 Column range_start: 3
Column range_stop: 3 Column range_stop: 4
Column content: 2 Column content: 2
Row 3: Row 3:
Column match_index: 1 Column match_index: 1
Column capture_index: 1 Column capture_index: 1
Column capture_name: Column capture_name:
Column capture_count: 2 Column capture_count: 2
Column range_start: 2 Column range_start: 3
Column range_stop: 3 Column range_stop: 4
Column content: 2 Column content: 2
Row 4: Row 4:
Column match_index: 2 Column match_index: 2
Column capture_index: 0 Column capture_index: 0
Column capture_name: (null) Column capture_name: (null)
Column capture_count: 2 Column capture_count: 2
Column range_start: 4 Column range_start: 5
Column range_stop: 5 Column range_stop: 6
Column content: 3 Column content: 3
Row 5: Row 5:
Column match_index: 2 Column match_index: 2
Column capture_index: 1 Column capture_index: 1
Column capture_name: Column capture_name:
Column capture_count: 2 Column capture_count: 2
Column range_start: 4 Column range_start: 5
Column range_stop: 5 Column range_stop: 6
Column content: 3 Column content: 3
Row 6: Row 6:
Column match_index: 3 Column match_index: 3
Column capture_index: 0 Column capture_index: 0
Column capture_name: (null) Column capture_name: (null)
Column capture_count: 2 Column capture_count: 2
Column range_start: 6 Column range_start: 7
Column range_stop: 8 Column range_stop: 9
Column content: 45 Column content: 45
Row 7: Row 7:
Column match_index: 3 Column match_index: 3
Column capture_index: 1 Column capture_index: 1
Column capture_name: Column capture_name:
Column capture_count: 2 Column capture_count: 2
Column range_start: 6 Column range_start: 7
Column range_stop: 8 Column range_stop: 9
Column content: 45 Column content: 45
EOF EOF
@ -351,7 +358,7 @@ Row 0:
Column capture_index: 0 Column capture_index: 0
Column capture_name: (null) Column capture_name: (null)
Column capture_count: 1 Column capture_count: 1
Column range_start: 0 Column range_start: 1
Column range_stop: 3 Column range_stop: 4
Column content: foo Column content: foo
EOF EOF