diff options
author | elliott_c <ocielliottc@users.noreply.github.com> | 2003-03-07 14:54:58 +0000 |
---|---|---|
committer | elliott_c <ocielliottc@users.noreply.github.com> | 2003-03-07 14:54:58 +0000 |
commit | 315347acd9ffe634886f3ca41b1bbb908eca89aa (patch) | |
tree | adaf027b084921ffc0f7ec4c0139f7937b63ad9c | |
parent | 6bdff210ac31e3862cb7de04f727d26f6cd05788 (diff) | |
download | ATCD-315347acd9ffe634886f3ca41b1bbb908eca89aa.tar.gz |
ChangeLogTag: Fri Mar 7 08:51:56 2003 Chad Elliott <elliott_c@ociweb.com>
-rw-r--r-- | ChangeLog | 12 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/Driver.pm | 35 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/Parser.pm | 84 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/ProjectCreator.pm | 2 | ||||
-rw-r--r-- | bin/MakeProjectCreator/modules/StringProcessor.pm | 99 |
5 files changed, 143 insertions, 89 deletions
diff --git a/ChangeLog b/ChangeLog index f65f47383b0..5197745725f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +Fri Mar 7 08:51:56 2003 Chad Elliott <elliott_c@ociweb.com> + + * bin/MakeProjectCreator/modules/Driver.pm: + * bin/MakeProjectCreator/modules/Parser.pm: + * bin/MakeProjectCreator/modules/ProjectCreator.pm: + * bin/MakeProjectCreator/modules/StringProcessor.pm: + + Reverted my change from "Fri Mar 7 06:35:09 2003 Chad Elliott" + to Parser.pm and factored out code from that module and Driver + into a new module, StringProcessor.pm. Driver and Parser now + inherit from StringProcessor. + Fri Mar 7 07:19:46 2003 Chad Elliott <elliott_c@ociweb.com> * ACEXML/apps/svcconf/svcconf.mpc: diff --git a/bin/MakeProjectCreator/modules/Driver.pm b/bin/MakeProjectCreator/modules/Driver.pm index cfdd51a9d69..76a759a23f8 100644 --- a/bin/MakeProjectCreator/modules/Driver.pm +++ b/bin/MakeProjectCreator/modules/Driver.pm @@ -13,7 +13,10 @@ package Driver; use strict; use File::Basename; -use Parser; +use StringProcessor; + +use vars qw(@ISA); +@ISA = qw(StringProcessor); # ************************************************************ # Data Section @@ -32,28 +35,16 @@ sub new { my($path) = shift; my($name) = shift; my(@creators) = @_; - my($self) = bless {'path' => $path, - 'name' => $name, - 'version' => 1.3, - 'types' => {}, - 'creators' => \@creators, - 'default' => $creators[0], - }, $class; + my($self) = $class->SUPER::new(); - return $self; -} + $self->{'path'} = $path; + $self->{'name'} = $name; + $self->{'version'} = 1.3; + $self->{'types'} = {}; + $self->{'creators'} = \@creators; + $self->{'default'} = $creators[0]; - -sub extractType { - my($self) = shift; - my($name) = shift; - my($type) = $name; - - if ($name =~ /(.*)(Project|Workspace)Creator/) { - $type = $1; - } - - return lc($type); + return $self; } @@ -178,7 +169,7 @@ sub run { ## Before we process the arguments, we will prepend the $cmdenv ## environment variable. if (defined $ENV{$cmdenv}) { - my($envargs) = Parser::create_array(undef, $ENV{$cmdenv}); + my($envargs) = $self->create_array($ENV{$cmdenv}); unshift(@args, @$envargs); } diff --git a/bin/MakeProjectCreator/modules/Parser.pm b/bin/MakeProjectCreator/modules/Parser.pm index 342784c4fa2..d281b2ef039 100644 --- a/bin/MakeProjectCreator/modules/Parser.pm +++ b/bin/MakeProjectCreator/modules/Parser.pm @@ -13,15 +13,26 @@ package Parser; use strict; use FileHandle; +use StringProcessor; + +use vars qw(@ISA); +@ISA = qw(StringProcessor); + +# ************************************************************ +# Data Section +# ************************************************************ + +my($cwd) = Cwd::getcwd(); + # ************************************************************ # Subroutine Section # ************************************************************ sub new { my($class) = shift; - my($self) = bless {'line_number' => 0, - 'cwd' => Cwd::getcwd(), - }, $class; + my($self) = $class->SUPER::new(); + + $self->{'line_number'} = 0; return $self; } @@ -32,10 +43,10 @@ sub cd { my($status) = chdir($dir); if ($status && $dir ne '.') { if ($dir =~ /^\// || $dir =~ /^[A-Za-z]:/) { - $self->{'cwd'} = $dir; + $cwd = $dir; } else { - $self->{'cwd'} .= "/$dir"; + $cwd .= "/$dir"; } } return $status; @@ -43,8 +54,8 @@ sub cd { sub getcwd { - my($self) = shift; - return $self->{'cwd'}; + #my($self) = shift; + return $cwd; } @@ -61,27 +72,6 @@ sub strip_line { } -sub process_special { - my($self) = shift; - my($line) = shift; - my($length) = length($line); - - for(my $i = 0; $i < $length; $i++) { - my($ch) = substr($line, $i, 1); - if ($ch eq "\\" && $i + 1 < $length) { - substr($line, $i, 1) = ''; - $length--; - } - elsif ($ch eq '"') { - substr($line, $i, 1) = ''; - $length--; - $i--; - } - } - return $line; -} - - sub collect_line { my($self) = shift; my($fh) = shift; @@ -133,44 +123,6 @@ sub line_number { } -sub create_array { - my($self) = shift; - my($line) = shift; - my(@array) = (); - my($length) = length($line); - my($prev) = 0; - my($double) = 0; - - for(my $i = 0; $i <= $length; $i++) { - my($ch) = substr($line, $i, 1); - if (!$double && ($ch eq '' || $ch =~ /\s/)) { - my($val) = substr($line, $prev, $i - $prev); - $val =~ s/^\s+//; - $val =~ s/\s+$//; - if ($val =~ /^\"(.*)\"$/) { - $val = $1; - } - push(@array, $val); - for(; $i < $length; $i++) { - if (substr($line, $i, 1) !~ /\s/) { - $i--; - last; - } - } - $prev = $i + 1; - } - elsif ($double && $ch eq "\\" && $i + 1 < $length) { - substr($line, $i, 1) = ''; - $length--; - } - elsif ($ch eq '"') { - $double ^= 1; - } - } - return \@array; -} - - sub slash_to_backslash { my($self) = shift; my($file) = shift; diff --git a/bin/MakeProjectCreator/modules/ProjectCreator.pm b/bin/MakeProjectCreator/modules/ProjectCreator.pm index 4942608ef14..10f94ad6462 100644 --- a/bin/MakeProjectCreator/modules/ProjectCreator.pm +++ b/bin/MakeProjectCreator/modules/ProjectCreator.pm @@ -1462,7 +1462,7 @@ sub update_project_info { sub get_verbatim { my($self) = shift; my($marker) = shift; - my($type) = Driver::extractType($self, "$self"); + my($type) = $self->extractType("$self"); my($str) = undef; my($thash) = $self->{'verbatim'}->{$type}; diff --git a/bin/MakeProjectCreator/modules/StringProcessor.pm b/bin/MakeProjectCreator/modules/StringProcessor.pm new file mode 100644 index 00000000000..1f025f2b3fc --- /dev/null +++ b/bin/MakeProjectCreator/modules/StringProcessor.pm @@ -0,0 +1,99 @@ +package StringProcessor; + +# ************************************************************ +# Description : Perform various algorithms on strings +# Author : Chad Elliott +# Create Date : 3/07/2003 +# ************************************************************ + +# ************************************************************ +# Pragmas +# ************************************************************ + +use strict; + +# ************************************************************ +# Subroutine Section +# ************************************************************ + +sub new { + my($class) = shift; + my($self) = bless { + }, $class; + return $self; +} + + +sub extractType { + my($self) = shift; + my($name) = shift; + my($type) = $name; + + if ($name =~ /(.*)(Project|Workspace)Creator/) { + $type = $1; + } + + return lc($type); +} + + +sub process_special { + my($self) = shift; + my($line) = shift; + my($length) = length($line); + + for(my $i = 0; $i < $length; $i++) { + my($ch) = substr($line, $i, 1); + if ($ch eq "\\" && $i + 1 < $length) { + substr($line, $i, 1) = ''; + $length--; + } + elsif ($ch eq '"') { + substr($line, $i, 1) = ''; + $length--; + $i--; + } + } + return $line; +} + + +sub create_array { + my($self) = shift; + my($line) = shift; + my(@array) = (); + my($length) = length($line); + my($prev) = 0; + my($double) = 0; + + for(my $i = 0; $i <= $length; $i++) { + my($ch) = substr($line, $i, 1); + if (!$double && ($ch eq '' || $ch =~ /\s/)) { + my($val) = substr($line, $prev, $i - $prev); + $val =~ s/^\s+//; + $val =~ s/\s+$//; + if ($val =~ /^\"(.*)\"$/) { + $val = $1; + } + push(@array, $val); + for(; $i < $length; $i++) { + if (substr($line, $i, 1) !~ /\s/) { + $i--; + last; + } + } + $prev = $i + 1; + } + elsif ($double && $ch eq "\\" && $i + 1 < $length) { + substr($line, $i, 1) = ''; + $length--; + } + elsif ($ch eq '"') { + $double ^= 1; + } + } + return \@array; +} + + +1; |