OSSP CVS Repository

ossp - Check-in [5298]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 5298
Date: 2005-Nov-16 13:51:13 (local)
2005-Nov-16 12:51:13 (UTC)
User:rse
Branch:
Comment: change "divert" method without arg to really divert to the last established folder.
Tickets:
Inspections:
Files:
ossp-pkg/string-divert/ChangeLog      added-> 1.11
ossp-pkg/string-divert/Divert.pm      1.14 -> 1.15     13 inserted, 7 deleted
ossp-pkg/string-divert/Divert.pod      1.8 -> 1.9     2 inserted, 2 deleted

ossp-pkg/string-divert/ChangeLog -> 1.11

*** /dev/null    Sat May 18 20:15:33 2024
--- -    Sat May 18 20:19:31 2024
***************
*** 0 ****
--- 1,42 ----
+   
+   ChangeLog
+   =========
+ 
+   0.96 (16-Nov-2005)
+       o add folding loop detection to "string" method
+       o use anonymous names already in "new" method
+       o don't follow diversions on "folding" method to
+         allow one to divert back to upper objects, too.
+       o document that "folding" method returns all
+         foldings if no name or object is specified.
+       o change sample2.pl to show the usual "head" diversion
+         once one is already diverted in "body".
+       o change "divert" method without arg to really divert to the last
+         established folder.
+   0.95 (16-Nov-2005)
+       o document "bool" method in Divert.pod, too.
+       o allow objects to be passed to "append" and "assign" methods
+       o call "destroy" method in "DESTROY"
+       o support anonymous sub-objects
+       o completely reviewed and cleaned up implementation
+   0.94 (22-Feb-2005)
+       o add "copy constructor" in overloaded API plus a copying() method
+         for selecting what to do in the "copy constructor": passing
+         the object as is or cloning via clone() method.
+       o add clone() method for recursively cloning object
+       o replace "die" with Carp's "croak" for better error messages
+       o use empty EXPORT_OK because we have an OO style API only
+       o add default empty EXPORT array
+   0.93 (22-Sep-2003)
+       o fix obj->folder(format, pattern) implementation
+   0.92 (29-Apr-2003)
+       o fix auto-indentation generation on unfolding
+       o add "storage" mode functionality
+   0.91 (23-Apr-2003)
+       o direct MakeMaker to not install sample[12].pl
+       o cleanup naming of module, etc.
+       o remove trailing whitespaces from codes
+       o cleanup and extend documentation
+   0.90 (22-Apr-2003)
+       o initial release
+ 


ossp-pkg/string-divert/Divert.pm 1.14 -> 1.15

--- Divert.pm    2005/11/16 12:08:49     1.14
+++ Divert.pm    2005/11/16 12:51:13     1.15
@@ -67,6 +67,7 @@
     $self->{diversion} = [];                                # stack of active diversions
     $self->{foldermk}  = '{#%s#}';                          # folder text representation format
     $self->{folderre}  = '\{#([a-zA-Z_][a-zA-Z0-9_]*)#\}';  # folder text representation regexp
+    $self->{folderlst} = undef;                             # folder object of last folding operation
 
     return $self;
 }
@@ -185,11 +186,13 @@
         if (not defined($obj));
     if (&String::Divert::_isobj($obj)) {
         $self->{chunks} = [ $obj ];
+        $self->{folderlst} = $obj if (ref($obj));
     }
     else {
         $self->{chunks} = [];
         foreach my $chunk ($self->_chunking($obj)) {
             push(@{$self->{chunks}}, $chunk);
+            $self->{folderlst} = $chunk if (ref($chunk));
         }
     }
     return $self;
@@ -211,11 +214,13 @@
     else {
         if (&String::Divert::_isobj($obj)) {
             push(@{$self->{chunks}}, $obj);
+            $self->{folderlst} = $obj if (ref($obj));
         }
         else {
             foreach my $chunk ($self->_chunking($obj)) {
                 if (ref($chunk) or (@{$self->{chunks}} > 0 and ref($self->{chunks}->[-1]))) {
                     push(@{$self->{chunks}}, $chunk);
+                    $self->{folderlst} = $chunk if (ref($chunk));
                 }
                 elsif (@{$self->{chunks}} > 0) {
                     $self->{chunks}->[-1] .= $chunk;
@@ -301,6 +306,7 @@
         croak "folding object not of class String::Divert"
             if (not &String::Divert::_isobj($id));
         push(@{$self->{chunks}}, $id);
+        $self->{folderlst} = $id;
         return $id;
     }
     else {
@@ -309,6 +315,7 @@
         croak "unable to create new folding object"
             if (not defined($object));
         push(@{$self->{chunks}}, $object);
+        $self->{folderlst} = $object;
         return $object;
     }
 }
@@ -320,6 +327,7 @@
         if (@{$self->{diversion}} > 0);
     my $string = $self->string();
     $self->{chunks} = $string ne '' ? [ $string ] : [];
+    $self->{folderlst} = undef;
     return $string;
 }
 
@@ -356,7 +364,7 @@
                     $folding = $chunk;
                     last;
                 }
-                $folding = $chunk->folding($id);
+                $folding = $chunk->folding($id); # recursion!
                 last if (defined($folding));
             }
         }
@@ -405,11 +413,9 @@
     my $object; $object = undef;
     if (not defined($id)) {
         #   choose last folding object
-        foreach my $chunk ($self->folding()) {
-            if (ref($chunk)) {
-                $object = $chunk;
-                last;
-            }
+        foreach my $obj (reverse ($self, @{$self->{diversion}})) {
+            $object = $obj->{folderlst};
+            last if (defined($object));
         }
         croak "no last folding sub-object found"
             if (not defined($object));
@@ -431,7 +437,7 @@
     if ($num !~ m|^\d+$|) {
         #   lookup number by name
         my $name = $num;
-        for ($num = 1; $num <= @{$self->{diversion}}; $num++) {
+        for (my $num = 1; $num <= @{$self->{diversion}}; $num++) {
             last if ($self->{diversion}->[-$num]->{name} eq $name);
         }
         croak "no object named \"$name\" found for undiversion"


ossp-pkg/string-divert/Divert.pod 1.8 -> 1.9

--- Divert.pod   2005/11/16 12:08:49     1.8
+++ Divert.pod   2005/11/16 12:51:13     1.9
@@ -316,8 +316,8 @@
 a content diversion to a sub-object (given by name C<$name> or object
 reference C<$y>). The diversion target should be a folded sub-object of
 C<$x>, but is not technically required. If no C<$name> or object C<$y>
-is specified, a diversion is activated to the last folder in the current
-diversion.
+is specified, a diversion is activated to the folder which was
+inserted last into the currently or previously active objects.
 
 =item SAPI: [C<$x =>] C<$x-E<gt>>B<undivert>C<($num);>
 

CVSTrac 2.0.1