9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] plumber bug when matching with click attribute
@ 2020-12-28 10:20 umbraticus
  0 siblings, 0 replies; only message in thread
From: umbraticus @ 2020-12-28 10:20 UTC (permalink / raw)
  To: 9front

In spite of the comment in the source, plumber was not calculating
the offset of a click attribute into the string correctly.

umbraticus

diff -r 54bd41c74f5f sys/src/cmd/plumb/match.c
--- a/sys/src/cmd/plumb/match.c	Sun Dec 27 23:39:28 2020 +0100
+++ b/sys/src/cmd/plumb/match.c	Mon Dec 28 23:12:21 2020 +1300
@@ -48,13 +48,12 @@
 clickmatch(Reprog *re, char *text, Resub rs[10], int click)
 {
 	char *clickp;
-	int i, w;
+	int i;
 	Rune r;
 
 	/* click is in characters, not bytes */
-	for(i=0; i<click && text[i]!='\0'; i+=w)
-		w = chartorune(&r, text+i);
-	clickp = text+i;
+	for(i=0, clickp=text; i<click && *clickp!='\0'; i++)
+		clickp += chartorune(&r, clickp);
 	for(i=0; i<=click; i++){
 		memset(rs, 0, 10*sizeof(Resub));
 		if(regexec(re, text+i, rs, 10))

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-12-28 10:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28 10:20 [9front] plumber bug when matching with click attribute umbraticus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).