#!/usr/bin/perl -w use FindBin; use lib "$FindBin::Bin/.."; use General::FileSystem; use POSIX; chdir($FindBin::Bin) || die "Can't chmod $FindBin::Bin: $!\n"; my $functableSrc = "../../fvwm/functable.c"; my $contentRef = loadFile($functableSrc); die "No commands found, so Commands.pm is not generated.\n" unless $contentRef; my $commandEntriesCode = ""; foreach my $entry ($$contentRef =~ m{(?:/\* )?CMD_ENT\(\s*(?:"|PRE_).*?\),(?: \*/)?.*?/\* .*?- .*? \*/}sg) { my ($name, $flags, $cursor, $name2, $descr) = $entry =~ m{ , .*? CMD_(\w+) , .*? , .*? ([\w\s|]+?) , .*? (?:CRS_)?(\w+) .*? \) , .*? /\*\s (?:(.+)\s)? -\s (.*?) \s\*/ }xs; $name = $name2 if $name2; my $window = $flags =~ FUNC_NEEDS_WINDOW? 1: 0; $cursor = "" if $cursor eq "0"; $commandEntriesCode .= "\t{\n\t\tname => '$name',\n\t\tcursor => '$cursor',\n" . "\t\twindow => $window,\n\t\tdescr => q{$descr},\n\t},\n"; } my $version = `egrep '^VERSION = |^VERSIONINFO = ' Makefile | cut -d"=" -f2 \\ | perl -pe 's/^ //;s/\\n//'`; my $time = time; my $output = <{name}, \$command->{descr}; } =head1 PUBLIC CONSTANTS =over 4 =item \$VERS The fvwm version number at the generation time like "2.6.0" plus the info that may indicate that this is not a final version, but a cvs snapshot. =item \$TIME The unix time of the command list generation. Example: print "The fvwm command list found on your system was generated " . (time() - \$FVWM::Commands::TIME) / 86400 . " days ago\\n"; =item \@LIST The command list that is an array of hashes with keys I, I, I (string) and I (boolean). I may be special, like "+", "#" and "*". Other names usually contain only isalpha characters, like B, B. I may be either empty or the cursor context used in B (like "SELECT" or "MOVE"), associated with the command. I is a short one line description of the command. I is true for commands that need a window. Example: # get command names only \@commandNames = map { \$_->{name} } \@FVWM::Commands::LIST; =head1 AUTHOR Mikhael Goikhman . =head1 SEE ALSO For more information about the commands themselves, see fvwm(1). =back =cut ENDOUTPUT # --------------------------------- print "Creating Commands.pm\n"; saveFile("Commands.pm", \$output); # --------------------------------- print "Testing Commands.pm\n"; eval qq{ use lib '$FindBin::Bin/..'; use FVWM::Commands; }; die $@ if $@; $FVWM::Commands::TIME ||= 0; # avoid "used once" warning my $date = strftime("%d-%b-%Y", gmtime($FVWM::Commands::TIME)); my $cmds = "The recognized commands for fvwm $version as of $date:\n\n"; foreach my $command (@FVWM::Commands::LIST = @FVWM::Commands::LIST) { $cmds .= sprintf " %-21s - %s\n", $command->{name}, $command->{descr}; } # --------------------------------- print "Creating ../../docs/COMMANDS\n"; saveFile("../../docs/COMMANDS", \$cmds);