@@ -361,51 +361,51 @@ contains
361361
362362 end function reverse
363363
364- pure function slice(string, start, end , stride, include_end ) result(sliced_string)
364+ pure function slice(string, start, last , stride, include_last ) result(sliced_string)
365365 character(len=*), intent(in) :: string
366- integer, intent(in), optional :: start, end , stride
367- logical, intent(in), optional :: include_end
368- integer :: start_index, end_index , stride_vector, n, i, j
366+ integer, intent(in), optional :: first, last , stride
367+ logical, intent(in), optional :: include_last
368+ integer :: first_index, last_index , stride_vector, n, i, j
369369 character(len=:), allocatable :: sliced_string
370370
371- start_index = 1
372- end_index = len(string)
371+ first_index = 1
372+ last_index = len(string)
373373 stride_vector = 1
374374 if (len(string) > 0) then
375375 if (present(stride)) then
376376 if (stride /= 0) then
377377 if (stride < 0) then
378- start_index = len(string)
379- end_index = 1
378+ first_index = len(string)
379+ last_index = 1
380380 end if
381381 stride_vector = stride
382382 end if
383383 else
384- if (present(start ) .and. present(end )) then
385- if (end < start ) then
384+ if (present(first ) .and. present(last )) then
385+ if (last < first ) then
386386 stride_vector = -1
387387 end if
388388 end if
389389 end if
390390
391- if (present(start )) then
392- start_index = clip(start , 1, len(string))
391+ if (present(first )) then
392+ first_index = clip(first , 1, len(string))
393393 end if
394- if (present(end )) then
395- end_index = clip(end , 1, len(string))
394+ if (present(last )) then
395+ last_index = clip(last , 1, len(string))
396396 end if
397397
398- n = int((end_index - start_index ) / stride_vector)
398+ n = int((last_index - first_index ) / stride_vector)
399399 allocate(character(len=max(0, n + 1)) :: sliced_string)
400400
401- if (present(include_end )) then
402- if (include_end ) then
403- start_index = end_index - (n * stride_vector)
401+ if (present(include_last )) then
402+ if (include_last ) then
403+ first_index = last_index - (n * stride_vector)
404404 end if
405405 end if
406406
407407 j = 1
408- do i = start_index, end_index , stride_vector
408+ do i = first_index, last_index , stride_vector
409409 sliced_string(j:j) = string(i:i)
410410 j = j + 1
411411 end do
0 commit comments