diff options
| author | Joseph Arceneaux | 1992-10-14 23:12:09 +0000 |
|---|---|---|
| committer | Joseph Arceneaux | 1992-10-14 23:12:09 +0000 |
| commit | e0b634930e6e2876a8f4d2449084ee477cc93a51 (patch) | |
| tree | b1561ac18a59c26dbc099512210d53773e89fac2 /src | |
| parent | 433c217556540e08eb563047eaa43ffbe27904e1 (diff) | |
| download | emacs-e0b634930e6e2876a8f4d2449084ee477cc93a51.tar.gz emacs-e0b634930e6e2876a8f4d2449084ee477cc93a51.zip | |
* intervals.c (traverse_intervals): New parameter `depth'.
Increment this when passing recursively.
Diffstat (limited to 'src')
| -rw-r--r-- | src/intervals.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/intervals.c b/src/intervals.c index bffb7a7aabe..b0f11114d11 100644 --- a/src/intervals.c +++ b/src/intervals.c | |||
| @@ -173,29 +173,25 @@ static int icount; | |||
| 173 | static int idepth; | 173 | static int idepth; |
| 174 | static int zero_length; | 174 | static int zero_length; |
| 175 | 175 | ||
| 176 | static int depth; | ||
| 177 | |||
| 178 | /* Traverse an interval tree TREE, performing FUNCTION on each node. | 176 | /* Traverse an interval tree TREE, performing FUNCTION on each node. |
| 179 | 177 | ||
| 180 | Perhaps we should pass the depth as an argument. */ | 178 | Perhaps we should pass the depth as an argument. */ |
| 181 | 179 | ||
| 182 | void | 180 | void |
| 183 | traverse_intervals (tree, position, function) | 181 | traverse_intervals (tree, position, depth, function) |
| 184 | INTERVAL tree; | 182 | INTERVAL tree; |
| 185 | int position; | 183 | int position, depth; |
| 186 | void (* function) (); | 184 | void (* function) (); |
| 187 | { | 185 | { |
| 188 | if (NULL_INTERVAL_P (tree)) | 186 | if (NULL_INTERVAL_P (tree)) |
| 189 | return; | 187 | return; |
| 190 | 188 | ||
| 191 | depth++; | 189 | traverse_intervals (tree->left, position, depth + 1, function); |
| 192 | traverse_intervals (tree->left, position, function); | ||
| 193 | position += LEFT_TOTAL_LENGTH (tree); | 190 | position += LEFT_TOTAL_LENGTH (tree); |
| 194 | tree->position = position; | 191 | tree->position = position; |
| 195 | (*function) (tree); | 192 | (*function) (tree); |
| 196 | position += LENGTH (tree); | 193 | position += LENGTH (tree); |
| 197 | traverse_intervals (tree->right, position, function); | 194 | traverse_intervals (tree->right, position, depth + 1, function); |
| 198 | depth--; | ||
| 199 | } | 195 | } |
| 200 | 196 | ||
| 201 | #if 0 | 197 | #if 0 |
| @@ -221,7 +217,7 @@ search_for_interval (i, tree) | |||
| 221 | icount = 0; | 217 | icount = 0; |
| 222 | search_interval = i; | 218 | search_interval = i; |
| 223 | found_interval = NULL_INTERVAL; | 219 | found_interval = NULL_INTERVAL; |
| 224 | traverse_intervals (tree, 1, &check_for_interval); | 220 | traverse_intervals (tree, 1, 0, &check_for_interval); |
| 225 | return found_interval; | 221 | return found_interval; |
| 226 | } | 222 | } |
| 227 | 223 | ||
| @@ -243,7 +239,7 @@ count_intervals (i) | |||
| 243 | icount = 0; | 239 | icount = 0; |
| 244 | idepth = 0; | 240 | idepth = 0; |
| 245 | zero_length = 0; | 241 | zero_length = 0; |
| 246 | traverse_intervals (i, 1, &inc_interval_count); | 242 | traverse_intervals (i, 1, 0, &inc_interval_count); |
| 247 | 243 | ||
| 248 | return icount; | 244 | return icount; |
| 249 | } | 245 | } |