diff src/mygetline.c @ 754:ecb991e41a4c

Add $controlN$ substitution The interfaces to substitute() and substitute_one() have changed, as they now need to know the listdir to be able to find control files
author Ben Schmidt
date Wed, 06 Oct 2010 23:30:26 +1100
parents 136e5bc27f7a
children 5bab557020a6
line wrap: on
line diff
--- a/src/mygetline.c	Wed Oct 06 23:26:26 2010 +1100
+++ b/src/mygetline.c	Wed Oct 06 23:30:26 2010 +1100
@@ -30,7 +30,7 @@
 #include "mygetline.h"
 #include "memory.h"
 
-char *mygetline(int fd)
+static char *mygetuntil(int fd, char eof)
 {
 	size_t i = 0, res, buf_size = BUFSIZE;  /* initial buffer size */
 	char *buf, ch;
@@ -62,9 +62,19 @@
 			buf = myrealloc(buf, buf_size);
 		}
 		buf[i++] = ch;
-		if(ch == '\n') {
+		if(ch == eof) {
 			buf[i] = '\0';
 			return buf;
 		}
 	}
 }
+
+char *mygetline(int fd)
+{
+	return mygetuntil(fd, '\n');
+}
+
+char *mygetcontent(int fd)
+{
+	return mygetuntil(fd, '\0');
+}