diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2003-06-24 17:09:49 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2003-06-24 17:09:49 +0000 |
commit | 701245c81dcff1a77edb027b55a361e4b0c168ee (patch) | |
tree | be789002fc67117cf1ac2aed455f35fd9afd6ca4 | |
parent | e17b3ba9e61d7ce5e95773376caccdc4106081d8 (diff) | |
download | MPC-701245c81dcff1a77edb027b55a361e4b0c168ee.tar.gz |
ChangeLogTag: Tue Jun 24 12:07:06 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | modules/ProjectCreator.pm | 81 | ||||
-rw-r--r-- | modules/TemplateParser.pm | 83 |
2 files changed, 84 insertions, 80 deletions
diff --git a/modules/ProjectCreator.pm b/modules/ProjectCreator.pm index 49820ccd..d2b5dbab 100644 --- a/modules/ProjectCreator.pm +++ b/modules/ProjectCreator.pm @@ -847,6 +847,11 @@ sub parse_define_custom { if (!defined $self->{'generated_exts'}->{$tag}) { $self->{'generated_exts'}->{$tag} = {}; } + ## First try to convert the value into a relative path + $value = $self->relative($value); + + ## If that didn't work, try to convert it to the + ## right environment variable form. if ($value =~ /\$\(.*\)/) { my($envstart, $envend) = $self->get_env_accessor(); if (defined $envstart) { @@ -2165,6 +2170,82 @@ sub update_project_info { } +sub relative { + my($self) = shift; + my($value) = shift; + my($rel) = $self->get_relative(); + my(@keys) = keys %$rel; + + if (defined $value && defined $keys[0]) { + if (UNIVERSAL::isa($value, 'ARRAY')) { + my(@built) = (); + foreach my $val (@$value) { + push(@built, $self->relative($val)); + } + $value = \@built; + } + elsif ($value =~ /\$/) { + my($cwd) = $self->getcwd(); + my($start) = 0; + my($fixed) = 0; + + if ($cwd =~ /[a-z]:[\/\\]/) { + substr($cwd, 0, 1) = uc(substr($cwd, 0, 1)); + } + + while(substr($value, $start) =~ /(\$\(([^)]+)\))/) { + my($whole) = $1; + my($name) = $2; + my($val) = $$rel{$name}; + + if (defined $val) { + if ($^O eq 'cygwin' && !$fixed && + $cwd !~ /[A-Za-z]:/ && $val =~ /[A-Za-z]:/) { + my($cyg) = `cygpath -w $cwd`; + if (defined $cyg) { + $cyg =~ s/\\/\//g; + chop($cwd = $cyg); + $fixed = 1; + } + } + + ## Fix up the value for Windows switch the \\'s to / + $val =~ s/\\/\//g; + + ## 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) { + my($count) = 0; + my($current) = $icwd; + substr($current, 0, length($ival)) = ''; + while($current =~ /^\\/) { + $current =~ s/^\///; + } + my($length) = length($current); + for(my $i = 0; $i < $length; ++$i) { + if (substr($current, $i, 1) eq '/') { + ++$count; + } + } + $ival = '../' x $count; + $ival =~ s/\/$//; + if ($self->convert_slashes()) { + $ival = $self->slash_to_backslash($ival); + } + substr($value, $start) =~ s/\$\([^)]+\)/$ival/; + $whole = $ival; + } + } + $start += length($whole); + } + } + } + + return $value; +} + + sub get_verbatim { my($self) = shift; my($marker) = shift; diff --git a/modules/TemplateParser.pm b/modules/TemplateParser.pm index 046d103d..b082b31b 100644 --- a/modules/TemplateParser.pm +++ b/modules/TemplateParser.pm @@ -51,7 +51,6 @@ 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'} = {}; @@ -215,82 +214,6 @@ sub set_current_values { } -sub relative { - my($self) = shift; - my($value) = shift; - my($rel) = $self->{'relative'}; - my(@keys) = keys %$rel; - - if (defined $value && defined $keys[0]) { - if (UNIVERSAL::isa($value, 'ARRAY')) { - my(@built) = (); - foreach my $val (@$value) { - push(@built, $self->relative($val)); - } - $value = \@built; - } - elsif ($value =~ /\$/) { - my($cwd) = $self->getcwd(); - my($start) = 0; - my($fixed) = 0; - - if ($cwd =~ /[a-z]:[\/\\]/) { - substr($cwd, 0, 1) = uc(substr($cwd, 0, 1)); - } - - while(substr($value, $start) =~ /(\$\(([^)]+)\))/) { - my($whole) = $1; - my($name) = $2; - my($val) = $$rel{$name}; - - if (defined $val) { - if ($^O eq 'cygwin' && !$fixed && - $cwd !~ /[A-Za-z]:/ && $val =~ /[A-Za-z]:/) { - my($cyg) = `cygpath -w $cwd`; - if (defined $cyg) { - $cyg =~ s/\\/\//g; - chop($cwd = $cyg); - $fixed = 1; - } - } - - ## Fix up the value for Windows switch the \\'s to / - $val =~ s/\\/\//g; - - ## 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) { - my($count) = 0; - my($current) = $icwd; - substr($current, 0, length($ival)) = ''; - while($current =~ /^\\/) { - $current =~ s/^\///; - } - my($length) = length($current); - for(my $i = 0; $i < $length; ++$i) { - if (substr($current, $i, 1) eq '/') { - ++$count; - } - } - $ival = '../' x $count; - $ival =~ s/\/$//; - if ($self->{'cslashes'}) { - $ival = $self->slash_to_backslash($ival); - } - substr($value, $start) =~ s/\$\([^)]+\)/$ival/; - $whole = $ival; - } - } - $start += length($whole); - } - } - } - - return $value; -} - - sub get_nested_value { my($self) = shift; my($name) = shift; @@ -361,7 +284,7 @@ sub get_value { } } - return $self->relative($value); + return $self->{'prjc'}->relative($value); } @@ -385,7 +308,7 @@ sub get_value_with_default { # print "DEBUG: WARNING: $name using default value of $value\n"; $value = $self->adjust_value($name, $value); } - $value = $self->relative($value); + $value = $self->{'prjc'}->relative($value); } return $value; @@ -560,7 +483,7 @@ sub get_flag_overrides { } } - return $self->relative($value);; + return $prjc->relative($value); } |