From 2e87199d7b27f8e2ca03ccbf13cfa01fc23d2865 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Thu, 18 Jun 2020 20:05:37 -0400 Subject: Improved line wrapping calcs to search for break from beginning of string. Fixed unnecessary connection error when reporting unsupported protocol by adding a protocol fail status. --- main.F90 | 9 ++++++--- protocol.f90 | 26 ++++++++++++++++---------- render.f90 | 26 ++++++++++++++++++-------- 3 files changed, 40 insertions(+), 21 deletions(-) diff --git a/main.F90 b/main.F90 index 126796b..7021195 100644 --- a/main.F90 +++ b/main.F90 @@ -114,7 +114,7 @@ implicit none redo_layout = r%report_unsupported_protocol(trim(desired_url)) populated = .false. loaded = .true. - return_code = STATUS_LOCALFAIL + return_code = STATUS_PROTOCOLFAIL end if if(.not. loaded) then @@ -123,7 +123,6 @@ implicit none return_code = request_url(desired_url, io, return_type, bh) populated = .not. is_failure_code(return_code) - Print *, "return code: ", return_code call update_status(r, desired_url, return_code) end if @@ -188,7 +187,11 @@ implicit none else if(is_failure_code(return_code)) then - call r%draw_error("Could not connect to "//desired_url) + ! Only explicitly show an error if it isn't a protocol failure + if(return_code /= STATUS_PROTOCOLFAIL) then + call r%draw_error("Could not connect to "//desired_url) + end if + loaded = .true. end if diff --git a/protocol.f90 b/protocol.f90 index adb3760..613ca9f 100644 --- a/protocol.f90 +++ b/protocol.f90 @@ -23,15 +23,16 @@ module gemini_protocol implicit none - integer, parameter::STATUS_INPUT = 1 - integer, parameter::STATUS_SUCCESS = 2 - integer, parameter::STATUS_REDIRECT = 3 - integer, parameter::STATUS_TEMPFAIL = 4 - integer, parameter::STATUS_PERMFAIL = 5 - integer, parameter::STATUS_CERTREQ = 6 - integer, parameter::STATUS_BADRESPONSE = 7 - integer, parameter::STATUS_LOCALFAIL = -1 - integer, parameter::STATUS_CONNECTFAIL = -2 + integer, parameter::STATUS_INPUT = 1 + integer, parameter::STATUS_SUCCESS = 2 + integer, parameter::STATUS_REDIRECT = 3 + integer, parameter::STATUS_TEMPFAIL = 4 + integer, parameter::STATUS_PERMFAIL = 5 + integer, parameter::STATUS_CERTREQ = 6 + integer, parameter::STATUS_BADRESPONSE = 7 + integer, parameter::STATUS_LOCALFAIL = -1 + integer, parameter::STATUS_CONNECTFAIL = -2 + integer, parameter::STATUS_PROTOCOLFAIL = -3 integer, parameter::BUFFER_SIZE = 256 @@ -46,7 +47,12 @@ contains logical::is_failure_code is_failure_code = any(return_code == & - [STATUS_CONNECTFAIL, STATUS_LOCALFAIL, STATUS_BADRESPONSE, STATUS_PERMFAIL, STATUS_TEMPFAIL]) + [STATUS_CONNECTFAIL, & + STATUS_LOCALFAIL, & + STATUS_BADRESPONSE, & + STATUS_PERMFAIL, & + STATUS_TEMPFAIL, & + STATUS_PROTOCOLFAIL]) end function is_failure_code diff --git a/render.f90 b/render.f90 index b37eb50..54f50e4 100644 --- a/render.f90 +++ b/render.f90 @@ -296,7 +296,7 @@ contains integer, intent(in)::startpos integer, intent(in)::proportional_type integer::endpos - integer::my_start + integer::my_start, last_end integer::w my_start = startpos @@ -306,15 +306,25 @@ contains endpos = len_trim(text) w = width_of_line(r, text, my_start, endpos, proportional_type) - do while(w > r%max_width) - - endpos = endpos - 1 - do while(text(endpos:endpos) /= ' ' .and. text(endpos:endpos) /= '-' .and. endpos > my_start) - endpos = endpos - 1 + if(w > r%max_width) then + + w = 0 + endpos = startpos+1 + do while(w <= r%max_width) + + last_end = endpos + endpos = endpos + 1 + do while(text(endpos:endpos) /= ' ' .and. text(endpos:endpos) /= '-') + endpos = endpos + 1 + end do + + w = width_of_line(r, text, my_start, endpos, proportional_type) + end do - w = width_of_line(r, text, my_start, endpos, proportional_type) - end do + endpos = last_end + + end if end function wrap_line -- cgit v1.2.3