From: Stuart Morrow <morrow.stuart@gmail.com>
To: 9front@9front.org
Subject: Re: [9front] exportfs: fix debug logging
Date: Sat, 14 Aug 2021 20:14:26 +0000 [thread overview]
Message-ID: <CABB-WO9NeTsAVQAhbDm8S-5wE8RsT5ZCzcmBpiSb1Phb90YLfw@mail.gmail.com> (raw)
In-Reply-To: <A38F288BD5DE7D67681A84CA07ECA66B@smtp.pobox.com>
[-- Attachment #1: Type: text/plain, Size: 478 bytes --]
On 13/08/2021, unobe@cpan.org <unobe@cpan.org> wrote:
> I know you already created a different patch, but this part of the
> patch looks pointless, but I don't program in C a lot so maybe I can
> learn something new. I thought declarations generally go together, so
> why move this one declaration down to after initializations?
In Plan 9 C you *can't* put declarations just anywhere, if you wanted
to. Found this out doing a personal Abaco mod, attached for who may
want it.
[-- Attachment #2: abaco --]
[-- Type: application/octet-stream, Size: 1733 bytes --]
rationale for this is, there was going to be a cursor in the status
bar anyway (and it was going to be ugly anyway), so might as well
put it to use
--- //.git/fs/object/2af46e406bbd443ae10025777247798a685afc3c/tree/sys/src/cmd/abaco/html.c
+++ sys/src/cmd/abaco/html.c
@@ -458,7 +458,7 @@
void
mouselink(Box *b, Page *p, int but)
{
- Runestr rs;
+ Runestr url, base;
Anchor *a;
/* eat mouse */
@@ -477,18 +477,30 @@
return;
p = whichtarget(p, a->target);
- rs.r = urlcombine(getbase(p), a->href);
- if(rs.r == nil)
+ base.r = getbase(p);
+ url.r = urlcombine(base.r, a->href);
+ if(url.r == nil)
return;
- rs.nr = runestrlen(rs.r);
+ url.nr = runestrlen(url.r);
- if(but == 1)
- pageget(p, &rs, nil, HGet, p==&p->w->page);
- else if(but == 2)
- textset(&p->w->status, rs.r, rs.nr);
- else if(but == 3)
- plumbrunestr(&rs, nil);
- closerunestr(&rs);
+ switch(but){
+ case 1:
+ pageget(p, &url, nil, HGet, p==&p->w->page);
+ break;
+ case 2: {
+ Text *status = &p->w->status;
+ int i = min(url.nr, runestrdiff(url.r, base.r));
+
+ textset(status, url.r, url.nr);
+ textsetselect(status, i, i);
+ break;
+ }
+ case 3:
+ plumbrunestr(&url, nil);
+ break;
+ }
+ closerunestr(&url);
+ /* and not needed for &base */
}
static
--- //.git/fs/object/2af46e406bbd443ae10025777247798a685afc3c/tree/sys/src/cmd/abaco/util.c
+++ sys/src/cmd/abaco/util.c
@@ -14,7 +14,7 @@
#include "dat.h"
#include "fns.h"
-static Point prevmouse;
+static Point prevmouse;
static Window *mousew;
int
@@ -149,6 +149,16 @@
if(n1 != n2)
return FALSE;
return memcmp(s1, s2, n1*sizeof(Rune)) == 0;
+}
+
+int
+runestrdiff(Rune *s1, Rune *s2)
+{
+ int n = 0;
+
+ while(*s1++ == *s2++)
+ n++;
+ return n;
}
void
next prev parent reply other threads:[~2021-08-14 21:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-13 6:46 unobe
2021-08-13 11:15 ` Amavect
2021-08-14 20:14 ` Stuart Morrow [this message]
2021-08-15 16:40 ` kvik
2021-08-15 20:44 ` Stuart Morrow
2021-08-16 20:17 ` Humm
-- strict thread matches above, loose matches on Subject: below --
2021-08-13 1:11 Amavect
2021-08-13 19:11 ` ori
2021-08-14 22:04 ` Amavect
2021-08-15 16:29 ` kvik
2021-08-16 4:40 ` unobe
2021-08-16 5:20 ` ori
2021-08-16 16:49 ` unobe
2021-08-16 13:55 ` kvik
2021-08-16 16:50 ` unobe
2021-08-16 17:56 ` Amavect
2021-08-16 19:32 ` ori
2021-08-16 22:48 ` ori
2021-08-18 14:24 ` cinap_lenrek
2021-08-18 14:49 ` k m
2021-08-16 20:19 ` Steve Simon
2021-08-16 23:26 ` ori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CABB-WO9NeTsAVQAhbDm8S-5wE8RsT5ZCzcmBpiSb1Phb90YLfw@mail.gmail.com \
--to=morrow.stuart@gmail.com \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).