shithub: pdffs

Download patch

ref: 2cfd1426cbdc0a97f054760564d9409821c5cf32
parent: 2ff084d1629e80f99b35576f10ea87dc4d9f8941
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue Sep 1 16:08:12 EDT 2020

dump to stdout as is

--- a/main.c
+++ b/main.c
@@ -41,17 +41,20 @@
 		if(argv[i][0] == '['){
 			n = atoi(argv[i]+1);
 			v = arrayget(v, n);
-		}else if(argv[i][0] == '@' && argv[i][1] == 0 && v->type == Ostream){
+		}else if((argv[i][0] == '@') && argv[i][1] == 0 && v->type == Ostream){
 			if((s = Sopen(v)) == nil)
 				sysfatal("%r");
-			print("%.*s\n", s->buf.sz, s->buf.b);
+			if(write(1, s->buf.b, s->buf.sz) != s->buf.sz)
+				sysfatal("write failed");
 			Sclose(s);
+			v = nil;
 			break;
 		}else{
 			v = dictget(v, argv[i]);
 		}
 	}
-	print("%O\n", v);
+	if(v != nil)
+		print("%O\n", v);
 /*
 	if((v = dictget(pdf->info, "Creator")) != nil)
 		fprint(2, "creator: %s\n", v->str);