katef / libfsm

DFA regular expression library & friends
BSD 2-Clause "Simplified" License
931 stars 52 forks source link

Behavior of `-G length` inconsistent, moreover returns error code. #478

Open pierreganty opened 3 months ago

pierreganty commented 3 months ago

Hi,

When asking re for an example of length up to 20 then none is returned. If, for the same regular expression, I ask re to return an example of length 21 then it returns two examples, the first of which has length 20.

Moreover, in both calls re returns 1 which is an error code according to the man page. I am not sure why, though.

: ~/.local/libfsm/bin ; ./re  -b -G20 '([A-Z0-9]+);([^;]+);([^;]+);([0-9]+);([^;]+);([^;]*);([0-9]*);([0-9]*);([-0-9/]*);([YN]);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*)'; echo $?
1
: ~/.local/libfsm/bin ; ./re  -b -G21 '([A-Z0-9]+);([^;]+);([^;]+);([0-9]+);([^;]+);([^;]*);([0-9]*);([0-9]*);([-0-9/]*);([YN]);([^;]*);([^;]*);([^;]*);([^;]*);([^;]*)'; echo $?
0;!;!;0;!;;;;;N;;;;;
0;!;!;0;!;;;;;N;;;;;!
1
katef commented 3 weeks ago

Finally getting to this, sorry it's taken so long!

I think this is a more compelling example:

; ./build/bin/re -r literal -G 3 abc
; ./build/bin/re -r literal -G 4 abc
abc
; 
katef commented 3 weeks ago

Also a good case:

; ./build/bin/re -r literal -G 1 '' 

; ./build/bin/re -r literal -G 1 'x'
; 
pierreganty commented 3 weeks ago

Nice! Thank you.