Skip to content

Autotools: Quote PHP_SUBST arguments in extensions #14748

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
Jul 2, 2024

Conversation

petk
Copy link
Member

@petk petk commented Jul 1, 2024

No description provided.

@alexdowad
Copy link
Contributor

@petk, thanks so much for your work.

Sorry to be a dummy, but can you briefly bring me up to speed on the background of this change? I have hacked on autoconf scripts here and there but don't understand them as well as I should.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

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

Seems sensible to me

@petk
Copy link
Member Author

petk commented Jul 2, 2024

@petk, thanks so much for your work.

Sorry to be a dummy, but can you briefly bring me up to speed on the background of this change? I have hacked on autoconf scripts here and there but don't understand them as well as I should.

Hm, good question. :D Quoting characters in Autoconf take care among other things whether to pass the content in them further or do an early expansion (if in the content there is macro name used it gets expanded earlier). And when there are special characters used (commas etc). In this specific case, there won't be much difference. It's a more like a consistency change at the moment but done more for future - a code style sync with other calls where quotes are used.

To give you some sort of documentation like example. Hm. I'd really have to think about this how to explain simply. This becomes more apparent when macro calls are wrapped inside other macros or in their arguments. These later Autoconf versions from 2.70 on, they also have this slightly differently solved. But mostly the issue comes when dealing with $1 and how to pass that further or to assign it to a variable.

@petk petk merged commit bee84c0 into php:master Jul 2, 2024
10 of 11 checks passed
@petk petk deleted the patch-PHP_SUBST-ext branch July 2, 2024 05:01
petk added a commit to petk/php_zip that referenced this pull request Jul 2, 2024
@petk
Copy link
Member Author

petk commented Jul 2, 2024

So, one very simple but still a bit stupid example of quoting and expansion in effect since Autoconf 2.70 and later versions (I think):

dnl In PHP's configure.ac file, for example.

dnl Define a macro named PHP_FOO, that expands to a some string PHP_BAR.
AC_DEFUN([PHP_FOO], [PHP_BAR])

dnl Define a macro that emits an error with content of the first argument.
AC_DEFUN([PHP_FOO_SUBST], [AC_MSG_NOTICE([m4_normalize([$1])])])

dnl First one is not quoted, second one is:
PHP_FOO_SUBST(PHP_FOO)
PHP_FOO_SUBST([PHP_FOO])

This will output something this:

configure: PHP_BAR
configure: PHP_FOO

However, this all depends on how the PHP_FOO_SUBST is implemented. This is perhaps more noticeable in Autoconf's macros where all sorts of parsing, normalization, expansion etc happens on arguments.

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