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.
This commit is contained in:
parent
5f3e72eb84
commit
2327b48d77
1 changed files with 5 additions and 3 deletions
|
@ -76,6 +76,7 @@ main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *flags, *p, *s, *e, buf[512];
|
char *flags, *p, *s, *e, buf[512];
|
||||||
int i, n;
|
int i, n;
|
||||||
|
Rune r;
|
||||||
Fmt fmt;
|
Fmt fmt;
|
||||||
|
|
||||||
doquote = needsrcquote;
|
doquote = needsrcquote;
|
||||||
|
@ -92,14 +93,15 @@ main(int argc, char *argv[])
|
||||||
fmtfdinit(&fmt, 1, buf, sizeof buf);
|
fmtfdinit(&fmt, 1, buf, sizeof buf);
|
||||||
for(p=skipspace(flags); *p; p=nextarg(p)){
|
for(p=skipspace(flags); *p; p=nextarg(p)){
|
||||||
s = e = nil;
|
s = e = nil;
|
||||||
if(p[1] == ':'){
|
n = chartorune(&r, p);
|
||||||
s = p + 2;
|
if(p[n] == ':'){
|
||||||
|
s = p + n + 1;
|
||||||
e = argname(s);
|
e = argname(s);
|
||||||
}
|
}
|
||||||
if(s != e)
|
if(s != e)
|
||||||
fmtprint(&fmt, "%.*s=()\n", (int)(e - s), s);
|
fmtprint(&fmt, "%.*s=()\n", (int)(e - s), s);
|
||||||
else
|
else
|
||||||
fmtprint(&fmt, "flag%.1s=()\n", p);
|
fmtprint(&fmt, "flag%C=()\n", r);
|
||||||
}
|
}
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue