diff mbox series

conform/conformtest.pl: Escape literal braces in regular expressions

Message ID 20180706132927.DA37843994575@oldenburg.str.redhat.com
State New
Headers show
Series conform/conformtest.pl: Escape literal braces in regular expressions | expand

Commit Message

Florian Weimer July 6, 2018, 1:29 p.m. UTC
This suppresses Perl warnings like these:

Unescaped left brace in regex is deprecated here (and will be fatal in
Perl 5.32), passed through in regex; marked by <-- HERE in m/^element
*({ <-- HERE ([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*)
*(.*)/ at conformtest.pl line 370.

2018-07-06  Florian Weimer  <fweimer@redhat.com>

	* conform/conformtest.pl (checknamespace): Escape literal braces
	in regular expressions.

Comments

Carlos O'Donell July 6, 2018, 2:26 p.m. UTC | #1
On 07/06/2018 09:29 AM, Florian Weimer wrote:
> This suppresses Perl warnings like these:
> 
> Unescaped left brace in regex is deprecated here (and will be fatal in
> Perl 5.32), passed through in regex; marked by <-- HERE in m/^element
> *({ <-- HERE ([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*)
> *(.*)/ at conformtest.pl line 370.
> 
> 2018-07-06  Florian Weimer  <fweimer@redhat.com>
> 
> 	* conform/conformtest.pl (checknamespace): Escape literal braces
> 	in regular expressions.
Please commit.

You should feel free to check something like this in without review,
particularly if it fixes a direct warning. If someone wants to rewrite
this in python, or in a different way in perl, then they can always
follow up with another patch.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Joseph Myers July 18, 2018, 4:38 p.m. UTC | #2
On Fri, 6 Jul 2018, Carlos O'Donell wrote:

> You should feel free to check something like this in without review,
> particularly if it fixes a direct warning. If someone wants to rewrite

Agreed.

> this in python, or in a different way in perl, then they can always
> follow up with another patch.

I support the idea of moving the various functionality using perl to 
python (this is not volunteering to rewrite it all, though if we had 
consensus for such a change I might well end up doing it for the math/ and 
conform/ pieces).
Carlos O'Donell July 18, 2018, 5:39 p.m. UTC | #3
On 07/18/2018 12:38 PM, Joseph Myers wrote:
> On Fri, 6 Jul 2018, Carlos O'Donell wrote:
> 
>> You should feel free to check something like this in without review,
>> particularly if it fixes a direct warning. If someone wants to rewrite
> 
> Agreed.
> 
>> this in python, or in a different way in perl, then they can always
>> follow up with another patch.
> 
> I support the idea of moving the various functionality using perl to 
> python (this is not volunteering to rewrite it all, though if we had 
> consensus for such a change I might well end up doing it for the math/ and 
> conform/ pieces).

Python is turning out to be easier to maintain than perl.

We see more volunteers with python experience than perl.

I am strongly in favour of migrating perl or awk scripts to python and shell.
Adhemerval Zanella Netto July 18, 2018, 7:27 p.m. UTC | #4
On 18/07/2018 14:39, Carlos O'Donell wrote:
> On 07/18/2018 12:38 PM, Joseph Myers wrote:
>> On Fri, 6 Jul 2018, Carlos O'Donell wrote:
>>
>>> You should feel free to check something like this in without review,
>>> particularly if it fixes a direct warning. If someone wants to rewrite
>>
>> Agreed.
>>
>>> this in python, or in a different way in perl, then they can always
>>> follow up with another patch.
>>
>> I support the idea of moving the various functionality using perl to 
>> python (this is not volunteering to rewrite it all, though if we had 
>> consensus for such a change I might well end up doing it for the math/ and 
>> conform/ pieces).
> 
> Python is turning out to be easier to maintain than perl.
> 
> We see more volunteers with python experience than perl.
> 
> I am strongly in favour of migrating perl or awk scripts to python and shell.
> 

+1
Zack Weinberg July 18, 2018, 7:34 p.m. UTC | #5
On Wed, Jul 18, 2018 at 3:27 PM, Adhemerval Zanella
<adhemerval.zanella@linaro.org> wrote:
> On 18/07/2018 14:39, Carlos O'Donell wrote:
>> On 07/18/2018 12:38 PM, Joseph Myers wrote:
>>> On Fri, 6 Jul 2018, Carlos O'Donell wrote:
>>>
>>>> You should feel free to check something like this in without review,
>>>> particularly if it fixes a direct warning. If someone wants to rewrite
>>>
>>> Agreed.
>>>
>>>> this in python, or in a different way in perl, then they can always
>>>> follow up with another patch.
>>>
>>> I support the idea of moving the various functionality using perl to
>>> python (this is not volunteering to rewrite it all, though if we had
>>> consensus for such a change I might well end up doing it for the math/ and
>>> conform/ pieces).
>>
>> Python is turning out to be easier to maintain than perl.
>>
>> We see more volunteers with python experience than perl.
>>
>> I am strongly in favour of migrating perl or awk scripts to python and shell.
>>
>
> +1

Strike out "and shell" and I'll endorse this plan too :)

zw
Joseph Myers July 18, 2018, 9:03 p.m. UTC | #6
On Wed, 18 Jul 2018, Carlos O'Donell wrote:

> I am strongly in favour of migrating perl or awk scripts to python and shell.

For the perl scripts, they are already optional in the build (albeit 
needed to build the manual), so that's a matter of replacing one tool used 
optionally with another.

For the awk scripts, while I'd certainly prefer to maintain such scripts 
in python, many such scripts are also required for the build, and if 
you're adding a new required build dependency, that needs considering much 
more carefully.  (I wouldn't consider there to be such an issue with awk 
scripts used only in individual testcases, even though moving those to 
Python would replace always-supported tests with ones that have a new 
dependency.)

It's entirely possible the new dependency is actually theoretical, in that 
if a broad enough range of python versions is allowed, no-one is actually 
building glibc on a system without python.
Florian Weimer July 18, 2018, 9:12 p.m. UTC | #7
* Joseph Myers:

> I support the idea of moving the various functionality using perl to 
> python (this is not volunteering to rewrite it all, though if we had 
> consensus for such a change I might well end up doing it for the math/ and 
> conform/ pieces).

Can we assume that Python 3 is available?

I spent some time on writing awk code where I would have preferred
Python because I assumed that both Perl and Python were optional, and
that the actual build and most testing should not require anything but
the core build tools and awk.
Joseph Myers July 18, 2018, 10:37 p.m. UTC | #8
On Wed, 18 Jul 2018, Florian Weimer wrote:

> * Joseph Myers:
> 
> > I support the idea of moving the various functionality using perl to 
> > python (this is not volunteering to rewrite it all, though if we had 
> > consensus for such a change I might well end up doing it for the math/ and 
> > conform/ pieces).
> 
> Can we assume that Python 3 is available?

My assumption is that if we require Python for the build, it would allow 
at least any non-EOL version, so 2.7 or 3.4 or later (but as of 
2020-01-01, everything before 3.5 will be EOL).  The existing configure 
test makes no version checks (and makefile code can't readily express a 
condition for a particular test etc. on any more restricted choice of 
version), and install.texi says "Python 2.7.6/3.4.3 or later" for the 
optional uses; 
https://sourceware.org/glibc/wiki/Style_and_Conventions#Code_formatting_in_python_sources 
says "Require python-2.7, but be compatible with python-3.2+".

Scripts not used directly from normal build / test, only for other 
purposes in development, of course already often require Python 3 (all of 
the unicode-gen code, build-many-glibcs.py and list-fixed-bugs.py do so, 
and quite likely other such code).  It's only code that might end up used 
by "make" and "make check" for which greater portability may be a concern.
diff mbox series

Patch

diff --git a/conform/conformtest.pl b/conform/conformtest.pl
index cb500f0e76..a4ef756105 100644
--- a/conform/conformtest.pl
+++ b/conform/conformtest.pl
@@ -367,7 +367,7 @@  while ($#headers >= 0) {
       s/^optional-//;
       $optional = 1;
     }
-    if (/^element *({([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
+    if (/^element *(\{([^}]*)\}|([^{ ]*)) *(\{([^}]*)\}|([^{ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
       my($struct) = "$2$3";
       my($type) = "$5$6";
       my($member) = "$7";
@@ -556,7 +556,7 @@  while ($#headers >= 0) {
 			"Symbol \"$symbol\" has not the right value.", $res,
 			$xfail);
       }
-    } elsif (/^type *({([^}]*)|([a-zA-Z0-9_]*))/) {
+    } elsif (/^type *(\{([^}]*)|([a-zA-Z0-9_]*))/) {
       my($type) = "$2$3";
       my($maybe_opaque) = 0;
 
@@ -586,7 +586,7 @@  while ($#headers >= 0) {
 		    ? "NOT AVAILABLE"
 		    : "Type \"$type\" not available."), $missing, $optional,
 		   $xfail);
-    } elsif (/^tag *({([^}]*)|([a-zA-Z0-9_]*))/) {
+    } elsif (/^tag *(\{([^}]*)|([a-zA-Z0-9_]*))/) {
       my($type) = "$2$3";
 
       # Remember that this name is allowed.
@@ -607,7 +607,7 @@  while ($#headers >= 0) {
 
       compiletest ($fnamebase, "Testing for type $type",
 		   "Type \"$type\" not available.", $missing, 0, $xfail);
-    } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
+    } elsif (/^function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
       my($rettype) = "$2$3";
       my($fname) = "$4";
       my($args) = "$5";
@@ -644,7 +644,7 @@  while ($#headers >= 0) {
 		     "Function \"$fname\" has incorrect type.", $res, 0,
 		     $xfail);
       }
-    } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+    } elsif (/^function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
       my($rettype) = "$2$3";
       my($fname) = "$4";
       my($args) = "$5";
@@ -681,7 +681,7 @@  while ($#headers >= 0) {
 		     "Function \"$fname\" has incorrect type.", $res, 0,
 		     $xfail);
       }
-    } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) *(.*)/) {
+    } elsif (/^variable *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) *(.*)/) {
       my($type) = "$2$3";
       my($vname) = "$4";
       my($rest) = "$5";
@@ -713,7 +713,7 @@  while ($#headers >= 0) {
 
       compiletest ($fnamebase, "Test for type of variable $fname",
 		   "Variable \"$vname\" has incorrect type.", $res, 0, $xfail);
-    } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+    } elsif (/^macro-function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
       my($rettype) = "$2$3";
       my($fname) = "$4";
       my($args) = "$5";
@@ -812,11 +812,11 @@  while ($#headers >= 0) {
 
       s/^xfail(\[([^\]]*)\])?-//;
       s/^optional-//;
-      if (/^element *({([^}]*)}|([^ ]*)) *({([^}]*)}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
+      if (/^element *(\{([^}]*)\}|([^ ]*)) *(\{([^}]*)\}|([^ ]*)) *([A-Za-z0-9_]*) *(.*)/) {
 	push @allow, $7;
       } elsif (/^(macro|constant|macro-constant|macro-int-constant) +([a-zA-Z0-9_]*) *(?:{([^}]*)} *)?(?:([>=<!]+) ([A-Za-z0-9_-]*))?/) {
 	push @allow, $2;
-      } elsif (/^(type|tag) *({([^}]*)|([a-zA-Z0-9_]*))/) {
+      } elsif (/^(type|tag) *(\{([^}]*)|([a-zA-Z0-9_]*))/) {
 	my($type) = "$3$4";
 
 	# Remember that this name is allowed.
@@ -827,13 +827,13 @@  while ($#headers >= 0) {
 	} else {
 	  push @allow, $type;
 	}
-      } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
+      } elsif (/^function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) [(][*]([a-zA-Z0-9_]*) ([(].*[)])/) {
 	push @allow, $4;
-      } elsif (/^function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+      } elsif (/^function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
 	push @allow, $4;
-      } elsif (/^variable *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
+      } elsif (/^variable *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*)/) {
 	push @allow, $4;
-      } elsif (/^macro-function *({([^}]*)}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
+      } elsif (/^macro-function *(\{([^}]*)\}|([a-zA-Z0-9_]*)) ([a-zA-Z0-9_]*) ([(].*[)])/) {
 	push @allow, $4;
       } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) {
 	push @allow, $1;