diff scripts/strings/strrep.m @ 8506:bc982528de11

comment style fixes
author John W. Eaton <jwe@octave.org>
date Tue, 13 Jan 2009 11:56:00 -0500
parents 502e58a0d44f
children cadc73247d65
line wrap: on
line diff
--- a/scripts/strings/strrep.m
+++ b/scripts/strings/strrep.m
@@ -52,14 +52,17 @@
 
   if (length(ind) == 0)
     t = s;
-  elseif (length(y) > 0)      # replacement
+  elseif (length(y) > 0)
+    ## Replacement.
+    ##
     ## Copy the parts of s that aren't being replaced.  This is done
     ## with an index vector, with jumps where each search string
     ## is found.  For a jump of 0 (target length == replacement length)
     ## the index is just cumsum ( ones (length (s))).  For non-zero
     ## jumps, add the jump size to the ones vector at each found position.
     jump = length(y) - length(x);
-    if (jump > 0)     # s expands
+    if (jump > 0)
+      ## S expands.
       di = ones(size(s));
       di(ind) = 1 + jump * ones (length (ind), 1);
       t(cumsum (di)) = s;
@@ -67,7 +70,8 @@
       di = ones (jump * length (ind) + length (s), 1);
       di (ind + jump * [0:length(ind)-1]) = 1 - jump * ones(length(ind), 1);
       t = s (cumsum (di));
-    else              # s stays the same length
+    else
+      ## S stays the same length.
       t = s;
     endif
     ## Now, substitute a copy of the replacement string whereever the
@@ -78,7 +82,9 @@
     repeat = [1:length(y)]' * ones (1, length (ind));
     dest = ones (length (y), 1) * ind + repeat - 1;
     t(dest) = y(repeat);
-  else                        # deletion
+  else
+    ## Deletion.
+    ##
     ## Build an index vector of all locations where the target was found
     ## in the search string, and zap them. 
     t = toascii (s);