aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2020-05-27 16:20:20 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2020-05-27 16:20:20 -0400
commitbeb210f16f2e351470f90b771ff95d9f18e95073 (patch)
tree91b56041e41391c27930f62bc274a35d66941577
parent8088abdfae2f18520b9135221885479ae37a5dae (diff)
downloadLR-87-beb210f16f2e351470f90b771ff95d9f18e95073.tar.gz
LR-87-beb210f16f2e351470f90b771ff95d9f18e95073.zip
Fixed handling of status code in renderers. Added a desired_url variable to maintain a current_url when a failure occurs.
-rw-r--r--files.f9019
-rw-r--r--gemini.prj3
-rw-r--r--main.F9035
3 files changed, 40 insertions, 17 deletions
diff --git a/files.f90 b/files.f90
index b9f6d5a..9da1ae8 100644
--- a/files.f90
+++ b/files.f90
@@ -48,6 +48,21 @@ contains
end function is_file_end_marker
+ subroutine skip_line(unit_number)
+ implicit none
+
+ integer, intent(in)::unit_number
+
+ character::c
+ integer::iostatus
+
+ read(unit_number, '(A1)', advance='no', iostat=iostatus) c
+ do while(c /= CHAR(10) .AND. iostatus == 0)
+ read(unit_number, '(A1)', advance='no', iostat=iostatus) c
+ end do
+
+ end subroutine skip_line
+
subroutine read_line_text(unit_number, res, iostatus)
implicit none
@@ -166,6 +181,10 @@ contains
allocate(first_line)
+ ! Skip the first line - it has the status code
+ rewind(unit_number)
+ call skip_line(unit_number)
+
call read_line_text(unit_number, first_line%text, iostatus)
first_line%next => null()
diff --git a/gemini.prj b/gemini.prj
index f61f32e..f16d855 100644
--- a/gemini.prj
+++ b/gemini.prj
@@ -50,6 +50,9 @@
"filename":"main.F90",
"enabled":"1"
},{
+ "filename":"makefile.gnu",
+ "enabled":"1"
+ },{
"filename":"protocol.f90",
"enabled":"1"
},{
diff --git a/main.F90 b/main.F90
index 9055664..02eab98 100644
--- a/main.F90
+++ b/main.F90
@@ -45,7 +45,7 @@ use wsa_network, only: windows_network_startup => startup
implicit none
character(256)::initial_site
- character(1024)::current_url, input
+ character(1024)::current_url, desired_url, input
type(connection)::conn
#ifdef WINDOWS_GUI
@@ -101,15 +101,16 @@ implicit none
call r%initialize()
locations_visited => null()
- current_url = initial_site
+ desired_url = initial_site
+ current_url = " "
first_line => null()
open(unit=io, form="formatted", status="scratch", access='stream')
do while(running)
- if(index(current_url, "gemini://") /= 1) then
- redo_layout = r%report_unsupported_protocol(trim(current_url))
+ if(index(desired_url, "gemini://") /= 1) then
+ redo_layout = r%report_unsupported_protocol(trim(desired_url))
populated = .false.
loaded = .true.
return_code = STATUS_LOCALFAIL
@@ -117,24 +118,24 @@ implicit none
if(.not. loaded) then
- call r%report_status("Requesting "//trim(current_url))
+ call r%report_status("Requesting "//trim(desired_url))
- return_code = request_url(current_url, io, return_type, bh)
+ return_code = request_url(desired_url, io, return_type, bh)
populated = .true.
- call update_status(r, current_url, return_code)
+ call update_status(r, desired_url, return_code)
end if
if(return_code == STATUS_REDIRECT) then
- call get_redirect_url(io, current_url)
+ call get_redirect_url(io, desired_url)
loaded = .false.
populated = .false.
else if(return_code == STATUS_INPUT) then
- if(handle_input(r, current_url, io)) then
+ if(handle_input(r, desired_url, io)) then
! Should force a new load
loaded = .false.
else
@@ -143,6 +144,9 @@ implicit none
else if(populated) then
+ current_url = desired_url
+ desired_url = " "
+
locations_visited => add_location(locations_visited, current_url)
if(r%type_supported(return_type)) then
@@ -162,7 +166,7 @@ implicit none
else
call r%draw_error("Cannot display file of type "//return_type)
- call back_location(locations_visited, current_url)
+ call back_location(locations_visited, desired_url)
end if
@@ -185,7 +189,7 @@ implicit none
running = .false.
case (render_action_back)
- call back_location(locations_visited, current_url)
+ call back_location(locations_visited, desired_url)
loaded = .false.
case (render_action_layout)
@@ -196,16 +200,13 @@ implicit none
end if
case (render_action_goto)
-
if(index(input, "://") > 0) then
- current_url = input
+ desired_url = input
else
- call handle_relative_url(current_url, input)
+ desired_url = current_url
+ call handle_relative_url(desired_url, input)
end if
- !if(associated(first_line)) then
- ! call free_lines(first_line)
- !end if
loaded = .false.
end select