fix: skip <<< (here-string) in heredoc detection — was consuming subsequent lines as heredoc content
- SHA
f972eadd6a458ced993ee083a49087869bdda1d0- Parents
-
f89c518 - Tree
390d173
f972ead
f972eadd6a458ced993ee083a49087869bdda1d0f89c518
390d173| Status | File | + | - |
|---|---|---|---|
| M |
src/fortsh.f90
|
10 | 2 |
| M |
src/parsing/parser.f90
|
6 | 1 |
src/fortsh.f90modified@@ -599,9 +599,11 @@ contains | ||
| 599 | 599 | in_double_quote = .not. in_double_quote |
| 600 | 600 | end if |
| 601 | 601 | |
| 602 | - ! Check for << when outside quotes | |
| 602 | + ! Check for << when outside quotes (but NOT <<< which is here-string) | |
| 603 | 603 | if (.not. in_single_quote .and. .not. in_double_quote) then |
| 604 | 604 | if (str(i:i+1) == '<<') then |
| 605 | + ! Skip <<< (here-string) | |
| 606 | + if (i + 2 <= len_trim(str) .and. str(i+2:i+2) == '<') cycle | |
| 605 | 607 | has_heredoc = .true. |
| 606 | 608 | return |
| 607 | 609 | end if |
@@ -682,9 +684,15 @@ contains | ||
| 682 | 684 | in_double_quote = .not. in_double_quote |
| 683 | 685 | end if |
| 684 | 686 | |
| 685 | - ! Check for << when outside quotes | |
| 687 | + ! Check for << when outside quotes (but NOT <<< which is here-string) | |
| 686 | 688 | if (.not. in_single_quote .and. .not. in_double_quote) then |
| 687 | 689 | if (cmd_line(search_pos:search_pos+1) == '<<') then |
| 690 | + ! Skip <<< (here-string) | |
| 691 | + if (search_pos + 2 <= len_trim(cmd_line) .and. & | |
| 692 | + cmd_line(search_pos+2:search_pos+2) == '<') then | |
| 693 | + search_pos = search_pos + 3 | |
| 694 | + cycle | |
| 695 | + end if | |
| 688 | 696 | j = search_pos |
| 689 | 697 | exit |
| 690 | 698 | end if |
src/parsing/parser.f90modified@@ -2727,8 +2727,13 @@ contains | ||
| 2727 | 2727 | i = i + 1; cycle |
| 2728 | 2728 | end if |
| 2729 | 2729 | |
| 2730 | - ! Look for << not inside quotes | |
| 2730 | + ! Look for << not inside quotes (but NOT <<< which is here-string) | |
| 2731 | 2731 | if (line(i:i) == '<' .and. i + 1 <= line_len .and. line(i+1:i+1) == '<') then |
| 2732 | + ! Skip <<< (here-string, not heredoc) | |
| 2733 | + if (i + 2 <= line_len .and. line(i+2:i+2) == '<') then | |
| 2734 | + i = i + 3 | |
| 2735 | + cycle | |
| 2736 | + end if | |
| 2732 | 2737 | i = i + 2 |
| 2733 | 2738 | ! Skip <<- (strip tabs variant) |
| 2734 | 2739 | strip_tabs = .false. |