The SILC Project

source navigation ]
identifier search ]
freetext search ]
file search ]

silc/irssi/syntax.pl

  1 #!/usr/bin/perl
  2 #
  3 # This script reads the syntaces of commands from irssi source tree.
  4 # Then it browses through all '.in' files in the current directory and
  5 # substitutes '@SYNTAX:foo@' tags with real syntaces found. This data
  6 # is written into the corresponding files without the '.in' extension.
  7 # For example:  help.in -> ../help
  8 #
  9 # This path has to be changed. It should point to your irssi/src directory
 10 # Remember to include the asterisk ('*').
 11 $SRC_PATH='src';
 12 
 13 $FOO = `find src -name '*.c' -exec perl findsyntax.pl \{\} \\; | sed 's/.*SYNTAX: //' > irssi_syntax`;
 14 
 15 while (<docs/help/in/*.in>) {
 16    next if (/Makefile/);
 17 
 18    open (FILE, "$_");
 19    @data = <FILE>;
 20    close (FILE);
 21    $count = 0;
 22    foreach $DATARIVI (@data) {
 23       if ($DATARIVI =~ /\@SYNTAX\:(.+)\@/) {
 24           $etsittava = "\U$1 ";
 25           $SYNTAX = `grep \'^$etsittava\' irssi_syntax`;
 26           $SYNTAX =~ s/\*\///g;
 27           $SYNTAX =~ s/ *$//; $SYNTAX =~ s/ *\n/\n/g;
 28 
 29           # add %| after "COMMAND SUB " so parameters will indent correctly
 30           $SYNTAX =~ s/^([A-Z ]+)/\1%|/;
 31           $SYNTAX =~ s/(\n[A-Z ]+)/\1%|/g;
 32           # no need for this if there's no parameters
 33           $SYNTAX =~ s/%\|$//;
 34           $DATARIVI = $SYNTAX;
 35       } elsif ($DATARIVI =~ /^\S+/) {
 36         if ($data[$count+1] =~ /^\S+/) {
 37           chomp $DATARIVI;
 38           $DATARIVI =~ s/ *$//g;
 39           $DATARIVI .= " ";
 40         }
 41       } else {
 42           $DATARIVI =~ s/^\t/         / while ($DATARIVI =~ /^\t/);
 43       }
 44       $count++;
 45    }
 46 
 47    # must always end with empty line
 48    push @data, "\n" if ($data[@data-1] ne "\n");
 49    push @data, "\n" if ($data[@data-2] !~ /\n$/);
 50 
 51    $newfilename = $_; $newfilename =~ s/\.in$//;
 52    $newfilename =~ s/\/in\//\//;
 53    open (NEWFILE, ">$newfilename");
 54    print NEWFILE @data;
 55    close (NEWFILE);
 56 }
 57 unlink "irssi_syntax";

This page was automatically generated by the LXR engine.
Free-text search provided by Glimpse