Skip to content

Declare ext/mbstring constants in stubs #8798

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

Merged
merged 1 commit into from
Jun 23, 2022

Conversation

kocsismate
Copy link
Member

No description provided.

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Looks good overall to me. I wonder, though, whether we want to use some macro expansion trickery to get the MB_ONIGURUMA_VERSION value, instead of assembling it via runtime.

@alexdowad may also want to review.

@alexdowad
Copy link
Contributor

Thanks, looks good.

@kocsismate
Copy link
Member Author

Thank you! Looks good overall to me. I wonder, though, whether we want to use some macro expansion trickery to get the MB_ONIGURUMA_VERSION value, instead of assembling it via runtime.

I like the idea, and I wasn't pleased that I had to add a global variable. However, I didn't manage to make the macro expansion trickery work. :(

@cmb69
Copy link
Member

cmb69 commented Jun 18, 2022

@kocsismate, you can do something like:

#define STR_HELPER(x) #x
#define STR(x) STR_HELPER(x)
#define PHP_ONIGURUMA_VERSION STR(ONIGURUMA_VERSION_MAJOR) "." STR(ONIGURUMA_VERSION_MINOR) "." STR(ONIGURUMA_VERSION_TEENY)

The STR_HELPER() and STR() macros might be useful for other cases as well, so they might generally be provided (somewhere in Zend/) and renamed (ZEND_ prefix).

@kocsismate
Copy link
Member Author

you can do something like:

Thank you for the suggestion, but that's exactly what I tried. Unfortunately, I got the constant names printed instead of the values. I don't have any idea what causes this.

@cmb69
Copy link
Member

cmb69 commented Jun 20, 2022

Unfortunately, I got the constant names printed instead of the values. I don't have any idea what causes this.

It works for me on Windows (MSVC) and Debian (WSL; gcc). Are you sure that you're using the indirection? The following is supposed to show the constant names:

#define STR(x) #x
#define PHP_ONIGURUMA_VERSION STR(ONIGURUMA_VERSION_MAJOR) "." STR(ONIGURUMA_VERSION_MINOR) "." STR(ONIGURUMA_VERSION_TEENY)

@kocsismate
Copy link
Member Author

Are you sure that you're using the indirection?

Yes, sure! I've just tried to use the original PHP_ONIGURUMA_VERSION inside the PHP_MINFO_FUNCTION(mb_regex), and it worked, but it still didn't work as constant value.

@cmb69
Copy link
Member

cmb69 commented Jun 21, 2022

Oh, indeed, there is an inclusion (order) issue. PHP_MB_ONIGURUMA_VERSION would need to be defined in a compilation unit where ONIGURUMA_VERSION_* are defined, and where mbstring_arginfo.h is included. That's likely not really viable; it might be an option to split off a mbregex.stub.php; or just leave it as is.

@kocsismate
Copy link
Member Author

I'm going to simply go with the current solution :)

@kocsismate kocsismate merged commit 56137cd into php:master Jun 23, 2022
@kocsismate kocsismate deleted the const-mbstring branch June 23, 2022 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants