Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always enclose filename in quotes in execute function if it isn't already #51

Merged
merged 2 commits into from
Aug 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/pyplot_module.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1397,6 +1397,12 @@
file = trim(pyfile) !use the user-specified name
end if

if (file == '') then
if (present(istat)) istat = -1
write(error_unit,'(A)') 'Error: filename is blank.'
return

Check warning on line 1403 in src/pyplot_module.F90

View check run for this annotation

Codecov / codecov/patch

src/pyplot_module.F90#L1401-L1403

Added lines #L1401 - L1403 were not covered by tests
end if

!open the file:
open(newunit=iunit, file=file, status='REPLACE', iostat=iostat)
if (iostat/=0) then
Expand All @@ -1423,8 +1429,8 @@
end if

!run the file using python:
if (index(file,' ')>0) then
! space in path, probably should enclose in quotes
if (file(1:1)/='"') then
! if not already in quotes, should enclose in quotes
call execute_command_line(python_//' "'//file//'"')
else
call execute_command_line(python_//' '//file)
Expand Down
6 changes: 6 additions & 0 deletions test/test.f90
Original file line number Diff line number Diff line change
Expand Up @@ -201,5 +201,11 @@ program test
dpi='200', &
transparent=.true.,istat=istat, python='python')

! also test one with spaces and () in the filename
call plt%savefig(testdir//'error bar (1).png', &
pyfile=testdir//'error bar (1).py', &
dpi='200', &
transparent=.true.,istat=istat, python='python')

end program test
!*****************************************************************************************
Loading