From 4982d4ebc3bd4924d73f2f2ad584309e9ec97435 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 4 May 2020 19:52:02 -0700 Subject: all: update build scripts to fix AIX XL/C compatibility --- src/cmd/mkfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd') diff --git a/src/cmd/mkfile b/src/cmd/mkfile index bc8b5a0d..2d0c657e 100644 --- a/src/cmd/mkfile +++ b/src/cmd/mkfile @@ -27,7 +27,7 @@ $PLAN9/bin/lex: $PLAN9/bin/yacc # This should not be necessary. $PLAN9/bin/yacc: $O.yacc - install -c $O.yacc $PLAN9/bin/yacc + $INSTALL -c $O.yacc $PLAN9/bin/yacc $O.yacc: yacc.$O $LD -o $target $prereq yacc.$O: yacc.c -- cgit v1.2.3 From f84d54a0337f9e101c8baeb51272f33b05b2a0e1 Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 4 May 2020 19:52:40 -0700 Subject: mk: support Big Archive Format under AIX --- src/cmd/mk/archive.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/cmd') diff --git a/src/cmd/mk/archive.c b/src/cmd/mk/archive.c index 5b0c1d00..6d646979 100644 --- a/src/cmd/mk/archive.c +++ b/src/cmd/mk/archive.c @@ -1,5 +1,9 @@ #include "mk.h" +#if defined(__AIX__) +#define ARMAG "\n" +#else #define ARMAG "!\n" +#endif #define SARMAG (sizeof(ARMAG) - sizeof("")) #define ARFMAG "`\n" -- cgit v1.2.3 From 5802b09e9d8ceadd2cefdccfd0391c04e492369b Mon Sep 17 00:00:00 2001 From: Ben Huntsman Date: Mon, 4 May 2020 19:53:21 -0700 Subject: all: fix #includes for AIX, add a few AIX "implementation" files --- src/cmd/9term/AIX.c | 2 ++ src/cmd/9term/bsdpty.c | 2 ++ src/cmd/auxstats/AIX.c | 9 +++++++++ src/cmd/draw/mc.c | 3 +++ src/cmd/vbackup/mount-AIX.c | 1 + 5 files changed, 17 insertions(+) create mode 100644 src/cmd/9term/AIX.c create mode 100644 src/cmd/auxstats/AIX.c create mode 100644 src/cmd/vbackup/mount-AIX.c (limited to 'src/cmd') diff --git a/src/cmd/9term/AIX.c b/src/cmd/9term/AIX.c new file mode 100644 index 00000000..b7ccbf0f --- /dev/null +++ b/src/cmd/9term/AIX.c @@ -0,0 +1,2 @@ +#define TIOCSCTTY 0x540E +#include "bsdpty.c" diff --git a/src/cmd/9term/bsdpty.c b/src/cmd/9term/bsdpty.c index d64e4c2f..3710a18d 100644 --- a/src/cmd/9term/bsdpty.c +++ b/src/cmd/9term/bsdpty.c @@ -5,7 +5,9 @@ #include #include #include +#ifdef HAS_SYS_TERMIOS #include +#endif #ifdef __linux__ #include #endif diff --git a/src/cmd/auxstats/AIX.c b/src/cmd/auxstats/AIX.c new file mode 100644 index 00000000..33ebdedc --- /dev/null +++ b/src/cmd/auxstats/AIX.c @@ -0,0 +1,9 @@ +#include +#include +#include +#include "dat.h" + +void (*statfn[])(int) = +{ + 0 +}; diff --git a/src/cmd/draw/mc.c b/src/cmd/draw/mc.c index ee112194..f1bcc82a 100644 --- a/src/cmd/draw/mc.c +++ b/src/cmd/draw/mc.c @@ -9,7 +9,10 @@ */ #include #include +#include +#ifdef HAS_SYS_TERMIOS #include +#endif #include #include #include diff --git a/src/cmd/vbackup/mount-AIX.c b/src/cmd/vbackup/mount-AIX.c new file mode 100644 index 00000000..3dde4fdf --- /dev/null +++ b/src/cmd/vbackup/mount-AIX.c @@ -0,0 +1 @@ +#include "mount-none.c" -- cgit v1.2.3 From 154140a22b1c697f6a3edb3e5913efded1be082a Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sun, 17 May 2020 20:06:31 -0400 Subject: mk: replace overlapping strcpy with memmove Found by ASAN. --- src/cmd/mk/env.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/cmd') diff --git a/src/cmd/mk/env.c b/src/cmd/mk/env.c index d7c6481d..e01aa21a 100644 --- a/src/cmd/mk/env.c +++ b/src/cmd/mk/env.c @@ -123,7 +123,8 @@ buildenv(Job *j, int slot) qp = strchr(cp+1, ')'); if(qp){ *qp = 0; - strcpy(w->s, cp+1); + /* strcpy, but might overlap */ + memmove(w->s, cp+1, strlen(cp+1)+1); l = &w->next; w = w->next; continue; -- cgit v1.2.3 From 94d381ec9d579e5336f3817b68cf4d1a8a7333db Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 25 Jan 2020 14:31:52 -0500 Subject: devdraw: use indirect impl interface Setting up for a real window system. --- src/cmd/devdraw/devdraw.c | 4 ++-- src/cmd/devdraw/devdraw.h | 23 ++++++++++++++--------- src/cmd/devdraw/mac-screen.m | 38 ++++++++++++++++++++++++++++++-------- src/cmd/devdraw/srv.c | 26 +++++++++++++++----------- 4 files changed, 61 insertions(+), 30 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index b4c373ad..6269dfda 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -143,7 +143,7 @@ addflush(Client *c, Rectangle r) // during a resize. rpc_gfxdrawunlock(); qunlock(&c->drawlk); - rpc_flush(c, fr); + c->impl->rpc_flush(c, fr); qlock(&c->drawlk); rpc_gfxdrawlock(); } @@ -188,7 +188,7 @@ drawflush(Client *c) // during a resize. rpc_gfxdrawunlock(); qunlock(&c->drawlk); - rpc_flush(c, r); + c->impl->rpc_flush(c, r); qlock(&c->drawlk); rpc_gfxdrawlock(); } diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 6829ab32..1dac2d50 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -7,6 +7,7 @@ typedef struct Mousebuf Mousebuf; typedef struct Tagbuf Tagbuf; typedef struct Client Client; +typedef struct ClientImpl ClientImpl; typedef struct DImage DImage; typedef struct DScreen DScreen; typedef struct CScreen CScreen; @@ -43,6 +44,18 @@ struct Tagbuf int wi; }; +struct ClientImpl +{ + void (*rpc_resizeimg)(Client*); + void (*rpc_resizewindow)(Client*, Rectangle); + void (*rpc_setcursor)(Client*, Cursor*, Cursor2*); + void (*rpc_setlabel)(Client*, char*); + void (*rpc_setmouse)(Client*, Point); + void (*rpc_topwin)(Client*); + void (*rpc_bouncemouse)(Client*, Mouse); + void (*rpc_flush)(Client*, Rectangle); +}; + struct Client { int rfd; @@ -82,6 +95,7 @@ struct Client int nname; DName* name; int namevers; + ClientImpl* impl; // Only accessed/modified by the graphics thread. const void* view; @@ -196,17 +210,8 @@ void gfx_started(void); Memimage *rpc_attach(Client*, char*, char*); char* rpc_getsnarf(void); void rpc_putsnarf(char*); -void rpc_resizeimg(Client*); -void rpc_resizewindow(Client*, Rectangle); -void rpc_serve(Client*); -void rpc_setcursor(Client*, Cursor*, Cursor2*); -void rpc_setlabel(Client*, char*); -void rpc_setmouse(Client*, Point); void rpc_shutdown(void); -void rpc_topwin(Client*); void rpc_main(void); -void rpc_bouncemouse(Client*, Mouse); -void rpc_flush(Client*, Rectangle); // rpc_gfxdrawlock and rpc_gfxdrawunlock // are called around drawing operations to lock and unlock diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index c6e58341..9454be05 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -37,6 +37,27 @@ static void setprocname(const char*); static uint keycvt(uint); static uint msec(void); +static void rpc_resizeimg(Client*); +static void rpc_resizewindow(Client*, Rectangle); +static void rpc_serve(Client*); +static void rpc_setcursor(Client*, Cursor*, Cursor2*); +static void rpc_setlabel(Client*, char*); +static void rpc_setmouse(Client*, Point); +static void rpc_topwin(Client*); +static void rpc_bouncemouse(Client*, Mouse); +static void rpc_flush(Client*, Rectangle); + +static ClientImpl macimpl = { + rpc_resizeimg, + rpc_resizewindow, + rpc_setcursor, + rpc_setlabel, + rpc_setmouse, + rpc_topwin, + rpc_bouncemouse, + rpc_flush +}; + @class DrawView; @class DrawLayer; @@ -201,6 +222,7 @@ rpc_attach(Client *c, char *label, char *winsize) { LOG(@"attachscreen(%s, %s)", label, winsize); + c->impl = &macimpl; dispatch_sync(dispatch_get_main_queue(), ^(void) { @autoreleasepool { DrawView *view = [[DrawView new] attach:c winsize:winsize label:label]; @@ -302,7 +324,7 @@ rpc_attach(Client *c, char *label, char *winsize) // rpc_topwin moves the window to the top of the desktop. // Called from an RPC thread with no client lock held. -void +static void rpc_topwin(Client *c) { DrawView *view = (__bridge DrawView*)c->view; @@ -319,7 +341,7 @@ rpc_topwin(Client *c) // rpc_setlabel updates the client window's label. // If label == nil, the call is a no-op. // Called from an RPC thread with no client lock held. -void +static void rpc_setlabel(Client *client, char *label) { DrawView *view = (__bridge DrawView*)client->view; @@ -344,7 +366,7 @@ rpc_setlabel(Client *client, char *label) // rpc_setcursor updates the client window's cursor image. // Either c and c2 are both non-nil, or they are both nil to use the default arrow. // Called from an RPC thread with no client lock held. -void +static void rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2) { DrawView *view = (__bridge DrawView*)client->view; @@ -460,7 +482,7 @@ rpc_setcursor(Client *client, Cursor *c, Cursor2 *c2) // rpc_flush flushes changes to view.img's rectangle r // to the on-screen window, making them visible. // Called from an RPC thread with no client lock held. -void +static void rpc_flush(Client *client, Rectangle r) { DrawView *view = (__bridge DrawView*)client->view; @@ -506,7 +528,7 @@ rpc_flush(Client *client, Rectangle r) // rpc_resizeimg forces the client window to discard its current window and make a new one. // It is called when the user types Cmd-R to toggle whether retina mode is forced. // Called from an RPC thread with no client lock held. -void +static void rpc_resizeimg(Client *c) { DrawView *view = (__bridge DrawView*)c->view; @@ -541,7 +563,7 @@ rpc_resizeimg(Client *c) // rpc_resizewindow asks for the client window to be resized to size r. // Called from an RPC thread with no client lock held. -void +static void rpc_resizewindow(Client *c, Rectangle r) { DrawView *view = (__bridge DrawView*)c->view; @@ -696,7 +718,7 @@ rpc_resizewindow(Client *c, Rectangle r) // rpc_setmouse moves the mouse cursor. // Called from an RPC thread with no client lock held. -void +static void rpc_setmouse(Client *c, Point p) { DrawView *view = (__bridge DrawView*)c->view; @@ -1095,7 +1117,7 @@ rpc_putsnarf(char *s) // rpc_bouncemouse is for sending a mouse event // back to the X11 window manager rio(1). // Does not apply here. -void +static void rpc_bouncemouse(Client *c, Mouse m) { } diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index 570091bc..bdfc1654 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -54,6 +54,7 @@ threadmain(int argc, char **argv) usage(); }ARGEND + memimageinit(); fmtinstall('H', encodefmt); if((p = getenv("DEVDRAWTRACE")) != nil) trace = atoi(p); @@ -202,8 +203,11 @@ runmsg(Client *c, Wsysmsg *m) break; case Tinit: - memimageinit(); i = rpc_attach(c, m->label, m->winsize); + if(i == nil) { + replyerror(c, m); + break; + } draw_initdisplaymemimage(c, i); replymsg(c, m); break; @@ -241,35 +245,35 @@ runmsg(Client *c, Wsysmsg *m) break; case Tmoveto: - rpc_setmouse(c, m->mouse.xy); + c->impl->rpc_setmouse(c, m->mouse.xy); replymsg(c, m); break; case Tcursor: if(m->arrowcursor) - rpc_setcursor(c, nil, nil); + c->impl->rpc_setcursor(c, nil, nil); else { scalecursor(&m->cursor2, &m->cursor); - rpc_setcursor(c, &m->cursor, &m->cursor2); + c->impl->rpc_setcursor(c, &m->cursor, &m->cursor2); } replymsg(c, m); break; case Tcursor2: if(m->arrowcursor) - rpc_setcursor(c, nil, nil); + c->impl->rpc_setcursor(c, nil, nil); else - rpc_setcursor(c, &m->cursor, &m->cursor2); + c->impl->rpc_setcursor(c, &m->cursor, &m->cursor2); replymsg(c, m); break; case Tbouncemouse: - rpc_bouncemouse(c, m->mouse); + c->impl->rpc_bouncemouse(c, m->mouse); replymsg(c, m); break; case Tlabel: - rpc_setlabel(c, m->label); + c->impl->rpc_setlabel(c, m->label); replymsg(c, m); break; @@ -306,12 +310,12 @@ runmsg(Client *c, Wsysmsg *m) break; case Ttop: - rpc_topwin(c); + c->impl->rpc_topwin(c); replymsg(c, m); break; case Tresize: - rpc_resizewindow(c, m->rect); + c->impl->rpc_resizewindow(c, m->rect); replymsg(c, m); break; } @@ -513,7 +517,7 @@ gfx_keystroke(Client *c, int ch) else c->forcedpi = 225; qunlock(&c->eventlk); - rpc_resizeimg(c); + c->impl->rpc_resizeimg(c); return; } if(!c->kbd.alting){ -- cgit v1.2.3 From 587933c16132d880a06ff99bd087e64a3a04975e Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Sat, 25 Jan 2020 14:33:20 -0500 Subject: devdraw: use global drawlk instead of per-client Setting up for a real window system. --- src/cmd/devdraw/devdraw.c | 26 ++++++++++++++------------ src/cmd/devdraw/devdraw.h | 5 +++-- src/cmd/devdraw/mac-screen.m | 7 +++---- 3 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/devdraw/devdraw.c b/src/cmd/devdraw/devdraw.c index 6269dfda..234cdf1b 100644 --- a/src/cmd/devdraw/devdraw.c +++ b/src/cmd/devdraw/devdraw.c @@ -14,6 +14,8 @@ #include #include "devdraw.h" +QLock drawlk; + static int drawuninstall(Client*, int); static Memimage* drawinstall(Client*, int, Memimage*, DScreen*); static void drawfreedimage(Client*, DImage*); @@ -47,14 +49,14 @@ gfx_replacescreenimage(Client *c, Memimage *m) */ Memimage *om; - qlock(&c->drawlk); + qlock(&drawlk); om = c->screenimage; c->screenimage = m; m->screenref = 1; if(om && --om->screenref == 0){ _freememimage(om); } - qunlock(&c->drawlk); + qunlock(&drawlk); gfx_mouseresized(c); } @@ -142,9 +144,9 @@ addflush(Client *c, Rectangle r) // and gfx thread might be blocked on drawlk trying to install a new screen // during a resize. rpc_gfxdrawunlock(); - qunlock(&c->drawlk); + qunlock(&drawlk); c->impl->rpc_flush(c, fr); - qlock(&c->drawlk); + qlock(&drawlk); rpc_gfxdrawlock(); } } @@ -187,9 +189,9 @@ drawflush(Client *c) // and gfx thread might be blocked on drawlk trying to install a new screen // during a resize. rpc_gfxdrawunlock(); - qunlock(&c->drawlk); + qunlock(&drawlk); c->impl->rpc_flush(c, r); - qlock(&c->drawlk); + qlock(&drawlk); rpc_gfxdrawlock(); } } @@ -614,7 +616,7 @@ drawcoord(uchar *p, uchar *maxp, int oldx, int *newx) int draw_dataread(Client *cl, void *a, int n) { - qlock(&cl->drawlk); + qlock(&drawlk); if(cl->readdata == nil){ werrstr("no draw data"); goto err; @@ -627,11 +629,11 @@ draw_dataread(Client *cl, void *a, int n) memmove(a, cl->readdata, cl->nreaddata); free(cl->readdata); cl->readdata = nil; - qunlock(&cl->drawlk); + qunlock(&drawlk); return n; err: - qunlock(&cl->drawlk); + qunlock(&drawlk); return -1; } @@ -656,7 +658,7 @@ draw_datawrite(Client *client, void *v, int n) Refreshfn reffn; Refx *refx; - qlock(&client->drawlk); + qlock(&drawlk); rpc_gfxdrawlock(); a = v; m = 0; @@ -1431,7 +1433,7 @@ draw_datawrite(Client *client, void *v, int n) } } rpc_gfxdrawunlock(); - qunlock(&client->drawlk); + qunlock(&drawlk); return oldn - n; Enodrawimage: @@ -1502,6 +1504,6 @@ Ebadarg: error: werrstr("%s", err); rpc_gfxdrawunlock(); - qunlock(&client->drawlk); + qunlock(&drawlk); return -1; } diff --git a/src/cmd/devdraw/devdraw.h b/src/cmd/devdraw/devdraw.h index 1dac2d50..261d04d1 100644 --- a/src/cmd/devdraw/devdraw.h +++ b/src/cmd/devdraw/devdraw.h @@ -56,6 +56,8 @@ struct ClientImpl void (*rpc_flush)(Client*, Rectangle); }; +extern QLock drawlk; + struct Client { int rfd; @@ -69,10 +71,9 @@ struct Client char* wsysid; - // drawlk protects the draw data structures. + // drawlk protects the draw data structures for all clients. // It can be acquired by an RPC thread or a graphics thread // but must not be held on one thread while waiting for the other. - QLock drawlk; /*Ref r;*/ DImage* dimage[NHASH]; CScreen* cscreen; diff --git a/src/cmd/devdraw/mac-screen.m b/src/cmd/devdraw/mac-screen.m index 9454be05..ad9c029e 100644 --- a/src/cmd/devdraw/mac-screen.m +++ b/src/cmd/devdraw/mac-screen.m @@ -39,7 +39,6 @@ static uint msec(void); static void rpc_resizeimg(Client*); static void rpc_resizewindow(Client*, Rectangle); -static void rpc_serve(Client*); static void rpc_setcursor(Client*, Cursor*, Cursor2*); static void rpc_setlabel(Client*, char*); static void rpc_setmouse(Client*, Point); @@ -496,17 +495,17 @@ rpc_flush(Client *client, Rectangle r) if(!rectclip(&r, Rect(0, 0, self.dlayer.texture.width, self.dlayer.texture.height)) || !rectclip(&r, self.img->r)) return; - // self.client->drawlk protects the pixel data in self.img. + // drawlk protects the pixel data in self.img. // In addition to avoiding a technical data race, // the lock avoids drawing partial updates, which makes // animations like sweeping windows much less flickery. - qlock(&self.client->drawlk); + qlock(&drawlk); [self.dlayer.texture replaceRegion:MTLRegionMake2D(r.min.x, r.min.y, Dx(r), Dy(r)) mipmapLevel:0 withBytes:byteaddr(self.img, Pt(r.min.x, r.min.y)) bytesPerRow:self.img->width*sizeof(u32int)]; - qunlock(&self.client->drawlk); + qunlock(&drawlk); NSRect nr = NSMakeRect(r.min.x, r.min.y, Dx(r), Dy(r)); dispatch_time_t time; -- cgit v1.2.3 From 84167be4ad170c879db48493438f507c2d40d28d Mon Sep 17 00:00:00 2001 From: Gabriel Diaz Date: Mon, 18 May 2020 17:38:16 +0200 Subject: devdraw: use indirect impl interface in x11 --- src/cmd/devdraw/x11-screen.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/cmd') diff --git a/src/cmd/devdraw/x11-screen.c b/src/cmd/devdraw/x11-screen.c index 62f49f2f..0bbc25d6 100644 --- a/src/cmd/devdraw/x11-screen.c +++ b/src/cmd/devdraw/x11-screen.c @@ -40,6 +40,26 @@ static void _xmovewindow(Xwin *w, Rectangle r); static int _xtoplan9kbd(XEvent *e); static int _xselect(XEvent *e); +static void rpc_resizeimg(Client*); +static void rpc_resizewindow(Client*, Rectangle); +static void rpc_setcursor(Client*, Cursor*, Cursor2*); +static void rpc_setlabel(Client*, char*); +static void rpc_setmouse(Client*, Point); +static void rpc_topwin(Client*); +static void rpc_bouncemouse(Client*, Mouse); +static void rpc_flush(Client*, Rectangle); + +static ClientImpl x11impl = { + rpc_resizeimg, + rpc_resizewindow, + rpc_setcursor, + rpc_setlabel, + rpc_setmouse, + rpc_topwin, + rpc_bouncemouse, + rpc_flush +}; + static Xwin* newxwin(Client *c) { @@ -51,6 +71,7 @@ newxwin(Client *c) w->client = c; w->next = _x.windows; _x.windows = w; + c->impl = &x11impl; c->view = w; return w; } -- cgit v1.2.3 From d4a4b66a401d8988441dd663bf1664e11c045797 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 19:55:01 -0400 Subject: diff: rename class to fix AIX math.h defines a function named class on AIX. --- src/cmd/diff/diffreg.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cmd') diff --git a/src/cmd/diff/diffreg.c b/src/cmd/diff/diffreg.c index ed4d17b8..478c1b1b 100644 --- a/src/cmd/diff/diffreg.c +++ b/src/cmd/diff/diffreg.c @@ -66,6 +66,9 @@ * 3*(number of k-candidates installed), typically about * 6n words for files of length n. */ + +#define class diffclass + /* TIDY THIS UP */ struct cand { int x; -- cgit v1.2.3 From dea4dbdba6e8a4652e682627dce50503bca5c4b4 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 22:31:22 -0400 Subject: acme: avoid global named "class" For AIX. --- src/cmd/acme/regx.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/cmd') diff --git a/src/cmd/acme/regx.c b/src/cmd/acme/regx.c index 56ea900c..ec574563 100644 --- a/src/cmd/acme/regx.c +++ b/src/cmd/acme/regx.c @@ -15,6 +15,9 @@ Rangeset sel; Rune *lastregexp; +#undef class +#define class regxclass /* some systems declare "class" in system headers */ + /* * Machine Information */ -- cgit v1.2.3 From 20c841bac102e777a3a1723724fa5d31018fefcc Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 22:32:59 -0400 Subject: rc: avoid problematic internal names "var", "thread" For AIX. --- src/cmd/rc/rc.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/cmd') diff --git a/src/cmd/rc/rc.h b/src/cmd/rc/rc.h index 46ff9510..2fd6758b 100644 --- a/src/cmd/rc/rc.h +++ b/src/cmd/rc/rc.h @@ -33,6 +33,12 @@ #undef pipe /* so that /dev/fd works */ #define searchpath rcsearchpath /* avoid new libc function */ +/* some systems define a global "var", "thread" */ +#undef var +#define var rcvar +#undef thread +#define thread rcthread + typedef struct tree tree; typedef struct word word; typedef struct io io; -- cgit v1.2.3 From d25d0ca1a3682d97df67f62789767562aa5bf1b3 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Mon, 18 May 2020 23:45:03 -0400 Subject: devdraw, libdraw: handle keyboard runes > U+FFFF Runes in Plan 9 were limited to the 16-bit BMP when I drew up the RPC protocol between graphical programs and devdraw a long time ago. Now that they can be 32-bit, use a 32-bit wire encoding too. A new message number to avoid problems with other clients (like 9fans.net/go). Add keyboard shortcut alt : , for U+1F602, face with tears of joy, to test that it all works. --- src/cmd/devdraw/mklatinkbd.c | 2 +- src/cmd/devdraw/srv.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/devdraw/mklatinkbd.c b/src/cmd/devdraw/mklatinkbd.c index db34b6ec..50dd26b0 100644 --- a/src/cmd/devdraw/mklatinkbd.c +++ b/src/cmd/devdraw/mklatinkbd.c @@ -191,7 +191,7 @@ readfile(char *fname) r = strtol(line, nil, 16); p = strchr(line, ' '); - if(r == 0 || p != line+4 || p[0] != ' ' || p[1] != ' ') { + if(r == 0 || (p != line+4 && p != line+5) || p[0] != ' ' || (p == line+4 && p[1] != ' ')) { fprint(2, "%s:%d: cannot parse line\n", fname, lineno); continue; } diff --git a/src/cmd/devdraw/srv.c b/src/cmd/devdraw/srv.c index bdfc1654..05a08fda 100644 --- a/src/cmd/devdraw/srv.c +++ b/src/cmd/devdraw/srv.c @@ -229,6 +229,7 @@ runmsg(Client *c, Wsysmsg *m) break; case Trdkbd: + case Trdkbd4: qlock(&c->eventlk); if((c->kbdtags.wi+1)%nelem(c->kbdtags.t) == c->kbdtags.ri) { qunlock(&c->eventlk); @@ -236,7 +237,7 @@ runmsg(Client *c, Wsysmsg *m) replyerror(c, m); break; } - c->kbdtags.t[c->kbdtags.wi++] = m->tag; + c->kbdtags.t[c->kbdtags.wi++] = (m->tag<<1) | (m->type==Trdkbd4); if(c->kbdtags.wi == nelem(c->kbdtags.t)) c->kbdtags.wi = 0; c->kbd.stall = 0; @@ -357,13 +358,17 @@ replymsg(Client *c, Wsysmsg *m) static void matchkbd(Client *c) { + int tag; Wsysmsg m; if(c->kbd.stall) return; while(c->kbd.ri != c->kbd.wi && c->kbdtags.ri != c->kbdtags.wi){ + tag = c->kbdtags.t[c->kbdtags.ri++]; m.type = Rrdkbd; - m.tag = c->kbdtags.t[c->kbdtags.ri++]; + if(tag&1) + m.type = Rrdkbd4; + m.tag = tag>>1; if(c->kbdtags.ri == nelem(c->kbdtags.t)) c->kbdtags.ri = 0; m.rune = c->kbd.r[c->kbd.ri++]; -- cgit v1.2.3 From 5f0fa185d0a978b45de5bf206193769596c056b5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 26 May 2020 11:36:59 -0400 Subject: fontsrv: handle non-BMP runes on X11 Have to adjust algorithms to deal with much larger number of subfont files as well. --- src/cmd/fontsrv/a.h | 9 ++++++--- src/cmd/fontsrv/mac.c | 6 ++++-- src/cmd/fontsrv/main.c | 53 ++++++++++++++++++++++---------------------------- src/cmd/fontsrv/x11.c | 19 ++++++++++-------- 4 files changed, 44 insertions(+), 43 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/fontsrv/a.h b/src/cmd/fontsrv/a.h index 164b1bd6..2eeb404f 100644 --- a/src/cmd/fontsrv/a.h +++ b/src/cmd/fontsrv/a.h @@ -4,19 +4,22 @@ int nxfont; enum { SubfontSize = 32, - SubfontMask = (1<<16)/SubfontSize - 1, + MaxSubfont = (Runemax+1)/SubfontSize, }; struct XFont { char *name; int loaded; - uchar range[(1<<16)/SubfontSize]; // range[i] == whether to have subfont i*SubfontSize to (i+1)*SubfontSize - 1. - int nrange; + uchar range[MaxSubfont]; // range[i] = fontfile starting at i*SubfontSize exists + ushort file[MaxSubfont]; // file[i] == fontfile i's lo rune / SubfontSize + int nfile; int unit; double height; double originy; void (*loadheight)(XFont*, int, int*, int*); + char *fonttext; + int nfonttext; // fontconfig workarround, as FC_FULLNAME does not work for matching fonts. char *fontfile; diff --git a/src/cmd/fontsrv/mac.c b/src/cmd/fontsrv/mac.c index b4dadd90..9829b5a8 100644 --- a/src/cmd/fontsrv/mac.c +++ b/src/cmd/fontsrv/mac.c @@ -200,9 +200,12 @@ load(XFont *f) f->loadheight = fontheight; // enable all Unicode ranges + if(nelem(f->file) > 0xffff) + sysfatal("too many subfiles"); // f->file holds ushorts for(i=0; irange); i++) { f->range[i] = 1; - f->nrange++; + f->file[i] = i; + f->nfile++; } } @@ -233,7 +236,6 @@ mksubfont(XFont *f, char *name, int lo, int hi, int size, int antialias) if(font == nil) return nil; - bbox = CTFontGetBoundingBox(font); x = (int)(bbox.size.width*2 + 0.99999999); diff --git a/src/cmd/fontsrv/main.c b/src/cmd/fontsrv/main.c index ebab6249..b2189be9 100644 --- a/src/cmd/fontsrv/main.c +++ b/src/cmd/fontsrv/main.c @@ -52,7 +52,7 @@ enum #define QFONT(p) (((p) >> 4) & 0xFFFF) #define QSIZE(p) (((p) >> 20) & 0xFF) #define QANTIALIAS(p) (((p) >> 28) & 0x1) -#define QRANGE(p) (((p) >> 29) & SubfontMask) +#define QRANGE(p) (((p) >> 29) & 0xFFFFFF) static int sizes[] = { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 22, 24, 28 }; static vlong @@ -102,7 +102,7 @@ dostat(vlong path, Qid *qid, Dir *dir) case Qfontfile: f = &xfont[QFONT(path)]; load(f); - length = 11+1+11+1+f->nrange*(6+1+6+1+9+1); + length = 11+1+11+1+f->nfile*(6+1+6+1+9+1); name = "font"; break; @@ -189,9 +189,9 @@ xwalk1(Fid *fid, char *name, Qid *qid) goto NotFound; p++; n = strtoul(p, &p, 16); - if(p != name+5 || n%SubfontSize != 0 || strcmp(p, ".bit") != 0 || !f->range[(n/SubfontSize) & SubfontMask]) + if(p < name+5 || p > name+5 && name[1] == '0' || n%SubfontSize != 0 || n/SubfontSize >= MaxSubfont || strcmp(p, ".bit") != 0 || !f->range[n/SubfontSize]) goto NotFound; - path += Qsubfontfile - Qsizedir + qpath(0, 0, 0, 0, (n/SubfontSize) & SubfontMask); + path += Qsubfontfile - Qsizedir + qpath(0, 0, 0, 0, n/SubfontSize); break; } Found: @@ -229,7 +229,6 @@ sizegen(int i, Dir *d, void *v) vlong path; Fid *fid; XFont *f; - int j; fid = v; path = fid->qid.path; @@ -240,15 +239,10 @@ sizegen(int i, Dir *d, void *v) i--; f = &xfont[QFONT(path)]; load(f); - for(j=0; jrange); j++) { - if(f->range[j] == 0) - continue; - if(i == 0) { - path += Qsubfontfile - Qsizedir; - path += qpath(0, 0, 0, 0, j); - goto Done; - } - i--; + if(i < f->nfile) { + path += Qsubfontfile - Qsizedir; + path += qpath(0, 0, 0, 0, f->file[i]); + goto Done; } return -1; @@ -315,23 +309,22 @@ xread(Req *r) readstr(r, "font missing\n"); break; } - height = 0; - ascent = 0; - if(f->unit > 0) { - height = f->height * (int)QSIZE(path)/f->unit + 0.99999999; - ascent = height - (int)(-f->originy * (int)QSIZE(path)/f->unit + 0.99999999); - } - if(f->loadheight != nil) - f->loadheight(f, QSIZE(path), &height, &ascent); - fmtprint(&fmt, "%11d %11d\n", height, ascent); - for(i=0; irange); i++) { - if(f->range[i] == 0) - continue; - fmtprint(&fmt, "0x%04x 0x%04x x%04x.bit\n", i*SubfontSize, ((i+1)*SubfontSize) - 1, i*SubfontSize); + if(f->fonttext == nil) { + height = 0; + ascent = 0; + if(f->unit > 0) { + height = f->height * (int)QSIZE(path)/f->unit + 0.99999999; + ascent = height - (int)(-f->originy * (int)QSIZE(path)/f->unit + 0.99999999); + } + if(f->loadheight != nil) + f->loadheight(f, QSIZE(path), &height, &ascent); + fmtprint(&fmt, "%11d %11d\n", height, ascent); + for(i=0; infile; i++) + fmtprint(&fmt, "0x%04x 0x%04x x%04x.bit\n", f->file[i]*SubfontSize, ((f->file[i]+1)*SubfontSize) - 1, f->file[i]*SubfontSize); + f->fonttext = fmtstrflush(&fmt); + f->nfonttext = strlen(f->fonttext); } - data = fmtstrflush(&fmt); - readstr(r, data); - free(data); + readbuf(r, f->fonttext, f->nfonttext); break; case Qsubfontfile: f = &xfont[QFONT(path)]; diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index 0f6b97bb..c78ad036 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -85,20 +85,23 @@ load(XFont *f) int idx = charcode/SubfontSize; - if(charcode > 0xffff) + if(charcode > Runemax) break; - if(!f->range[idx]) { + if(!f->range[idx]) f->range[idx] = 1; - f->nrange++; - } } + FT_Done_Face(face); + // libdraw expects U+0000 to be present - if(!f->range[0]) { + if(!f->range[0]) f->range[0] = 1; - f->nrange++; - } - FT_Done_Face(face); + + // fix up file list + for(i=0; irange); i++) + if(f->range[i]) + f->file[f->nfile++] = i; + f->loaded = 1; } -- cgit v1.2.3 From 2c70acc3ab751ab1ccb1999f1d22310ad8c35b27 Mon Sep 17 00:00:00 2001 From: dzklaim Date: Sat, 30 May 2020 01:02:10 +0000 Subject: fontsrv: scale f->originy to match f->height on x11 Co-authored-by: dzklaim --- src/cmd/fontsrv/x11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/cmd') diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index c78ad036..417dcfa6 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -78,7 +78,7 @@ load(XFont *f) } f->unit = face->units_per_EM; f->height = (int)((face->ascender - face->descender) * 1.35); - f->originy = face->descender; // bbox.yMin (or descender) is negative, becase the baseline is y-coord 0 + f->originy = face->descender * 1.35; // bbox.yMin (or descender) is negative, because the baseline is y-coord 0 for(charcode=FT_Get_First_Char(face, &glyph_index); glyph_index != 0; charcode=FT_Get_Next_Char(face, charcode, &glyph_index)) { -- cgit v1.2.3 From 3850e6e177677885074c8896ef24534894726ad5 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 29 May 2020 21:19:32 -0400 Subject: devdraw: accept 5- and 6-byte Unicode hex values Alt X 1234 for U+1234 Alt X X 12345 for U+12345 Alt X X X 103456 for U+103456. --- src/cmd/devdraw/latin1.c | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/devdraw/latin1.c b/src/cmd/devdraw/latin1.c index a3d13a08..87c0be45 100644 --- a/src/cmd/devdraw/latin1.c +++ b/src/cmd/devdraw/latin1.c @@ -17,16 +17,15 @@ static struct cvlist }; /* - * Given 5 characters k[0]..k[4], find the rune or return -1 for failure. + * Given 5 characters k[0]..k[n], find the rune or return -1 for failure. */ static long -unicode(Rune *k) +unicode(Rune *k, int n) { long i, c; - k++; /* skip 'X' */ c = 0; - for(i=0; i<4; i++,k++){ + for(i=0; i Runemax) + return -1; } return c; } @@ -53,10 +54,32 @@ latin1(Rune *k, int n) char* p; if(k[0] == 'X'){ - if(n>=5) - return unicode(k); - else - return -5; + if(n < 2) + return -2; + if(k[1] == 'X') { + if(n < 3) + return -3; + if(k[2] == 'X') { + if(n < 9) { + if(unicode(k+3, n-3) < 0) + return -1; + return -(n+1); + } + return unicode(k+3, 6); + } + if(n < 7) { + if(unicode(k+2, n-2) < 0) + return -1; + return -(n+1); + } + return unicode(k+2, 5); + } + if(n < 5) { + if(unicode(k+1, n-1) < 0) + return -1; + return -(n+1); + } + return unicode(k+1, 4); } for(l=latintab; l->ld!=0; l++) -- cgit v1.2.3 From 95220bf88775deab4a037264d08b21bacc612d70 Mon Sep 17 00:00:00 2001 From: sean Date: Thu, 21 May 2020 16:10:30 +0100 Subject: ed: handle Unicode beyond the BMP correctly in list mode. List mode was constrained to the BMP. This change introduces the following new list mode convention, using Go string literal syntax: Non-printing ASCII characters display as \xhh. Non-ASCII characters in the BMP display as \uhhhh. Characters beyond the BMP display as \Uhhhhhhhh. --- src/cmd/ed.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'src/cmd') diff --git a/src/cmd/ed.c b/src/cmd/ed.c index 8b0f36e5..a04f0d3f 100644 --- a/src/cmd/ed.c +++ b/src/cmd/ed.c @@ -21,6 +21,12 @@ enum EOF = -1 }; +enum +{ + LINELEN = 70, /* max number of glyphs in a display line */ + BELL = 6 /* A char could require up to BELL glyphs to display */ +}; + void (*oldhup)(int); void (*oldquit)(int); int* addr1; @@ -40,7 +46,7 @@ int ichanged; int io; Biobuf iobuf; int lastc; -char line[70]; +char line[LINELEN]; Rune* linebp; Rune linebuf[LBSIZE]; int listf; @@ -1543,7 +1549,7 @@ putchr(int ac) *lp++ = 'n'; } } else { - if(col > (72-6-2)) { + if(col > (LINELEN-BELL)) { col = 8; *lp++ = '\\'; *lp++ = '\n'; @@ -1558,15 +1564,32 @@ putchr(int ac) if(c == '\t') c = 't'; col++; - } else - if(c<' ' || c>='\177') { + } else if (c<' ' || c=='\177') { *lp++ = '\\'; *lp++ = 'x'; - *lp++ = hex[c>>12]; - *lp++ = hex[c>>8&0xF]; - *lp++ = hex[c>>4&0xF]; - c = hex[c&0xF]; + *lp++ = hex[(c>>4)&0xF]; + c = hex[c&0xF]; + col += 3; + } else if (c>'\177' && c<=0xFFFF) { + *lp++ = '\\'; + *lp++ = 'u'; + *lp++ = hex[(c>>12)&0xF]; + *lp++ = hex[(c>>8)&0xF]; + *lp++ = hex[(c>>4)&0xF]; + c = hex[c&0xF]; col += 5; + } else if (c>0xFFFF) { + *lp++ = '\\'; + *lp++ = 'U'; + *lp++ = hex[(c>>28)&0xF]; + *lp++ = hex[(c>>24)&0xF]; + *lp++ = hex[(c>>20)&0xF]; + *lp++ = hex[(c>>16)&0xF]; + *lp++ = hex[(c>>12)&0xF]; + *lp++ = hex[(c>>8)&0xF]; + *lp++ = hex[(c>>4)&0xF]; + c = hex[c&0xF]; + col += 9; } } } @@ -1574,7 +1597,7 @@ putchr(int ac) rune = c; lp += runetochar(lp, &rune); - if(c == '\n' || lp >= &line[sizeof(line)-5]) { + if(c == '\n' || lp >= &line[LINELEN-BELL]) { linp = line; write(oflag? 2: 1, line, lp-line); return; -- cgit v1.2.3 From c3d31baca0a73a9e8033db8a0b47093233c636c1 Mon Sep 17 00:00:00 2001 From: Gregor Best Date: Thu, 4 Jun 2020 19:55:26 +0200 Subject: fontsrv: fix compilation on X11 (#420) --- src/cmd/fontsrv/x11.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/cmd') diff --git a/src/cmd/fontsrv/x11.c b/src/cmd/fontsrv/x11.c index 417dcfa6..c1d10197 100644 --- a/src/cmd/fontsrv/x11.c +++ b/src/cmd/fontsrv/x11.c @@ -61,6 +61,7 @@ load(XFont *f) FT_Error e; FT_ULong charcode; FT_UInt glyph_index; + int i; if(f->loaded) return; -- cgit v1.2.3