@@ -167,6 +167,7 @@ module command_tree |
| 167 | 167 | ! ===================================== |
| 168 | 168 | type :: case_data_t |
| 169 | 169 | character(len=MAX_TOKEN_LEN) :: word ! case $word in |
| 170 | + integer :: word_len = 0 ! Actual word length (for whitespace-only values) |
| 170 | 171 | type(case_item_t), allocatable :: items(:) ! Case items |
| 171 | 172 | integer :: num_items = 0 |
| 172 | 173 | end type case_data_t |
@@ -312,16 +313,22 @@ contains |
| 312 | 313 | node%for_loop%body => body |
| 313 | 314 | end function create_for_loop |
| 314 | 315 | |
| 315 | | - function create_case_statement(word, items, num_items) result(node) |
| 316 | + function create_case_statement(word, items, num_items, word_len) result(node) |
| 316 | 317 | character(len=*), intent(in) :: word |
| 317 | 318 | type(case_item_t), intent(in) :: items(:) |
| 318 | 319 | integer, intent(in) :: num_items |
| 320 | + integer, intent(in), optional :: word_len |
| 319 | 321 | type(command_node_t), pointer :: node |
| 320 | 322 | |
| 321 | 323 | allocate(node) |
| 322 | 324 | node%node_type = NODE_CASE |
| 323 | 325 | allocate(node%case_stmt) |
| 324 | 326 | node%case_stmt%word = word |
| 327 | + if (present(word_len)) then |
| 328 | + node%case_stmt%word_len = word_len |
| 329 | + else |
| 330 | + node%case_stmt%word_len = len_trim(word) |
| 331 | + end if |
| 325 | 332 | allocate(node%case_stmt%items(num_items)) |
| 326 | 333 | node%case_stmt%items = items |
| 327 | 334 | node%case_stmt%num_items = num_items |