fortrangoingonforty/ferp / c5ced7d

Browse files

fixes

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
c5ced7d76be1466968088018dd973a799e208756
Parents
7373e0f
Tree
ca166dd

2 changed files

StatusFile+-
M src/ferp_io.f90 6 1
M src/regex/regex_optimizer.f90 3 11
src/ferp_io.f90modified
@@ -230,7 +230,12 @@ contains
230230
 
231231
     ! Read byte by byte until NUL or EOF
232232
     do
233
-      read(this%unit_num, iostat=ios) ch
233
+      ! Use formatted read for stdin, unformatted for files
234
+      if (this%source_type == SOURCE_STDIN) then
235
+        read(this%unit_num, '(A1)', iostat=ios, advance='no') ch
236
+      else
237
+        read(this%unit_num, iostat=ios) ch
238
+      end if
234239
 
235240
       if (ios == iostat_end) then
236241
         this%eof_reached = .true.
src/regex/regex_optimizer.f90modified
@@ -561,18 +561,10 @@ contains
561561
         call next_set%clear()
562562
 
563563
         ! Compute NFA transitions for this character
564
+        ! Note: DFA is case-sensitive. Case-insensitive matching uses NFA path.
564565
         call compute_char_transitions_simple(opt%nfa, opt%dfa%states(dfa_idx)%nfa_states, &
565566
                                              char(char_code), next_set)
566567
 
567
-        ! For alphabetic characters, also compute transitions for opposite case
568
-        if (char_code >= ichar('a') .and. char_code <= ichar('z')) then
569
-          call compute_char_transitions_simple(opt%nfa, opt%dfa%states(dfa_idx)%nfa_states, &
570
-                                               char(char_code - 32), next_set)
571
-        else if (char_code >= ichar('A') .and. char_code <= ichar('Z')) then
572
-          call compute_char_transitions_simple(opt%nfa, opt%dfa%states(dfa_idx)%nfa_states, &
573
-                                               char(char_code + 32), next_set)
574
-        end if
575
-
576568
         ! Compute epsilon closure of result
577569
         if (.not. next_set%is_empty()) then
578570
           call expand_epsilon_closure_simple(opt, next_set)
@@ -1033,8 +1025,8 @@ contains
10331025
     if (opt%nfa%num_states == 0) return
10341026
 
10351027
     ! Fast path: use DFA if available (O(n) matching)
1036
-    ! DFA now supports case-insensitive matching via case-folded transitions
1037
-    if (opt%use_dfa) then
1028
+    ! DFA is case-sensitive; case-insensitive matching falls through to NFA path
1029
+    if (opt%use_dfa .and. .not. ignore_case) then
10381030
       res = dfa_search(opt%dfa, text, text_len)
10391031
       return
10401032
     end if