9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] Correct acid's rune size to 4 bytes
@ 2023-11-29 10:47 Grimmware
  2023-11-29 19:13 ` cinap_lenrek
  0 siblings, 1 reply; 4+ messages in thread
From: Grimmware @ 2023-11-29 10:47 UTC (permalink / raw)
  To: 9front

Correctly display runes that utilize the higher bits and correctly render rune strings with the \R format

---
diff c6af55fef7800d6a151f05a25ab19feb29abb9aa ea9dfc8d6c6d3ecfb6cfa16ac37db9cccd12adf7
--- a/sys/doc/acid.ms
+++ b/sys/doc/acid.ms
@@ -285,9 +285,9 @@
 Interpret the addressed bytes as UTF characters
 and print successive characters until a zero byte is reached.
 .IP \f(CWr\fP
-Print a two-byte integer as a rune.
+Print a four-byte integer as a rune.
 .IP \f(CWR\fP
-Print successive two-byte integers as runes
+Print successive four-byte integers as runes
 until a zero rune is reached.
 .IP \f(CWi\fP
 Print as machine instructions.
--- a/sys/src/cmd/acid/exec.c
+++ b/sys/src/cmd/acid/exec.c
@@ -264,7 +264,6 @@
 	case 'u':
 	case 'o':
 	case 'q':
-	case 'r':
 		r->type = TINT;
 		ret = get2(m, addr, &sval);
 		if (ret < 0)
@@ -286,6 +285,7 @@
 	case 'U':
 	case 'O':
 	case 'Q':
+	case 'r':
 		r->type = TINT;
 		ret = get4(m, addr, &lval);
 		if (ret < 0)
@@ -318,11 +318,11 @@
 		break;
 	case 'R':
 		r->type = TSTRING;
-		for(i = 0; i < sizeof(buf)-2; i += 2) {
-			ret = get1(m, addr, (uchar*)&buf[i], 2);
+		for(i = 0; i < sizeof(buf)-sizeof(Rune); i += sizeof(Rune)) {
+			ret = get1(m, addr, (uchar*)&buf[i], sizeof(Rune));
 			if (ret < 0)
 				error("indir: %r");
-			addr += 2;
+			addr += sizeof(Rune);
 			if(buf[i] == 0 && buf[i+1] == 0)
 				break;
 		}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] [PATCH] Correct acid's rune size to 4 bytes
  2023-11-29 10:47 [9front] [PATCH] Correct acid's rune size to 4 bytes Grimmware
@ 2023-11-29 19:13 ` cinap_lenrek
  2023-12-01 12:32   ` Grimmware
  0 siblings, 1 reply; 4+ messages in thread
From: cinap_lenrek @ 2023-11-29 19:13 UTC (permalink / raw)
  To: 9front

> 			if(buf[i] == 0 && buf[i+1] == 0)
> 				break;

this seems still to assume 2 byte runes.

--
cinap

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] [PATCH] Correct acid's rune size to 4 bytes
  2023-11-29 19:13 ` cinap_lenrek
@ 2023-12-01 12:32   ` Grimmware
  2023-12-01 16:37     ` cinap_lenrek
  0 siblings, 1 reply; 4+ messages in thread
From: Grimmware @ 2023-12-01 12:32 UTC (permalink / raw)
  To: 9front

Yeah so it does, I've updated my test case to include a rune that triggers this bug (𐀀, U+10000, lower 2 bytes are empty) and have a fix for it, but before I do that I'm suddenly having second thoughts about the use of sizeof here for the rune string when I've just changed the \r (single rune) case to use `get4` anyway.

I think I want to switch this back to hardcoding 4 bytes instead of using sizeof on the basis that a) the rune size is probably not going to change again any time soon b) if it *does* acid would then be inconsistently wrong instead of consistently wrong c) consistency with the rest of the acid codebase.

Opinions?

On Wed, Nov 29, 2023, at 7:13 PM, cinap_lenrek@felloff.net wrote:
>> 			if(buf[i] == 0 && buf[i+1] == 0)
>> 				break;
>
> this seems still to assume 2 byte runes.
>
> --
> cinap

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [9front] [PATCH] Correct acid's rune size to 4 bytes
  2023-12-01 12:32   ` Grimmware
@ 2023-12-01 16:37     ` cinap_lenrek
  0 siblings, 0 replies; 4+ messages in thread
From: cinap_lenrek @ 2023-12-01 16:37 UTC (permalink / raw)
  To: 9front

> I think I want to switch this back to hardcoding 4 bytes
> instead of using sizeof on the basis that
> a) the rune size is probably not going to change again any time soon
> b) if it *does* acid would then be inconsistently wrong instead of consistently wrong
> c) consistency with the rest of the acid codebase.

> Opinions?

yeah, i agree with all your points.

--
cinap

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-01 16:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-29 10:47 [9front] [PATCH] Correct acid's rune size to 4 bytes Grimmware
2023-11-29 19:13 ` cinap_lenrek
2023-12-01 12:32   ` Grimmware
2023-12-01 16:37     ` cinap_lenrek

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).