[Bio] / FigKernelPackages / Tracer.pm Repository:
ViewVC logotype

Diff of /FigKernelPackages/Tracer.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.24, Tue Sep 13 05:39:07 2005 UTC revision 1.25, Tue Sep 13 20:04:25 2005 UTC
# Line 824  Line 824 
824    
825  C<< my $codedString = Tracer::Escape($realString); >>  C<< my $codedString = Tracer::Escape($realString); >>
826    
827  Escape a string for use in a command length. Spaces will be replaced by C<\b>,  Escape a string for use in a command length. Tabs will be replaced by C<\t>, new-lines
828  tabs replaced by C<\t>, new-lines replaced by C<\n>, and backslashes will be  replaced by C<\n>, and backslashes will be doubled. The effect is to exactly reverse the
829  doubled. The effect is to exactly reverse the effect of L</UnEscape>.  effect of L</UnEscape>.
830    
831  =over 4  =over 4
832    
# Line 858  Line 858 
858              $realString = substr $realString, (length $2) + (length $1);              $realString = substr $realString, (length $2) + (length $1);
859              # Encode the escape sequence.              # Encode the escape sequence.
860              my $char = $2;              my $char = $2;
861              $char =~ tr/ \t\n/btn/;              $char =~ tr/\t\n/tn/;
862              $retVal .= "\\" . $char;              $retVal .= "\\" . $char;
863          } else {          } else {
864              # Here there are no more escape sequences. The rest of the string is              # Here there are no more escape sequences. The rest of the string is
# Line 875  Line 875 
875    
876  C<< my $realString = Tracer::UnEscape($codedString); >>  C<< my $realString = Tracer::UnEscape($codedString); >>
877    
878  Replace escape sequences with their actual equivalents. C<\b> will be replaced by a space,  Replace escape sequences with their actual equivalents. C<\t> will be replaced by
879  C<\t> by a tab, C<\n> by a new-line character, and C<\\> by a back-slash.  a tab, C<\n> by a new-line character, and C<\\> by a back-slash.
880    
881  =over 4  =over 4
882    
# Line 902  Line 902 
902      # Only proceed if the incoming string is nonempty.      # Only proceed if the incoming string is nonempty.
903      if (defined $codedString) {      if (defined $codedString) {
904          # Loop through the parameter string, looking for escape sequences. We can't do          # Loop through the parameter string, looking for escape sequences. We can't do
905          # translating because it causes problems with the escaped slash. ("\\b" becomes          # translating because it causes problems with the escaped slash. ("\\t" becomes
906          # "\ " no matter what we do.)          # "\<tab>" no matter what we do.)
907          while (length $codedString > 0) {          while (length $codedString > 0) {
908              # Look for the first escape sequence.              # Look for the first escape sequence.
909              if ($codedString =~ /^(.*?)\\(\\|b|n|t)/) {              if ($codedString =~ /^(.*?)\\(\\|n|t)/) {
910                  # Here we found it. The text preceding the sequence is in $1. The sequence                  # Here we found it. The text preceding the sequence is in $1. The sequence
911                  # itself is in $2. First, move the clear text to the return variable.                  # itself is in $2. First, move the clear text to the return variable.
912                  $retVal .= $1;                  $retVal .= $1;
913                  $codedString = substr $codedString, (2 + length $1);                  $codedString = substr $codedString, (2 + length $1);
914                  # Decode the escape sequence.                  # Decode the escape sequence.
915                  my $char = $2;                  my $char = $2;
916                  $char =~ tr/\\btn/\\ \t\n/;                  $char =~ tr/\\tn/\\\t\n/;
917                  $retVal .= $char;                  $retVal .= $char;
918              } else {              } else {
919                  # Here there are no more escape sequences. The rest of the string is                  # Here there are no more escape sequences. The rest of the string is

Legend:
Removed from v.1.24  
changed lines
  Added in v.1.25

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3