shithub: misc

Download patch

ref: 922df766d609ac2cdc6fc5a8acc5c9f7dfcb255c
parent: d50596a489b51df5603567e2784b2be6b32239c3
author: Philip Silva <philip.silva@protonmail.com>
date: Mon Oct 18 15:08:38 EDT 2021

Minor changes

--- a/filecon/filecon.go
+++ b/filecon/filecon.go
@@ -3,13 +3,36 @@
 import (
 	"bufio"
 	"fmt"
+	"io"
 	"log"
 	"os"
 )
 
+func usage() {
+	fmt.Printf("filecon [-v] filename")
+	os.Exit(1)
+}
+
 func main() {
-	fn := os.Args[1]
-	log.Printf("opening %v...", fn)
+	var fn string
+	var verbose bool
+
+	args := append([]string{}, os.Args[1:]...)
+	if len(args) == 0 {
+		usage()
+	}
+	for len(args) > 0 {
+		var arg string
+		arg, args = args[0], args[1:]
+		if arg == "-v" {
+			verbose = true
+		} else {
+			fn = arg
+		}
+	}
+	if verbose {
+		log.Printf("opening %v...", fn)
+	}
 	f, err := os.OpenFile(fn, os.O_RDWR|os.O_CREATE, 0666)
 	if err != nil {
 		log.Fatalf("%v", err)
@@ -22,12 +45,20 @@
 		if err != nil {
 			log.Fatalf("%v", err)
 		}
-		log.Printf("send '%v'\n", l)
+		if verbose {
+			log.Printf("send '%v'\n", l)
+		}
 		fmt.Fprintf(f, "%v\n", l)
 		l, err = r.ReadString('\n')
-		if err != nil {
+		if err == io.EOF {
+			break
+		} else if err != nil {
 			log.Fatalf("%v", err)
 		}
-		log.Printf("filecon: received '%v'.", l)
+		if verbose {
+			log.Printf("filecon: received '%v'.", l)
+		} else {
+			fmt.Printf(l)
+		}
 	}
 }
--- a/hidpi-1.patch
+++ b/hidpi-1.patch
@@ -53,16 +53,16 @@
 +		
 +		/* query: 'Q' n[1] queryspec[n] */
 +		case 'q':
-+			if(n < 2) {
++			if(n < 2){
 +				error(Eshortdraw);
 +			}
 +			m = 1+1+a[1];
-+			if(n < m) {
++			if(n < m){
 +				error(Eshortdraw);
 +			}
 +			fmtstrinit(&f);
-+			for(c=0; c<a[1]; c++) {
-+				switch(a[2+c]) {
++			for(c=0; c<a[1]; c++){
++				switch(a[2+c]){
 +				default:
 +					error("unknown query");
 +				case 'd':       /* dpi */
@@ -104,7 +104,7 @@
 +	a[1] = 1;
 +	a[2] = 'd';
 +	disp->dpi = 100;
-+	if(flushimage(disp, 0) >= 0) {
++	if(flushimage(disp, 0) >= 0){
 +		if((read(datafd, info, sizeof info)) == 12)
 +			disp->dpi = atoi(info);
 +	}
--- a/hidpi-2.patch
+++ b/hidpi-2.patch
@@ -25,7 +25,7 @@
  	cl->clientid = ++sdraw.clientid;
  	cl->op = SoverD;
 -	cl->displaydpi=100;
-+	if((p = getconf("dpi")) == nil || (cl->displaydpi = atoi(p)) == 0) {
++	if((p = getconf("dpi")) == nil || (cl->displaydpi = atoi(p)) == 0){
 +		cl->displaydpi=100;
 +	}
  	sdraw.client[i] = cl;