1 package StringProcessor
;
3 # ************************************************************
4 # Description : Perform various algorithms on strings
5 # Author : Chad Elliott
6 # Create Date : 3/07/2003
7 # ************************************************************
9 # ************************************************************
11 # ************************************************************
15 # ************************************************************
17 # ************************************************************
19 sub parse_assignment
{
20 my($self, $line, $values) = @_;
22 ## In MPC, a scope can have spaces in it. However, it can not end
24 ## Line may have embedded new lines, so using 's' modifier.
25 if ($line =~ /^((\w+[-\s\w]+\w::)*\w+)\s*([\-+]?=)\s*(.*)?/s) {
26 my $op = ($3 eq '+=' ?
1 : $3 eq '-=' ?
-1 : 0);
27 push(@
$values, $op, $self->resolve_alias(lc($1)), $4);
36 my($self, $name) = @_;
39 if ($name =~ /(.*)(Project|Workspace)Creator/) {
48 my($self, $line) = @_;
50 ## Replace all escaped double quotes and escaped backslashes
51 ## with special characters
52 my $escaped = ($line =~ s/\\\\/\01/g);
53 $escaped |= ($line =~ s/\\"/\02/g);
55 ## Un-escape all other characters
56 $line =~ s/\\(.)/$1/g;
58 ## Remove any non-escaped double quotes
61 ## Put the escaped double quotes and backslashes back in
72 my($self, $line) = @_;
75 ## Replace all escaped double and single quotes with special
76 ## characters. We need to distinguish between doubly escaped quotes
77 ## (<%equote%>) and escaped quotes (\"). We also need to retain the
78 ## escaped escape characters.
79 my $escaped = ($line =~ s/\\\\\"/\01/g);
80 $escaped |= ($line =~ s/\\\'/\02/g);
81 $escaped |= ($line =~ s/\\ /\03/g);
82 $escaped |= ($line =~ s/\\\t/\04/g);
83 $escaped |= ($line =~ s/\\\"/\05/g);
84 $escaped |= ($line =~ s/\\\\/\06/g);
86 foreach my $part (grep(!/^\s*$/,
87 split(/(\"[^\"]+\"|\'[^\']+\'|\s+)/, $line))) {
88 ## Remove enclosing double and single quotes
89 $part =~ s/^"(.*)"$/$1/;
90 $part =~ s/^'(.*)'$/$1/;
92 ## Put any escaped escaped characters back into the string, but
93 ## processed to take out one of the escape sequences.
103 ## Push it onto the array
118 ## Windows and cygwin require a carriage return and line feed.
119 ## However, at some point cygwin changed the way it does output and can
120 ## be controled through an environment variable.
121 return ($^O
eq 'MSWin32' ||
123 ($] < 5.008 || (defined $ENV{PERLIO
} && $ENV{PERLIO
} eq 'crlf'))) ?
135 my($str, $array) = @_;
136 foreach my $target (@
$array) {
137 return 1 if ($str eq $target);
143 # Push each element of @$list on to @$into, unless it's already in @$into.
144 my($into, $list) = @_;
145 foreach my $in (@
$list) {
146 push(@
$into, $in) if (!fgrep
($in, $into));