@@ -628,8 +628,6 @@ function mslex_quote(s,for_cmd) result(quoted)
628628
629629 if (scan (s,SPACE_CHARS// DOUBLE_QUOTE)<= 0 ) then
630630
631- ! for example the string Çx\!È can be quoted as Çx\^!È, but
632- ! # _quote_for_cmd would quote it as Ç"x\\"^!È
633631 alt = ms_alternative_quote_for_cmd(s)
634632
635633 ! Use caret-escaped version if it's shorter
@@ -776,6 +774,7 @@ end function mslex_scan_stream
776774 function parse_msvcrt_groups (groups ) result(list)
777775 type (mslex_group), optional , intent (in ) :: groups(:)
778776 type (shlex_token), allocatable :: list(:)
777+ type (shlex_token) :: token
779778
780779 character (kind= SCK,len= :), allocatable :: buffer
781780 integer :: i
@@ -798,7 +797,8 @@ function parse_msvcrt_groups(groups) result(list)
798797
799798 ! End of quote-delimited group: emit buffer (even if "")
800799 if (.not. allocated (buffer)) buffer = " "
801- list = [list, new_token(TOKEN_WORD, buffer)]
800+ token = new_token(TOKEN_WORD, buffer)
801+ list = [list, token]
802802 deallocate (buffer)
803803 quote_mode = .false.
804804 end if
@@ -819,13 +819,17 @@ function parse_msvcrt_groups(groups) result(list)
819819 end do group_loop
820820
821821 ! Always emit buffer (even if it's "")
822- if (allocated (buffer)) list = [list, new_token(TOKEN_WORD, buffer)]
822+ if (allocated (buffer)) then
823+ token = new_token(TOKEN_WORD, buffer)
824+ list = [list, token]
825+ end if
823826
824827 end function parse_msvcrt_groups
825828
826829 function parse_ucrt_groups (groups ) result(list)
827830 type (mslex_group), optional , intent (in ) :: groups(:)
828831 type (shlex_token), allocatable :: list(:)
832+ type (shlex_token) :: token
829833
830834 character (kind= SCK,len= :), allocatable :: buffer
831835 integer :: i
@@ -847,7 +851,8 @@ function parse_ucrt_groups(groups) result(list)
847851 elseif (allocated (buffer)) then
848852 if (.not. allocated (buffer)) buffer = " "
849853 ! Emit current token
850- list = [list, new_token(TOKEN_WORD, buffer)]
854+ token = new_token(TOKEN_WORD, buffer)
855+ list = [list, token]
851856 deallocate (buffer)
852857 end if
853858 end if
@@ -882,7 +887,10 @@ function parse_ucrt_groups(groups) result(list)
882887
883888 end do group_loop
884889
885- if (allocated (buffer)) list = [list, new_token(TOKEN_WORD, buffer)]
890+ if (allocated (buffer)) then
891+ token = new_token(TOKEN_WORD, buffer)
892+ list = [list, token]
893+ end if
886894
887895 end function parse_ucrt_groups
888896
0 commit comments