fortrangoingonforty/ferp / 4dc60e3

Browse files

Fix -f pattern file reading

- Change from formatted to unformatted stream access for byte-by-byte reading
- Fixes issue where only first pattern was read from pattern files
- Properly handle newlines across different platforms
Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
4dc60e32c5a31a4661cabf2ef13d84221be2d911
Parents
be9dcf3
Tree
e60ae4a

1 changed file

StatusFile+-
M src/ferp_cli.f90 5 5
src/ferp_cli.f90modified
@@ -115,8 +115,8 @@ contains
115115
       return
116116
     end if
117117
 
118
-    ! Validate: need at least one pattern
119
-    if (size(patterns) == 0) then
118
+    ! Validate: need at least one pattern source (but empty pattern file is valid)
119
+    if (.not. has_explicit_pattern) then
120120
       write(error_unit, '(A)') 'ferp: no pattern specified'
121121
       write(error_unit, '(A)') "Try 'ferp --help' for more information."
122122
       ierr = 2
@@ -699,9 +699,9 @@ contains
699699
     character(len=1) :: ch
700700
 
701701
     ierr = 0
702
-    ! Use stream access to read exact line lengths (preserving whitespace patterns)
702
+    ! Use unformatted stream access for byte-by-byte reading
703703
     open(newunit=unit_num, file=filename, status='old', action='read', &
704
-         access='stream', form='formatted', iostat=ios)
704
+         access='stream', form='unformatted', iostat=ios)
705705
     if (ios /= 0) then
706706
       write(error_unit, '(A)') 'ferp: ' // trim(filename) // ': No such file or directory'
707707
       ierr = 2
@@ -712,7 +712,7 @@ contains
712712
     line = ''
713713
 
714714
     do
715
-      read(unit_num, '(A1)', iostat=ios, advance='no') ch
715
+      read(unit_num, iostat=ios) ch
716716
       if (ios /= 0) then
717717
         ! EOF or error - save current line if non-empty
718718
         if (line_len > 0) then