git: 9front

Download patch

ref: 1d8901939abe578dfb1cda6cdbf53662d0447354
parent: 0d2a10e4416dc7e9d94c8f37e4b0b27ddf2ccc73
author: Aidan K. Wiggins <akw@oneiri.one>
date: Mon Nov 3 12:21:43 EST 2025

sam(term): replace cruft with library rune routines

--- a/sys/src/cmd/samterm/main.c
+++ b/sys/src/cmd/samterm/main.c
@@ -333,18 +333,7 @@
 int
 alnum(int c)
 {
-	/*
-	 * Hard to get absolutely right.  Use what we know about ASCII
-	 * and assume anything above the Latin control characters is
-	 * potentially an alphanumeric.
-	 */
-	if(c<=' ')
-		return 0;
-	if(0x7F<=c && c<=0xA0)
-		return 0;
-	if(utfrune("!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~", c))
-		return 0;
-	return 1;
+	return isalpharune(c) || isdigitrune(c);
 }
 
 int
--- a/sys/src/cmd/samterm/rasp.c
+++ b/sys/src/cmd/samterm/rasp.c
@@ -89,7 +89,7 @@
 		s->next->text = 0;
 	else{
 		s->next->text = alloc(RUNESIZE*(TBLOCKSIZE+1));
-		Strcpy(s->next->text, s->text+n0);
+		runestrcpy(s->next->text, s->text+n0);
 		s->text[n0] = 0;
 	}
 	s->next->nrunes = s->nrunes-n0;
@@ -161,17 +161,11 @@
 			if(s->text){
 				if(s->nrunes+s->next->nrunes>TBLOCKSIZE)
 					break;
-				Strcpy(s->text+s->nrunes, s->next->text);
+				runestrcpy(s->text+s->nrunes, s->next->text);
 			}
 			s->nrunes += s->next->nrunes;
 			rsdelete(r, s->next);
 		}
-}
-
-void
-Strcpy(Rune *to, Rune *from)
-{
-	do; while(*to++ = *from++);
 }
 
 Rune*
--- a/sys/src/cmd/samterm/samterm.h
+++ b/sys/src/cmd/samterm/samterm.h
@@ -158,8 +158,6 @@
 long	scrtotal(Flayer*);
 void	flnewlyvisible(Flayer*);
 char	*rcvstring(void);
-void	Strcpy(Rune*, Rune*);
-void	Strncpy(Rune*, Rune*, long);
 void	flushtyping(int);
 void	dumperrmsg(int, int, int, int);
 int	screensize(int*,int*);
--