Skip to content

Commit

Permalink
8297963: Partially fix string expansion issues in UTIL_DEFUN_NAMED an…
Browse files Browse the repository at this point in the history
…d related macros

Backport-of: f8f46305ef0d1c12154075c7a7d4dc75f91529b5
  • Loading branch information
Ben Taylor authored and Paul Hohensee committed Jan 27, 2023
1 parent 4e5f5de commit 1a38e26
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
8 changes: 4 additions & 4 deletions make/autoconf/flags.m4
Expand Up @@ -489,14 +489,14 @@ UTIL_DEFUN_NAMED([FLAGS_CXX_COMPILER_CHECK_ARGUMENTS],
UTIL_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS],
[*ARGUMENT IF_TRUE IF_FALSE PREFIX], [$@],
[
FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT],
FLAGS_C_COMPILER_CHECK_ARGUMENTS(ARGUMENT: ARG_ARGUMENT,
IF_TRUE: [C_COMP_SUPPORTS="yes"],
IF_FALSE: [C_COMP_SUPPORTS="no"],
PREFIX: [ARG_PREFIX])
FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARG_ARGUMENT],
PREFIX: ARG_PREFIX)
FLAGS_CXX_COMPILER_CHECK_ARGUMENTS(ARGUMENT: ARG_ARGUMENT,
IF_TRUE: [CXX_COMP_SUPPORTS="yes"],
IF_FALSE: [CXX_COMP_SUPPORTS="no"],
PREFIX: [ARG_PREFIX])
PREFIX: ARG_PREFIX)
AC_MSG_CHECKING([if both ARG_PREFIX[CC] and ARG_PREFIX[CXX] support "ARG_ARGUMENT"])
supports=no
Expand Down
45 changes: 25 additions & 20 deletions make/autoconf/util.m4
Expand Up @@ -52,7 +52,7 @@ m4_include([util_paths.m4])
AC_DEFUN([UTIL_DEFUN_NAMED],
[
AC_DEFUN($1, [
m4_foreach(arg, m4_split(m4_normalize($2)), [
m4_foreach([arg], m4_split(m4_normalize($2)), [
m4_if(m4_bregexp(arg, [^\*]), -1,
[
m4_set_add(legal_named_args, arg)
Expand All @@ -64,13 +64,18 @@ AC_DEFUN([UTIL_DEFUN_NAMED],
)
])
m4_foreach([arg], [$3], [
m4_if(m4_bregexp(arg, [: ]), -1, m4_define([arg], m4_bpatsubst(arg, [:], [: ])))
m4_define(arg_name, m4_substr(arg, 0, m4_bregexp(arg, [: ])))
# Delicate quoting and unquoting sequence to ensure the actual value is passed along unchanged
# For details on how this works, see https://git.openjdk.org/jdk/pull/11458#discussion_r1038173051
# WARNING: Proceed at the risk of your own sanity, getting this to work has made me completely
# incapable of feeling love or any other positive emotion
# ~Julian
m4_foreach([arg], m4_dquote(m4_dquote_elt($3)), [
m4_if(m4_index(arg, [: ]), -1, [m4_define([arg], m4_dquote(m4_bpatsubst(m4_dquote(arg), [:], [: ])))])
m4_define(arg_name, m4_substr(arg, 0, m4_index(arg, [: ])))
m4_set_contains(legal_named_args, arg_name, [],[AC_MSG_ERROR([Internal error: m4_if(arg_name, , arg, arg_name) is not a valid named argument to [$1]. Valid arguments are 'm4_set_contents(defined_args, [ ]) m4_set_contents(legal_named_args, [ ])'.])])
m4_set_remove(required_named_args, arg_name)
m4_set_remove(legal_named_args, arg_name)
m4_pushdef([ARG_][]arg_name, m4_bpatsubst(m4_substr(arg, m4_incr(m4_incr(m4_bregexp(arg, [: ])))), [^\s*], []))
m4_pushdef([ARG_][]arg_name, m4_bpatsubst(m4_bpatsubst(m4_dquote(m4_dquote(arg)), arg_name[: ]), [^\s*]))
m4_set_add(defined_args, arg_name)
m4_undefine([arg_name])
])
Expand Down Expand Up @@ -373,18 +378,18 @@ UTIL_DEFUN_NAMED([UTIL_ARG_ENABLE],
m4_define(ARG_GIVEN, m4_translit(ARG_NAME, [a-z-], [A-Z_])[_GIVEN])
# If DESC is not specified, set it to a generic description.
m4_define([ARG_DESC], m4_if(ARG_DESC, , [Enable the ARG_NAME feature], m4_normalize(ARG_DESC)))
m4_define([ARG_DESC], m4_if(m4_quote(ARG_DESC), , [[Enable the ARG_NAME feature]], [m4_normalize(ARG_DESC)]))
# If CHECKING_MSG is not specified, set it to a generic description.
m4_define([ARG_CHECKING_MSG], m4_if(ARG_CHECKING_MSG, , [for --enable-ARG_NAME], m4_normalize(ARG_CHECKING_MSG)))
m4_define([ARG_CHECKING_MSG], m4_if(m4_quote(ARG_CHECKING_MSG), , [[for --enable-ARG_NAME]], [m4_normalize(ARG_CHECKING_MSG)]))
# If the code blocks are not given, set them to the empty statements to avoid
# tripping up bash.
m4_define([ARG_CHECK_AVAILABLE], m4_if(ARG_CHECK_AVAILABLE, , :, ARG_CHECK_AVAILABLE))
m4_define([ARG_IF_GIVEN], m4_if(ARG_IF_GIVEN, , :, ARG_IF_GIVEN))
m4_define([ARG_IF_NOT_GIVEN], m4_if(ARG_IF_NOT_GIVEN, , :, ARG_IF_NOT_GIVEN))
m4_define([ARG_IF_ENABLED], m4_if(ARG_IF_ENABLED, , :, ARG_IF_ENABLED))
m4_define([ARG_IF_DISABLED], m4_if(ARG_IF_DISABLED, , :, ARG_IF_DISABLED))
m4_if(ARG_CHECK_AVAILABLE, , [m4_define([ARG_CHECK_AVAILABLE], [:])])
m4_if(ARG_IF_GIVEN, , [m4_define([ARG_IF_GIVEN], [:])])
m4_if(ARG_IF_NOT_GIVEN, , [m4_define([ARG_IF_NOT_GIVEN], [:])])
m4_if(ARG_IF_ENABLED, , [m4_define([ARG_IF_ENABLED], [:])])
m4_if(ARG_IF_DISABLED, , [m4_define([ARG_IF_DISABLED], [:])])
##########################
# Part 2: Set up autoconf shell code
Expand Down Expand Up @@ -647,21 +652,21 @@ UTIL_DEFUN_NAMED([UTIL_ARG_WITH],
m4_define(ARG_GIVEN, m4_translit(ARG_NAME, [a-z-], [A-Z_])[_GIVEN])
# If DESC is not specified, set it to a generic description.
m4_define([ARG_DESC], m4_if(ARG_DESC, , [Give a value for the ARG_NAME feature], m4_normalize(ARG_DESC)))
m4_define([ARG_DESC], m4_if(m4_quote(ARG_DESC), , [[Give a value for the ARG_NAME feature]], [m4_normalize(ARG_DESC)]))
# If CHECKING_MSG is not specified, set it to a generic description.
m4_define([ARG_CHECKING_MSG], m4_if(ARG_CHECKING_MSG, , [for --with-ARG_NAME], m4_normalize(ARG_CHECKING_MSG)))
m4_define([ARG_CHECKING_MSG], m4_if(m4_quote(ARG_CHECKING_MSG), , [[for --with-ARG_NAME]], [m4_normalize(ARG_CHECKING_MSG)]))
m4_define([ARG_HAS_AUTO_BLOCK], m4_if(ARG_IF_AUTO, , false, true))
# If the code blocks are not given, set them to the empty statements to avoid
# tripping up bash.
m4_define([ARG_CHECK_AVAILABLE], m4_if(ARG_CHECK_AVAILABLE, , :, ARG_CHECK_AVAILABLE))
m4_define([ARG_CHECK_VALUE], m4_if(ARG_CHECK_VALUE, , :, ARG_CHECK_VALUE))
m4_define([ARG_CHECK_FOR_FILES], m4_if(ARG_CHECK_FOR_FILES, , :, ARG_CHECK_FOR_FILES))
m4_define([ARG_IF_AUTO], m4_if(ARG_IF_AUTO, , :, ARG_IF_AUTO))
m4_define([ARG_IF_GIVEN], m4_if(ARG_IF_GIVEN, , :, ARG_IF_GIVEN))
m4_define([ARG_IF_NOT_GIVEN], m4_if(ARG_IF_NOT_GIVEN, , :, ARG_IF_NOT_GIVEN))
m4_if(ARG_CHECK_AVAILABLE, , [m4_define([ARG_CHECK_AVAILABLE], [:])])
m4_if(ARG_CHECK_VALUE, , [m4_define([ARG_CHECK_VALUE], [:])])
m4_if(ARG_CHECK_FOR_FILES, , [m4_define([ARG_CHECK_FOR_FILES], [:])])
m4_if(ARG_IF_AUTO, , [m4_define([ARG_IF_AUTO], [:])])
m4_if(ARG_IF_GIVEN, , [m4_define([ARG_IF_GIVEN], [:])])
m4_if(ARG_IF_NOT_GIVEN, , [m4_define([ARG_IF_NOT_GIVEN], [:])])
##########################
# Part 2: Set up autoconf shell code
Expand Down

3 comments on commit 1a38e26

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@RealCLanger
Copy link
Contributor

Choose a reason for hiding this comment

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

/backport jdk11u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 1a38e26 Feb 15, 2023

Choose a reason for hiding this comment

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

@RealCLanger the backport was successfully created on the branch RealCLanger-backport-1a38e26e in my personal fork of openjdk/jdk11u-dev. To create a pull request with this backport targeting openjdk/jdk11u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 1a38e26e from the openjdk/jdk17u-dev repository.

The commit being backported was authored by Ben Taylor on 27 Jan 2023 and had no reviewers.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk11u-dev:

$ git fetch https://github.com/openjdk-bots/jdk11u-dev RealCLanger-backport-1a38e26e:RealCLanger-backport-1a38e26e
$ git checkout RealCLanger-backport-1a38e26e
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk11u-dev RealCLanger-backport-1a38e26e

Please sign in to comment.