0
  8   ˆl–ßi~”*ClÊ
�rã,ÜªbÑ¿�þC+�•f‡Š@Y ?ŸÉ…žm¦ÈÇÆ ?÷     #!/usr/bin/perl
#
#(c) Copyright 2005-2010  VERSION 1.13 April 26, 2010  
#                    Apostolos Syropoulos   &  R.W.D. Nickalls
#                    asyropoulos@yahoo.com     dick@nickalls.org
#
# This program can be redistributed and/or modified under the terms
# of the LaTeX Project Public License Distributed from CTAN
# archives in directory macros/latex/base/lppl.txt; either
# version 1 of the License, or any later version.
#
package DummyFH;
my $index = 0;
sub TIEHANDLE {
    my $class = shift;
    my $self= shift;
    bless $self, $class;
}
sub READLINE {
    my $self = shift;
    #shift @$self;
    if ($index > $#$self) {
      $index = 0;
      return undef;
    }
    else {
      return $self->[$index++];
    }
}

package main;
use Math::Trig;
our $version_number = "1.13 Apr 26, 2010";
our $commandLineArgs = join(" ", @ARGV);
our $command  = "";
our $curr_in_file = "";
our %PointTable = ();
our %VarTable = ();
our %ConstTable = ();
our $no_errors = 0;
our $xunits = "1pt";
our $yunits = "1pt";
our $units = "pt|pc|in|bp|cm|mm|dd|cc|sp";
our $defaultsymbol = "\$\\bullet\$";
our $defaultLFradius = 0;
use constant PI => atan2(1,1)*4;
use constant R2D => 180 / PI;
use constant D2R => PI / 180;
our $arrowLength = 2;
our $arrowLengthUnits = "mm";
our $arrowAngleB = 30;
our $arrowAngleC = 40; 
our %DimOfPoint = ();
our $GlobalDimOfPoints = 0;
our @Macros = ();
our $LineThickness = 0.4;

  sub mpp {
    my $in_line;
    chomp($in_line = shift);
    my $LC = shift;
    my $out_line = $in_line;
    my $macro_name = "";
    my @macro_param = ();
    my $macro_code = "";
    if ($in_line =~ s/^%def\s*//) {
      if ($in_line =~ s/^(\w+)\s*//){
        $macro_name = $1;
      }
      else {
        PrintErrorMessage("No macro name has been found",$LC);
        return ""
      }
      if ($in_line =~ s/^\(\s*//) {
        # do nothing
      }
      else {
        PrintErrorMessage("No left parenthesis after macro name has been found",$LC);
        return "";
      }
      if ($in_line =~ s/^\)//) {
        # Macro has no parameters!
      }
      else {
        MACROS: while (1) {
          if ($in_line =~ s/^(\w+)\s*//) {
            push (@macro_param, $1);
          }
          else {
            PrintErrorMessage("No macro parameter name has been found",$LC);
            return "";
          }
          if ($in_line =~ s/^,\s*//) {
            next MACROS;
          }
          else {
            last MACROS;
          } 
        }
        if ($in_line =~ s/^\)//) {
          # do nothing!
        }
        else {
          PrintErrorMessage("No closing parenthesis after macro parameters",$LC);
          return "";
        }
      }
      $in_line =~ s/([^%]+)(%.*)/$1/;
      $macro_code = $in_line;
      push ( @Macros , { 'macro_name' => $macro_name,
                         'macro_code' => $macro_code,
                         'macro_param' => \@macro_param }); 
      return $out_line;
    }
    elsif ($in_line =~ s/^%undef\s*//) {
      if ($in_line =~ s/^(\w+)//) {
        my $undef_macro = $1;
        for(my $i = $#Macros; $i >= 0; $i--) {
          if ($Macros[$i]->{'macro_name'} eq $undef_macro) {
           splice(@Macros,$i,1);
          }   
        }
      }
      return $out_line;
    }
    elsif ($in_line =~ s/^\s*%//) {
      return $out_line;
    }
    else {
      my $comment = $2 if $in_line =~ s/([^%]+)(%.+)/$1/;
      EXPANSIONLOOP: while () {
        my $org_in_line = $in_line;
        for(my $i = $#Macros; $i >= 0; $i--) {
          my $macro_name = $Macros[$i]->{'macro_name'};
          if ($in_line =~ /&$macro_name\b/) {       ############################
            my $num_of_macro_args = @{$Macros[$i]->{'macro_param'}};
            if ( $num_of_macro_args > 0 ) { 
            # Macro with parameters
              my $pattern = "&$macro_name\\(";
              foreach my $p ( 1..$num_of_macro_args ) {
                my $comma = ($p == $num_of_macro_args) ? "\\s*" : "\\s*,\\s*";
                $pattern .= "\\s*[^\