X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=apps%2Firssi%2Fsyntax.pl;fp=apps%2Firssi%2Fsyntax.pl;h=f0ec779b3e31fc57f5c9e98ece8114bfc330a6d8;hb=23c5df1c8b0bfe539d3fa65802186e6e09e044aa;hp=0000000000000000000000000000000000000000;hpb=0f9738ce962b8498bbed0a75d5fb6fa127e3577f;p=silc.git diff --git a/apps/irssi/syntax.pl b/apps/irssi/syntax.pl new file mode 100755 index 00000000..f0ec779b --- /dev/null +++ b/apps/irssi/syntax.pl @@ -0,0 +1,57 @@ +#!/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 ('*'). +$SRC_PATH='src'; + +$FOO = `find src -name '*.c' -exec perl findsyntax.pl \{\} \\; | sed 's/.*SYNTAX: //' > irssi_syntax`; + +while () { + next if (/Makefile/); + + open (FILE, "$_"); + @data = ; + close (FILE); + $count = 0; + foreach $DATARIVI (@data) { + if ($DATARIVI =~ /\@SYNTAX\:(.+)\@/) { + $etsittava = "\U$1 "; + $SYNTAX = `grep \'^$etsittava\' irssi_syntax`; + $SYNTAX =~ s/\*\///g; + $SYNTAX =~ s/ *$//; $SYNTAX =~ s/ *\n/\n/g; + + # 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/%\|$//; + $DATARIVI = $SYNTAX; + } elsif ($DATARIVI =~ /^\S+/) { + if ($data[$count+1] =~ /^\S+/) { + chomp $DATARIVI; + $DATARIVI =~ s/ *$//g; + $DATARIVI .= " "; + } + } else { + $DATARIVI =~ s/^\t/ / while ($DATARIVI =~ /^\t/); + } + $count++; + } + + # must always end with empty line + push @data, "\n" if ($data[@data-1] ne "\n"); + push @data, "\n" if ($data[@data-2] !~ /\n$/); + + $newfilename = $_; $newfilename =~ s/\.in$//; + $newfilename =~ s/\/in\//\//; + open (NEWFILE, ">$newfilename"); + print NEWFILE @data; + close (NEWFILE); +} +unlink "irssi_syntax";