dolibarr-doxygen-filter.pl 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #!/usr/bin/perl
  2. #--------------------------------------------------------------------
  3. # \brief This script is a preprocessor for PHP files to be used
  4. # on PHP source files before running Doxygen.
  5. # \author Laurent Destailleur
  6. #--------------------------------------------------------------------
  7. # Usage: dolibarr-doxygen-filter.pl pathtofilefromdolibarrroot
  8. $file=$ARGV[0];
  9. if (! $file)
  10. {
  11. print "Usage: dolibarr-doxygen-filter.pl pathtofilefromdolibarrroot\n";
  12. exit;
  13. }
  14. open(FILE,$file) || die "Failed to open file $file";
  15. while (<FILE>)
  16. {
  17. if ($_ =~ /\\version\s/i)
  18. {
  19. $_ =~ s/\$Id://i;
  20. $_ =~ s/(Exp|)\s\$$//i;
  21. $_ =~ s/(\\version\s+)[^\s]+\s/$1/i;
  22. $_ =~ s/(\w)\s(\w)/$1_$2/g;
  23. }
  24. $_ =~ s/exit\s*;/exit(0);/i;
  25. $i=0;
  26. $len=length($_);
  27. $s="";
  28. $insidequote=0;
  29. $insidedquote=0;
  30. $ignore="";
  31. while ($i < $len)
  32. {
  33. $c=substr($_,$i,1);
  34. if ($c eq "\\")
  35. {
  36. if ($insidequote) { $ignore="'"; };
  37. if ($insidedquote) { $ignore="\""; };
  38. }
  39. else
  40. {
  41. if ($c eq "'")
  42. {
  43. if (! $insidedquote)
  44. {
  45. $c="\"";
  46. #print "X".$ignore;
  47. if ($ignore ne "'")
  48. {
  49. #print "Z".$ignore;
  50. $insidequote++;
  51. if ($insidequote == 2)
  52. {
  53. $insidequote=0;
  54. }
  55. }
  56. }
  57. #print "X".$insidequote;
  58. }
  59. elsif ($c eq "\"")
  60. {
  61. #print "Y".$insidequote;
  62. if ($insidequote)
  63. {
  64. $c="'";
  65. }
  66. else
  67. {
  68. if ($ignore ne "\"")
  69. {
  70. $insidedquote++;
  71. if ($insidedquote == 2)
  72. {
  73. $insidedquote=0;
  74. }
  75. }
  76. }
  77. }
  78. $ignore="";
  79. }
  80. $s.=$c;
  81. $i++;
  82. }
  83. print $s;
  84. }
  85. close(FILE);