Mercurial > octave-nkf
comparison scripts/deprecated/split.m @ 10549:95c3e38098bf
Untabify .m scripts
author | Rik <code@nomad.inbox5.com> |
---|---|
date | Fri, 23 Apr 2010 11:28:50 -0700 |
parents | 923c7cb7f13f |
children | 1740012184f9 |
comparison
equal
deleted
inserted
replaced
10548:479536c5bb10 | 10549:95c3e38098bf |
---|---|
69 | 69 |
70 l_s = length (s); | 70 l_s = length (s); |
71 l_t = length (t); | 71 l_t = length (t); |
72 | 72 |
73 if (l_s == 0) | 73 if (l_s == 0) |
74 m = ""; | 74 m = ""; |
75 return; | 75 return; |
76 elseif (l_t == 0) | 76 elseif (l_t == 0) |
77 m = s'; | 77 m = s'; |
78 return; | 78 return; |
79 elseif (l_s < l_t) | 79 elseif (l_s < l_t) |
80 error ("split: s must not be shorter than t"); | 80 error ("split: s must not be shorter than t"); |
81 endif | 81 endif |
82 | 82 |
83 if (min (size (s)) != 1 || min (size (t)) != 1) | 83 if (min (size (s)) != 1 || min (size (t)) != 1) |
84 error("split: multi-line strings are not supported"); | 84 error("split: multi-line strings are not supported"); |
85 endif | 85 endif |
86 | 86 |
87 ind = findstr (s, t, 0); | 87 ind = findstr (s, t, 0); |
88 if (length (ind) == 0) | 88 if (length (ind) == 0) |
89 m = s; | 89 m = s; |
90 return; | 90 return; |
91 elseif (n - 1 < length(ind)) | 91 elseif (n - 1 < length(ind)) |
92 ind = ind(1:n-1); | 92 ind = ind(1:n-1); |
93 endif | 93 endif |
94 ind2 = [1, ind+l_t]; | 94 ind2 = [1, ind+l_t]; |
95 ind = [ind, l_s+1]; | 95 ind = [ind, l_s+1]; |
96 | 96 |
97 ind_diff = ind-ind2; | 97 ind_diff = ind-ind2; |
101 m_cols = max (ind_diff); | 101 m_cols = max (ind_diff); |
102 m = repmat (" ", m_rows, m_cols); | 102 m = repmat (" ", m_rows, m_cols); |
103 | 103 |
104 ## Copy the strings to the matrix. | 104 ## Copy the strings to the matrix. |
105 for i = 1:length (ind) | 105 for i = 1:length (ind) |
106 tmp = ind2(i):(ind(i)-1); | 106 tmp = ind2(i):(ind(i)-1); |
107 m(i,1:length(tmp)) = s(tmp); | 107 m(i,1:length(tmp)) = s(tmp); |
108 endfor | 108 endfor |
109 else | 109 else |
110 error ("split: both s and t must be strings"); | 110 error ("split: both s and t must be strings"); |
111 endif | 111 endif |
112 else | 112 else |