diff --git a/src/perl/make_xmlwritecode.pl b/src/perl/make_xmlwritecode.pl --- a/src/perl/make_xmlwritecode.pl +++ b/src/perl/make_xmlwritecode.pl @@ -36,23 +36,23 @@ open prlist, "ls *.pro |"; @projectfiles = (); while () { - chomp; - push @projectfiles, $_; + chomp; + push @projectfiles, $_; } if ($#projectfiles > 0) { - print stderr "Oops, I found several project files: "; - for $p (@projectfiles) { - print stderr "$p "; - } - print stderr "\n"; - print stderr "Please make sure you have only one, and try again\n"; - exit(1); + print stderr "Oops, I found several project files: "; + for $p (@projectfiles) { + print stderr "$p "; + } + print stderr "\n"; + print stderr "Please make sure you have only one, and try again\n"; + exit(1); } if ($#projectfiles < 0) { - print stderr "No project files found. Please add a project file.\n"; - exit(1); + print stderr "No project files found. Please add a project file.\n"; + exit(1); } $project = $projectfiles[0]; @@ -64,35 +64,35 @@ print stderr "Using project file \"$proj open pfile,"<$project"; my @targets = (); while () { - if (/^[ \t]*TARGET/) { - my @line = split(/=/); - my $target = $line[1]; - chomp $target; - $target =~ s/[ \t]//g; - push @targets, $target; - } - if (/^[ \t]*REACTIONS/) { - my @line = split(/=/); - my $reaction = $line[1]; - chomp $reaction; - $reaction =~ s/[ \t]//g; - push @reactions, $reaction; - } + if (/^[ \t]*TARGET/) { + my @line = split(/=/); + my $target = $line[1]; + chomp $target; + $target =~ s/[ \t]//g; + push @targets, $target; + } + if (/^[ \t]*REACTIONS/) { + my @line = split(/=/); + my $reaction = $line[1]; + chomp $reaction; + $reaction =~ s/[ \t]//g; + push @reactions, $reaction; + } } if ($#targets > 0) { - print stderr "Too many targets found: "; - for $t (@targets) { - print stderr "$t "; - } - print stderr "\n"; - exit(1); + print stderr "Too many targets found: "; + for $t (@targets) { + print stderr "$t "; + } + print stderr "\n"; + exit(1); } if ($#targets < 0) { - print stderr "No targets found in project $project\n"; - exit(1); + print stderr "No targets found in project $project\n"; + exit(1); } $target = $targets[0]; @@ -100,17 +100,17 @@ if ($#targets < 0) { print "Target is $target\n"; if ($#reactions > 0) { - print stderr "Too many reactions found: "; - for $t (@reactions) { - print stderr "$t "; - } - print stderr "\n"; - exit(1); + print stderr "Too many reactions found: "; + for $t (@reactions) { + print stderr "$t "; + } + print stderr "\n"; + exit(1); } if ($#reactions < 0) { - print stderr "No reactions found in project $project\n"; - exit(1); + print stderr "No reactions found in project $project\n"; + exit(1); } $reaction = $reactions[0]; @@ -171,53 +171,54 @@ print xmlsrc <) { - chomp; - s/\\/\\\\/g; - s/\"/\\\"/g; - s/\&/\&/g; - $str.=$_."\\n"; - } - $str .= "\";\n"; - return $str; -} + my $fname = shift; + my $str = ""; + + open srcfile, "<$fname"; + while () { + chomp; + s/\\/\\\\/g; + s/\"/\\\"/g; + s/\&/\&/g; + $str.=$_."\\n"; + } + $str .= "\";\n"; + return $str; + } -print xmlsrc "xmlChar *sourcecode = (xmlChar *)\"".construct_string_constant_from_file( "$mainsource" ); - print xmlsrc <