diff options
author | Jeffrey Armstrong <jeff@approximatrix.com> | 2020-08-08 12:02:59 -0400 |
---|---|---|
committer | Jeffrey Armstrong <jeff@approximatrix.com> | 2020-08-08 12:02:59 -0400 |
commit | f833fc391d3192733c799dcdaf1c4df4c9919f8b (patch) | |
tree | 61960f846063a7cda6843159e3a1c84294817d5d | |
parent | f6a2bd488ca74881855f74f5302078526cfbd81c (diff) | |
download | LR-87-f833fc391d3192733c799dcdaf1c4df4c9919f8b.tar.gz LR-87-f833fc391d3192733c799dcdaf1c4df4c9919f8b.zip |
Added make_directory subroutine. Fixed allocatable favorites to be pointers instead so the program doesn't crash.
-rw-r--r-- | favorites.f90 | 22 | ||||
-rw-r--r-- | gemini.prj | 16 | ||||
-rw-r--r-- | main.F90 | 13 | ||||
-rw-r--r-- | platform.F90 | 14 |
4 files changed, 47 insertions, 18 deletions
diff --git a/favorites.f90 b/favorites.f90 index d1ba7d1..f51a753 100644 --- a/favorites.f90 +++ b/favorites.f90 @@ -187,7 +187,7 @@ contains implicit none integer, intent(in)::unit_number - type(favorite), dimension(:), allocatable::faves + type(favorite), dimension(:), pointer::faves character(80)::temp integer::n, i @@ -250,10 +250,10 @@ contains implicit none integer::find_favorite - type(favorite), dimension(:), allocatable, intent(in)::faves + type(favorite), dimension(:), intent(in), pointer::faves character(*), intent(in)::link - if(.not. allocated(faves)) then + if(.not. associated(faves)) then find_favorite = -1 else do find_favorite = 1, size(faves) @@ -272,17 +272,17 @@ contains subroutine add_favorite(faves, link, name) implicit none - type(favorite), dimension(:), intent(inout), allocatable::faves + type(favorite), dimension(:), intent(inout), pointer::faves character(*), intent(in)::link character(*), intent(in)::name character(8)::now integer::n - type(favorite), dimension(:), allocatable::holding + type(favorite), dimension(:), pointer::holding n = -1 - if(.not. allocated(faves)) then + if(.not. associated(faves)) then n = 1 allocate(faves(1)) @@ -290,16 +290,17 @@ contains else if(find_favorite(faves, link) < 0) then n = size(faves) - allocate(holding(n)) - holding = faves + holding => faves - deallocate(faves) + faves => null() allocate(faves(n+1)) faves(1:n) = holding n = n + 1 + deallocate(holding) + end if if(n > 0) then @@ -315,7 +316,7 @@ contains subroutine remove_favorite(faves, link) implicit none - type(favorite), dimension(:), intent(inout), allocatable::faves + type(favorite), dimension(:), intent(inout), pointer::faves character(*), intent(in)::link integer::i, n @@ -331,6 +332,7 @@ contains else n = size(faves) + allocate(holding(n-1)) if(i > 1) then holding(1:i-1) = faves(1:i-1) @@ -35,6 +35,9 @@ "filename":"escape.f90", "enabled":"1" },{ + "filename":"favorites.f90", + "enabled":"1" + },{ "filename":"files.f90", "enabled":"1" },{ @@ -53,6 +56,9 @@ "filename":"makefile.gnu", "enabled":"1" },{ + "filename":"platform.F90", + "enabled":"1" + },{ "filename":"protocol.f90", "enabled":"1" },{ @@ -65,6 +71,9 @@ "filename":"request.f90", "enabled":"1" },{ + "filename":"sdl_render.f90", + "enabled":"0" + },{ "filename":"test.f90", "enabled":"0" }] @@ -89,7 +98,7 @@ "Target":"lr87", "Fortran Options":{ "Use C Preprocessor":"false", - "Runtime Diagnostics":"false", + "Runtime Diagnostics":"true", "Cray Pointers":"false", "Enable OpenMP":"false", "Enable Coarrays":"false", @@ -105,12 +114,13 @@ }, "Build Dependencies":1, "Launch Options":{ + "Build Before Launch":"true", "Working Directory":"", "Launch Using MPI":"false", "Keep Console":"true", - "External Console":"false", + "Executable":"", "Command Line Arguments":"", - "Build Before Launch":"true" + "External Console":"false" }, "Build Options":{ "Makefile":"Makefile", @@ -27,6 +27,7 @@ use request use ag_render, only: appgraphics_renderer use ag_binary, only: appgraphics_binary_handler #else +!use sdl_render use dumb_render use dumb_binary #endif @@ -71,7 +72,7 @@ implicit none type(line), pointer::first_line type(location), pointer::locations_visited - type(favorite), dimension(:), allocatable::faves + type(favorite), dimension(:), pointer::faves #ifdef WINDOWS call windows_network_startup() @@ -106,7 +107,7 @@ implicit none call r%initialize() ! Load in any favorites - faves = load_favorites() + faves => load_favorites() locations_visited => null() desired_url = initial_site @@ -302,7 +303,7 @@ contains use favorite_handling, only: read_favorites, favorite implicit none - type(favorite), dimension(:), allocatable::faves + type(favorite), dimension(:), pointer::faves character(260)::filename integer::ios, loadunit @@ -315,6 +316,10 @@ contains faves = read_favorites(loadunit) close(loadunit) + else + + faves => null() + end if end function load_favorites @@ -324,7 +329,7 @@ contains use favorite_handling, only: write_favorites, favorite implicit none - type(favorite), dimension(:), allocatable::faves + type(favorite), dimension(:)::faves character(260)::filename integer::ios, loadunit diff --git a/platform.F90 b/platform.F90 index e10ca64..f71abdd 100644 --- a/platform.F90 +++ b/platform.F90 @@ -11,6 +11,15 @@ implicit none contains + subroutine make_directory(dir) + implicit none + + character(*), intent(in)::dir + + call execute_command_line('mkdir "'//trim(dir)//'"') + + end subroutine make_directory + subroutine get_settings_directory(dir) use iso_c_binding implicit none @@ -60,6 +69,9 @@ contains dir = trim(dir)//".lr87" #endif + ! Harmless + call make_directory(dir) + end subroutine get_settings_directory subroutine get_favorites_file(filename) @@ -72,4 +84,4 @@ contains end subroutine get_favorites_file -end module platform
\ No newline at end of file +end module platform |