12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #!/usr/bin/perl
- #--------------------------------------------------------------------
- # \brief This script is a preprocessor for PHP files to be used
- # on PHP source files before running Doxygen.
- # \author Laurent Destailleur
- #--------------------------------------------------------------------
- # Usage: dolibarr-doxygen-filter.pl pathtofilefromdolibarrroot
- $file=$ARGV[0];
- if (! $file)
- {
- print "Usage: dolibarr-doxygen-filter.pl pathtofilefromdolibarrroot\n";
- exit;
- }
- open(FILE,$file) || die "Failed to open file $file";
- while (<FILE>)
- {
- if ($_ =~ /\\version\s/i)
- {
- $_ =~ s/\$Id://i;
- $_ =~ s/(Exp|)\s\$$//i;
- $_ =~ s/(\\version\s+)[^\s]+\s/$1/i;
- $_ =~ s/(\w)\s(\w)/$1_$2/g;
- }
- $_ =~ s/exit\s*;/exit(0);/i;
- $i=0;
- $len=length($_);
- $s="";
- $insidequote=0;
- $insidedquote=0;
- $ignore="";
- while ($i < $len)
- {
- $c=substr($_,$i,1);
- if ($c eq "\\")
- {
- if ($insidequote) { $ignore="'"; };
- if ($insidedquote) { $ignore="\""; };
- }
- else
- {
- if ($c eq "'")
- {
- if (! $insidedquote)
- {
- $c="\"";
- #print "X".$ignore;
- if ($ignore ne "'")
- {
- #print "Z".$ignore;
- $insidequote++;
- if ($insidequote == 2)
- {
- $insidequote=0;
- }
- }
- }
- #print "X".$insidequote;
- }
- elsif ($c eq "\"")
- {
- #print "Y".$insidequote;
- if ($insidequote)
- {
- $c="'";
- }
- else
- {
- if ($ignore ne "\"")
- {
- $insidedquote++;
- if ($insidedquote == 2)
- {
- $insidedquote=0;
- }
- }
- }
- }
- $ignore="";
- }
- $s.=$c;
- $i++;
- }
- print $s;
- }
- close(FILE);
|