From de3c122337b6bc9ec69308047575b90d64208f3b Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 10 Dec 2017 21:29:56 +0200 Subject: [PATCH 1/2] generate-command-parser.pl: remove trailing comma --- generate-command-parser.pl | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/generate-command-parser.pl b/generate-command-parser.pl index a7687c7b..eeec7dfe 100755 --- a/generate-command-parser.pl +++ b/generate-command-parser.pl @@ -116,17 +116,16 @@ my @keys = sort { (length($b) <=> length($a)) or ($a cmp $b) } keys %states; open(my $enumfh, '>', "GENERATED_${prefix}_enums.h"); -# XXX: we might want to have a way to do this without a trailing comma, but gcc -# seems to eat it. my %statenum; say $enumfh 'typedef enum {'; my $cnt = 0; for my $state (@keys, '__CALL') { - say $enumfh " $state = $cnt,"; + say $enumfh ',' if $cnt > 0; + print $enumfh " $state = $cnt"; $statenum{$state} = $cnt; $cnt++; } -say $enumfh '} cmdp_state;'; +say $enumfh "\n} cmdp_state;"; close($enumfh); # Third step: Generate the call function. From 5225e34b9d76dd4ae114970ab80437c02ea9a2da Mon Sep 17 00:00:00 2001 From: Orestis Floros Date: Sun, 10 Dec 2017 21:30:09 +0200 Subject: [PATCH 2/2] generate-command-parser.pl: remove trailing whitespace --- generate-command-parser.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/generate-command-parser.pl b/generate-command-parser.pl index eeec7dfe..4c45b6ed 100755 --- a/generate-command-parser.pl +++ b/generate-command-parser.pl @@ -224,7 +224,7 @@ for my $state (@keys) { $next_state = '__CALL'; } my $identifier = $token->{identifier}; - say $tokfh qq| { "$token_name", "$identifier", $next_state, { $call_identifier } }, |; + say $tokfh qq| { "$token_name", "$identifier", $next_state, { $call_identifier } },|; } say $tokfh '};'; }