shithub: riscv

Download patch

ref: 2327b48d77c28dbf70d811b765ddd7e1a72618ac
parent: 5f3e72eb844582693e1b0bd4f73be59ab822531e
author: Ori Bernstein <[email protected]>
date: Thu Jun 4 07:41:03 EDT 2020

aux/getflags: fix named rune arguments.

Flags can be runes. That means that we can't just
look at p[1] to decide if we have a named argument,
we need to look one rune forward. This change
does that.

--- a/sys/src/cmd/aux/getflags.c
+++ b/sys/src/cmd/aux/getflags.c
@@ -76,6 +76,7 @@
 {
 	char *flags, *p, *s, *e, buf[512];
 	int i, n;
+	Rune r;
 	Fmt fmt;
 	
 	doquote = needsrcquote;
@@ -92,14 +93,15 @@
 	fmtfdinit(&fmt, 1, buf, sizeof buf);
 	for(p=skipspace(flags); *p; p=nextarg(p)){
 		s = e = nil;
-		if(p[1] == ':'){
-			s = p + 2;
+		n = chartorune(&r, p);
+		if(p[n] == ':'){
+			s = p + n + 1;
 			e = argname(s);
 		}
 		if(s != e)
 			fmtprint(&fmt, "%.*s=()\n", (int)(e - s), s);
 		else
-			fmtprint(&fmt, "flag%.1s=()\n", p);
+			fmtprint(&fmt, "flag%C=()\n", r);
 	}
 	ARGBEGIN{
 	default: