Patchwork [Bug,bootstrap/53607] opt-functions.awk --> "awk: There is a regular expression error."

login
register
mail settings
Submitter Daniel Richard G.
Date Jan. 6, 2013, 4:49 p.m.
Message ID <1357490975.23068.140661174083089.5B023E3C@webmail.messagingengine.com>
Download mbox | patch
Permalink /patch/209784/
State New
Headers show

Comments

Daniel Richard G. - Jan. 6, 2013, 4:49 p.m.
This patch addresses a build failure on HP-UX due to the vendor
awk(1) apparently treating a lone curly-brace as an incomplete
repetition operator:

[...]
awk -f /home/src/gcc-4.7.2/gcc/opt-functions.awk -f
/home/src/gcc-4.7.2/gcc/opt-read.awk \
               -f /home/src/gcc-4.7.2/gcc/opth-gen.awk \
               < optionlist > tmp-options.h
awk: There is a regular expression error.
        ?, *, or + not preceded by valid regular expression
 The source line number is 90.
 The error context is
                        if (flags ~ >>>  "^{") <<< 
gmake[3]: *** [s-options-h] Error 2
gmake[3]: Leaving directory `/tmp/gcc-build/gcc'
gmake[2]: *** [all-stage1-gcc] Error 2
gmake[2]: Leaving directory `/tmp/gcc-build'
gmake[1]: *** [stage1-bubble] Error 2
gmake[1]: Leaving directory `/tmp/gcc-build'
gmake: *** [bootstrap-lean] Error 2


Fixed by escaping two curly-braces with backslashes.

Tested by getting past that point in the bootstrap successfully on
hppa2.0w-hp-hpux11.00; formal test case not applicable.

ChangeLog entry:

        PR bootstrap/53607
        * opt-functions.awk: Fix compatibility with HP-UX awk.

Patch: See attached.


--Daniel


On Sun, 2012 Dec 23 3:18+0000, danglin at gcc dot gnu.org wrote:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53607
> 
> --- Comment #1 from John David Anglin <...> 2012-12-23 03:18:19 UTC ---
> Please send patch with ChangeLog to gcc-patches and CC me.  I will
> apply if approved.
> 
> -- 
> Configure bugmail: http://gcc.gnu.org/bugzilla/userprefs.cgi?tab=email
> ------- You are receiving this mail because: -------
> You reported the bug.
Andreas Schwab - Jan. 6, 2013, 5:45 p.m.
"Daniel Richard G." <skunk@iSKUNK.ORG> writes:

> Index: gcc/opt-functions.awk
> ===================================================================
> --- gcc/opt-functions.awk	(revision 194916)
> +++ gcc/opt-functions.awk	(working copy)
> @@ -62,9 +62,9 @@
>  	if (flags !~ " " name "\\(")
>  		return ""
>  	sub(".* " name "\\(", "", flags)
> -	if (flags ~ "^{")
> +	if (flags ~ "^\{")
>  	{
> -		sub ("^{", "", flags)
> +		sub ("^\{", "", flags)
>  		sub("}\\).*", "", flags)

You need to escape the backslash inside a string.

Andreas.

Patch

Index: gcc/opt-functions.awk
===================================================================
--- gcc/opt-functions.awk	(revision 194916)
+++ gcc/opt-functions.awk	(working copy)
@@ -62,9 +62,9 @@ 
 	if (flags !~ " " name "\\(")
 		return ""
 	sub(".* " name "\\(", "", flags)
-	if (flags ~ "^{")
+	if (flags ~ "^\{")
 	{
-		sub ("^{", "", flags)
+		sub ("^\{", "", flags)
 		sub("}\\).*", "", flags)
 	}
 	else