From de7db72c0433683482944a2a05c140814ff9dbf5 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Mon, 23 Jan 2023 12:46:15 -0800 Subject: [PATCH] applets/c2english: fix issue parsing `int *(foo)[5]` --- applets/c2english/CGrammar.pm | 6 +++++- applets/c2english/c2eng.pl | 19 +++++++++++-------- lib/PBot/VERSION.pm | 4 ++-- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/applets/c2english/CGrammar.pm b/applets/c2english/CGrammar.pm index 934d9455..e99db12d 100755 --- a/applets/c2english/CGrammar.pm +++ b/applets/c2english/CGrammar.pm @@ -1,7 +1,7 @@ # C-to-English Grammar # Pragmatic Software -# SPDX-FileCopyrightText: 2021 Pragmatic Software +# SPDX-FileCopyrightText: 2023 Pragmatic Software # SPDX-License-Identifier: MIT { @@ -1367,6 +1367,10 @@ direct_declarator: } | '(' declarator ')' array_declarator(s) { + if (ref $item{declarator} ne 'ARRAY') { + $item{declarator} = [$item{declarator}]; + } + push @{$item{declarator}}, join(' ', @{$item{'array_declarator(s)'}}); $item{declarator} } diff --git a/applets/c2english/c2eng.pl b/applets/c2english/c2eng.pl index 658d2a03..9ab50216 100755 --- a/applets/c2english/c2eng.pl +++ b/applets/c2english/c2eng.pl @@ -1,6 +1,6 @@ #!/usr/bin/env perl -# SPDX-FileCopyrightText: 2021 Pragmatic Software +# SPDX-FileCopyrightText: 2023 Pragmatic Software # SPDX-License-Identifier: MIT use strict; @@ -47,11 +47,14 @@ sub istrue { } sub main { - my ($opt_T, $opt_t, $opt_o, $opt_P); - getopts('TPto:'); + my %opts; - if ($opt_T ) { - $::RD_TRACE = 1; + getopts('TPo:', \%opts); + + + if ($opts{T}) { + print STDERR "Tracing enabled.\n"; + $::RD_TRACE = 1; } $::RD_HINT = 1; @@ -59,15 +62,15 @@ sub main { my $parser; - if ($opt_P or !eval { require PCGrammar }) { + if ($opts{P} or !eval { require PCGrammar }) { precompile_grammar(); require PCGrammar; } $parser = PCGrammar->new or die "Bad grammar!\n"; - if ($opt_o) { - open(OUTFILE, ">>$opt_o"); + if ($opts{o}) { + open(OUTFILE, ">>$opts{o}"); *STDOUT = *OUTFILE{IO}; } diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 8156bdb0..b544368c 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,8 +25,8 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4603, - BUILD_DATE => "2023-01-22", + BUILD_REVISION => 4604, + BUILD_DATE => "2023-01-23", }; sub initialize {}