# HG changeset patch # User jwe # Date 981692038 0 # Node ID 1e0d844b8f540884c5a93a9c3a2ab5028da73702 # Parent 2a257be5e4883b3c0f94af454fe508135bd12820 [project @ 2001-02-09 04:12:54 by jwe] diff -r 2a257be5e488 -r 1e0d844b8f54 scripts/ChangeLog --- a/scripts/ChangeLog Fri Feb 09 04:12:31 2001 +0000 +++ b/scripts/ChangeLog Fri Feb 09 04:13:58 2001 +0000 @@ -1,3 +1,13 @@ +2001-02-08 Paul Kienzle + + * strings/dec2base.m: New file. + * strings/base2dec.m: New file. + * strings/strjust.m: New file. + * strings/dec2hex.m: Replace with version that just calls 2dec2base. + * strings/dec2bin.m: Likewise. + * strings/hex2dec.m: Replace with version that just calls base2dec. + * strings/bin2dec.m: Likewise. + 2001-02-07 David Livings * statistics/base/ppplot.m: Use gset, not set. diff -r 2a257be5e488 -r 1e0d844b8f54 scripts/strings/patch --- a/scripts/strings/patch Fri Feb 09 04:12:31 2001 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,81 +0,0 @@ -*** strrep.m-2.1.28 Tue May 2 01:39:24 2000 ---- strrep.m Fri May 12 08:21:15 2000 -*************** -*** 45,70 **** - t = s; - return; - endif - ind = findstr (s, x, 0); -! len = length (ind); -! if (len == 0) - t = s; -! else -! save_empty_list_elements_ok = empty_list_elements_ok; -! unwind_protect -! empty_list_elements_ok = 1; -! l_x = length (x); -! tmp = s (1 : ind (1) - 1); -! t = strcat (tmp, y); -! for k = 1 : len - 1 -! tmp = s (ind (k) + l_x : ind (k+1) - 1); -! t = strcat (t, tmp, y); -! endfor -! tmp = s (ind(len) + l_x : length (s)); -! t = [t, tmp]; -! unwind_protect_cleanup -! empty_list_elements_ok = save_empty_list_elements_ok; -! end_unwind_protect - endif - - endfunction ---- 45,94 ---- - t = s; - return; - endif -+ - ind = findstr (s, x, 0); -! if (length(ind) == 0) - t = s; -! -! 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 -! di = ones(size(s)); -! di (ind) = 1 + jump * ones (length (ind), 1); -! t (cumsum (di)) = s; -! if (size(s,1) == 1) -! t = t'; -! endif -! elseif (jump < 0) # s contracts -! 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 -! t = s; -! endif -! -! ## Now, substitute a copy of the replacement string whereever the -! ## search string was found. Note that we must first update the -! ## target positions to account for any expansion or contraction -! ## of s that may have occurred. -! ind = ind + jump * [ 0 : length (ind) - 1 ]; -! repeat = [1 : length (y)]' * ones (1, length (ind)); -! dest = ones (length (y), 1) * ind + repeat - 1; -! t (dest) = y (repeat); -! -! else # deletion -! ## Build an index vector of all locations where the target was found -! ## in the search string, and zap them. -! t = toascii(s); -! repeat = [1 : length (x)]' * ones (1, length (ind)); -! delete = ones (length (x), 1) * ind + repeat - 1; -! t (delete) = []; -! t = setstr(t); - endif - - endfunction