Skip to content

Commit

Permalink
Fix ESMF_ConfigGetLen for blank config lines
Browse files Browse the repository at this point in the history
  • Loading branch information
danrosen25 committed Mar 28, 2024
1 parent 96ab923 commit cca4469
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/Infrastructure/Config/src/ESMF_Config.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1351,13 +1351,14 @@ subroutine ESMF_ConfigGetString(config, value, &
endif

ib = config%cptr%next_item
ie = config%cptr%next_line-1
ie = config%cptr%next_line-2
if ( config%cptr%eolflag ) then
! reached end of line
config%cptr%next_item = config%cptr%next_line-1
value = BLK
if ( present ( default )) then
value = default
else
value = BLK
endif
if (present (eolFlag)) then
eolFlag = .true.
Expand All @@ -1376,6 +1377,10 @@ subroutine ESMF_ConfigGetString(config, value, &
value = BLK
config%cptr%eolflag = .true.
config%cptr%next_item = config%cptr%next_line-1
if (present (eolFlag)) then
eolFlag = .true.
end if
localrc = ESMF_SUCCESS
else
! shift to first non blank
ib = ib + nb - 1
Expand Down Expand Up @@ -1411,12 +1416,13 @@ subroutine ESMF_ConfigGetString(config, value, &
if (nb .eq. 0) config%cptr%eolflag = .true.
end if
end if
end if
value = config%cptr%buffer(ib:ie)
if (len (value) >= ie-ib+1) then
localrc = ESMF_SUCCESS
else
localrc = ESMF_RC_ARG_SIZE
value = config%cptr%buffer(ib:ie)
! error if value truncated
if (len (value) >= ie-ib+1) then
localrc = ESMF_SUCCESS
else
localrc = ESMF_RC_ARG_SIZE
end if
end if
end if

Expand Down

0 comments on commit cca4469

Please sign in to comment.