enable strings > 2Gb
This commit is contained in:
parent
a2bde4a0f0
commit
3e439503fe
16
src/IO.f90
16
src/IO.f90
|
@ -136,7 +136,7 @@ function IO_read(fileName) result(fileContent)
|
|||
if (myStat /= 0) call IO_error(102,trim(fileName))
|
||||
close(fileUnit)
|
||||
|
||||
if (index(fileContent,CR//LF) /= 0) fileContent = CRLF2LF(fileContent)
|
||||
if (index(fileContent,CR//LF,kind=pI64) /= 0) fileContent = CRLF2LF(fileContent)
|
||||
if (fileContent(fileLength:fileLength) /= IO_EOL) fileContent = fileContent//IO_EOL ! ensure EOL@EOF
|
||||
|
||||
end function IO_read
|
||||
|
@ -607,17 +607,17 @@ pure function CRLF2LF(string)
|
|||
character(len=*), intent(in) :: string
|
||||
character(len=:), allocatable :: CRLF2LF
|
||||
|
||||
integer :: c,n
|
||||
integer(pI64) :: c,n
|
||||
|
||||
|
||||
allocate(character(len=len_trim(string))::CRLF2LF)
|
||||
if (len(CRLF2LF) == 0) return
|
||||
allocate(character(len=len_trim(string,pI64))::CRLF2LF)
|
||||
if (len(CRLF2LF,pI64) == 0) return
|
||||
|
||||
n = 0
|
||||
do c=1, len_trim(string)
|
||||
n = 0_pI64
|
||||
do c=1_pI64, len_trim(string,pI64)
|
||||
CRLF2LF(c-n:c-n) = string(c:c)
|
||||
if (c == len_trim(string)) exit
|
||||
if (string(c:c+1) == CR//LF) n = n + 1
|
||||
if (c == len_trim(string,pI64)) exit
|
||||
if (string(c:c+1_pI64) == CR//LF) n = n + 1_pI64
|
||||
end do
|
||||
|
||||
CRLF2LF = CRLF2LF(:c-n)
|
||||
|
|
|
@ -221,7 +221,7 @@ function to_flow(mixed) result(flow)
|
|||
|
||||
|
||||
call to_flow_C(str_ptr,strlen,f_c_string(mixed))
|
||||
if (strlen < 1) call IO_error(703,ext_msg='libyfaml')
|
||||
if (strlen < 1_C_LONG) call IO_error(703,ext_msg='libyfaml')
|
||||
allocate(character(len=strlen,kind=c_char) :: flow)
|
||||
|
||||
block
|
||||
|
|
|
@ -181,15 +181,15 @@ pure function c_f_string(c_string) result(f_string)
|
|||
character(kind=C_CHAR), dimension(:), intent(in) :: c_string
|
||||
character(len=:), allocatable :: f_string
|
||||
|
||||
integer :: i
|
||||
integer(pI64) :: i
|
||||
|
||||
|
||||
allocate(character(len=size(c_string))::f_string)
|
||||
arrayToString: do i=1,len(f_string)
|
||||
allocate(character(len=size(c_string,kind=pI64))::f_string)
|
||||
arrayToString: do i=1_pI64,len(f_string,pI64)
|
||||
if (c_string(i) /= C_NULL_CHAR) then
|
||||
f_string(i:i)=c_string(i)
|
||||
else
|
||||
f_string = f_string(:i-1)
|
||||
f_string = f_string(:i-1_pI64)
|
||||
exit
|
||||
end if
|
||||
end do arrayToString
|
||||
|
@ -203,11 +203,11 @@ end function c_f_string
|
|||
!--------------------------------------------------------------------------------------------------
|
||||
pure function f_c_string(f_string) result(c_string)
|
||||
|
||||
character(len=*), intent(in) :: f_string
|
||||
character(kind=C_CHAR), dimension(len_trim(f_string)+1) :: c_string
|
||||
character(len=*), intent(in) :: f_string
|
||||
character(kind=C_CHAR), dimension(len_trim(f_string,pI64)+1_pI64) :: c_string
|
||||
|
||||
|
||||
c_string = transfer(trim(f_string)//C_NULL_CHAR,c_string,size=size(c_string))
|
||||
c_string = transfer(trim(f_string)//C_NULL_CHAR,c_string,size=size(c_string,kind=pI64))
|
||||
|
||||
end function f_c_string
|
||||
|
||||
|
|
Loading…
Reference in New Issue