2000-07-26 13:52:19 -04:00
|
|
|
#!/usr/bin/perl
|
|
|
|
#
|
|
|
|
# This script reads the syntaces of commands from irssi source tree.
|
|
|
|
# Then it browses through all '.in' files in the current directory and
|
|
|
|
# substitutes '@SYNTAX:foo@' tags with real syntaces found. This data
|
|
|
|
# is written into the corresponding files without the '.in' extension.
|
|
|
|
# For example: help.in -> ../help
|
|
|
|
#
|
|
|
|
# This path has to be changed. It should point to your irssi/src directory
|
|
|
|
# Remember to include the asterisk ('*').
|
2000-07-31 08:50:57 -04:00
|
|
|
$SRC_PATH='src';
|
2000-07-26 13:52:19 -04:00
|
|
|
|
2015-07-12 13:03:58 -04:00
|
|
|
@files = sort `find src -name '*.c'`;
|
2000-10-17 19:45:00 -04:00
|
|
|
|
2008-11-13 05:22:35 -05:00
|
|
|
foreach $file (@files) {
|
|
|
|
open (FILE, "$file");
|
|
|
|
while (<FILE>) {
|
|
|
|
chomp;
|
|
|
|
if (m!/\*.SYNTAX\:! || $state) {
|
|
|
|
s/^\s+/ /;
|
|
|
|
s/.*SYNTAX: //;
|
|
|
|
if (/^ [A-Z]+/) {
|
|
|
|
push @lines, $line;
|
|
|
|
$line = "";
|
|
|
|
s/^ //;
|
|
|
|
}
|
|
|
|
$line .= $_;
|
|
|
|
if (m!\*/!) {
|
|
|
|
$line =~ s!\*/!!;
|
|
|
|
push @lines, $line;
|
|
|
|
$line = "";
|
|
|
|
$state = 0;
|
|
|
|
} else {
|
|
|
|
$state = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close (FILE);
|
|
|
|
}
|
2000-07-26 13:52:19 -04:00
|
|
|
while (<docs/help/in/*.in>) {
|
2001-01-05 04:38:08 -05:00
|
|
|
next if (/Makefile/);
|
|
|
|
|
2000-07-26 13:52:19 -04:00
|
|
|
open (FILE, "$_");
|
|
|
|
@data = <FILE>;
|
|
|
|
close (FILE);
|
2001-01-05 04:38:08 -05:00
|
|
|
$count = 0;
|
2000-07-26 13:52:19 -04:00
|
|
|
foreach $DATARIVI (@data) {
|
|
|
|
if ($DATARIVI =~ /\@SYNTAX\:(.+)\@/) {
|
2008-11-13 05:22:35 -05:00
|
|
|
$SYNTAX = join "\n", (grep /^\U$1 /, @lines);
|
|
|
|
$SYNTAX .= "\n" if $SYNTAX;
|
2000-10-17 19:45:00 -04:00
|
|
|
$SYNTAX =~ s/ *$//; $SYNTAX =~ s/ *\n/\n/g;
|
2001-01-05 04:38:08 -05:00
|
|
|
|
|
|
|
# add %| after "COMMAND SUB " so parameters will indent correctly
|
|
|
|
$SYNTAX =~ s/^([A-Z ]+)/\1%|/;
|
|
|
|
$SYNTAX =~ s/(\n[A-Z ]+)/\1%|/g;
|
|
|
|
# no need for this if there's no parameters
|
|
|
|
$SYNTAX =~ s/%\|$//;
|
2000-07-26 13:52:19 -04:00
|
|
|
$DATARIVI = $SYNTAX;
|
2001-01-05 04:38:08 -05:00
|
|
|
} elsif ($DATARIVI =~ /^\S+/) {
|
2001-03-03 19:13:06 -05:00
|
|
|
if ($data[$count+1] =~ /^\S+/) {
|
|
|
|
chomp $DATARIVI;
|
|
|
|
$DATARIVI =~ s/ *$//g;
|
|
|
|
$DATARIVI .= " ";
|
|
|
|
}
|
2001-01-05 04:43:38 -05:00
|
|
|
} else {
|
|
|
|
$DATARIVI =~ s/^\t/ / while ($DATARIVI =~ /^\t/);
|
2000-07-26 13:52:19 -04:00
|
|
|
}
|
2001-01-05 04:38:08 -05:00
|
|
|
$count++;
|
2000-07-26 13:52:19 -04:00
|
|
|
}
|
2001-01-05 04:38:08 -05:00
|
|
|
|
|
|
|
# must always end with empty line
|
|
|
|
push @data, "\n" if ($data[@data-1] ne "\n");
|
|
|
|
push @data, "\n" if ($data[@data-2] !~ /\n$/);
|
|
|
|
|
2000-07-26 13:52:19 -04:00
|
|
|
$newfilename = $_; $newfilename =~ s/\.in$//;
|
|
|
|
$newfilename =~ s/\/in\//\//;
|
|
|
|
open (NEWFILE, ">$newfilename");
|
|
|
|
print NEWFILE @data;
|
|
|
|
close (NEWFILE);
|
|
|
|
}
|