regex: fix compilation issues with gcc under ubuntu (#7112)
parent
793f9ae9e3
commit
15ffce1317
|
@ -92,9 +92,7 @@ fn utf8util_char_len(b byte) int {
|
|||
fn (re RE) get_char(in_txt string, i int) (u32,int) {
|
||||
ini := unsafe {in_txt.str[i]}
|
||||
// ascii 8 bit
|
||||
if (re.flag & f_bin) !=0 ||
|
||||
ini & 0x80 == 0
|
||||
{
|
||||
if (re.flag & f_bin) !=0 || ini & 0x80 == 0 {
|
||||
return u32(ini), 1
|
||||
}
|
||||
// unicode char
|
||||
|
@ -112,9 +110,7 @@ fn (re RE) get_char(in_txt string, i int) (u32,int) {
|
|||
[inline]
|
||||
fn (re RE) get_charb(in_txt byteptr, i int) (u32,int) {
|
||||
// ascii 8 bit
|
||||
if (re.flag & f_bin) !=0 ||
|
||||
unsafe {in_txt[i]} & 0x80 == 0
|
||||
{
|
||||
if (re.flag & f_bin) !=0 || unsafe {in_txt[i]} & 0x80 == 0 {
|
||||
return u32(unsafe {in_txt[i]}), 1
|
||||
}
|
||||
// unicode char
|
||||
|
@ -131,11 +127,11 @@ fn (re RE) get_charb(in_txt byteptr, i int) (u32,int) {
|
|||
[inline]
|
||||
fn is_alnum(in_char byte) bool {
|
||||
mut tmp := in_char - `A`
|
||||
if tmp >= 0x00 && tmp <= 25 { return true }
|
||||
if tmp <= 25 { return true }
|
||||
tmp = in_char - `a`
|
||||
if tmp >= 0x00 && tmp <= 25 { return true }
|
||||
if tmp <= 25 { return true }
|
||||
tmp = in_char - `0`
|
||||
if tmp >= 0x00 && tmp <= 9 { return true }
|
||||
if tmp <= 9 { return true }
|
||||
if tmp == `_` { return true }
|
||||
return false
|
||||
}
|
||||
|
@ -158,7 +154,7 @@ fn is_not_space(in_char byte) bool {
|
|||
[inline]
|
||||
fn is_digit(in_char byte) bool {
|
||||
tmp := in_char - `0`
|
||||
return tmp <= 0x09 && tmp >= 0
|
||||
return tmp <= 0x09
|
||||
}
|
||||
|
||||
[inline]
|
||||
|
@ -179,13 +175,13 @@ fn is_not_wordchar(in_char byte) bool {
|
|||
[inline]
|
||||
fn is_lower(in_char byte) bool {
|
||||
tmp := in_char - `a`
|
||||
return tmp >= 0x00 && tmp <= 25
|
||||
return tmp <= 25
|
||||
}
|
||||
|
||||
[inline]
|
||||
fn is_upper(in_char byte) bool {
|
||||
tmp := in_char - `A`
|
||||
return tmp >= 0x00 && tmp <= 25
|
||||
return tmp <= 25
|
||||
}
|
||||
|
||||
pub fn (re RE) get_parse_error_string(err int) string {
|
||||
|
@ -920,7 +916,6 @@ pub fn (mut re RE) compile(in_txt string) (int,int) {
|
|||
fn (mut re RE) impl_compile(in_txt string) (int,int) {
|
||||
mut i := 0 // input string index
|
||||
mut pc := 0 // program counter
|
||||
mut tmp_code := u32(0)
|
||||
|
||||
// group management variables
|
||||
mut group_count := -1
|
||||
|
@ -932,7 +927,6 @@ fn (mut re RE) impl_compile(in_txt string) (int,int) {
|
|||
|
||||
i = 0
|
||||
for i < in_txt.len {
|
||||
tmp_code = u32(0)
|
||||
mut char_tmp := u32(0)
|
||||
mut char_len := 0
|
||||
//println("i: ${i:3d} ch: ${in_txt.str[i]:c}")
|
||||
|
@ -1502,8 +1496,10 @@ pub fn (mut re RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
|
|||
mut ist := rune(0) // actual instruction
|
||||
mut l_ist :=rune(0) // last matched instruction
|
||||
|
||||
mut group_stack := [-1].repeat(re.group_max)
|
||||
mut group_data := [-1].repeat(re.group_max)
|
||||
//mut group_stack := [-1].repeat(re.group_max)
|
||||
//mut group_data := [-1].repeat(re.group_max)
|
||||
mut group_stack := []int{len: re.group_max, init: -1}
|
||||
mut group_data := []int{len: re.group_max, init: -1}
|
||||
|
||||
mut group_index := -1 // group id used to know how many groups are open
|
||||
|
||||
|
@ -1962,7 +1958,7 @@ pub fn (mut re RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
|
|||
/***********************************
|
||||
* Quantifier management
|
||||
***********************************/
|
||||
// ist_quant_ng
|
||||
// ist_quant_ng => quantifier negative test on group
|
||||
if m_state == .ist_quant_ng {
|
||||
|
||||
// we are finished here
|
||||
|
@ -2039,7 +2035,7 @@ pub fn (mut re RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
|
|||
return err_internal_error, i
|
||||
|
||||
}
|
||||
// ist_quant_pg
|
||||
// ist_quant_pg => quantifier positive test on group
|
||||
else if m_state == .ist_quant_pg {
|
||||
//println(".ist_quant_pg")
|
||||
mut tmp_pc := pc
|
||||
|
@ -2084,7 +2080,7 @@ pub fn (mut re RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
|
|||
return err_internal_error, i
|
||||
}
|
||||
|
||||
// ist_quant_n
|
||||
// ist_quant_n => quantifier negative test on token
|
||||
else if m_state == .ist_quant_n {
|
||||
rep := re.prog[pc].rep
|
||||
//println("Here!! PC $pc is_next_or: ${re.prog[pc].next_is_or}")
|
||||
|
@ -2125,7 +2121,7 @@ pub fn (mut re RE) match_base(in_txt byteptr, in_txt_len int ) (int,int) {
|
|||
//return no_match_found, 0
|
||||
}
|
||||
|
||||
// ist_quant_p
|
||||
// ist_quant_p => quantifier positive test on token
|
||||
else if m_state == .ist_quant_p {
|
||||
// exit on first match
|
||||
if (re.flag & f_efm) != 0 {
|
||||
|
|
Loading…
Reference in New Issue