about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation
diff options
context:
space:
mode:
Diffstat (limited to 'WWW/Library/Implementation')
-rw-r--r--WWW/Library/Implementation/HTFile.c5
-rw-r--r--WWW/Library/Implementation/HTFile.h1
-rw-r--r--WWW/Library/Implementation/HTMLDTD.c4
-rw-r--r--WWW/Library/Implementation/HTTCP.c27
4 files changed, 33 insertions, 4 deletions
diff --git a/WWW/Library/Implementation/HTFile.c b/WWW/Library/Implementation/HTFile.c
index a0064f53..7a647b24 100644
--- a/WWW/Library/Implementation/HTFile.c
+++ b/WWW/Library/Implementation/HTFile.c
@@ -2929,6 +2929,11 @@ void HTInitProgramPaths(void)
 	    path = RMDIR_PATH;
 	    break;
 #endif
+#ifdef SETFONT_PATH
+	case ppSETFONT:
+	    path = SETFONT_PATH;
+	    break;
+#endif
 #ifdef TAR_PATH
 	case ppTAR:
 	    path = TAR_PATH;
diff --git a/WWW/Library/Implementation/HTFile.h b/WWW/Library/Implementation/HTFile.h
index 4541fb49..146857ff 100644
--- a/WWW/Library/Implementation/HTFile.h
+++ b/WWW/Library/Implementation/HTFile.h
@@ -301,6 +301,7 @@ extern "C" {
 	,ppRLOGIN
 	,ppRM
 	,ppRMDIR
+	,ppSETFONT
 	,ppTAR
 	,ppTELNET
 	,ppTN3270
diff --git a/WWW/Library/Implementation/HTMLDTD.c b/WWW/Library/Implementation/HTMLDTD.c
index 2cd6bc69..b46d8a05 100644
--- a/WWW/Library/Implementation/HTMLDTD.c
+++ b/WWW/Library/Implementation/HTMLDTD.c
@@ -1736,11 +1736,11 @@ void HTStartAnchor5(HTStructured * obj, const char *name,
 	present[HTML_A_NAME] = YES;
 	value[HTML_A_NAME] = name;
     }
-    if (href) {
+    if (href && *href) {
 	present[HTML_A_HREF] = YES;
 	value[HTML_A_HREF] = href;
     }
-    if (linktype) {
+    if (linktype && *linktype) {
 	present[HTML_A_TYPE] = YES;
 	value[HTML_A_TYPE] = linktype;
     }
diff --git a/WWW/Library/Implementation/HTTCP.c b/WWW/Library/Implementation/HTTCP.c
index 3b02528d..25cdb170 100644
--- a/WWW/Library/Implementation/HTTCP.c
+++ b/WWW/Library/Implementation/HTTCP.c
@@ -608,6 +608,28 @@ extern int h_errno;
 #endif
 #endif
 
+/*
+ * Even though it is a small amount, we cannot count on reading the whole
+ * struct via a pipe in one read -TD
+ */
+static unsigned readit(int fd, char *buffer, unsigned length)
+{
+    unsigned result = 0;
+
+    while (length != 0) {
+	unsigned got = read(fd, buffer, length);
+
+	if (got != 0) {
+	    result += got;
+	    buffer += got;
+	    length -= got;
+	} else {
+	    break;
+	}
+    }
+    return result;
+}
+
 /*	Resolve an internet hostname, like gethostbyname
  *	------------------------------------------------
  *
@@ -883,6 +905,7 @@ LYNX_HOSTENT *LYGetHostByName(char *str)
 		 * Return our resulting rehostent through pipe...
 		 */
 		write(pfd[1], rehostent, rehostentlen);
+		close(pfd[1]);
 		_exit(0);
 	    } else {
 		/*
@@ -952,7 +975,7 @@ LYNX_HOSTENT *LYGetHostByName(char *str)
 		/*
 		 * First get status, including length of address.  -BL, kw
 		 */
-		readret = read(pfd[0], &statuses, sizeof(statuses));
+		readret = readit(pfd[0], (char *) &statuses, sizeof(statuses));
 		if (readret == sizeof(statuses)) {
 		    h_errno = statuses.child_h_errno;
 		    set_errno(statuses.child_errno);
@@ -997,7 +1020,7 @@ LYNX_HOSTENT *LYGetHostByName(char *str)
 			/*
 			 * Then get the full reorganized hostent.  -BL, kw
 			 */
-			readret = read(pfd[0], rehostent, statuses.rehostentlen);
+			readret = readit(pfd[0], rehostent, statuses.rehostentlen);
 #ifdef DEBUG_HOSTENT
 			dump_hostent("Read from pipe", (LYNX_HOSTENT *) rehostent);
 #endif
.il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
-- helpers for selecting portions of text

-- Return any intersection of the region from State.selection1 to State.cursor1 (or
-- current mouse, if mouse is pressed; or recent mouse if mouse is pressed and
-- currently over a drawing) with the region between {line=line_index, pos=apos}
-- and {line=line_index, pos=bpos}.
-- apos must be less than bpos. However State.selection1 and State.cursor1 can be in any order.
-- Result: positions spos,epos between apos,bpos.
function Text.clip_selection(State, line_index, apos, bpos)
  if State.selection1.line == nil then return nil,nil end
  -- min,max = sorted(State.selection1,State.cursor1)
  local minl,minp = State.selection1.line,State.selection1.pos
  local maxl,maxp
  if App.mouse_down(1) then
    maxl,maxp = Text.mouse_pos(State)
  else
    maxl,maxp = State.cursor1.line,State.cursor1.pos
  end
  if Text.lt1({line=maxl, pos=maxp},
              {line=minl, pos=minp}) then
    minl,maxl = maxl,minl
    minp,maxp = maxp,minp
  end
  -- check if intervals are disjoint
  if line_index < minl then return nil,nil end
  if line_index > maxl then return nil,nil end
  if line_index == minl and bpos <= minp then return nil,nil end
  if line_index == maxl and apos >= maxp then return nil,nil end
  -- compare bounds more carefully (start inclusive, end exclusive)
  local a_ge = Text.le1({line=minl, pos=minp}, {line=line_index, pos=apos})
  local b_lt = Text.lt1({line=line_index, pos=bpos}, {line=maxl, pos=maxp})
--?   print(minl,line_index,maxl, '--', minp,apos,bpos,maxp, '--', a_ge,b_lt)
  if a_ge and b_lt then
    -- fully contained
    return apos,bpos
  elseif a_ge then
    assert(maxl == line_index)
    return apos,maxp
  elseif b_lt then
    assert(minl == line_index)
    return minp,bpos
  else
    assert(minl == maxl and minl == line_index)
    return minp,maxp
  end
end

-- draw highlight for line corresponding to (lo,hi) given an approximate x,y and pos on the same screen line
-- Creates text objects every time, so use this sparingly.
-- Returns some intermediate computation useful elsewhere.
function Text.draw_highlight(State, line, x,y, pos, lo,hi)
  if lo then
    local lo_offset = Text.offset(line.data, lo)
    local hi_offset = Text.offset(line.data, hi)
    local pos_offset = Text.offset(line.data, pos)
    local lo_px
    if pos == lo then
      lo_px = 0
    else
      local before = line.data:sub(pos_offset, lo_offset-1)
      local before_text = App.newText(love.graphics.getFont(), before)
      lo_px = App.width(before_text)
    end
--?     print(lo,pos,hi, '--', lo_offset,pos_offset,hi_offset, '--', lo_px)
    local s = line.data:sub(lo_offset, hi_offset-1)
    local text = App.newText(love.graphics.getFont(), s)
    local text_width = App.width(text)
    App.color(Highlight_color)
    love.graphics.rectangle('fill', x+lo_px,y, text_width,State.line_height)
    App.color(Text_color)
    return lo_px
  end
end

-- inefficient for some reason, so don't do it on every frame
function Text.mouse_pos(State)
  local time = love.timer.getTime()
  if State.recent_mouse.time and State.recent_mouse.time > time-0.1 then
    return State.recent_mouse.line, State.recent_mouse.pos
  end
  State.recent_mouse.time = time
  local line,pos = Text.to_pos(State, App.mouse_x(), App.mouse_y())
  if line then
    State.recent_mouse.line = line
    State.recent_mouse.pos = pos
  end
  return State.recent_mouse.line, State.recent_mouse.pos
end

function Text.to_pos(State, x,y)
  for line_index,line in ipairs(State.lines) do
    if Text.in_line(State, line_index, x,y) then
      return line_index, Text.to_pos_on_line(State, line_index, x,y)
    end
  end
end

function Text.cut_selection(State)
  if State.selection1.line == nil then return end
  local result = Text.selection(State)
  Text.delete_selection(State)
  return result
end

function Text.delete_selection(State)
  if State.selection1.line == nil then return end
  local minl,maxl = minmax(State.selection1.line, State.cursor1.line)
  local before = snapshot(State, minl, maxl)
  Text.delete_selection_without_undo(State)
  record_undo_event(State, {before=before, after=snapshot(State, State.cursor1.line)})
end

function Text.delete_selection_without_undo(State)
  if State.selection1.line == nil then return end
  -- min,max = sorted(State.selection1,State.cursor1)
  local minl,minp = State.selection1.line,State.selection1.pos
  local maxl,maxp = State.cursor1.line,State.cursor1.pos
  if minl > maxl then
    minl,maxl = maxl,minl
    minp,maxp = maxp,minp
  elseif minl == maxl then
    if minp > maxp then
      minp,maxp = maxp,minp
    end
  end
  -- update State.cursor1 and State.selection1
  State.cursor1.line = minl
  State.cursor1.pos = minp
  if Text.lt1(State.cursor1, State.screen_top1) then
    State.screen_top1.line = State.cursor1.line
    State.screen_top1.pos = Text.pos_at_start_of_screen_line(State, State.cursor1)
  end
  State.selection1 = {}
  -- delete everything between min (inclusive) and max (exclusive)
  Text.clear_screen_line_cache(State, minl)
  local min_offset = Text.offset(State.lines[minl].data, minp)
  local max_offset = Text.offset(State.lines[maxl].data, maxp)
  if minl == maxl then
--?     print('minl == maxl')
    State.lines[minl].data = State.lines[minl].data:sub(1, min_offset-1)..State.lines[minl].data:sub(max_offset)
    return
  end
  assert(minl < maxl)
  local rhs = State.lines[maxl].data:sub(max_offset)
  for i=maxl,minl+1,-1 do
    table.remove(State.lines, i)
    table.remove(State.line_cache, i)
  end
  State.lines[minl].data = State.lines[minl].data:sub(1, min_offset-1)..rhs
end

function Text.selection(State)
  if State.selection1.line == nil then return end
  -- min,max = sorted(State.selection1,State.cursor1)
  local minl,minp = State.selection1.line,State.selection1.pos
  local maxl,maxp = State.cursor1.line,State.cursor1.pos
  if minl > maxl then
    minl,maxl = maxl,minl
    minp,maxp = maxp,minp
  elseif minl == maxl then
    if minp > maxp then
      minp,maxp = maxp,minp
    end
  end
  local min_offset = Text.offset(State.lines[minl].data, minp)
  local max_offset = Text.offset(State.lines[maxl].data, maxp)
  if minl == maxl then
    return State.lines[minl].data:sub(min_offset, max_offset-1)
  end
  assert(minl < maxl)
  local result = {State.lines[minl].data:sub(min_offset)}
  for i=minl+1,maxl-1 do
    table.insert(result, State.lines[i].data)
  end
  table.insert(result, State.lines[maxl].data:sub(1, max_offset-1))
  return table.concat(result, '\n')
end