@@ -544,14 +544,17 @@ subroutine format_output_string( self, unit, string, procedure_name, &
544
544
545
545
subroutine format_first_line ()
546
546
547
- if ( length <= self % max_width .or. self % max_width == 0 ) then
547
+ if ( self % max_width == 0 .or. &
548
+ ( length <= self % max_width .and. &
549
+ index ( string (1 :min (length, self % max_width)), new_line(' a' )) == 0 &
550
+ )) then
548
551
write ( unit, ' (a)' , err= 999 , iostat= iostat, iomsg= iomsg ) &
549
552
string (1 :length)
550
553
remain = 0
551
554
return
552
555
else
553
556
554
- index_ = index ( string (1 :self % max_width), new_line(' a' ))
557
+ index_ = index ( string (1 :min (length, self % max_width) ), new_line(' a' ))
555
558
if ( index_ == 0 ) then
556
559
do index_= self % max_width, 1 , - 1
557
560
if ( string (index_:index_) == ' ' ) exit
@@ -627,8 +630,9 @@ subroutine indent_format_subsequent_line()
627
630
return
628
631
else
629
632
630
- index_ = count + index ( string (count+1 :count+ self % max_width &
631
- - indent_len), new_line(' a' ))
633
+ index_ = count + index ( string (count+1 : &
634
+ min ( length, count+ self % max_width - indent_len) ), &
635
+ new_line(' a' ))
632
636
if (index_ == count) then
633
637
do index_= count+ self % max_width- indent_len, count+1 , - 1
634
638
if ( string (index_:index_) == ' ' ) exit
0 commit comments