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 if ($line =~ /^((\w+[\s\w]+\w::)*\w+)\s*([\-+]?=)\s*(.*)?/) {
25 my $op = ($3 eq '+=' ?
1 : $3 eq '-=' ?
-1 : 0);
26 push(@
$values, $op, $self->resolve_alias(lc($1)), $4);
35 my($self, $name) = @_;
38 if ($name =~ /(.*)(Project|Workspace)Creator/) {
47 my($self, $line) = @_;
49 ## Replace all escaped double quotes and escaped backslashes
50 ## with special characters
51 my $escaped = ($line =~ s/\\\\/\01/g);
52 $escaped |= ($line =~ s/\\"/\02/g);
54 ## Un-escape all other characters
55 $line =~ s/\\(.)/$1/g;
57 ## Remove any non-escaped double quotes
60 ## Put the escaped double quotes and backslashes back in
71 my($self, $line) = @_;
74 ## Replace all escaped double and single quotes with special characters
75 my $escaped = ($line =~ s/\\\"/\01/g);
76 $escaped |= ($line =~ s/\\\'/\02/g);
77 $escaped |= ($line =~ s/\\ /\03/g);
78 $escaped |= ($line =~ s/\\\t/\04/g);
80 foreach my $part (grep(!/^\s*$/,
81 split(/(\"[^\"]+\"|\'[^\']+\'|\s+)/, $line))) {
82 ## Remove enclosing double and single quotes
83 $part =~ s/^"(.*)"$/$1/;
84 $part =~ s/^'(.*)'$/$1/;
86 ## Put any escaped double or single quotes back into the string.
94 ## Push it onto the array
109 ## Windows, OS/2 and cygwin require a carriage return and line feed.
110 ## However, at some point cygwin changed the way it does output and can
111 ## be controled through an environment variable.
112 return ($^O
eq 'MSWin32' || $^O
eq 'os2' ||
114 ($] < 5.008 || (defined $ENV{PERLIO
} && $ENV{PERLIO
} eq 'crlf'))) ?
126 my($str, $array) = @_;
127 foreach my $target (@
$array) {
128 return 1 if ($str eq $target);