summary refs log tree commit diff stats
path: root/src/common/text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/text.c')
-rw-r--r--src/common/text.c33
1 files changed, 1 insertions, 32 deletions
diff --git a/src/common/text.c b/src/common/text.c
index a2198517..fcde5870 100644
--- a/src/common/text.c
+++ b/src/common/text.c
@@ -19,13 +19,11 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <unistd.h>
 #include <ctype.h>
 #include <time.h>
 #include <sys/types.h>
 #include <fcntl.h>
 #include <sys/stat.h>
-#include <sys/mman.h>
 
 #include "xchat.h"
 #include <glib/ghash.h>
@@ -271,9 +269,6 @@ scrollback_load (session *sess)
 	char *text;
 	time_t stamp;
 	int lines;
-	char *map, *end_map;
-	struct stat statbuf;
-	const char *begin, *eol;
 
 	if (sess->text_scrollback == SET_DEFAULT)
 	{
@@ -293,32 +288,9 @@ scrollback_load (session *sess)
 	if (fh == -1)
 		return;
 
-	if (fstat (fh, &statbuf) < 0)
-		return;
-
-	map = mmap (NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, fh, 0);
-	if (map == MAP_FAILED)
-		return;
-
-	end_map = map + statbuf.st_size;
-	
 	lines = 0;
-	begin = map;
-	while (begin < end_map)
+	while (waitline (fh, buf, sizeof buf, FALSE) != -1)
 	{
-		int n_bytes;
-
-		eol = memchr (begin, '\n', end_map - begin);
-
-		if (!eol)
-			eol = end_map;
-
-		n_bytes = MIN (eol - begin, sizeof (buf) - 1);
-		
-		strncpy (buf, begin, n_bytes);
-
-		buf[n_bytes] = 0;
-		
 		if (buf[0] == 'T')
 		{
 			if (sizeof (time_t) == 4)
@@ -334,8 +306,6 @@ scrollback_load (session *sess)
 			}
 			lines++;
 		}
-
-		begin = eol + 1;
 	}
 
 	sess->scrollwritten = lines;
@@ -349,7 +319,6 @@ scrollback_load (session *sess)
 		/*EMIT_SIGNAL (XP_TE_GENMSG, sess, "*", buf, NULL, NULL, NULL, 0);*/
 	}
 
-	munmap (map, statbuf.st_size);
 	close (fh);
 }