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

gcc7 fall-through warning (and fix) #2

Closed
sgbeal opened this issue Nov 24, 2018 · 3 comments
Closed

gcc7 fall-through warning (and fix) #2

sgbeal opened this issue Nov 24, 2018 · 3 comments

Comments

@sgbeal
Copy link

sgbeal commented Nov 24, 2018

gcc7, in its infinite braindeadedness, warns when a switch's case statement will fall through, and this causes 1 warning in regexp.c:

egexp.c:125:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
   case 0: die("unterminated escape sequence");
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In this case it's trivial to solve by adding:

; return 0

after the call to die(). It won't ever return, so the return is harmless.

That said: the use of die() makes this code ill-suited for use in a library :( - we can't kill the app just because a user inputs an invalid regex:

[stephan@host:~/cvs/minilibs]$ ./test_regexp.exe '\bbl(e+)p\b\' 'foo bar bleep baz bleeeeep'
regcomp: unterminated escape sequence

If you can tell that this code is public domain, MIT, or has a similar non-viral license, i will refactor it for use as a library and contribute the changes back to you.

@sgbeal
Copy link
Author

sgbeal commented Nov 24, 2018

Nevermind: this is addressed (indirectly) by issue #1. i'll take a look at the copy to linked there.

@sgbeal sgbeal closed this as completed Nov 24, 2018
@ccxvii
Copy link
Owner

ccxvii commented Nov 24, 2018

The die() function call just longjmps to an error handler in regcomp, which returns an error code to the user.

The version in mujs is thread safe by putting all the "global" state on the stack, so is likely of more use to you.

@sgbeal
Copy link
Author

sgbeal commented Nov 24, 2018

Definitely - i have already extracted it and will start hacking it for use with my library later today. :)

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

No branches or pull requests

2 participants