about summary refs log tree commit diff
path: root/mscan.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2016-07-20 23:22:59 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2016-07-20 23:22:59 +0200
commitaf9e32ecf836906f8c817dccaa7ea171ad404587 (patch)
treeb4104c192095320701767f9d3bf64d7c2d1c21b0 /mscan.c
parenta2f2a80ee216c9b9ad6619bf4fe6ed4386f43648 (diff)
downloadmblaze-af9e32ecf836906f8c817dccaa7ea171ad404587.tar.gz
mblaze-af9e32ecf836906f8c817dccaa7ea171ad404587.tar.xz
mblaze-af9e32ecf836906f8c817dccaa7ea171ad404587.zip
mscan: delay loading of map until first line is read
Diffstat (limited to 'mscan.c')
-rw-r--r--mscan.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/mscan.c b/mscan.c
index 7a94c55..8093f7f 100644
--- a/mscan.c
+++ b/mscan.c
@@ -50,6 +50,16 @@ u8putstr(FILE *out, char *s, size_t l, int pad)
 void
 oneline(char *file)
 {
+	static int init;
+	if (!init) {
+		// delay loading of the seqmap until we need to scan the first
+		// file, in case someone in the pipe updated the map before
+		char *seqmap = blaze822_seq_open(0);
+		blaze822_seq_load(seqmap);
+		cur = blaze822_seq_cur();
+		init = 1;
+	}
+
 	int indent = 0;
 	while (*file == ' ' || *file == '\t') {
 		indent++;
@@ -168,10 +178,6 @@ main(int argc, char *argv[])
 	if (cols <= 40)
 		cols = 80;
 
-	char *seqmap = blaze822_seq_open(0);
-	blaze822_seq_load(seqmap);
-	cur = blaze822_seq_cur();
-
 	long i;
 	if (argc == 1 && isatty(0)) {
 		char *all[] = { ":" };