Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pierreganty opened this issue Jun 7, 2024 · 3 comments
Open
Labels

Comments

@pierreganty
Copy link

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
Copy link
Owner

katef commented Aug 24, 2024

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
Copy link
Owner

katef commented Aug 24, 2024

Also a good case:

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

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

katef added a commit that referenced this issue Aug 24, 2024
Previously this gave:
```
; ./build/bin/re -r literal -G 3 abc
; ./build/bin/re -r literal -G 4 abc
abc
;
```
and now -G 3 does construct "abc" (not including the newline, which is a property of the printing, not of the constructed string):
```
; ./build/bin/re -r literal -G 3 abc
abc
; ./build/bin/re -r literal -G 4 abc
abc
;
```

and:
```
; ./build/bin/re -r native -G 3 '^x+$'
x
xx
xxx
```

Spotted by @pierreganty (#478), thank you
@pierreganty
Copy link
Author

Nice! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants