Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8263057

Non-portable m4 regular expression in UTIL_DEFUN_NAMED

XMLWordPrintable

    • other
    • other

      ADDITIONAL SYSTEM INFORMATION :
      Affects systems that use bsd m4 with autoconf configure always fails with an error such as this:

      configure: error: unrecognized options: --disable-ccache
      configure exiting with result code 1

      A DESCRIPTION OF THE PROBLEM :
      JDK-8240820 modified UTIL_DEFUN_NAMED and introduced a non-portable m4 regular expression [^\s*] in the following line:

      ` m4_pushdef([ARG_][]arg_name, m4_bpatsubst(m4_substr(arg, m4_incr(m4_incr(m4_bregexp(arg, [: ])))), [^\s*], []))`

      m4 regular expressions syntax is the same as in gnu emacs [1]. `\s*` is not valid for emacs regular expressions. `\s` in emacs must be followed by a character that designates a particular syntax class [2] and `*` is not one of them [3].

      On systems that use BSD m4 with autoconf the regular expression doesn’t work and causes configure to fail. I tried to find a regular expression that works for both BSD m4 and gnu m4 and they both don’t implement gnu emacs regular expressions fully. I came up with this that works for both: `[^[ ]*]`. The inner brackets contain a space and a tab character.

      In addition to the above the following line was added to insert a space after the colon when a space was missing:

      ` m4_if(m4_bregexp(arg, [: ]), -1, m4_define([arg], m4_bpatsubst(arg, [:], [: ])))`

      On both GNU m4 and BSD m4 this line always adds a space due to the m4_define in the else case being executed in regardless of the m4_if results. This can be reworked as follows which works correctly for both GNU m4 and BSD m4:

      ` m4_define([arg], m4_if(m4_bregexp(arg, [: ]), -1, m4_bpatsubst(arg, [:], [: ]), arg))`

      Although it probably just would be better to not insert a space and match on `[:]` instead of `[: ]` in the subsequent m4_bregexp uses.

      [1] https://www.gnu.org/software/m4/manual/m4-1.4.18/html_node/Patsubst.html
      [2] https://www.gnu.org/software/emacs/manual/html_node/emacs/Regexp-Backslash.html#Regexp-Backslash
      [3] https://www.gnu.org/software/emacs/manual/html_node/elisp/Syntax-Class-Table.html#Syntax-Class-Table


      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: