!
select case (ic)
case (10)
nl = nl + one ! line control characters ; 10:LF indicates end of line
num_line = num_line + 1
if (num_line < million) line_index(num_line) = next_char
max_len = max (max_len, line_len)
line_len = 0
case (13)
nl = nl + one ! line control characters ; 10:LF indicates end of line
case (0:9,11,12,14:31)
nc = nc + one ! control characters
case (32:126)
na = na + one ! normal character
line_content(next_char) = c
if (next_char < max_file_size) next_char = next_char + 1
line_len = line_len + 1
case (127:256)
nz = nz + one ! other character
case default
write (*,*) 'Unrecognised character : ichar =',ic
end select
end do
!
write (*,2001) trim(file_name)
2001 format (/'Count of active characters in file ',a// 'Ichar C Char_Count')
2002 format (i5,a5,b'zz,zzz,zzz,zz#',2x,a)
do ic = 256,0,-1
if (count_ic(ic) < one) cycle
if (ic >= 32 .AND. ic < 128) then
write (*,2002) ic, char(ic), count_ic(ic)
else if (ic < 32 .or. ic == 128) then
jc = min (ic,32)
c_typ = ch_name(jc)(4:7)
write (*,2002) ic, c_typ, count_ic(ic), trim (ch_name(jc)(10:))
else
c_typ = '???'
if (ic==10) c_typ = '<LF>'
if (ic==13) c_typ = '<CR>'
write (*,2002) ic, c_typ, count_ic(ic)
end if
end do
!
write (*,*) ' '
if (iostat == -1) then
write (*,2003) n,' characters read from file ',trim(file_name)
else
write (*,2004) 'end of file after',n,' characters : IOSTAT = ',iostat
end if
2003 format (b'zz,zzz,zzz,zz#',a,a)
2004 format (a,b'zz,zzz,zzz,zz#',a,i0)
write (*,2003) na, ' normal text characters 32-126'
write (*,2003) nl, ' line control characters 10,13'
write (*,2003) nc, ' other control characters 0-31'
write (*,2003) nz, ' non-printable characters 127-255'
nl = max (count_ic(10), count_ic(13))
write (*,2003) nl, ' lines identified if text file'
!
if (count_ic(10) == nl .and. count_ic(13) == 0) then
write (*,2000) ' NOTE : No <CR> in file : not typical DOS text file'
end if
!
if ( count_ic(10) /= count_ic(13)) then
if ( count_ic(10) == 0) then
write (*,2000) ' Only <CR> used for end of line'
else if ( count_ic(13) == 0) then
write (*,2000) ' Only <LF> used for end of line'
else
write (*,2000) ' Inconsistent <LF> and <CR> count found'
end if
end if
!
write (*,*) ' '
write (*,2003) num_line-1, ' lines stored'
write (*,2003) max_len, ' maximum line length identified'
write (*,2003) next_char-1, ' text characters identified in file'
!
end