git: drawterm

Download patch

ref: 02c7626b5e227e096549e167609445a456202c5a
parent: 73fadf6cc5bb45316209d2b8e11d47a535dc8f5c
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Sep 22 19:23:52 EDT 2025

libc: sync fmt with 9front behavior, but without doquote

doquote was unused, fmtdoquote was added but unset, let's
just make '%q' always do the right thing since we don't
have external dependencies.

--- a/include/lib.h
+++ b/include/lib.h
@@ -228,7 +228,6 @@
 extern	int	fprint(int, char*, ...);
 extern	int	vfprint(int, char*, va_list);
 
-extern	int	(*doquote)(int);
 extern	int	runesprint(Rune*, char*, ...);
 extern	int	runesnprint(Rune*, int, char*, ...);
 extern	int	runevsnprint(Rune*, int, char*, va_list);
@@ -285,9 +284,6 @@
 extern	int	utfnlen(char*, long);
 extern	double	__Inf(int);
 extern	int	__isInf(double, int);
-
-extern int (*fmtdoquote)(int);
-
 
 /*
  * Time-of-day
--- a/libc/fmt.c
+++ b/libc/fmt.c
@@ -64,9 +64,6 @@
 	0,	0,
 };
 
-
-int	(*fmtdoquote)(int);
-
 /*
  * __fmtlock() must be set
  */
--- a/libc/fmtquote.c
+++ b/libc/fmtquote.c
@@ -2,6 +2,16 @@
 #include <libc.h>
 #include "fmtdef.h"
 
+static int
+fmtdoquote(int c)
+{
+	if(c <= ' ')
+		return 1;
+	if(utfrune("`^#*[]=|\\?${}()'<>&;", c))
+		return 1;
+	return 0;
+}
+
 /*
  * How many bytes of output UTF will be produced by quoting (if necessary) this string?
  * How many runes? How much of the input will be consumed?
@@ -51,7 +61,7 @@
 				break;
 		}
 
-		if((c <= L' ') || (c == L'\'') || (fmtdoquote!=0 && fmtdoquote(c))){
+		if((c <= L' ') || (c == L'\'') || fmtdoquote(c)){
 			if(!q->quoted){
 				if(runesout){
 					if(1+q->nrunesout+1+1 > nout)	/* no room for quotes */
--