subroutineoriginal_prefixprivate
subroutine original_prefix(line, low, n, attribs, text)
Set text to line(1:n) with the words of attribs removed, keeping the case of what is left.
Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
| line | character(len=*) | in | the statement | |
| low | character(len=*) | in | the statement, in lowercase | |
| n | integer | in | the length of the prefix | |
| attribs | type(string_t) | in | dimension(:) | the words to remove |
| text | character(len=:) | out | allocatable | the result |
Source
Show the code
subroutine original_prefix(line, low, n, attribs, text)
character(len=*), intent(in) :: line !! the statement
character(len=*), intent(in) :: low !! the statement, in lowercase
integer, intent(in) :: n !! the length of the prefix
type(string_t), intent(in) :: attribs(:) !! the words to remove
character(len=:), allocatable, intent(out) :: text !! the result
character(len=:), allocatable :: lowered
integer :: k, at
text = line(1:n)
lowered = low(1:n)
do k = 1, size(attribs)
at = index(lowered, attribs(k)%s)
if (at == 0) cycle
text = text(:at - 1)//text(at + len(attribs(k)%s):)
lowered = lowered(:at - 1)//lowered(at + len(attribs(k)%s):)
end do
end subroutine original_prefix