summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelliott_c <ocielliottc@users.noreply.github.com>2003-06-06 14:32:36 +0000
committerelliott_c <ocielliottc@users.noreply.github.com>2003-06-06 14:32:36 +0000
commit065abe4ee96054e270825c8f534f7ba39a32d949 (patch)
treee3378e936d18de8f8618414147e417c1f118fa68
parente019ec7f928327968141506901827b8edc7a668b (diff)
downloadMPC-065abe4ee96054e270825c8f534f7ba39a32d949.tar.gz
ChangeLogTag: Fri Jun 6 09:31:21 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r--modules/ProjectCreator.pm48
-rw-r--r--modules/TemplateParser.pm13
2 files changed, 36 insertions, 25 deletions
diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm
index 4cdfc798..e3f9a5b1 100644
--- a/modules/ProjectCreator.pm
+++ b/modules/ProjectCreator.pm
@@ -298,12 +298,23 @@ sub parse_line {
}
if (defined $file) {
- push(@{$self->{'reading_parent'}}, 1);
- $status = $self->parse_file($file);
- pop(@{$self->{'reading_parent'}});
+ foreach my $currently (@{$self->{'reading_parent'}}) {
+ if ($currently eq $file) {
+ $status = 0;
+ $errorString = 'ERROR: Cyclic inheritance detected: ' .
+ $parent;
+ }
+ }
+
+ if ($status) {
+ ## Begin reading the parent
+ push(@{$self->{'reading_parent'}}, $file);
+ $status = $self->parse_file($file);
+ pop(@{$self->{'reading_parent'}});
- if (!$status) {
- $errorString = "ERROR: Invalid parent: $parent";
+ if (!$status) {
+ $errorString = "ERROR: Invalid parent: $parent";
+ }
}
}
else {
@@ -993,8 +1004,8 @@ sub generate_default_pch_filenames {
if (!defined $self->get_assignment('pch_header')) {
my($count) = 0;
my($matching) = undef;
- foreach my $ext (@{$self->{'valid_components'}->{'header_files'}}) {
- foreach my $file (@$files) {
+ foreach my $file (@$files) {
+ foreach my $ext (@{$self->{'valid_components'}->{'header_files'}}) {
if ($file =~ /(.*_pch$ext)/) {
$self->process_assignment('pch_header', $1);
++$count;
@@ -1013,8 +1024,8 @@ sub generate_default_pch_filenames {
if (!defined $self->get_assignment('pch_source')) {
my($count) = 0;
my($matching) = undef;
- foreach my $ext (@{$self->{'valid_components'}->{'source_files'}}) {
- foreach my $file (@$files) {
+ foreach my $file (@$files) {
+ foreach my $ext (@{$self->{'valid_components'}->{'source_files'}}) {
if ($file =~ /(.*_pch$ext)/) {
$self->process_assignment('pch_source', $1);
++$count;
@@ -1262,6 +1273,10 @@ sub remove_duplicated_files {
my($source) = shift;
my($names) = $self->{$dest};
my(@slist) = $self->get_component_list($source);
+ my(%shash) = ();
+
+ ## Convert the array into keys for a hash table
+ @shash{@slist} = ();
## Find out which source files are listed
foreach my $name (keys %$names) {
@@ -1270,15 +1285,12 @@ sub remove_duplicated_files {
my($array) = $$comps{$key};
my($count) = scalar(@$array);
for(my $i = 0; $i < $count; ++$i) {
- foreach my $sfile (@slist) {
- ## Is the source file in the component array?
- if ($$array[$i] eq $sfile) {
- ## Remove the element and fix the index and count
- splice(@$array, $i, 1);
- --$count;
- --$i;
- last;
- }
+ ## Is the source file in the component array?
+ if (exists $shash{$$array[$i]}) {
+ ## Remove the element and fix the index and count
+ splice(@$array, $i, 1);
+ --$count;
+ --$i;
}
}
}
diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm
index ab3d3ea2..046d103d 100644
--- a/modules/TemplateParser.pm
+++ b/modules/TemplateParser.pm
@@ -51,6 +51,8 @@ sub new {
$self->{'prjc'} = $prjc;
$self->{'ti'} = $prjc->get_template_input();
$self->{'cslashes'} = $prjc->convert_slashes();
+ $self->{'relative'} = $prjc->get_relative();
+ $self->{'addtemp'} = $prjc->get_addtemp();
$self->{'crlf'} = undef;
$self->{'values'} = {};
$self->{'defaults'} = {};
@@ -146,7 +148,7 @@ sub adjust_value {
## Perform any additions, subtractions
## or overrides for the template values.
- my($addtemp) = $self->{'prjc'}->get_addtemp();
+ my($addtemp) = $self->{'addtemp'};
foreach my $at (keys %$addtemp) {
if ($at eq $name) {
my($val) = $$addtemp{$at};
@@ -216,7 +218,7 @@ sub set_current_values {
sub relative {
my($self) = shift;
my($value) = shift;
- my($rel) = $self->{'prjc'}->get_relative();
+ my($rel) = $self->{'relative'};
my(@keys) = keys %$rel;
if (defined $value && defined $keys[0]) {
@@ -252,13 +254,10 @@ sub relative {
}
}
- ## Fix up the value for Windows (capitalize the drive and
- ## switch the \\'s to /
+ ## Fix up the value for Windows switch the \\'s to /
$val =~ s/\\/\//g;
- if ($val =~ /[a-z]:\//) {
- substr($val, 0, 1) = uc(substr($val, 0, 1));
- }
+ ## Lowercase everything if we are running on Windows
my($icwd) = ($^O eq 'MSWin32' || $^O eq 'cygwin' ? lc($cwd) : $cwd);
my($ival) = ($^O eq 'MSWin32' || $^O eq 'cygwin' ? lc($val) : $val);
if (index($icwd, $ival) == 0) {