shithub: imgtools

Download patch

ref: 4a924242a625638ac4e2c7e6169950d981d36e2e
parent: 248d690e93e18139e11a75fb4425832357082383
author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Feb 17 12:19:31 EST 2021

iconv: add an optional filename argument

--- a/iconv.c
+++ b/iconv.c
@@ -33,7 +33,7 @@
 void
 main(int argc, char **argv)
 {
-	int ci, raw, uncomp;
+	int ci, raw, uncomp, fd;
 	Memimage *a, *b;
 	char *s;
 
@@ -64,8 +64,15 @@
 		usage();
 	}ARGEND
 
+	fd = 0;
+	if(argc == 1){
+		if((fd = open(*argv, OREAD)) < 0)
+			sysfatal("%r");
+	}else if(argc != 0)
+		usage();
+
 	memimageinit();
-	if((a = readmemimage(0)) == nil)
+	if((a = readmemimage(fd)) == nil)
 		sysfatal("memory");
 	if(ci >= 0 && a->chan != chans[ci].chan){
 		if((b = allocmemimage(a->r, chans[ci].chan)) == nil)