On Wed, Nov 12, 2014 at 07:34:28PM +0100, Martin Natano wrote:
> The 'struct _gs' type (aka. GS) contains pointers to screen interface
> functions, which are set by cl_func_std(), but this mechanism isn't
> necessary anymore, because the other frontends (tk, motif, ipc) have
> been removed. The only remaining frontend is curses and can be used
> directly. The only exception is the scr_msg function pointer, which is
> used by the perl api (disabled by default) and thus must remain in GS.
>
> Also, the tcl_interp, ip_private and tk_private fields are unused and
> can be removed.
Below is an updated version of the patch, which applies cleanly to vi as
it is in CVS now. I killed scr_msg, because the last user (the perl api)
is now gone.
This diff is mostly a mechanical change from scr_* to cl_* (or vs_* in
the cases of scr_busy and scr_msg). The benefit is, that the global
state is used less, and the code should be more readable, as less
indirections are involved when a function is called. Does anyone want
to commit that?
> See the diff below.
>
> cheers,
> natano
Index: cl/cl_funcs.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_funcs.c,v
retrieving revision 1.17
diff -u -r1.17 cl_funcs.c
--- cl/cl_funcs.c 12 Nov 2014 16:29:04 - 1.17
+++ cl/cl_funcs.c 20 Nov 2014 20:36:40 -
@@ -466,14 +466,12 @@
int
cl_rename(SCR *sp, char *name, int on)
{
- GS *gp;
CL_PRIVATE *clp;
char *ttype;
- gp = sp->gp;
clp = CLP(sp);
- ttype = OG_STR(gp, GO_TERM);
+ ttype = OG_STR(sp->gp, GO_TERM);
/*
* XXX
Index: cl/cl_main.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_main.c,v
retrieving revision 1.25
diff -u -r1.25 cl_main.c
--- cl/cl_main.c19 Nov 2014 03:42:40 - 1.25
+++ cl/cl_main.c20 Nov 2014 20:36:40 -
@@ -33,7 +33,6 @@
GS *__global_list; /* GLOBAL: List of screens. */
sigset_t __sigblockset;/* GLOBAL: Blocked
signals. */
-static void cl_func_std(GS *);
static CL_PRIVATE *cl_init(GS *);
static GS*gs_init(char *);
static void perr(char *, char *);
@@ -202,9 +201,6 @@
(void)close(fd);
}
- /* Initialize the list of curses functions. */
- cl_func_std(gp);
-
return (clp);
}
@@ -351,36 +347,6 @@
(void)sigaction(SIGINT, NULL, &clp->oact[INDX_INT]);
(void)sigaction(SIGTERM, NULL, &clp->oact[INDX_TERM]);
(void)sigaction(SIGWINCH, NULL, &clp->oact[INDX_WINCH]);
-}
-
-/*
- * cl_func_std --
- * Initialize the standard curses functions.
- */
-static void
-cl_func_std(GS *gp)
-{
- gp->scr_addstr = cl_addstr;
- gp->scr_attr = cl_attr;
- gp->scr_baud = cl_baud;
- gp->scr_bell = cl_bell;
- gp->scr_busy = NULL;
- gp->scr_clrtoeol = cl_clrtoeol;
- gp->scr_cursor = cl_cursor;
- gp->scr_deleteln = cl_deleteln;
- gp->scr_event = cl_event;
- gp->scr_ex_adjust = cl_ex_adjust;
- gp->scr_fmap = cl_fmap;
- gp->scr_insertln = cl_insertln;
- gp->scr_keyval = cl_keyval;
- gp->scr_move = cl_move;
- gp->scr_msg = NULL;
- gp->scr_optchange = cl_optchange;
- gp->scr_refresh = cl_refresh;
- gp->scr_rename = cl_rename;
- gp->scr_screen = cl_screen;
- gp->scr_suspend = cl_suspend;
- gp->scr_usage = cl_usage;
}
/*
Index: cl/cl_read.c
===
RCS file: /cvs/src/usr.bin/vi/cl/cl_read.c,v
retrieving revision 1.19
diff -u -r1.19 cl_read.c
--- cl/cl_read.c12 Nov 2014 04:28:41 - 1.19
+++ cl/cl_read.c20 Nov 2014 20:36:40 -
@@ -128,12 +128,10 @@
{
struct termios term1, term2;
CL_PRIVATE *clp;
- GS *gp;
struct pollfd pfd[1];
input_t rval;
int nr, term_reset, timeout;
- gp = sp->gp;
clp = CLP(sp);
term_reset = 0;
@@ -205,7 +203,7 @@
* It's ugly that we wait on scripting file descriptors here, but it's
* the only way to keep from locking out scripting windows.
*/
- if (F_ISSET(gp, G_SCRWIN)) {
+ if (F_ISSET(sp->gp, G_SCRWIN)) {
if (sscr_check_input(sp))
goto err;
}
Index: common/gs.h
===
RCS file: /cvs/src/usr.bin/vi/common/gs.h,v
retrieving revision 1.13
diff -u -r1.13 gs.h
--- common/gs.h 20 Nov 2014 08:50:53 - 1.13
+++ common/gs.h 20 Nov 2014 20:36:40 -
@@ -40,13 +40,13 @@
u_int16_t flags;
};
-/* Action arguments to scr_exadjust(). */
+/* Action arguments to cl_ex_adjust(). */
typedef enum { EX_TERM_CE, EX_TERM_SCROLL } exadj_t;
-/* Screen attribute arguments to scr_attr(). */
+/* Screen attribute argu