3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-09 13:39:34 +01:00
pbot/modules/cdecl.pl
Pragmatic Software 8b8020c301 Update modules
2017-04-10 19:40:14 -07:00

28 lines
878 B
Perl
Executable File

#!/usr/bin/perl -w
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# quick and dirty by :pragma
my $command = join(' ', @ARGV);
my @args = split(' ', $command); # because @ARGV may be one quoted argument
if (@args < 2) {
print "Usage: cdecl <explain|declare|cast|set|...> <code>, see http://linux.die.net/man/1/cdecl (Don't use this command. Use `english` instead.)\n";
die;
}
$command = quotemeta($command);
$command =~ s/\\ / /g;
my $result = `/usr/bin/cdecl -c $command`;
chomp $result;
$result =~ s/\n/, /g;
print $result;
print " (Don't use this command. It can only handle C90 declarations -- poorly. Use `english` instead, which can translate any complete C11 code.)" if $result =~ m/^declare/;
print "\n";