#464122 perl-byacc: byacc incorrectly escapes '%' in printf thus creating erroneous bless line in new()

Package:
perl-byacc
Source:
perl-byacc
Description:
Berkeley LALR parser generator, Perl version
Submitter:
Bartek Kania
Date:
2024-04-25 13:12:03 UTC
Severity:
important
#464122#5
Date:
2008-02-05 09:31:07 UTC
From:
To:
On line 87 the following line is present:
   fprintf(code_file, "  my %s $p = bless [\\%FIELDS], $_[0];\n",
this does not escape the % correctly and as such fprintf() interprets it
as the control sequence %F.
The fix is to change % to %% resulting in the following line:
   fprintf(code_file, "  my %s $p = bless [\\%%FIELDS], $_[0];\n",

#464122#10
Date:
2008-02-05 09:34:48 UTC
From:
To:
Hi!

Forgot to specify that the problem is in output.c

/B

#464122#15
Date:
2024-04-25 13:14:22 UTC
From:
To:
[Bartek Kania 2008-02-05]

I suspect the patch you propose is this one:

diff --git a/output.c b/output.c
index dbd85be..b0ab93b 100644
--- a/output.c
+++ b/output.c
@@ -84,7 +84,7 @@ void output()
     if (language == PERL) {
       fprintf(code_file, "sub new {\n");
       if (perl5005flag) {
-	fprintf(code_file, "  my %s $p = bless [\\%FIELDS], $_[0];\n",
+	fprintf(code_file, "  my %s $p = bless [\\%%FIELDS], $_[0];\n",
 		perl_package);
       }
       else {


Unfortunately I do not have any way to test if it work or not.  Do you
have some test files that can be used to demonstrate the problem?