From abecab39b8cb411d5f9d00b660339903f34c0bb0 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Thu, 14 May 2009 12:19:57 +0200 Subject: [PATCH] window(1): Sync with NetBSD (which is cleaner than FreeBSD's). Raise WARNS to 6. --- usr.bin/window/Makefile | 5 +- usr.bin/window/README | 20 +- usr.bin/window/alias.h | 16 +- usr.bin/window/char.c | 97 +++- usr.bin/window/char.h | 26 +- usr.bin/window/cmd.c | 50 +- usr.bin/window/cmd1.c | 33 +- usr.bin/window/cmd2.c | 40 +- usr.bin/window/cmd3.c | 32 +- usr.bin/window/cmd4.c | 26 +- usr.bin/window/cmd5.c | 36 +- usr.bin/window/cmd6.c | 45 +- usr.bin/window/cmd7.c | 61 ++- usr.bin/window/compress.c | 251 +++++----- usr.bin/window/context.c | 50 +- usr.bin/window/context.h | 16 +- usr.bin/window/defs.h | 115 +++-- usr.bin/window/error.c | 47 +- usr.bin/window/lcmd.c | 114 ++--- usr.bin/window/lcmd.h | 42 +- usr.bin/window/lcmd1.c | 175 +++---- usr.bin/window/lcmd2.c | 139 +++--- usr.bin/window/local.h | 10 +- usr.bin/window/main.c | 172 +++---- usr.bin/window/mloop.c | 40 +- usr.bin/window/parser.h | 31 +- usr.bin/window/parser1.c | 63 +-- usr.bin/window/parser2.c | 86 ++-- usr.bin/window/parser3.c | 44 +- usr.bin/window/parser4.c | 29 +- usr.bin/window/parser5.c | 34 +- usr.bin/window/scanner.c | 121 +++-- usr.bin/window/startup.c | 44 +- usr.bin/window/string.c | 76 ++- usr.bin/window/token.h | 10 +- usr.bin/window/tt.h | 113 +++-- usr.bin/window/ttf100.c | 24 +- usr.bin/window/ttgeneric.c | 143 ++++-- usr.bin/window/tth19.c | 95 ++-- usr.bin/window/tth29.c | 32 +- usr.bin/window/ttinit.c | 51 ++- usr.bin/window/ttoutput.c | 43 +- usr.bin/window/tttermcap.c | 63 +-- usr.bin/window/tttvi925.c | 24 +- usr.bin/window/ttwyse60.c | 24 +- usr.bin/window/ttwyse75.c | 24 +- usr.bin/window/ttzapple.c | 144 +++--- usr.bin/window/ttzentec.c | 24 +- usr.bin/window/value.h | 13 +- usr.bin/window/var.c | 67 ++- usr.bin/window/var.h | 27 +- usr.bin/window/win.c | 162 ++++--- usr.bin/window/window.1 | 484 ++++++++++++-------- usr.bin/window/{wwend.c => window_string.h} | 71 +-- usr.bin/window/windowrc | 3 + usr.bin/window/ww.h | 264 +++++++---- usr.bin/window/wwadd.c | 36 +- usr.bin/window/wwalloc.c | 31 +- usr.bin/window/wwbox.c | 31 +- usr.bin/window/wwchild.c | 34 +- usr.bin/window/wwclose.c | 27 +- usr.bin/window/wwclreol.c | 36 +- usr.bin/window/wwclreos.c | 29 +- usr.bin/window/wwcursor.c | 48 +- usr.bin/window/wwdata.c | 20 +- usr.bin/window/wwdelchar.c | 40 +- usr.bin/window/wwdelete.c | 51 ++- usr.bin/window/wwdelline.c | 32 +- usr.bin/window/wwdump.c | 49 +- usr.bin/window/wwend.c | 34 +- usr.bin/window/wwenviron.c | 49 +- usr.bin/window/wwerror.c | 28 +- usr.bin/window/wwflush.c | 55 ++- usr.bin/window/wwframe.c | 55 ++- usr.bin/window/wwgets.c | 50 +- usr.bin/window/wwinit.c | 166 +++---- usr.bin/window/wwinschar.c | 41 +- usr.bin/window/wwinsline.c | 32 +- usr.bin/window/wwiomux.c | 157 ++++--- usr.bin/window/wwlabel.c | 53 +-- usr.bin/window/wwmisc.c | 34 +- usr.bin/window/wwmove.c | 35 +- usr.bin/window/wwopen.c | 62 ++- usr.bin/window/wwprintf.c | 38 +- usr.bin/window/wwpty.c | 75 ++- usr.bin/window/wwputc.c | 26 +- usr.bin/window/wwputs.c | 28 +- usr.bin/window/wwredraw.c | 29 +- usr.bin/window/wwredrawwin.c | 36 +- usr.bin/window/wwrint.c | 38 +- usr.bin/window/wwscroll.c | 67 +-- usr.bin/window/wwsize.c | 37 +- usr.bin/window/wwspawn.c | 43 +- usr.bin/window/wwsuspend.c | 26 +- usr.bin/window/wwterminfo.c | 60 ++- usr.bin/window/wwtty.c | 54 +-- usr.bin/window/wwunframe.c | 35 +- usr.bin/window/wwupdate.c | 61 +-- usr.bin/window/wwwrite.c | 78 ++-- usr.bin/window/xx.c | 101 ++-- usr.bin/window/xx.h | 43 +- usr.bin/window/xxflush.c | 33 +- 102 files changed, 3555 insertions(+), 2759 deletions(-) copy usr.bin/window/{wwend.c => window_string.h} (64%) diff --git a/usr.bin/window/Makefile b/usr.bin/window/Makefile index af921c9764..9446be51fe 100644 --- a/usr.bin/window/Makefile +++ b/usr.bin/window/Makefile @@ -17,8 +17,7 @@ SRCS= char.c cmd.c cmd1.c cmd2.c cmd3.c cmd4.c cmd5.c cmd6.c cmd7.c \ wwterminfo.c wwtty.c wwunframe.c wwupdate.c wwwrite.c xx.c xxflush.c \ compress.c -DPADD= ${LIBTERMCAP} -LDADD= -ltermcap -WARNS?= 0 +DPADD= ${LIBTERMCAP} ${LIBUTIL} +LDADD= -ltermcap -lutil .include diff --git a/usr.bin/window/README b/usr.bin/window/README index 42d45b368a..1044ef197a 100644 --- a/usr.bin/window/README +++ b/usr.bin/window/README @@ -13,11 +13,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -110,12 +106,12 @@ Emacs. The IO system is semi-synchronous. Terminal input is signal driven, and everything else is done synchronously with a single -select(). It is roughly event-driven, though not in a clean way. +poll(). It is roughly event-driven, though not in a clean way. Normally, in both conversation mode and command mode, window -sleeps in a select() in wwiomux() waiting for data from the +sleeps in a poll() in wwiomux() waiting for data from the pseudo-terminals. At the same time, terminal input causes SIGIO which -is caught by wwrint(). The select() returns when at least one of the +is caught by wwrint(). The poll() returns when at least one of the pseudo-terminals becomes ready for reading. Wwrint() is the interrupt handler for tty input. It reads input @@ -133,7 +129,7 @@ Wwrint() appends characters at the end and increments wwibq (*wwibq++ wwgetc() and wwpeekc() macros. As is the convention in C, wwibq and wwibe point to one position beyond the end. In addition, wwrint() will do a longjmp(wwjmpbuf) if wwsetjmp is true. This is -used by wwiomux() to interrupt the select() which would otherwise +used by wwiomux() to interrupt the poll() which would otherwise resume after the interrupt. (Actually, I hear this is not true, but the longjmp feature is used to avoid a race condition as well. Anyway, it means I didn't have to depend on a feature in a @@ -156,15 +152,15 @@ can check for this condition with wwinterrupt() or by arranging that a longjmp() be done. Wwiomux() copies pseudo-terminal output into their corresponding -windows. Without anything to do, it blocks in a select(), waiting for +windows. Without anything to do, it blocks in a poll(), waiting for read ready on pseudo-terminals. Reads are done into per-window buffers in the window structures. When there is at least one buffer non-empty, wwiomux() finds the top most of these windows and writes it using -wwwrite(). Then the process is repeated. A non-blocking select() is +wwwrite(). Then the process is repeated. A non-blocking poll() is done after a wwwrite() to pick up any output that may have come in during the write, which may take a long time. Specifically, we use this to stop output or flush buffer when a pseudo-terminal tells us to -(we use pty packet mode). The select() blocks only when all of the +(we use pty packet mode). The poll() blocks only when all of the windows' buffers are empty. A wwupdate() is done prior to this, which is the only time the screen is guaranteed to be completely up to date. Wwiomux() loops until wwinterrupt() becomes true. diff --git a/usr.bin/window/alias.h b/usr.bin/window/alias.h index 178d3b3ad4..0be2a3a0ce 100644 --- a/usr.bin/window/alias.h +++ b/usr.bin/window/alias.h @@ -1,3 +1,5 @@ +/* $NetBSD: alias.h,v 1.5 2003/08/07 11:17:21 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,10 +32,12 @@ * SUCH DAMAGE. * * @(#)alias.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/alias.h,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/alias.h,v 1.2 2003/06/17 04:29:33 dillon Exp $ */ +#ifndef EXTERN +#define EXTERN extern +#endif + #define alias var #define a_name r_name #define a_buf r_val.v_str @@ -51,4 +51,4 @@ #define alias_unset(n) var_unset1(&alias_head, n) #define alias_lookup(n) (*var_lookup1(&alias_head, n)) -struct var *alias_head; +EXTERN struct var *alias_head; diff --git a/usr.bin/window/char.c b/usr.bin/window/char.c index eb247d2f54..8727df150e 100644 --- a/usr.bin/window/char.c +++ b/usr.bin/window/char.c @@ -1,3 +1,5 @@ +/* $NetBSD: char.c,v 1.6 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,15 +30,94 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)char.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/char.c,v 1.2.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/char.c,v 1.2 2003/06/17 04:29:33 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)char.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: char.c,v 1.6 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include "char.h" -char *_unctrl[] = { +char _cmap[] = { + _C|_U, _C|_U, _C|_U, _C|_U, /* ^@ - ^C */ + _C|_U, _C|_U, _C|_U, _C|_U, /* ^D - ^G */ + _C, _C|_P, _C, _C|_U, /* ^H - ^K */ + _C|_U, _C, _C|_U, _C|_U, /* ^L - ^O */ + _C|_U, _C|_U, _C|_U, _C|_U, /* ^P - ^S */ + _C|_U, _C|_U, _C|_U, _C|_U, /* ^T - ^W */ + _C|_U, _C|_U, _C|_U, _C|_U, /* ^U - ^[ */ + _C|_U, _C|_U, _C|_U, _C|_U, /* ^\ - ^_ */ + + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _P|_U, + _P|_U, _P|_U, _P|_U, _C|_U, + + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U, + _C|_U, _C|_U, _C|_U, _C|_U +}; + +const char *_unctrl[] = { "^@", "^A", "^B", "^C", "^D", "^E", "^F", "^G", "^H", "^I", "^J", "^K", "^L", "^M", "^N", "^O", "^P", "^Q", "^R", "^S", "^T", "^U", "^V", "^W", diff --git a/usr.bin/window/char.h b/usr.bin/window/char.h index 86f3e91aa3..36645bdfcd 100644 --- a/usr.bin/window/char.h +++ b/usr.bin/window/char.h @@ -1,3 +1,5 @@ +/* $NetBSD: char.h,v 1.5 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,8 +32,6 @@ * SUCH DAMAGE. * * @(#)char.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/char.h,v 1.3.6.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/char.h,v 1.2 2003/06/17 04:29:33 dillon Exp $ */ /* @@ -51,13 +47,13 @@ * using unctrl() by wwwrite() if ww_unctrl is set. */ -#include -#include -#include - -extern char *_unctrl[]; +extern const char *_unctrl[]; +extern char _cmap[]; #define ctrl(c) (c & 0x1f) #define unctrl(c) (_unctrl[(unsigned char) (c)]) -#define isctrl(c) iscntrl((unsigned char)(c)) -#define isprt(c) (isprint((unsigned char)(c)) || (c) == '\t') -#define isunctrl(c) (strchr("\b\t\n\r", (c)) == NULL && isctrl(c)) +#define _C 0x01 +#define _P 0x02 +#define _U 0x04 +#define isctrl(c) (_cmap[(unsigned char) (c)] & _C) +#define isprt(c) (_cmap[(unsigned char) (c)] & _P) +#define isunctrl(c) (_cmap[(unsigned char) (c)] & _U) diff --git a/usr.bin/window/cmd.c b/usr.bin/window/cmd.c index 97fcce587d..deec51dd0c 100644 --- a/usr.bin/window/cmd.c +++ b/usr.bin/window/cmd.c @@ -1,3 +1,5 @@ +/* $NetBSD: cmd.c,v 1.8 2003/08/07 11:17:21 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,18 +30,27 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cmd.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/cmd.c,v 1.2.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/cmd.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cmd.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: cmd.c,v 1.8 2003/08/07 11:17:21 agc Exp $"); +#endif +#endif /* not lint */ + +#include #include "defs.h" #include "char.h" -docmd() +int checkproc(struct ww *); + +void +docmd(void) { - register c; + int c; struct ww *w; char out = 0; @@ -213,7 +220,7 @@ docmd() } struct ww * -getwin() +getwin(void) { int c; struct ww *w = 0; @@ -242,8 +249,8 @@ getwin() return w; } -checkproc(w) -struct ww *w; +int +checkproc(struct ww *w) { if (w->ww_state != WWS_HASPROC) { error("No process in window."); @@ -252,8 +259,8 @@ struct ww *w; return 0; } -setcmd(new) -char new; +void +setcmd(char new) { if (new && !incmd) { if (!terse) @@ -273,23 +280,24 @@ char new; incmd = new; } -setterse(new) -char new; +void +setterse(char new) { - if (incmd) + if (incmd) { if (new && !terse) { wwdelete(cmdwin); reframe(); } else if (!new && terse) wwadd(cmdwin, &wwhead); + } terse = new; } /* * Set the current window. */ -setselwin(w) -struct ww *w; +void +setselwin(struct ww *w) { if (selwin == w) return; diff --git a/usr.bin/window/cmd1.c b/usr.bin/window/cmd1.c index 345ee445a6..d31997e3e2 100644 --- a/usr.bin/window/cmd1.c +++ b/usr.bin/window/cmd1.c @@ -1,3 +1,5 @@ +/* $NetBSD: cmd1.c,v 1.7 2003/08/07 11:17:22 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,16 +30,22 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cmd1.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/cmd1.c,v 1.2.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/cmd1.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cmd1.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: cmd1.c,v 1.7 2003/08/07 11:17:22 agc Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" #include "char.h" -c_window() +void +c_window(void) { int col, row, xcol, xrow; int id; @@ -105,13 +109,12 @@ c_window() wwputc('\n', cmdwin); wwcurtowin(cmdwin); (void) openwin(id, row, col, xrow-row+1, xcol-col+1, default_nline, - NULL, 1, 1, default_shellfile, default_shell); + (char *) 0, WWT_PTY, WWU_HASFRAME, default_shellfile, + default_shell); } -getpos(row, col, minrow, mincol, maxrow, maxcol) -int *row, *col; -int minrow, mincol; -int maxrow, maxcol; +int +getpos(int *row, int *col, int minrow, int mincol, int maxrow, int maxcol) { static int scount; int count; diff --git a/usr.bin/window/cmd2.c b/usr.bin/window/cmd2.c index 2283660e17..333c92c3b5 100644 --- a/usr.bin/window/cmd2.c +++ b/usr.bin/window/cmd2.c @@ -1,3 +1,5 @@ +/* $NetBSD: cmd2.c,v 1.7 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,15 +30,20 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cmd2.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/cmd2.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/cmd2.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cmd2.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: cmd2.c,v 1.7 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" -char *help_shortcmd[] = { +const char *help_shortcmd[] = { "# Select window # and return to conversation mode", "%# Select window # but stay in command mode", "escape Return to conversation mode without changing window", @@ -71,7 +74,8 @@ char *help_shortcmd[] = { ": Enter a long command", 0 }; -char *help_longcmd[] = { + +const char *help_longcmd[] = { ":alias name string ... Make `name' an alias for `string ...'", ":alias Show all aliases", ":close # ... Close windows", @@ -100,7 +104,10 @@ char *help_longcmd[] = { 0 }; -c_help() +int help_print(struct ww *, const char *, const char **); + +void +c_help(void) { struct ww *w; @@ -115,10 +122,8 @@ c_help() closeiwin(w); } -help_print(w, name, list) -struct ww *w; -char *name; -char **list; +int +help_print(struct ww *w, const char *name, const char **list) { wwprintf(w, "%s:\n\n", name); while (*list) @@ -136,7 +141,8 @@ char **list; return more(w, 1) == 2 ? -1 : 0; } -c_quit() +void +c_quit(void) { char oldterse = terse; diff --git a/usr.bin/window/cmd3.c b/usr.bin/window/cmd3.c index 62e48db561..cac5d7f647 100644 --- a/usr.bin/window/cmd3.c +++ b/usr.bin/window/cmd3.c @@ -1,3 +1,5 @@ +/* $NetBSD: cmd3.c,v 1.8 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,17 +30,22 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cmd3.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/cmd3.c,v 1.1.1.1.14.2 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/cmd3.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cmd3.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: cmd3.c,v 1.8 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" -#include "mystring.h" +#include "window_string.h" -setescape(esc) -char *esc; +void +setescape(const char *esc) { if (*esc == '^') { if (esc[1] != 0) @@ -53,9 +56,8 @@ char *esc; escapec = *esc; } -setlabel(w, label) -struct ww *w; -char *label; +int +setlabel(struct ww *w, const char *label) { if (w->ww_label != 0) str_free(w->ww_label); diff --git a/usr.bin/window/cmd4.c b/usr.bin/window/cmd4.c index dc2fe0f10f..270ab4b090 100644 --- a/usr.bin/window/cmd4.c +++ b/usr.bin/window/cmd4.c @@ -1,3 +1,5 @@ +/* $NetBSD: cmd4.c,v 1.6 2003/08/07 11:17:22 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,15 +30,21 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cmd4.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/cmd4.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/cmd4.c,v 1.2 2003/06/17 04:29:33 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cmd4.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: cmd4.c,v 1.6 2003/08/07 11:17:22 agc Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" -c_colon() +void +c_colon(void) { char oldterse = terse; char buf[512]; @@ -51,6 +55,6 @@ c_colon() wwputc('\n', cmdwin); wwcurtowin(cmdwin); setterse(oldterse); - if (dolongcmd(buf, NULL, 0) < 0) + if (dolongcmd(buf, (struct value *)0, 0) < 0) error("Out of memory."); } diff --git a/usr.bin/window/cmd5.c b/usr.bin/window/cmd5.c index d17728b66a..1a64864627 100644 --- a/usr.bin/window/cmd5.c +++ b/usr.bin/window/cmd5.c @@ -1,3 +1,5 @@ +/* $NetBSD: cmd5.c,v 1.7 2003/08/07 11:17:23 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,20 +30,27 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cmd5.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/cmd5.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/cmd5.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cmd5.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: cmd5.c,v 1.7 2003/08/07 11:17:23 agc Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" /* * Window movement. */ -c_move(w) -struct ww *w; +void getminmax(int, int, int, int, int *, int *, int *); + +void +c_move(struct ww *w) { int col, row; int mincol, minrow; @@ -88,8 +93,8 @@ struct ww *w; movewin(w, row, col); } -movewin(w, row, col) -struct ww *w; +void +movewin(struct ww *w, int row, int col) { struct ww *back = w->ww_back; @@ -104,9 +109,8 @@ struct ww *w; /* * Weird stufff, don't ask. */ -getminmax(x, n, a, b, curx, minx, maxx) -register x, n, a, b; -int *curx, *minx, *maxx; +void +getminmax(int x, int n, int a, int b, int *curx, int *minx, int *maxx) { if (x < 0) *curx = x + n - 1; diff --git a/usr.bin/window/cmd6.c b/usr.bin/window/cmd6.c index 0c52190070..e747723540 100644 --- a/usr.bin/window/cmd6.c +++ b/usr.bin/window/cmd6.c @@ -1,3 +1,5 @@ +/* $NetBSD: cmd6.c,v 1.8 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,26 +30,35 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cmd6.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/cmd6.c,v 1.1.1.1.14.2 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/cmd6.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cmd6.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: cmd6.c,v 1.8 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" -#include "mystring.h" +#include "window_string.h" #include "char.h" /* * Debugging commands. */ -c_debug() +void debug_str(void); + +void +c_debug(void) { struct ww *w; if (!terse) - wwputs("[m(smap) n(ns) o(os) s(string) v(nvis) w(win)]? ", cmdwin); + wwputs("[m(smap) n(ns) o(os) s(string) v(nvis) w(win)]? ", + cmdwin); wwcurtowin(cmdwin); while (wwpeekc() < 0) wwiomux(); @@ -83,11 +90,12 @@ c_debug() } } -#ifdef STR_DEBUG -debug_str() +void +debug_str(void) { +#ifdef STR_DEBUG struct ww *w; - struct mystring *s; + struct string *s; if ((w = openiwin(wwnrow - 3, "Allocated Strings")) == 0) { error("Can't open string window: %s.", wwerror()); @@ -96,15 +104,12 @@ debug_str() for (s = str_head.s_forw; s != &str_head; s = s->s_forw) { if (more(w, 0) == 2) goto out; - wwprintf(w, "(0x%x)\t\"%s\"\n", s->s_data, s->s_data); + wwprintf(w, "(%p)\t\"%s\"\n", s->s_data, s->s_data); } waitnl(w); out: closeiwin(w); -} #else -debug_str() -{ error("No string debugging."); -} #endif +} diff --git a/usr.bin/window/cmd7.c b/usr.bin/window/cmd7.c index 9f5bd8ec5f..f69593b593 100644 --- a/usr.bin/window/cmd7.c +++ b/usr.bin/window/cmd7.c @@ -1,3 +1,5 @@ +/* $NetBSD: cmd7.c,v 1.8 2006/05/02 22:30:25 christos Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,22 +30,32 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)cmd7.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/cmd7.c,v 1.2.6.2 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/cmd7.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)cmd7.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: cmd7.c,v 1.8 2006/05/02 22:30:25 christos Exp $"); +#endif +#endif /* not lint */ + #include +#include #include "defs.h" -#include "mystring.h" +#include "window_string.h" + +void unyank(void); +void yank_highlight(int, int, int, int); +void yank_highlight_line(int, int, int); +void yank_line(int, int, int); /* * Window size. */ - -c_size(w) -struct ww *w; +void +c_size(struct ww *w) { int col, row; @@ -96,7 +104,8 @@ struct yb { }; struct yb *yb_head, *yb_tail; -c_yank() +void +c_yank(void) { struct ww *w = selwin; int col1, row1; @@ -149,7 +158,7 @@ c_yank() } break; } - if (row2 < row1 || row2 == row1 && col2 < col1) { + if (row2 < row1 || (row2 == row1 && col2 < col1)) { r = row1; c = col1; row1 = row2; @@ -171,14 +180,15 @@ out: wwcursor(w, 1); } -yank_highlight(row1, col1, row2, col2) +void +yank_highlight(int row1, int col1, int row2, int col2) { struct ww *w = selwin; int r, c; if ((wwavailmodes & WWM_REV) == 0) return; - if (row2 < row1 || row2 == row1 && col2 < col1) { + if (row2 < row1 || (row2 == row1 && col2 < col1)) { r = row1; c = col1; row1 = row2; @@ -194,7 +204,8 @@ yank_highlight(row1, col1, row2, col2) yank_highlight_line(r, c, col2); } -yank_highlight_line(r, c, cend) +void +yank_highlight_line(int r, int c, int cend) { struct ww *w = selwin; char *win; @@ -218,7 +229,8 @@ yank_highlight_line(r, c, cend) } } -unyank() +void +unyank(void) { struct yb *yp, *yq; @@ -230,7 +242,8 @@ unyank() yb_head = yb_tail = 0; } -yank_line(r, c, cend) +void +yank_line(int r, int c, int cend) { struct yb *yp; int nl = 0; @@ -251,7 +264,10 @@ yank_line(r, c, cend) yp->length = n = cend - c + 1; if (nl) yp->length++; - yp->line = str_alloc(yp->length + 1); + if ((yp->line = str_alloc(yp->length + 1)) == NULL) { + free(yp); + return; + } for (bp += c, cp = yp->line; --n >= 0;) *cp++ = bp++->c_c; if (nl) @@ -263,7 +279,8 @@ yank_line(r, c, cend) yb_head = yb_tail = yp; } -c_put() +void +c_put(void) { struct yb *yp; diff --git a/usr.bin/window/compress.c b/usr.bin/window/compress.c index 3371f0b954..5e907fb9a5 100644 --- a/usr.bin/window/compress.c +++ b/usr.bin/window/compress.c @@ -1,3 +1,5 @@ +/* $NetBSD: compress.c,v 1.7 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,21 +30,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)compress.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/compress.c,v 1.2.12.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/compress.c,v 1.2 2003/06/17 04:29:33 dillon Exp $ */ - /* special */ -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)compress.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: compress.c,v 1.7 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include +#include #include #include - -#include "ww.h" +#include "defs.h" #include "tt.h" + /* special */ int cc_trace = 0; FILE *cc_trace_fp; @@ -111,13 +113,13 @@ short cc_wlimits[TOKEN_MAX + 1]; int cc_score_adjustments[TOKEN_MAX + 1][8]; /* XXX, 8 > max of cc_thresholds */ #define score_adjust(score, p) \ do { \ - int length = (p)->length; \ - int ccount = (p)->ccount; \ - if (threshp((p)->code, ccount, length) || \ - wthreshp((p)->weight, length)) /* XXX */ \ - (score) -= length - tt.tt_put_token_cost; \ + int _length = (p)->length; \ + int _ccount = (p)->ccount; \ + if (threshp((p)->code, _ccount, _length) || \ + wthreshp((p)->weight, _length)) /* XXX */ \ + (score) -= _length - tt.tt_put_token_cost; \ else \ - (score) += cc_score_adjustments[length][ccount]; \ + (score) += cc_score_adjustments[_length][_ccount]; \ } while (0) int cc_initial_scores[TOKEN_MAX + 1][8]; /* XXX, 8 > max of cc_thresholds */ @@ -126,8 +128,8 @@ struct cc cc_q0a, cc_q0b, cc_q1a, cc_q1b; #define qinsert(p1, p2) \ do { \ - register struct cc *forw = (p1)->qforw; \ - register struct cc *back = (p1)->qback; \ + struct cc *forw = (p1)->qforw; \ + struct cc *back = (p1)->qback; \ back->qforw = forw; \ forw->qback = back; \ forw = (p2)->qforw; \ @@ -148,7 +150,7 @@ struct cc cc_q0a, cc_q0b, cc_q1a, cc_q1b; #define H (14) #define HSIZE (1 << H) -#define hash(h, c) ((((h) >> H - 8 | (h) << 8) ^ (c)) & HSIZE - 1) +#define hash(h, c) (((((h) >> (H - 8)) | (h) << 8) ^ (c)) & (HSIZE - 1)) char *cc_buffer; struct cc **cc_output; /* the output array */ @@ -165,10 +167,22 @@ long cc_time, cc_time0; char *cc_tt_ob, *cc_tt_obe; -ccinit() +int cc_compress(struct cc **, struct cc **, char); +void cc_compress_cleanup(struct cc **, int); +void cc_compress_phase(struct cc **, int, struct cc **, int); +void cc_compress_phase1(struct cc **, struct cc **, int, int); +void cc_output_phase(char *, struct cc **, int); +int cc_sweep(char *, int, struct cc **, int); +void cc_sweep0(char *, int, int); +int cc_sweep_phase(char *, int, struct cc **); +void cc_sweep_reverse(struct cc **, short *); +int cc_token_compare(const void *, const void *); + +int +ccinit(void) { - register i, j; - register struct cc *p; + int i, j; + struct cc *p; if (tt.tt_token_max > cc_token_max) tt.tt_token_max = cc_token_max; @@ -181,7 +195,7 @@ ccinit() if (tt.tt_ntoken > cc_ntoken / 2) /* not likely */ tt.tt_ntoken = cc_ntoken / 2; #define C(x) (sizeof (x) / sizeof *(x)) - for (i = 0; i < C(cc_thresholds); i++) { + for (i = 0; i < (int)C(cc_thresholds); i++) { int h = i - tt.tt_put_token_cost; if (h > 0) cc_thresholds[i] = @@ -189,9 +203,9 @@ ccinit() else cc_thresholds[i] = 0; } - for (i = 0; i < C(cc_score_adjustments); i++) { + for (i = 0; i < (int)C(cc_score_adjustments); i++) { int t = cc_thresholds[i]; - for (j = 0; j < C(*cc_score_adjustments); j++) { + for (j = 0; j < (int)C(*cc_score_adjustments); j++) { if (j >= t) cc_score_adjustments[i][j] = - (i - tt.tt_put_token_cost); @@ -288,10 +302,9 @@ nomem: return -1; } -ccstart() +void +ccstart(void) { - int ccflush(); - ttflush(); tt_obp = tt_ob = cc_buffer; tt_obe = tt_ob + cc_bufsize; @@ -303,18 +316,20 @@ ccstart() ccreset(); } -ccreset() +void +ccreset(void) { - register struct cc *p; + struct cc *p; - bzero((char *) cc_htab, HSIZE * sizeof *cc_htab); + memset((char *) cc_htab, 0, HSIZE * sizeof *cc_htab); for (p = cc_q0a.qforw; p != &cc_q0a; p = p->qforw) p->hback = 0; for (p = cc_q1a.qforw; p != &cc_q1a; p = p->qforw) p->hback = 0; } -ccend() +void +ccend(void) { ttflush(); @@ -327,7 +342,8 @@ ccend() } } -ccflush() +void +ccflush(void) { int bufsize = tt_obp - tt_ob; int n; @@ -359,12 +375,11 @@ out: tt.tt_flush = ccflush; } -cc_sweep_phase(buffer, bufsize, tokens) - char *buffer; - struct cc **tokens; +int +cc_sweep_phase(char *buffer, int bufsize, struct cc **tokens) { - register struct cc **pp = tokens; - register i, n; + struct cc **pp = tokens; + int i, n; #ifdef STATS int nn, ii; #endif @@ -416,14 +431,14 @@ cc_sweep_phase(buffer, bufsize, tokens) return pp - tokens; } -cc_sweep0(buffer, n, length) - char *buffer; +void +cc_sweep0(char *buffer, int n, int length) { - register char *p; - register short *hc; - register i; - register short c; - register short pc = tt.tt_padc; + char *p; + short *hc; + int i; + short c; + short pc = tt.tt_padc; /* n and length are at least 1 */ p = buffer++; @@ -446,14 +461,12 @@ cc_sweep0(buffer, n, length) } } -cc_sweep(buffer, bufsize, tokens, length) - char *buffer; - struct cc **tokens; - register length; +int +cc_sweep(char *buffer, int bufsize, struct cc **tokens, int length) { - register struct cc *p; - register char *cp; - register i; + struct cc *p; + char *cp; + int i; short *hc; short *places = cc_places[length]; struct cc **pp = tokens; @@ -462,21 +475,21 @@ cc_sweep(buffer, bufsize, tokens, length) short wthreshold = wthresh(length); short limit = wlimit(length); #endif - int time; + int time0; short pc = tt.tt_padc; i = length - 1; bufsize -= i; cp = buffer + i; hc = cc_hashcodes; - time = cc_time0; - for (i = 0; i < bufsize; i++, time++) { + time0 = cc_time0; + for (i = 0; i < bufsize; i++, time0++) { struct cc **h; { - register short *hc1 = hc; - register short c = *cp++; - register short hh; + short *hc1 = hc; + short c = *cp++; + short hh; if ((hh = *hc1) < 0 || c == pc) { *hc1++ = -1; hc = hc1; @@ -487,9 +500,9 @@ cc_sweep(buffer, bufsize, tokens, length) } for (p = *h; p != 0; p = p->hforw) if (p->length == (char) length) { - register char *p1 = p->string; - register char *p2 = cp - length; - register n = length; + char *p1 = p->string; + char *p2 = cp - length; + int n = length; do if (*p1++ != *p2++) goto fail; @@ -500,15 +513,15 @@ cc_sweep(buffer, bufsize, tokens, length) if (p == 0) { p = cc_q1a.qback; if (p == &cc_q1a || - p->time >= cc_time0 && p->length == (char) length) + (p->time >= cc_time0 && p->length == (char) length)) continue; if (p->hback != 0) if ((*p->hback = p->hforw) != 0) p->hforw->hback = p->hback; { - register char *p1 = p->string; - register char *p2 = cp - length; - register n = length; + char *p1 = p->string; + char *p2 = cp - length; + int n = length; do *p1++ = *p2++; while (--n); @@ -517,7 +530,7 @@ cc_sweep(buffer, bufsize, tokens, length) #ifndef cc_weight p->weight = cc_weight; #endif - p->time = time; + p->time = time0; p->bcount = 1; p->ccount = 0; p->flag = 0; @@ -533,12 +546,12 @@ cc_sweep(buffer, bufsize, tokens, length) #endif } else if (p->time < cc_time0) { #ifndef cc_weight - if ((p->weight += p->time - time) < 0) + if ((p->weight += p->time - time0) < 0) p->weight = cc_weight; else if ((p->weight += cc_weight) > limit) p->weight = limit; #endif - p->time = time; + p->time = time0; p->bcount = 1; p->ccount = 0; if (p->code >= 0) { @@ -561,15 +574,15 @@ cc_sweep(buffer, bufsize, tokens, length) #ifdef STATS ntoken_stat++; #endif - } else if (p->time + length > time) { + } else if (p->time + length > time0) { /* * overlapping token, don't count as two and - * don't update time, but do adjust weight to offset + * don't update time0, but do adjust weight to offset * the difference */ #ifndef cc_weight if (cc_weight != 0) { /* XXX */ - p->weight += time - p->time; + p->weight += time0 - p->time; if (!p->flag && p->weight >= wthreshold) { p->flag = 1; *pp++ = p; @@ -581,12 +594,12 @@ cc_sweep(buffer, bufsize, tokens, length) p->places = i; } else { #ifndef cc_weight - if ((p->weight += p->time - time) < 0) + if ((p->weight += p->time - time0) < 0) p->weight = cc_weight; else if ((p->weight += cc_weight) > limit) p->weight = limit; #endif - p->time = time; + p->time = time0; p->bcount++; if (!p->flag && /* code must be < 0 if flag false here */ @@ -608,7 +621,6 @@ cc_sweep(buffer, bufsize, tokens, length) if (cc_reverse) cc_sweep_reverse(tokens, places); if (cc_sort && i > 1) { - int cc_token_compare(); qsort((char *) tokens, i, sizeof *tokens, cc_token_compare); } @@ -622,33 +634,31 @@ cc_sweep(buffer, bufsize, tokens, length) return i; } -cc_sweep_reverse(pp, places) - register struct cc **pp; - register short *places; +void +cc_sweep_reverse(struct cc **pp, short int *places) { - register struct cc *p; - register short front, back, t; + struct cc *p; + short frnt, back, t; while ((p = *pp++) != 0) { back = -1; t = p->places; /* the list is never empty */ do { - front = places[t]; + frnt = places[t]; places[t] = back; back = t; - } while ((t = front) >= 0); + } while ((t = frnt) >= 0); p->places = back; } } -cc_compress_phase(output, bufsize, tokens, ntoken) - struct cc **output; - struct cc **tokens; +void +cc_compress_phase(struct cc **output, int bufsize, struct cc **tokens, int ntoken) { - register i; + int i; - bzero((char *) output, bufsize * sizeof *output); + memset((char *) output, 0, bufsize * sizeof *output); for (i = 0; i < cc_npass0; i++) cc_compress_phase1(output, tokens, ntoken, 0); for (i = 0; i < cc_npass1; i++) @@ -656,13 +666,12 @@ cc_compress_phase(output, bufsize, tokens, ntoken) cc_compress_cleanup(output, bufsize); } -cc_compress_phase1(output, tokens, ntoken, flag) - register struct cc **output; - struct cc **tokens; +void +cc_compress_phase1(struct cc **output, struct cc **tokens, int ntoken, int flag) { - register struct cc **pp; + struct cc **pp; #ifdef STATS - register int i = 0; + int i = 0; int nt = 0, cc = 0, nc = 0; #endif @@ -707,16 +716,16 @@ cc_compress_phase1(output, tokens, ntoken, flag) #endif } -cc_compress_cleanup(output, bufsize) - register struct cc **output; +void +cc_compress_cleanup(struct cc **output, int bufsize) { - register struct cc **end; + struct cc **end; /* the previous output phase may have been interrupted */ qinsertq(&cc_q0b, &cc_q0a); for (end = output + bufsize; output < end;) { - register struct cc *p; - register length; + struct cc *p; + int length; if ((p = *output) == 0) { output++; continue; @@ -742,13 +751,11 @@ cc_compress_cleanup(output, bufsize) } } -cc_compress(output, tokens, flag) - struct cc **output; - struct cc **tokens; - char flag; +int +cc_compress(struct cc **output, struct cc **tokens, char flag) { struct cc **pp = tokens; - register struct cc *p = *pp++; + struct cc *p = *pp++; int length = p->length; int threshold = thresh(length); #ifndef cc_weight @@ -760,7 +767,7 @@ cc_compress(output, tokens, flag) do { int score; - register struct cc_undo *undop; + struct cc_undo *undop; int ccount; #ifdef STATS int ncover; @@ -785,10 +792,10 @@ cc_compress(output, tokens, flag) ncover = 0; #endif for (i = p->places; i >= 0; i = places[i]) { - register struct cc **jp; - register struct cc *x; - register struct cc **ip = output + i; - register score0 = initial_score0; + struct cc **jp; + struct cc *x; + struct cc **ip = output + i; + int score0 = initial_score0; struct cc **iip = ip + length; struct cc_undo *undop1 = undop; @@ -831,7 +838,7 @@ cc_compress(output, tokens, flag) continue; undo: while (--undop >= undop1) - if (*undop->pos = x = undop->val) + if ((*undop->pos = x = undop->val)) x->ccount++; undop++; } @@ -843,10 +850,10 @@ cc_compress(output, tokens, flag) #endif p->ccount = ccount; } else { - register struct cc_undo *u = cc_undo; + struct cc_undo *u = cc_undo; while (--undop >= u) { - register struct cc *x; - if (*undop->pos = x = undop->val) + struct cc *x; + if ((*undop->pos = x = undop->val)) x->ccount++; } } @@ -854,13 +861,11 @@ cc_compress(output, tokens, flag) return pp - tokens; } -cc_output_phase(buffer, output, bufsize) - register char *buffer; - register struct cc **output; - register bufsize; +void +cc_output_phase(char *buffer, struct cc **output, int bufsize) { - register i; - register struct cc *p, *p1; + int i; + struct cc *p, *p1; for (i = 0; i < bufsize;) { if ((p = output[i]) == 0) { @@ -895,8 +900,10 @@ cc_output_phase(buffer, output, bufsize) wwntokc += bufsize; } -cc_token_compare(p1, p2) - struct cc **p1, **p2; +int +cc_token_compare(const void *p1, const void *p2) { - return (*p2)->bcount - (*p1)->bcount; + const struct cc * const * vp1 = p1; + const struct cc * const * vp2 = p2; + return (*vp2)->bcount - (*vp1)->bcount; } diff --git a/usr.bin/window/context.c b/usr.bin/window/context.c index 97ee409f00..6de15c0af9 100644 --- a/usr.bin/window/context.c +++ b/usr.bin/window/context.c @@ -1,3 +1,5 @@ +/* $NetBSD: context.c,v 1.7 2003/08/07 11:17:24 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,24 +30,34 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)context.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/context.c,v 1.1.1.1.14.2 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/context.c,v 1.4 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)context.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: context.c,v 1.7 2003/08/07 11:17:24 agc Exp $"); +#endif +#endif /* not lint */ + #include #include - -#include "value.h" -#include "mystring.h" +#include "defs.h" +#include "window_string.h" +#undef EXTERN +#define EXTERN #include "context.h" +#undef EXTERN /* * Context push/pop for nested command files. */ +int cx_alloc(void); +void cx_free(void); -cx_alloc() +int +cx_alloc(void) { struct context *xp; @@ -68,7 +76,8 @@ cx_alloc() return 0; } -cx_free() +void +cx_free(void) { struct context *xp; @@ -79,8 +88,8 @@ cx_free() cx.x_type = 0; } -cx_beginfile(filename) -char *filename; +int +cx_beginfile(char *filename) { if (cx_alloc() < 0) return -1; @@ -103,10 +112,8 @@ bad: return -1; } -cx_beginbuf(buf, arg, narg) -char *buf; -struct value *arg; -int narg; +int +cx_beginbuf(char *buf, struct value *arg, int narg) { if (cx_alloc() < 0) return -1; @@ -117,7 +124,8 @@ int narg; return 0; } -cx_end() +void +cx_end(void) { switch (cx.x_type) { case X_BUF: diff --git a/usr.bin/window/context.h b/usr.bin/window/context.h index 9e80328c45..bddde1c2d3 100644 --- a/usr.bin/window/context.h +++ b/usr.bin/window/context.h @@ -1,3 +1,5 @@ +/* $NetBSD: context.h,v 1.5 2003/08/07 11:17:25 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,12 +32,14 @@ * SUCH DAMAGE. * * @(#)context.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/context.h,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/context.h,v 1.2 2003/06/17 04:29:33 dillon Exp $ */ #include +#ifndef EXTERN +#define EXTERN extern +#endif + struct context { struct context *x_link; /* nested contexts */ char x_type; /* tag for union */ @@ -82,4 +82,4 @@ struct context { #define X_FILE 1 /* input is a file */ #define X_BUF 2 /* input is a buffer */ -struct context cx; /* the current context */ +EXTERN struct context cx; /* the current context */ diff --git a/usr.bin/window/defs.h b/usr.bin/window/defs.h index c28c1a994b..6ecdd5e9de 100644 --- a/usr.bin/window/defs.h +++ b/usr.bin/window/defs.h @@ -1,3 +1,5 @@ +/* $NetBSD: defs.h,v 1.8 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,40 +32,97 @@ * SUCH DAMAGE. * * @(#)defs.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/defs.h,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/defs.h,v 1.2 2003/06/17 04:29:33 dillon Exp $ */ -#include "ww.h" #include +#include "value.h" +#include "ww.h" + +#ifndef EXTERN +#define EXTERN extern +#endif #define NWINDOW 9 -struct timeval starttime; +EXTERN struct timeval starttime; -struct ww *window[NWINDOW]; /* the windows */ -struct ww *selwin; /* the selected window */ -struct ww *lastselwin; /* the last selected window */ -struct ww *cmdwin; /* the command window */ -struct ww *framewin; /* the window for framing */ -struct ww *boxwin; /* the window for the box */ -struct ww *fgwin; /* the last foreground window */ +EXTERN struct ww *window[NWINDOW]; /* the windows */ +EXTERN struct ww *selwin; /* the selected window */ +EXTERN struct ww *lastselwin; /* the last selected window */ +EXTERN struct ww *cmdwin; /* the command window */ +EXTERN struct ww *framewin; /* the window for framing */ +EXTERN struct ww *boxwin; /* the window for the box */ +EXTERN struct ww *fgwin; /* the last foreground window */ #define isfg(w) ((w)->ww_order <= fgwin->ww_order) -char *default_shell[128]; /* default shell argv */ -char *default_shellfile; /* default shell program */ -int default_nline; /* default buffer size for new windows */ -int default_smooth; /* default "smooth" parameter */ -char escapec; /* the escape character */ +EXTERN char *default_shell[128]; /* default shell argv */ +EXTERN char *default_shellfile; /* default shell program */ +EXTERN int default_nline; /* default buffer size for new windows */ +EXTERN int default_smooth; /* default "smooth" parameter */ +EXTERN char escapec; /* the escape character */ - /* flags */ -char quit; /* quit command issued */ -char terse; /* terse mode */ -char debug; /* debug mode */ -char incmd; /* in command mode */ +/* flags */ +EXTERN char quit; /* quit command issued */ +EXTERN char terse; /* terse mode */ +EXTERN char debug; /* debug mode */ +EXTERN char incmd; /* in command mode */ -struct ww *getwin(); -struct ww *openwin(); -struct ww *vtowin(); -struct ww *openiwin(); +void addwin(struct ww *, char); +int ccinit(void); +void ccend(void); +void ccflush(void); +void ccreset(void); +void ccstart(void); +void c_colon(void); +void c_debug(void); +void c_help(void); +void c_move(struct ww *); +void c_put(void); +void c_quit(void); +void c_size(struct ww *); +void c_window(void); +void c_yank(void); +void closeiwin(struct ww *); +void closewin(struct ww *); +void closewin1(struct ww *); +int cx_beginbuf(char *, struct value *, int); +int cx_beginfile(char *); +void cx_end(void); +void deletewin(struct ww *); +void docmd(void); +int doconfig(void); +void dodefault(void); +int dolongcmd(char *, struct value *, int); +int dosource(char *); +void error(const char *, ...) + __attribute__((__format__(__printf__, 1, 2))); +void err_end(void); +int findid(void); +struct ww *findselwin(void); +void front(struct ww *, char); +int getpos(int *, int *, int, int, int, int); +struct ww *getwin(void); +void labelwin(struct ww *); +void mloop(void); +int more(struct ww *, char); +void movewin(struct ww *, int, int); +struct ww *openwin(int, int, int, int, int, int, char *, int, int, + char *, char **); +struct ww *openiwin(int, const char *); +void p_memerror(void); +void p_start(void); +void reframe(void); +void setcmd(char); +void setescape(const char *); +int setlabel(struct ww *, const char *); +void setselwin(struct ww *); +void setterse(char); +void setvars(void); +void sizewin(struct ww *, int, int); +void startwin(struct ww *); +void stopwin(struct ww *); +int s_gettok(void); +void verror(const char *, va_list); +void waitnl(struct ww *); +int waitnl1(struct ww *, const char *); diff --git a/usr.bin/window/error.c b/usr.bin/window/error.c index a5bfec4364..40d84980f7 100644 --- a/usr.bin/window/error.c +++ b/usr.bin/window/error.c @@ -1,3 +1,5 @@ +/* $NetBSD: error.c,v 1.6 2003/08/07 11:17:25 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,22 +30,35 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)error.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/error.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/error.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)error.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: error.c,v 1.6 2003/08/07 11:17:25 agc Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" -#include "value.h" #include "context.h" #include "char.h" #define ERRLINES 10 /* number of lines for errwin */ -/*VARARGS1*/ -error(fmt, a, b, c, d, e, f, g, h) -char *fmt; +void +error(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + verror(fmt, ap); + va_end(ap); +} + +void +verror(const char *fmt, va_list ap) { struct context *x; struct ww *w; @@ -58,7 +69,7 @@ char *fmt; if (terse) wwbell(); else { - wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h); + wwvprintf(cmdwin, fmt, ap); wwputs(" ", cmdwin); } return; @@ -68,7 +79,8 @@ char *fmt; if ((w = x->x_errwin) == 0) { char buf[512]; - (void) sprintf(buf, "Errors from %s", x->x_filename); + (void) snprintf(buf, sizeof(buf), "Errors from %s", + x->x_filename); if ((w = x->x_errwin = openiwin(ERRLINES, buf)) == 0) { wwputs("Can't open error window. ", cmdwin); x->x_noerr = 1; @@ -80,11 +92,12 @@ char *fmt; return; } wwprintf(w, "line %d: ", x->x_lineno); - wwprintf(w, fmt, a, b, c, d, e, f, g, h); + wwvprintf(w, fmt, ap); wwputc('\n', w); } -err_end() +void +err_end(void) { if (cx.x_type == X_FILE && cx.x_errwin != 0) { if (!cx.x_noerr) diff --git a/usr.bin/window/lcmd.c b/usr.bin/window/lcmd.c index 05ac81e1c6..8fecadfff3 100644 --- a/usr.bin/window/lcmd.c +++ b/usr.bin/window/lcmd.c @@ -1,3 +1,5 @@ +/* $NetBSD: lcmd.c,v 1.9 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,39 +30,20 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)lcmd.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/lcmd.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/lcmd.c,v 1.3 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)lcmd.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: lcmd.c,v 1.9 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include "defs.h" -#include "value.h" #include "lcmd.h" - -int l_alias(); -int l_close(); -int l_cursormodes(); -int l_debug(); -int l_def_nline(); -int l_def_shell(); -int l_def_smooth(); -int l_echo(); -int l_escape(); -int l_foreground(); -int l_iostat(); -int l_label(); -int l_list(); -int l_select(); -int l_smooth(); -int l_source(); -int l_terse(); -int l_time(); -int l_unalias(); -int l_unset(); -int l_variable(); -int l_window(); -int l_write(); +#include "window_string.h" extern struct lcmd_arg arg_alias[]; extern struct lcmd_arg arg_cursormodes[]; @@ -86,40 +65,39 @@ extern struct lcmd_arg arg_unalias[]; extern struct lcmd_arg arg_unset[]; extern struct lcmd_arg arg_window[]; extern struct lcmd_arg arg_write[]; -struct lcmd_arg arg_null[1] = { { 0 } }; +struct lcmd_arg arg_null[1] = { { NULL, 0, 0 } }; struct lcmd_tab lcmd_tab[] = { - "alias", 1, l_alias, arg_alias, - "close", 2, l_close, arg_close, - "cursormodes", 2, l_cursormodes, arg_cursormodes, - "debug", 1, l_debug, arg_debug, - "default_nlines", 9, l_def_nline, arg_def_nline, - "default_shell", 10, l_def_shell, arg_def_shell, - "default_smooth", 10, l_def_smooth, arg_def_smooth, - "echo", 2, l_echo, arg_echo, - "escape", 2, l_escape, arg_escape, - "foreground", 1, l_foreground, arg_foreground, - "iostat", 1, l_iostat, arg_null, - "label", 2, l_label, arg_label, - "list", 2, l_list, arg_null, - "nlines", 1, l_def_nline, arg_def_nline, - "select", 2, l_select, arg_select, - "shell", 2, l_def_shell, arg_def_shell, - "smooth", 2, l_smooth, arg_smooth, - "source", 2, l_source, arg_source, - "terse", 2, l_terse, arg_terse, - "time", 2, l_time, arg_time, - "unalias", 3, l_unalias, arg_unalias, - "unset", 3, l_unset, arg_unset, - "variable", 1, l_variable, arg_null, - "window", 2, l_window, arg_window, - "write", 2, l_write, arg_write, - 0 + { "alias", 1, l_alias, arg_alias }, + { "close", 2, l_close, arg_close }, + { "cursormodes", 2, l_cursormodes, arg_cursormodes }, + { "debug", 1, l_debug, arg_debug }, + { "default_nlines", 9, l_def_nline, arg_def_nline }, + { "default_shell", 10, l_def_shell, arg_def_shell }, + { "default_smooth", 10, l_def_smooth, arg_def_smooth }, + { "echo", 2, l_echo, arg_echo }, + { "escape", 2, l_escape, arg_escape }, + { "foreground", 1, l_foreground, arg_foreground }, + { "iostat", 1, l_iostat, arg_null }, + { "label", 2, l_label, arg_label }, + { "list", 2, l_list, arg_null }, + { "nlines", 1, l_def_nline, arg_def_nline }, + { "select", 2, l_select, arg_select }, + { "shell", 2, l_def_shell, arg_def_shell }, + { "smooth", 2, l_smooth, arg_smooth }, + { "source", 2, l_source, arg_source }, + { "terse", 2, l_terse, arg_terse }, + { "time", 2, l_time, arg_time }, + { "unalias", 3, l_unalias, arg_unalias }, + { "unset", 3, l_unset, arg_unset }, + { "variable", 1, l_variable, arg_null }, + { "window", 2, l_window, arg_window }, + { "write", 2, l_write, arg_write }, + { 0, 0, 0, 0 } }; struct lcmd_tab * -lcmd_lookup(name) -char *name; +lcmd_lookup(const char *name) { struct lcmd_tab *p; @@ -129,8 +107,8 @@ char *name; return 0; } -dosource(filename) -char *filename; +int +dosource(char *filename) { if (cx_beginfile(filename) < 0) return -1; @@ -140,10 +118,8 @@ char *filename; return 0; } -dolongcmd(buffer, arg, narg) -char *buffer; -struct value *arg; -int narg; +int +dolongcmd(char *buffer, struct value *arg, int narg) { if (cx_beginbuf(buffer, arg, narg) < 0) return -1; diff --git a/usr.bin/window/lcmd.h b/usr.bin/window/lcmd.h index a8f901ed89..5036fa6a08 100644 --- a/usr.bin/window/lcmd.h +++ b/usr.bin/window/lcmd.h @@ -1,3 +1,5 @@ +/* $NetBSD: lcmd.h,v 1.7 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,21 +32,19 @@ * SUCH DAMAGE. * * @(#)lcmd.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/lcmd.h,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/lcmd.h,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ #define LCMD_NARG 20 /* maximum number of arguments */ struct lcmd_tab { - char *lc_name; + const char *lc_name; int lc_minlen; - int (*lc_func)(); + void (*lc_func)(struct value *, struct value *); struct lcmd_arg *lc_arg; }; struct lcmd_arg { - char *arg_name; + const char *arg_name; int arg_minlen; int arg_flags; }; @@ -60,4 +56,28 @@ struct lcmd_arg { #define ARG_STR 0x02 /* must be a string */ #define ARG_LIST 0x10 /* this arg can be a list */ -struct lcmd_tab *lcmd_lookup(); +struct lcmd_tab *lcmd_lookup(const char *); +void l_alias(struct value *, struct value *); +void l_close(struct value *, struct value *); +void l_cursormodes(struct value *, struct value *); +void l_debug(struct value *, struct value *); +void l_def_nline(struct value *, struct value *); +void l_def_shell(struct value *, struct value *); +void l_def_smooth(struct value *, struct value *); +void l_echo(struct value *, struct value *); +void l_escape(struct value *, struct value *); +void l_foreground(struct value *, struct value *); +void l_iostat(struct value *, struct value *); +void l_label(struct value *, struct value *); +void l_list(struct value *, struct value *); +void l_select(struct value *, struct value *); +void l_smooth(struct value *, struct value *); +void l_source(struct value *, struct value *); +void l_terse(struct value *, struct value *); +void l_time(struct value *, struct value *); +void l_unalias(struct value *, struct value *); +void l_unset(struct value *, struct value *); +void l_variable(struct value *, struct value *); +void l_window(struct value *, struct value *); +void l_write(struct value *, struct value *); +struct ww *vtowin(struct value *, struct ww *); diff --git a/usr.bin/window/lcmd1.c b/usr.bin/window/lcmd1.c index e072777850..489e373c01 100644 --- a/usr.bin/window/lcmd1.c +++ b/usr.bin/window/lcmd1.c @@ -1,3 +1,5 @@ +/* $NetBSD: lcmd1.c,v 1.11 2006/12/18 20:04:55 christos Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,21 +30,26 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)lcmd1.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/lcmd1.c,v 1.2.6.2 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/lcmd1.c,v 1.4 2005/04/15 17:55:29 drhodus Exp $ */ -#include -#include /* System string definitions. */ - +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)lcmd1.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: lcmd1.c,v 1.11 2006/12/18 20:04:55 christos Exp $"); +#endif +#endif /* not lint */ + +#include +#include #include "defs.h" -#include "mystring.h" /* Local string definitions. */ -#include "value.h" +#include "window_string.h" #include "lcmd.h" #include "var.h" +char vtobool(struct value *, char, char); + struct lcmd_arg arg_window[] = { { "row", 1, ARG_NUM }, { "column", 1, ARG_NUM }, @@ -60,17 +63,16 @@ struct lcmd_arg arg_window[] = { { "keepopen", 1, ARG_ANY }, { "smooth", 1, ARG_ANY }, { "shell", 1, ARG_STR|ARG_LIST }, - 0 + { NULL, 0, 0 } }; -l_window(v, a) -struct value *v; -struct value *a; +void +l_window(struct value *v, struct value *a) { struct ww *w; int col, row, ncol, nrow, id, nline; char *label; - char haspty, hasframe, mapnl, keepopen, smooth; + int haspty, hasframe, mapnl, keepopen, smooth; char *shf, **sh; char *argv[sizeof default_shell / sizeof *default_shell]; char **pp; @@ -104,7 +106,7 @@ struct value *a; *pp = a->v_str; *pp = 0; shf = *(sh = argv); - if (*sh = strrchr(shf, '/')) + if ((*sh = strrchr(shf, '/'))) (*sh)++; else *sh = shf; @@ -112,23 +114,33 @@ struct value *a; sh = default_shell; shf = default_shellfile; } - if ((w = openwin(id, row, col, nrow, ncol, nline, label, haspty, - hasframe, shf, sh)) == 0) + if ((w = openwin(id, row, col, nrow, ncol, nline, label, + haspty ? WWT_PTY : WWT_SOCKET, hasframe ? WWU_HASFRAME : 0, shf, + sh)) == 0) return; - w->ww_mapnl = mapnl; - w->ww_keepopen = keepopen; - w->ww_noupdate = !smooth; + if (mapnl) + SET(w->ww_wflags, WWW_MAPNL); + else + CLR(w->ww_wflags, WWW_MAPNL); + if (keepopen) + SET(w->ww_uflags, WWU_KEEPOPEN); + else + CLR(w->ww_uflags, WWU_KEEPOPEN); + if (!smooth) + SET(w->ww_wflags, WWW_NOUPDATE); + else + CLR(w->ww_wflags, WWW_NOUPDATE); v->v_type = V_NUM; v->v_num = id + 1; } struct lcmd_arg arg_def_nline[] = { { "nlines", 1, ARG_NUM }, - 0 + { NULL, 0, 0 } }; -l_def_nline(v, a) -struct value *v, *a; +void +l_def_nline(struct value *v, struct value *a) { v->v_num = default_nline; v->v_type = V_NUM; @@ -139,11 +151,11 @@ struct value *v, *a; struct lcmd_arg arg_smooth[] = { { "window", 1, ARG_NUM }, { "flag", 1, ARG_ANY }, - 0 + { NULL, 0, 0 } }; -l_smooth(v, a) -struct value *v, *a; +void +l_smooth(struct value *v, struct value *a) { struct ww *w; @@ -151,17 +163,20 @@ struct value *v, *a; v->v_num = 0; if ((w = vtowin(a++, selwin)) == 0) return; - v->v_num = !w->ww_noupdate; - w->ww_noupdate = !vtobool(a, v->v_num, v->v_num); + v->v_num = ISSET(w->ww_wflags, WWW_NOUPDATE) == 0; + if (!vtobool(a, v->v_num, v->v_num)) + SET(w->ww_wflags, WWW_NOUPDATE); + else + CLR(w->ww_wflags, WWW_NOUPDATE); } struct lcmd_arg arg_def_smooth[] = { { "flag", 1, ARG_ANY }, - 0 + { NULL, 0, 0 } }; -l_def_smooth(v, a) -struct value *v, *a; +void +l_def_smooth(struct value *v, struct value *a) { v->v_type = V_NUM; v->v_num = default_smooth; @@ -170,11 +185,11 @@ struct value *v, *a; struct lcmd_arg arg_select[] = { { "window", 1, ARG_NUM }, - 0 + { NULL, 0, 0 } }; -l_select(v, a) -struct value *v, *a; +void +l_select(struct value *v, struct value *a) { struct ww *w; @@ -182,18 +197,18 @@ struct value *v, *a; v->v_num = selwin ? selwin->ww_id + 1 : -1; if (a->v_type == V_ERR) return; - if ((w = vtowin(a, NULL)) == 0) + if ((w = vtowin(a, (struct ww *)0)) == 0) return; setselwin(w); } struct lcmd_arg arg_debug[] = { { "flag", 1, ARG_ANY }, - 0 + { NULL, 0, 0 } }; -l_debug(v, a) -struct value *v, *a; +void +l_debug(struct value *v, struct value *a) { v->v_type = V_NUM; v->v_num = debug; @@ -202,11 +217,11 @@ struct value *v, *a; struct lcmd_arg arg_escape[] = { { "escapec", 1, ARG_STR }, - 0 + { NULL, 0, 0 } }; -l_escape(v, a) -struct value *v, *a; +void +l_escape(struct value *v, struct value *a) { char buf[2]; @@ -224,13 +239,11 @@ struct value *v, *a; struct lcmd_arg arg_label[] = { { "window", 1, ARG_NUM }, { "label", 1, ARG_STR }, - 0 + { NULL, 0, 0 } }; -/*ARGSUSED*/ -l_label(v, a) -struct value *v; -struct value *a; +void +l_label(struct value *v __unused, struct value *a) { struct ww *w; @@ -244,11 +257,11 @@ struct value *a; struct lcmd_arg arg_foreground[] = { { "window", 1, ARG_NUM }, { "flag", 1, ARG_ANY }, - 0 + { NULL, 0, 0 } }; -l_foreground(v, a) -struct value *v, *a; +void +l_foreground(struct value *v, struct value *a) { struct ww *w; char flag; @@ -267,11 +280,11 @@ struct value *v, *a; struct lcmd_arg arg_terse[] = { { "flag", 1, ARG_ANY }, - 0 + { NULL, 0, 0 } }; -l_terse(v, a) -struct value *v, *a; +void +l_terse(struct value *v, struct value *a) { v->v_type = V_NUM; v->v_num = terse; @@ -280,11 +293,11 @@ struct value *v, *a; struct lcmd_arg arg_source[] = { { "filename", 1, ARG_STR }, - 0 + { NULL, 0, 0 } }; -l_source(v, a) -struct value *v, *a; +void +l_source(struct value *v, struct value *a) { v->v_type = V_NUM; if (a->v_type != V_ERR && dosource(a->v_str) < 0) { @@ -297,13 +310,11 @@ struct value *v, *a; struct lcmd_arg arg_write[] = { { "window", 1, ARG_NUM }, { "", 0, ARG_ANY|ARG_LIST }, - 0 + { NULL, 0, 0 } }; -/*ARGSUSED*/ -l_write(v, a) -struct value *v; -struct value *a; +void +l_write(struct value *v __unused, struct value *a) { char buf[20]; struct ww *w; @@ -323,31 +334,29 @@ struct value *a; struct lcmd_arg arg_close[] = { { "window", 1, ARG_ANY|ARG_LIST }, - 0 + { NULL, 0, 0 } }; -/*ARGSUSED*/ -l_close(v, a) -struct value *v; -struct value *a; +void +l_close(struct value *v __unused, struct value *a) { struct ww *w; if (a->v_type == V_STR && str_match(a->v_str, "all", 3)) - closewin(NULL); + closewin((struct ww *)0); else for (; a->v_type != V_ERR; a++) - if ((w = vtowin(a, NULL)) != 0) + if ((w = vtowin(a, (struct ww *)0)) != 0) closewin(w); } struct lcmd_arg arg_cursormodes[] = { { "modes", 1, ARG_NUM }, - 0 + { NULL, 0, 0 } }; -l_cursormodes(v, a) -struct value *v, *a; +void +l_cursormodes(struct value *v, struct value *a) { v->v_type = V_NUM; @@ -358,11 +367,11 @@ struct value *v, *a; struct lcmd_arg arg_unset[] = { { "variable", 1, ARG_ANY }, - 0 + { NULL, 0, 0 } }; -l_unset(v, a) -struct value *v, *a; +void +l_unset(struct value *v, struct value *a) { v->v_type = V_NUM; switch (a->v_type) { @@ -382,9 +391,7 @@ struct value *v, *a; } struct ww * -vtowin(v, w) -struct value *v; -struct ww *w; +vtowin(struct value *v, struct ww *w) { switch (v->v_type) { case V_ERR: @@ -404,9 +411,8 @@ struct ww *w; return w; } -vtobool(v, def, err) -struct value *v; -char def, err; +char +vtobool(struct value *v, char def, char err) { switch (v->v_type) { case V_NUM: @@ -429,4 +435,5 @@ char def, err; return def; } /*NOTREACHED*/ + return (0); } diff --git a/usr.bin/window/lcmd2.c b/usr.bin/window/lcmd2.c index 6e723f564d..25f28e8983 100644 --- a/usr.bin/window/lcmd2.c +++ b/usr.bin/window/lcmd2.c @@ -1,3 +1,5 @@ +/* $NetBSD: lcmd2.c,v 1.15 2008/12/29 01:53:35 christos Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,28 +30,33 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)lcmd2.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/lcmd2.c,v 1.2.6.2 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/lcmd2.c,v 1.4 2005/04/15 17:55:29 drhodus Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)lcmd2.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: lcmd2.c,v 1.15 2008/12/29 01:53:35 christos Exp $"); +#endif +#endif /* not lint */ + #include +#include #include - -#include -#include /* System string definitions. */ - +#include #include "defs.h" -#include "mystring.h" /* Local string definitions. */ -#include "value.h" +#include "window_string.h" #include "var.h" #include "lcmd.h" #include "alias.h" -/*ARGSUSED*/ -l_iostat(v, a) -struct value *v, *a; +int printalias(void *, struct var *); +int printvar(void *, struct var *); +char *strtime(struct timeval *t); + +void +l_iostat(struct value *v __unused, struct value *a __unused) { struct ww *w; @@ -101,30 +104,23 @@ struct value *v, *a; struct lcmd_arg arg_time[] = { { "who", 1, ARG_STR }, - 0 + { NULL, 0, 0 } }; -/*ARGSUSED*/ -l_time(v, a) -struct value *v; -struct value *a; +void +l_time(struct value *v __unused, struct value *a) { struct ww *w; struct rusage rusage; struct timeval timeval; - char *strtime(); if ((w = openiwin(8, "Timing and Resource Usage")) == 0) { error("Can't open time window: %s.", wwerror()); return; } - (void) gettimeofday(&timeval, NULL); - timeval.tv_sec -= starttime.tv_sec; - if ((timeval.tv_usec -= starttime.tv_usec) < 0) { - timeval.tv_sec--; - timeval.tv_usec += 1000000; - } + (void) gettimeofday(&timeval, (struct timezone *)0); + timersub(&timeval, &starttime, &timeval); (void) getrusage(a->v_type == V_STR && str_match(a->v_str, "children", 1) ? RUSAGE_CHILDREN : RUSAGE_SELF, &rusage); @@ -153,15 +149,14 @@ struct value *a; } char * -strtime(t) -struct timeval *t; +strtime(struct timeval *t) { char fill = 0; static char buf[20]; char *p = buf; if (t->tv_sec > 60*60) { - (void) sprintf(p, "%ld:", t->tv_sec / (60*60)); + (void) sprintf(p, "%ld:", (long int)t->tv_sec / (60*60)); while (*p++) ; p--; @@ -169,24 +164,24 @@ struct timeval *t; fill++; } if (t->tv_sec > 60) { - (void) sprintf(p, fill ? "%02ld:" : "%ld:", t->tv_sec / 60); + (void) sprintf(p, fill ? "%02lld:" : "%lld:", + (long long)t->tv_sec / 60); while (*p++) ; p--; t->tv_sec %= 60; fill++; } - (void) sprintf(p, fill ? "%02ld.%02d" : "%ld.%02ld", - t->tv_sec, t->tv_usec / 10000); + (void) sprintf(p, fill ? "%02lld.%02ld" : "%lld.%02ld", + (long long)t->tv_sec, (long)t->tv_usec / 10000); return buf; } -/*ARGSUSED*/ -l_list(v, a) -struct value *v, *a; +void +l_list(struct value *v __unused, struct value *a __unused) { struct ww *w, *wp; - register i; + int i; int n; for (n = 0, i = 0; i < NWINDOW; i++) @@ -214,26 +209,24 @@ struct value *v, *a; closeiwin(w); } -/*ARGSUSED*/ -l_variable(v, a) -struct value *v, *a; +void +l_variable(struct value *v __unused, struct value *a __unused) { struct ww *w; - int printvar(); if ((w = openiwin(wwnrow - 3, "Variables")) == 0) { error("Can't open variable window: %s.", wwerror()); return; } - if (var_walk(printvar, (long)w) >= 0) + if (var_walk(printvar, (void *)w) >= 0) waitnl(w); closeiwin(w); } -printvar(w, r) -struct ww *w; -struct var *r; +int +printvar(void *vw, struct var *r) { + struct ww *w = vw; if (more(w, 0) == 2) return -1; wwprintf(w, "%16s ", r->r_name); @@ -253,11 +246,11 @@ struct var *r; struct lcmd_arg arg_def_shell[] = { { "", 0, ARG_ANY|ARG_LIST }, - 0 + { NULL, 0, 0 } }; -l_def_shell(v, a) - struct value *v, *a; +void +l_def_shell(struct value *v, struct value *a) { char **pp; struct value *vp; @@ -267,7 +260,7 @@ l_def_shell(v, a) v->v_type = V_STR; return; } - if (v->v_str = default_shellfile) { + if ((v->v_str = default_shellfile)) { v->v_type = V_STR; for (pp = default_shell + 1; *pp; pp++) { str_free(*pp); @@ -284,37 +277,37 @@ l_def_shell(v, a) p_memerror(); break; } - if (default_shellfile = *default_shell) - if (*default_shell = strrchr(default_shellfile, '/')) + if ((default_shellfile = *default_shell)) { + if ((*default_shell = strrchr(default_shellfile, '/'))) (*default_shell)++; else *default_shell = default_shellfile; + } } struct lcmd_arg arg_alias[] = { { "", 0, ARG_STR }, { "", 0, ARG_STR|ARG_LIST }, - 0 + { NULL, 0, 0 } }; -l_alias(v, a) - struct value *v, *a; +void +l_alias(struct value *v, struct value *a) { if (a->v_type == V_ERR) { struct ww *w; - int printalias(); if ((w = openiwin(wwnrow - 3, "Aliases")) == 0) { error("Can't open alias window: %s.", wwerror()); return; } - if (alias_walk(printalias, (long)w) >= 0) + if (alias_walk(printalias, (void *)w) >= 0) waitnl(w); closeiwin(w); } else { struct alias *ap = 0; - if (ap = alias_lookup(a->v_str)) { + if ((ap = alias_lookup(a->v_str))) { if ((v->v_str = str_cpy(ap->a_buf)) == 0) { p_memerror(); return; @@ -325,7 +318,7 @@ l_alias(v, a) struct value *vp; char *p, *q; char *str; - register n; + int n; for (n = 0, vp = a + 1; vp->v_type != V_ERR; vp++, n++) for (p = vp->v_str; *p; p++, n++) @@ -336,10 +329,10 @@ l_alias(v, a) } for (q = str, vp = a + 1; vp->v_type != V_ERR; vp++, q[-1] = ' ') - for (p = vp->v_str; *q++ = *p++;) + for (p = vp->v_str; (*q++ = *p++);) ; q[-1] = 0; - if ((ap = alias_set(a[0].v_str, NULL)) == 0) { + if ((ap = alias_set(a[0].v_str, (char *)0)) == 0) { p_memerror(); str_free(str); return; @@ -349,10 +342,10 @@ l_alias(v, a) } } -printalias(w, a) -struct ww *w; -struct alias *a; +int +printalias(void *vw, struct var *a) { + struct ww *w = vw; if (more(w, 0) == 2) return -1; wwprintf(w, "%16s %s\n", a->a_name, a->a_buf); @@ -361,11 +354,11 @@ struct alias *a; struct lcmd_arg arg_unalias[] = { { "alias", 1, ARG_STR }, - 0 + { NULL, 0, 0 } }; -l_unalias(v, a) -struct value *v, *a; +void +l_unalias(struct value *v, struct value *a) { if (a->v_type == ARG_STR) v->v_num = alias_unset(a->v_str); @@ -375,13 +368,11 @@ struct value *v, *a; struct lcmd_arg arg_echo[] = { { "window", 1, ARG_NUM }, { "", 0, ARG_ANY|ARG_LIST }, - 0 + { NULL, 0, 0 } }; -/*ARGSUSED*/ -l_echo(v, a) -struct value *v; -struct value *a; +void +l_echo(struct value *v __unused, struct value *a) { char buf[20]; struct ww *w; diff --git a/usr.bin/window/local.h b/usr.bin/window/local.h index deb0eefd4d..ce9f67da45 100644 --- a/usr.bin/window/local.h +++ b/usr.bin/window/local.h @@ -1,3 +1,5 @@ +/* $NetBSD: local.h,v 1.4 2003/08/07 11:17:26 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,8 +32,6 @@ * SUCH DAMAGE. * * @(#)local.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/local.h,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/local.h,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ /* diff --git a/usr.bin/window/main.c b/usr.bin/window/main.c index 7f0c43595d..1696ee7271 100644 --- a/usr.bin/window/main.c +++ b/usr.bin/window/main.c @@ -1,3 +1,5 @@ +/* $NetBSD: main.c,v 1.15 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,83 +30,87 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#) Copyright (c) 1983, 1993 The Regents of the University of California. All rights reserved. - * @(#)main.c 8.2 (Berkeley) 4/2/94 - * $FreeBSD: src/usr.bin/window/main.c,v 1.5.6.2 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/main.c,v 1.3 2004/08/30 18:06:50 eirikn Exp $ */ -#include "defs.h" +#include +#ifndef lint +__COPYRIGHT("@(#) Copyright (c) 1983, 1993\ + The Regents of the University of California. All rights reserved."); +#endif /* not lint */ + +#ifndef lint +#if 0 +static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/2/94"; +#else +__RCSID("$NetBSD: main.c,v 1.15 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + +#include #include -#include #include -#include /* System string definitions. */ -#include "mystring.h" /* Local string definitions. */ +#include +#include +#include + +#include "defs.h" +#include "window_string.h" #include "char.h" #include "local.h" -#define next(a) (*++*(a) ? *(a) : (*++(a) ? *(a) : (char *)usage())) +int main(int, char **); +void usage(void); -/*ARGSUSED*/ -main(argc, argv) -char **argv; +int +main(int argc, char **argv) { - register char *p; + char *p; + const char *kp; char fflag = 0; char dflag = 0; char xflag = 0; char *cmd = 0; char tflag = 0; + int ch; escapec = ESCAPEC; - if (p = strrchr(*argv, '/')) - p++; - else - p = *argv; - debug = strcmp(p, "a.out") == 0; - while (*++argv) { - if (**argv == '-') { - switch (*++*argv) { - case 'f': - fflag++; - break; - case 'c': - if (cmd != 0) { - (void) fprintf(stderr, - "Only one -c allowed.\n"); - (void) usage(); - } - cmd = next(argv); - break; - case 'e': - setescape(next(argv)); - break; - case 't': - tflag++; - break; - case 'd': - dflag++; - break; - case 'D': - debug = !debug; - break; - case 'x': - xflag++; - break; - default: - (void) usage(); + debug = strcmp(getprogname(), "a.out") == 0; + while ((ch = getopt(argc, argv, "fc:e:tdDx")) != -1) { + switch (ch) { + case 'f': + fflag++; + break; + case 'c': + if (cmd != 0) { + warnx("Only one -c allowed"); + usage(); } - } else - (void) usage(); - } - if ((p = getenv("SHELL")) == 0) - p = _PATH_BSHELL; - if ((default_shellfile = str_cpy(p)) == 0) { - (void) fprintf(stderr, "Out of memory.\n"); - exit(1); + cmd = optarg; + break; + case 'e': + setescape(optarg); + break; + case 't': + tflag++; + break; + case 'd': + dflag++; + break; + case 'D': + debug = !debug; + break; + case 'x': + xflag++; + break; + default: + usage(); + } } - if (p = strrchr(default_shellfile, '/')) + if ((kp = getenv("SHELL")) == 0) + kp = _PATH_BSHELL; + if ((default_shellfile = str_cpy(kp)) == 0) + errx(1, "Out of memory."); + if ((p = strrchr(default_shellfile, '/'))) p++; else p = default_shellfile; @@ -116,12 +118,9 @@ char **argv; default_shell[1] = 0; default_nline = NLINE; default_smooth = 1; - (void) gettimeofday(&starttime, NULL); - (void) setlocale(LC_CTYPE, ""); - if (wwinit() < 0) { - (void) fprintf(stderr, "%s.\n", wwerror()); - exit(1); - } + (void) gettimeofday(&starttime, (struct timezone *)0); + if (wwinit() < 0) + errx(1, "%s", wwerror()); #ifdef OLD_TTY if (debug) @@ -147,26 +146,25 @@ char **argv; if (debug || xflag) (void) wwsettty(0, &wwnewtty); - if ((cmdwin = wwopen(wwbaud > 2400 ? WWO_REVERSE : 0, 1, wwncol, - 0, 0, 0)) == 0) { + if ((cmdwin = wwopen(WWT_INTERNAL, wwbaud > 2400 ? WWO_REVERSE : 0, 1, + wwncol, 0, 0, 0)) == 0) { wwflush(); - (void) fprintf(stderr, "%s.\r\n", wwerror()); + warnx("%s.\r", wwerror()); goto bad; } - cmdwin->ww_mapnl = 1; - cmdwin->ww_nointr = 1; - cmdwin->ww_noupdate = 1; - cmdwin->ww_unctrl = 1; - if ((framewin = wwopen(WWO_GLASS|WWO_FRAME, wwnrow, wwncol, 0, 0, 0)) - == 0) { + SET(cmdwin->ww_wflags, + WWW_MAPNL | WWW_NOINTR | WWW_NOUPDATE | WWW_UNCTRL); + if ((framewin = wwopen(WWT_INTERNAL, WWO_GLASS|WWO_FRAME, wwnrow, + wwncol, 0, 0, 0)) == 0) { wwflush(); - (void) fprintf(stderr, "%s.\r\n", wwerror()); + warnx("%s.\r", wwerror()); goto bad; } wwadd(framewin, &wwhead); - if ((boxwin = wwopen(WWO_GLASS, wwnrow, wwncol, 0, 0, 0)) == 0) { + if ((boxwin = wwopen(WWT_INTERNAL, WWO_GLASS, wwnrow, wwncol, 0, 0, 0)) + == 0) { wwflush(); - (void) fprintf(stderr, "%s.\r\n", wwerror()); + warnx("%s.\r", wwerror()); goto bad; } fgwin = framewin; @@ -178,7 +176,7 @@ char **argv; setterse(tflag); setcmd(1); if (cmd != 0) - (void) dolongcmd(cmd, NULL, 0); + (void) dolongcmd(cmd, (struct value *)0, 0); if (!fflag) if (dflag || doconfig() < 0) dodefault(); @@ -192,9 +190,11 @@ bad: return 0; } -usage() +void +usage(void) { - (void) fprintf(stderr, "usage: window [-e escape-char] [-c command] [-t] [-f] [-d]\n"); + (void) fprintf(stderr, + "usage: %s [-e escape-char] [-c command] [-t] [-f] [-d]\n", + getprogname()); exit(1); - return 0; /* for lint */ } diff --git a/usr.bin/window/mloop.c b/usr.bin/window/mloop.c index e8f6d43593..89852155b1 100644 --- a/usr.bin/window/mloop.c +++ b/usr.bin/window/mloop.c @@ -1,3 +1,5 @@ +/* $NetBSD: mloop.c,v 1.8 2003/08/07 11:17:27 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,39 +30,49 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)mloop.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/mloop.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/mloop.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)mloop.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: mloop.c,v 1.8 2003/08/07 11:17:27 agc Exp $"); +#endif +#endif /* not lint */ + #include +#include #include "defs.h" -mloop() +void +mloop(void) { while (!quit) { if (incmd) { docmd(); } else if (wwcurwin->ww_state != WWS_HASPROC) { - if (!wwcurwin->ww_keepopen) + if (!ISSET(wwcurwin->ww_uflags, WWU_KEEPOPEN)) closewin(wwcurwin); setcmd(1); if (wwpeekc() == escapec) (void) wwgetc(); error("Process died."); } else { - register struct ww *w = wwcurwin; - register char *p; - register n; + struct ww *w = wwcurwin; + char *p; + int n; - if (wwibp >= wwibq) + if (wwibp >= wwibq) { + wwibp = wwibq = wwib; wwiomux(); + } for (p = wwibp; p < wwibq && wwmaskc(*p) != escapec; p++) ; if ((n = p - wwibp) > 0) { - if (!w->ww_ispty && w->ww_stopped) + if (w->ww_type != WWT_PTY && + ISSET(w->ww_pflags, WWP_STOPPED)) startwin(w); #if defined(sun) && !defined(BSD) /* workaround for SunOS pty bug */ diff --git a/usr.bin/window/parser.h b/usr.bin/window/parser.h index c651a2a2a8..f4f2381847 100644 --- a/usr.bin/window/parser.h +++ b/usr.bin/window/parser.h @@ -1,3 +1,5 @@ +/* $NetBSD: parser.h,v 1.8 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,16 +32,31 @@ * SUCH DAMAGE. * * @(#)parser.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/parser.h,v 1.1.1.1.14.2 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/parser.h,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ -#include "value.h" #include "context.h" #include "token.h" -#include "mystring.h" +#include "window_string.h" #define p_erred() (cx.x_erred) #define p_synerred() (cx.x_synerred) #define p_clearerr() (cx.x_erred = cx.x_synerred = 0) #define p_abort() (cx.x_abort) + +int p_assign(const char *, struct value *, int); +int p_convstr(struct value *v); +void p_error(const char *msg, ...) + __attribute__((__format__(__printf__, 1, 2))); +int p_expr(struct value *, char); +int p_expr0(struct value *, char); +int p_expr1(struct value *, char); +int p_expr11(struct value *, char); +int p_expr12(struct value *, char); +int p_expr2(struct value *, char); +int p_expr3_10(int, struct value *, char); +int p_expression(char); +int p_function(const char *, struct value *, int); +int p_if(char); +int p_statement(char); +void p_statementlist(char); +void p_synerror(void); diff --git a/usr.bin/window/parser1.c b/usr.bin/window/parser1.c index 92307f2e5a..6586bc3439 100644 --- a/usr.bin/window/parser1.c +++ b/usr.bin/window/parser1.c @@ -1,3 +1,5 @@ +/* $NetBSD: parser1.c,v 1.6 2003/08/07 11:17:28 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,15 +30,22 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)parser1.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/parser1.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/parser1.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)parser1.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: parser1.c,v 1.6 2003/08/07 11:17:28 agc Exp $"); +#endif +#endif /* not lint */ + +#include "defs.h" #include "parser.h" -p_start() +void +p_start(void) { char flag = 1; @@ -62,15 +67,15 @@ p_start() } } -p_statementlist(flag) -char flag; +void +p_statementlist(char flag) { for (; p_statement(flag) >= 0; p_clearerr()) ; } -p_statement(flag) -char flag; +int +p_statement(char flag) { switch (token) { case T_EOL: @@ -83,8 +88,8 @@ char flag; } } -p_if(flag) -char flag; +int +p_if(char flag) { struct value t; char true = 0; @@ -137,12 +142,11 @@ top: return -1; } -p_expression(flag) -char flag; +int +p_expression(char flag) { struct value t; char *cmd; - int p_function(), p_assign(); switch (token) { case T_NUM: @@ -183,8 +187,8 @@ char flag; return 0; } -p_convstr(v) -register struct value *v; +int +p_convstr(struct value *v) { if (v->v_type != V_NUM) return 0; @@ -197,7 +201,8 @@ register struct value *v; return 0; } -p_synerror() +void +p_synerror(void) { if (!cx.x_synerred) { cx.x_synerred = cx.x_erred = 1; @@ -205,17 +210,21 @@ p_synerror() } } -/*VARARGS1*/ -p_error(msg, a, b, c) -char *msg; +void +p_error(const char *msg, ...) { + va_list ap; + + va_start(ap, msg); if (!cx.x_erred) { cx.x_erred = 1; - error(msg, a, b, c); + verror(msg, ap); } + va_end(ap); } -p_memerror() +void +p_memerror(void) { cx.x_erred = cx.x_abort = 1; error("Out of memory."); diff --git a/usr.bin/window/parser2.c b/usr.bin/window/parser2.c index b065515b4c..1f3c43ea7c 100644 --- a/usr.bin/window/parser2.c +++ b/usr.bin/window/parser2.c @@ -1,3 +1,5 @@ +/* $NetBSD: parser2.c,v 1.11 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,44 +30,52 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)parser2.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/parser2.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/parser2.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)parser2.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: parser2.c,v 1.11 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + +#define EXTERN +#include "ww.h" +#include "defs.h" +#include "alias.h" +#undef EXTERN #include "parser.h" #include "var.h" #include "lcmd.h" -#include "alias.h" /* * name == 0 means we don't have a function name but * want to parse the arguments anyway. flag == 0 in this case. */ -p_function(name, v, flag) -char *name; -register struct value *v; +int +p_function(const char *name, struct value *v, int flag) { struct value t; - register struct lcmd_tab *c = 0; - register struct alias *a = 0; - register struct lcmd_arg *ap; /* this arg */ + struct lcmd_tab *c = 0; + struct alias *a = 0; + struct lcmd_arg *ap; /* this arg */ struct lcmd_arg *lp = 0; /* list arg */ - register i; + int i; struct value av[LCMD_NARG + 1]; - register struct value *vp; + struct value *vp; - if (name != 0) - if (c = lcmd_lookup(name)) + if (name != 0) { + if ((c = lcmd_lookup(name))) name = c->lc_name; - else if (a = alias_lookup(name)) + else if ((a = alias_lookup(name))) name = a->a_name; else { p_error("%s: No such command or alias.", name); flag = 0; } - + } for (vp = av; vp < &av[LCMD_NARG + 1]; vp++) vp->v_type = V_ERR; @@ -89,8 +95,8 @@ register struct value *v; } if (token != T_ASSIGN) { if (i >= LCMD_NARG || - c != 0 && (ap = lp) == 0 && - (ap = c->lc_arg + i)->arg_name == 0) { + (c != 0 && (ap = lp) == 0 && + (ap = c->lc_arg + i)->arg_name == 0)) { p_error("%s: Too many arguments.", name); flag = 0; } else @@ -138,29 +144,29 @@ register struct value *v; i = vp - av + 1; lp = ap; } - if (vp->v_type != V_ERR) { + if (vp && vp->v_type != V_ERR) { if (*ap->arg_name) p_error("%s: Argument %d (%s) duplicated.", - name, vp - av + 1, + name, (int)(vp - av + 1), ap->arg_name); else p_error("%s: Argument %d duplicated.", - name, vp - av + 1); + name, (int)(vp - av + 1)); flag = 0; vp = 0; } else if (t.v_type == V_ERR) { /* do nothing */ - } else if ((ap->arg_flags&ARG_TYPE) == ARG_NUM && - t.v_type != V_NUM || - (ap->arg_flags&ARG_TYPE) == ARG_STR && - t.v_type != V_STR) { + } else if (((ap->arg_flags&ARG_TYPE) == ARG_NUM && + t.v_type != V_NUM) || + ((ap->arg_flags&ARG_TYPE) == ARG_STR && + t.v_type != V_STR)) { if (*ap->arg_name) p_error("%s: Argument %d (%s) type mismatch.", - name, vp - av + 1, + name, (int)(vp - av + 1), ap->arg_name); else p_error("%s: Argument %d type mismatch.", - name, vp - av + 1); + name, (int)(vp - av + 1)); flag = 0; vp = 0; } @@ -180,10 +186,10 @@ register struct value *v; else if (token != T_EOL && token != T_EOF) flag = 0; /* look for legal follow set */ v->v_type = V_ERR; - if (flag) + if (flag) { if (c != 0) (*c->lc_func)(v, av); - else + else { if (a->a_flags & A_INUSE) p_error("%s: Recursive alias.", a->a_name); else { @@ -192,6 +198,8 @@ register struct value *v; p_memerror(); a->a_flags &= ~A_INUSE; } + } + } if (p_abort()) { val_free(*v); v->v_type = V_ERR; @@ -206,10 +214,8 @@ abort: return -1; } -p_assign(name, v, flag) -char *name; -struct value *v; -char flag; +int +p_assign(const char *name, struct value *v, int flag) { (void) s_gettok(); @@ -220,7 +226,7 @@ char flag; switch (v->v_type) { case V_STR: case V_NUM: - if (flag && var_set(name, v) == 0) { + if (name && flag && var_set(name, v) == 0) { p_memerror(); val_free(*v); return -1; diff --git a/usr.bin/window/parser3.c b/usr.bin/window/parser3.c index ffbec32d30..a1bc0dfdc0 100644 --- a/usr.bin/window/parser3.c +++ b/usr.bin/window/parser3.c @@ -1,3 +1,5 @@ +/* $NetBSD: parser3.c,v 1.6 2003/08/07 11:17:28 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,12 +30,18 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)parser3.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/parser3.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/parser3.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)parser3.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: parser3.c,v 1.6 2003/08/07 11:17:28 agc Exp $"); +#endif +#endif /* not lint */ + +#include "defs.h" #include "parser.h" /* @@ -55,9 +59,8 @@ * * / % * unary - + ~ ! */ -p_expr(v, flag) -register struct value *v; -char flag; +int +p_expr(struct value *v, char flag) { struct value t; int ret; @@ -85,12 +88,11 @@ char flag; /* * ? : */ -p_expr0(v, flag) -register struct value *v; -char flag; +int +p_expr0(struct value *v, char flag) { struct value t; - char true; + char true = 0; if (p_expr1(v, flag) < 0) return -1; @@ -124,9 +126,8 @@ char flag; /* * || */ -p_expr1(v, flag) -register struct value *v; -char flag; +int +p_expr1(struct value *v, char flag) { char true = 0; @@ -158,9 +159,8 @@ char flag; /* * && */ -p_expr2(v, flag) -register struct value *v; -char flag; +int +p_expr2(struct value *v, char flag) { char true = 1; diff --git a/usr.bin/window/parser4.c b/usr.bin/window/parser4.c index 78fe731db0..423deff772 100644 --- a/usr.bin/window/parser4.c +++ b/usr.bin/window/parser4.c @@ -1,3 +1,5 @@ +/* $NetBSD: parser4.c,v 1.9 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,13 +30,19 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)parser4.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/parser4.c,v 1.2.6.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/parser4.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)parser4.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: parser4.c,v 1.9 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include +#include "defs.h" #include "parser.h" /* @@ -51,13 +55,12 @@ * + - 9 * * / % 10 */ -p_expr3_10(level, v, flag) -register struct value *v; -char flag; +int +p_expr3_10(int level, struct value *v, char flag) { struct value l, r; int op; - char *opname; + const char *opname = 0; if ((level == 10 ? p_expr11(v, flag) : p_expr3_10(level + 1, v, flag)) < 0) diff --git a/usr.bin/window/parser5.c b/usr.bin/window/parser5.c index 76bf810610..3a835505d8 100644 --- a/usr.bin/window/parser5.c +++ b/usr.bin/window/parser5.c @@ -1,3 +1,5 @@ +/* $NetBSD: parser5.c,v 1.7 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,24 +30,29 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)parser5.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/parser5.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/parser5.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)parser5.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: parser5.c,v 1.7 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + +#include "defs.h" #include "parser.h" #include "var.h" /* * unary $ $? + - ! ~ */ -p_expr11(v, flag) -register struct value *v; -char flag; +int +p_expr11(struct value *v, char flag) { int op; - char *opname; + const char *opname; switch (token) { case T_DOLLAR: @@ -146,9 +149,8 @@ char flag; * * Always return v_type == V_ERR when flag == 0. */ -p_expr12(v, flag) -register struct value *v; -char flag; +int +p_expr12(struct value *v, char flag) { v->v_type = V_ERR; switch (token) { diff --git a/usr.bin/window/scanner.c b/usr.bin/window/scanner.c index 145c7ea4d5..7cbfe4a533 100644 --- a/usr.bin/window/scanner.c +++ b/usr.bin/window/scanner.c @@ -1,3 +1,5 @@ +/* $NetBSD: scanner.c,v 1.9 2003/08/07 11:17:29 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,24 +30,32 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)scanner.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/scanner.c,v 1.2.14.2 2001/05/17 09:46:29 obrien Exp $ - * $DragonFly: src/usr.bin/window/scanner.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)scanner.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: scanner.c,v 1.9 2003/08/07 11:17:29 agc Exp $"); +#endif +#endif /* not lint */ + #include -#include "value.h" +#include "defs.h" #include "token.h" #include "context.h" -#include "string.h" -#include "mystring.h" +#include "window_string.h" -s_getc() +int s_getc(void); +int s_gettok1(void); +int s_ungetc(int); + +int +s_getc(void) { - register c; + int c; switch (cx.x_type) { case X_FILE: @@ -68,9 +74,11 @@ s_getc() return EOF; } /*NOTREACHED*/ + return(0); /* XXX: placate gcc */ } -s_ungetc(c) +int +s_ungetc(int c) { if (c == EOF) return EOF; @@ -85,14 +93,16 @@ s_ungetc(c) return EOF; } /*NOTREACHED*/ + return(0); /* XXX: placate gcc */ } -s_gettok() +int +s_gettok(void) { char buf[100]; - register char *p = buf; - register c; - register state = 0; + char *p = buf; + int c; + int state = 0; loop: c = s_getc(); @@ -114,6 +124,22 @@ loop: cx.x_token = T_EOF; state = -1; break; + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '_': case '.': + *p++ = c; + state = 2; + break; case '"': state = 3; break; @@ -219,11 +245,6 @@ loop: state = -1; break; default: - if (isalpha(c) || c == '_' || c == '.') { - *p++ = c; - state = 2; - break; - } cx.x_val.v_num = c; cx.x_token = T_CHAR; state = -1; @@ -238,6 +259,24 @@ loop: break; case 2: /* unquoted string */ switch (c) { + case 'a': case 'b': case 'c': case 'd': case 'e': + case 'f': case 'g': case 'h': case 'i': case 'j': + case 'k': case 'l': case 'm': case 'n': case 'o': + case 'p': case 'q': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'y': + case 'z': + case 'A': case 'B': case 'C': case 'D': case 'E': + case 'F': case 'G': case 'H': case 'I': case 'J': + case 'K': case 'L': case 'M': case 'N': case 'O': + case 'P': case 'Q': case 'R': case 'S': case 'T': + case 'U': case 'V': case 'W': case 'X': case 'Y': + case 'Z': + case '_': case '.': + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + if (p < buf + sizeof buf - 1) + *p++ = c; + break; case '"': state = 3; break; @@ -256,11 +295,6 @@ loop: } break; default: - if (isalnum(c) || c == '_' || c == '.') { - if (p < buf + sizeof buf - 1) - *p++ = c; - break; - } (void) s_ungetc(c); case EOF: *p = 0; @@ -280,12 +314,20 @@ loop: && buf[3] == 'i' && buf[4] == 'f' && buf[5] == 0) cx.x_token = T_ENDIF; - else if (buf[1] == 'l' && buf[2] == 's') - if (buf[3] == 'i' && buf[4] == 'f' - && buf[5] == 0) - cx.x_token = T_ELSIF; - else if (buf[3] == 'e' && buf[4] == 0) - cx.x_token = T_ELSE; + else { + if (buf[1] == 'l' && buf[2] == 's') { + if (buf[3] == 'i' + && buf[4] == 'f' + && buf[5] == 0) + cx.x_token = T_ELSIF; + else { + if (buf[3] == 'e' + && buf[4] == 0) + cx.x_token = + T_ELSE; + } + } + } break; } if (cx.x_token == T_STR @@ -509,10 +551,11 @@ loop: return cx.x_token; } -s_gettok1() +int +s_gettok1(void) { - register c; - register n; + int c; + int n; c = s_getc(); /* got \ */ switch (c) { diff --git a/usr.bin/window/startup.c b/usr.bin/window/startup.c index 1d5dee6c80..3b683d5f62 100644 --- a/usr.bin/window/startup.c +++ b/usr.bin/window/startup.c @@ -1,3 +1,5 @@ +/* $NetBSD: startup.c,v 1.8 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,30 +30,34 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)startup.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/startup.c,v 1.1.1.1.14.1 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/startup.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)startup.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: startup.c,v 1.8 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ +#include #include "defs.h" -#include "value.h" #include "var.h" #include "char.h" #include "local.h" -doconfig() +int +doconfig(void) { char buf[100]; - char *home; + const char *home; static char runcom[] = RUNCOM; if ((home = getenv("HOME")) == 0) home = "."; (void) sprintf(buf, "%.*s/%s", - (sizeof buf - sizeof runcom) / sizeof (char) - 1, + (int)((sizeof buf - sizeof runcom) / sizeof (char) - 1), home, runcom); return dosource(buf); } @@ -63,21 +65,25 @@ doconfig() /* * The default is two windows of equal size. */ -dodefault() +void +dodefault(void) { struct ww *w; - register r = wwnrow / 2 - 1; + int r = wwnrow / 2 - 1; if (openwin(1, r + 2, 0, wwnrow - r - 2, wwncol, default_nline, - NULL, 1, 1, default_shellfile, default_shell) == 0) + (char *) 0, WWT_PTY, WWU_HASFRAME, default_shellfile, + default_shell) == 0) return; if ((w = openwin(0, 1, 0, r, wwncol, default_nline, - NULL, 1, 1, default_shellfile, default_shell)) == 0) + (char *) 0, WWT_PTY, WWU_HASFRAME, default_shellfile, + default_shell)) == 0) return; wwprintf(w, "Escape character is %s.\r\n", unctrl(escapec)); } -setvars() +void +setvars(void) { /* try to use a random ordering to balance the tree */ (void) var_setnum("nrow", wwnrow); diff --git a/usr.bin/window/string.c b/usr.bin/window/string.c index dbce1f8154..625d3c208a 100644 --- a/usr.bin/window/string.c +++ b/usr.bin/window/string.c @@ -1,3 +1,5 @@ +/* $NetBSD: string.c,v 1.10 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,41 +30,44 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)string.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/string.c,v 1.2.6.2 2001/05/17 09:45:00 obrien Exp $ - * $DragonFly: src/usr.bin/window/string.c,v 1.3 2005/02/28 13:57:05 joerg Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)string.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: string.c,v 1.10 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include #include -#include /* System string definitions. */ - -#include "mystring.h" /* Local string definitions. */ +#include +#define EXTERN +#include "window_string.h" +#undef EXTERN char * -str_cpy(s) -register char *s; +str_cpy(const char *s) { char *str; - register char *p; + char *p; str = p = str_alloc(strlen(s) + 1); if (p == 0) return 0; - while (*p++ = *s++) + while ((*p++ = *s++)) ; return str; } char * -str_ncpy(s, n) -register char *s; -register n; +str_ncpy(const char *s, int n) { int l = strlen(s); char *str; - register char *p; + char *p; if (n > l) n = l; @@ -80,28 +81,27 @@ register n; } char * -str_itoa(i) -int i; +str_itoa(int i) { char buf[30]; - (void) sprintf(buf, "%d", i); + (void) snprintf(buf, sizeof(buf), "%d", i); return str_cpy(buf); } char * -str_cat(s1, s2) -char *s1, *s2; +str_cat(const char *s1, const char *s2) { char *str; - register char *p, *q; + char *p; + const char *q; str = p = str_alloc(strlen(s1) + strlen(s2) + 1); if (p == 0) return 0; - for (q = s1; *p++ = *q++;) + for (q = s1; (*p++ = *q++);) ; - for (q = s2, p--; *p++ = *q++;) + for (q = s2, p--; (*p++ = *q++);) ; return str; } @@ -110,23 +110,21 @@ char *s1, *s2; * match s against p. * s can be a prefix of p with at least min characters. */ -str_match(s, p, min) -register char *s, *p; -register min; +int +str_match(const char *s, const char *p, int min) { for (; *s && *p && *s == *p; s++, p++, min--) ; - return *s == *p || *s == 0 && min <= 0; + return *s == *p || (*s == 0 && min <= 0); } #ifdef STR_DEBUG char * -str_alloc(l) -int l; +str_alloc(size_t l) { - register struct mystring *s; + struct string *s; - s = (struct mystring *) malloc((unsigned)l + str_offset); + s = (struct string *) malloc(l + str_offset); if (s == 0) return 0; if (str_head.s_forw == 0) @@ -138,10 +136,10 @@ int l; return s->s_data; } -str_free(str) -char *str; +void +str_free(char *str) { - register struct mystring *s; + struct string *s; for (s = str_head.s_forw; s != &str_head && s->s_data != str; s = s->s_forw) diff --git a/usr.bin/window/token.h b/usr.bin/window/token.h index cdf95dbfc8..939f6e6a92 100644 --- a/usr.bin/window/token.h +++ b/usr.bin/window/token.h @@ -1,3 +1,5 @@ +/* $NetBSD: token.h,v 1.4 2003/08/07 11:17:30 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,8 +32,6 @@ * SUCH DAMAGE. * * @(#)token.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/token.h,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/token.h,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ #define token (cx.x_token) diff --git a/usr.bin/window/tt.h b/usr.bin/window/tt.h index a217ec5bcc..72e71fe05e 100644 --- a/usr.bin/window/tt.h +++ b/usr.bin/window/tt.h @@ -1,3 +1,5 @@ +/* $NetBSD: tt.h,v 1.9 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,41 +32,48 @@ * SUCH DAMAGE. * * @(#)tt.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/tt.h,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/tt.h,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include + +#ifndef EXTERN +#define EXTERN extern +#endif + /* * Interface structure for the terminal drivers. */ struct tt { /* startup and cleanup */ - int (*tt_start)(); - int (*tt_reset)(); - int (*tt_end)(); + void (*tt_start)(void); + void (*tt_reset)(void); + void (*tt_end)(void); /* terminal functions */ - int (*tt_move)(); - int (*tt_insline)(); - int (*tt_delline)(); - int (*tt_inschar)(); - int (*tt_insspace)(); - int (*tt_delchar)(); - int (*tt_write)(); /* write a whole block */ - int (*tt_putc)(); /* write one character */ - int (*tt_clreol)(); - int (*tt_clreos)(); - int (*tt_clear)(); - int (*tt_scroll_down)(); - int (*tt_scroll_up)(); - int (*tt_setscroll)(); /* set scrolling region */ - int (*tt_setmodes)(); /* set display modes */ - int (*tt_set_token)(); /* define a token */ - int (*tt_put_token)(); /* refer to a defined token */ - int (*tt_compress)(); /* begin, end compression */ - int (*tt_checksum)(); /* compute checksum */ - int (*tt_checkpoint)(); /* checkpoint protocol */ - int (*tt_rint)(); /* input processing */ + void (*tt_move)(int, int); + void (*tt_insline)(int); + void (*tt_delline)(int); + void (*tt_inschar)(char); + void (*tt_insspace)(int); + void (*tt_delchar)(int); + void (*tt_write)(const char *, int); /* write a whole block */ + void (*tt_putc)(char); /* write one character */ + void (*tt_clreol)(void); + void (*tt_clreos)(void); + void (*tt_clear)(void); + void (*tt_scroll_down)(int); + void (*tt_scroll_up)(int); + void (*tt_setscroll)(int, int);/* set scrolling region */ + void (*tt_setmodes)(int); /* set display modes */ + void (*tt_set_token)(int, char *, int); + /* define a token */ + void (*tt_put_token)(int, const char *, int); + /* refer to a defined token */ + void (*tt_compress)(int); /* begin, end compression */ + void (*tt_checksum)(char *, int); + /* compute checksum */ + void (*tt_checkpoint)(void); /* checkpoint protocol */ + int (*tt_rint)(char *, int); /* input processing */ /* internal variables */ char tt_modes; /* the current display modes */ @@ -97,9 +102,9 @@ struct tt { short *tt_frame; /* ttflush() hook */ - int (*tt_flush)(); + void (*tt_flush)(void); }; -struct tt tt; +EXTERN struct tt tt; /* * tt_padc is used by the compression routine. @@ -111,28 +116,46 @@ struct tt tt; * List of terminal drivers. */ struct tt_tab { - char *tt_name; + const char *tt_name; int tt_len; - int (*tt_func)(); + int (*tt_func)(void); }; -extern struct tt_tab tt_tab[]; +EXTERN struct tt_tab tt_tab[]; /* * Clean interface to termcap routines. * Too may t's. */ -char tt_strings[1024]; /* string buffer */ -char *tt_strp; /* pointer for it */ +EXTERN char tt_strings[1024]; /* string buffer */ +EXTERN char *tt_strp; /* pointer for it */ struct tt_str { - char *ts_str; + const char *ts_str; int ts_n; }; -struct tt_str *tttgetstr(); -struct tt_str *ttxgetstr(); /* tgetstr() and expand delays */ +struct tt_str *tttgetstr(const char *); +struct tt_str *ttxgetstr(const char *); /* tgetstr() and expand delays */ + +int tt_f100(void); +int tt_generic(void); +int tt_h19(void); +int tt_h29(void); +int tt_tvi925(void); +int tt_wyse60(void); +int tt_wyse75(void); +int tt_zapple(void); +int tt_zentec(void); +void ttflush(void); +int ttinit(void); +void ttpgoto(struct tt_str *, int, int, int); +void ttputs(const char *); +int ttstrcmp(struct tt_str *, struct tt_str *); +void tttgoto(struct tt_str *, int, int); +int tttputc(int); +void ttwrite(const char *, int); +int ttxputc(int); -int tttputc(); #define tttputs(s, n) tputs((s)->ts_str, (n), tttputc) #define ttxputs(s) ttwrite((s)->ts_str, (s)->ts_n) @@ -141,9 +164,9 @@ int tttputc(); * These variables have different meanings from the ww_ob* variables. * But I'm too lazy to think up different names. */ -char *tt_ob; -char *tt_obp; -char *tt_obe; +EXTERN char *tt_ob; +EXTERN char *tt_obp; +EXTERN char *tt_obe; #define ttputc(c) (tt_obp < tt_obe ? (*tt_obp++ = (c)) \ : (ttflush(), *tt_obp++ = (c))) diff --git a/usr.bin/window/ttf100.c b/usr.bin/window/ttf100.c index 71fec66e6a..c8941ab733 100644 --- a/usr.bin/window/ttf100.c +++ b/usr.bin/window/ttf100.c @@ -1,3 +1,5 @@ +/* $NetBSD: ttf100.c,v 1.6 2003/08/07 11:17:30 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,12 +30,17 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttf100.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/ttf100.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/ttf100.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ttf100.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: ttf100.c,v 1.6 2003/08/07 11:17:30 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" @@ -54,7 +57,8 @@ short f100_frame[16] = { }; extern struct tt_str *gen_AE, *gen_AS; -tt_f100() +int +tt_f100(void) { static struct tt_str ae = { "\033%", 2 }; static struct tt_str as = { "\033$", 2 }; diff --git a/usr.bin/window/ttgeneric.c b/usr.bin/window/ttgeneric.c index 28ae088ebf..d2d6d5c89a 100644 --- a/usr.bin/window/ttgeneric.c +++ b/usr.bin/window/ttgeneric.c @@ -1,3 +1,5 @@ +/* $NetBSD: ttgeneric.c,v 1.10 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,16 +30,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttgeneric.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/ttgeneric.c,v 1.2.8.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/ttgeneric.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ttgeneric.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: ttgeneric.c,v 1.10 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + +#include +#include +#include #include "ww.h" #include "tt.h" char PC, *BC, *UP; +short ospeed; /* normal frame */ short gen_frame[16] = { @@ -118,8 +125,27 @@ int gen_LI; int gen_UG; int gen_SG; -gen_setinsert(new) -char new; +void gen_clear(void); +void gen_clreol(void); +void gen_clreos(void); +void gen_delchar(int); +void gen_delline(int); +void gen_end(void); +void gen_inschar(char); +void gen_insline(int); +void gen_insspace(int); +void gen_move(int, int); +void gen_putc(char); +void gen_scroll_down(int); +void gen_scroll_up(int); +void gen_setinsert(char); +void gen_setmodes(int); +void gen_setscroll(int, int); +void gen_start(void); +void gen_write(const char *, int); + +void +gen_setinsert(char new) { if (new) { if (gen_IM) @@ -130,10 +156,10 @@ char new; tt.tt_insert = new; } -gen_setmodes(new) -register new; +void +gen_setmodes(int new) { - register diff; + int diff; diff = new ^ tt.tt_modes; if (diff & WWM_REV) { @@ -141,16 +167,24 @@ register new; if (gen_SO) ttxputs(gen_SO); } else - if (gen_SE) + if (gen_SE) { ttxputs(gen_SE); + if (!strcmp(gen_SE->ts_str, gen_UE->ts_str) && + gen_UE && gen_US && new & WWM_UL) + ttxputs(gen_US); + } } if (diff & WWM_UL) { if (new & WWM_UL) { if (gen_US) ttxputs(gen_US); } else - if (gen_UE) + if (gen_UE) { ttxputs(gen_UE); + if (!strcmp(gen_UE->ts_str, gen_SE->ts_str) && + gen_SE && gen_SO && new & WWM_REV) + ttxputs(gen_SO); + } } if (diff & WWM_GRP) { if (new & WWM_GRP) { @@ -171,7 +205,8 @@ register new; tt.tt_modes = new; } -gen_insline(n) +void +gen_insline(int n) { if (tt.tt_modes) /* for concept 100 */ gen_setmodes(0); @@ -182,7 +217,8 @@ gen_insline(n) tttputs(gen_AL, gen_LI - tt.tt_row); } -gen_delline(n) +void +gen_delline(int n) { if (tt.tt_modes) /* for concept 100 */ gen_setmodes(0); @@ -193,26 +229,26 @@ gen_delline(n) tttputs(gen_DL, gen_LI - tt.tt_row); } -gen_putc(c) -register char c; +void +gen_putc(char c) { if (tt.tt_insert) gen_setinsert(0); if (tt.tt_nmodes != tt.tt_modes) gen_setmodes(tt.tt_nmodes); ttputc(c); - if (++tt.tt_col == gen_CO) + if (++tt.tt_col == gen_CO) { if (gen_XN) tt.tt_col = tt.tt_row = -10; else if (gen_AM) tt.tt_col = 0, tt.tt_row++; else tt.tt_col--; + } } -gen_write(p, n) - register char *p; - register n; +void +gen_write(const char *p, int n) { if (tt.tt_insert) gen_setinsert(0); @@ -220,17 +256,18 @@ gen_write(p, n) gen_setmodes(tt.tt_nmodes); ttwrite(p, n); tt.tt_col += n; - if (tt.tt_col == gen_CO) + if (tt.tt_col == gen_CO) { if (gen_XN) tt.tt_col = tt.tt_row = -10; else if (gen_AM) tt.tt_col = 0, tt.tt_row++; else tt.tt_col--; + } } -gen_move(row, col) -register int row, col; +void +gen_move(int row, int col) { if (tt.tt_row == row && tt.tt_col == col) return; @@ -278,7 +315,8 @@ out: tt.tt_row = row; } -gen_start() +void +gen_start(void) { if (gen_VS) ttxputs(gen_VS); @@ -290,7 +328,8 @@ gen_start() tt.tt_nmodes = tt.tt_modes = 0; } -gen_end() +void +gen_end(void) { if (tt.tt_insert) gen_setinsert(0); @@ -300,29 +339,32 @@ gen_end() ttxputs(gen_VE); } -gen_clreol() +void +gen_clreol(void) { if (tt.tt_modes) /* for concept 100 */ gen_setmodes(0); tttputs(gen_CE, gen_CO - tt.tt_col); } -gen_clreos() +void +gen_clreos(void) { if (tt.tt_modes) /* for concept 100 */ gen_setmodes(0); tttputs(gen_CD, gen_LI - tt.tt_row); } -gen_clear() +void +gen_clear(void) { if (tt.tt_modes) /* for concept 100 */ gen_setmodes(0); ttxputs(gen_CL); } -gen_inschar(c) -register char c; +void +gen_inschar(char c) { if (!tt.tt_insert) gen_setinsert(1); @@ -333,16 +375,18 @@ register char c; ttputc(c); if (gen_IP) tttputs(gen_IP, gen_CO - tt.tt_col); - if (++tt.tt_col == gen_CO) + if (++tt.tt_col == gen_CO) { if (gen_XN) tt.tt_col = tt.tt_row = -10; else if (gen_AM) tt.tt_col = 0, tt.tt_row++; else tt.tt_col--; + } } -gen_insspace(n) +void +gen_insspace(int n) { if (gen_ICn) ttpgoto(gen_ICn, 0, n, gen_CO - tt.tt_col); @@ -351,7 +395,8 @@ gen_insspace(n) tttputs(gen_IC, gen_CO - tt.tt_col); } -gen_delchar(n) +void +gen_delchar(int n) { if (gen_DCn) ttpgoto(gen_DCn, 0, n, gen_CO - tt.tt_col); @@ -360,7 +405,8 @@ gen_delchar(n) tttputs(gen_DC, gen_CO - tt.tt_col); } -gen_scroll_down(n) +void +gen_scroll_down(int n) { gen_move(tt.tt_scroll_bot, 0); if (gen_SFn) @@ -370,7 +416,8 @@ gen_scroll_down(n) ttxputs(gen_SF); } -gen_scroll_up(n) +void +gen_scroll_up(int n) { gen_move(tt.tt_scroll_top, 0); if (gen_SRn) @@ -380,7 +427,8 @@ gen_scroll_up(n) ttxputs(gen_SR); } -gen_setscroll(top, bot) +void +gen_setscroll(int top, int bot) { tttgoto(gen_CS, bot, top); tt.tt_scroll_top = top; @@ -388,10 +436,12 @@ gen_setscroll(top, bot) tt.tt_row = tt.tt_col = -10; } -tt_generic() +int +tt_generic(void) { gen_PC = tttgetstr("pc"); PC = gen_PC ? *gen_PC->ts_str : 0; + ospeed = wwospeed; gen_CM = ttxgetstr("cm"); /* may not work */ gen_IM = ttxgetstr("im"); @@ -452,13 +502,14 @@ tt_generic() /* * Deal with obsolete termcap fields. */ - if (gen_LE == 0) + if (gen_LE == 0) { if (gen_BC) gen_LE = gen_BC; else if (gen_BS) { static struct tt_str bc = { "\b", 1 }; gen_BC = &bc; } + } if (gen_NL == 0) { static struct tt_str nl = { "\n", 1 }; gen_NL = &nl; @@ -475,15 +526,15 @@ tt_generic() */ if (gen_SF == 0 && !gen_NS) gen_SF = gen_NL; - BC = gen_LE ? gen_LE->ts_str : 0; - UP = gen_UP ? gen_UP->ts_str : 0; + BC = gen_LE ? __DECONST(char *, gen_LE->ts_str) : 0; + UP = gen_UP ? __DECONST(char *, gen_UP->ts_str) : 0; /* * Fix up display attributes that we can't handle, or don't * really exist. */ if (gen_SG > 0) gen_SO = 0; - if (gen_UG > 0 || gen_US && gen_SO && ttstrcmp(gen_US, gen_SO) == 0) + if (gen_UG > 0 || (gen_US && gen_SO && ttstrcmp(gen_US, gen_SO) == 0)) gen_US = 0; if (gen_IM && gen_IM->ts_n == 0) { @@ -518,7 +569,7 @@ tt_generic() * Don't allow scroll_up if da or db but not cs. * See comment in wwscroll.c. */ - if (gen_SR && (gen_CS || !gen_DA && !gen_DB)) + if (gen_SR && (gen_CS || (!gen_DA && !gen_DB))) tt.tt_scroll_up = gen_scroll_up; if (gen_CS) tt.tt_setscroll = gen_setscroll; diff --git a/usr.bin/window/tth19.c b/usr.bin/window/tth19.c index 240bf6683d..956af6aa93 100644 --- a/usr.bin/window/tth19.c +++ b/usr.bin/window/tth19.c @@ -1,3 +1,5 @@ +/* $NetBSD: tth19.c,v 1.7 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,12 +30,17 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tth19.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/tth19.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/tth19.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)tth19.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: tth19.c,v 1.7 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" #include "char.h" @@ -71,7 +74,7 @@ extern struct tt_str *gen_VE; int h19_msp10c; #define PAD(ms10) { \ - register i; \ + int i; \ for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \ ttputc('\0'); \ } @@ -80,10 +83,26 @@ int h19_msp10c; #define H19_SETINSERT(m) ttesc((tt.tt_insert = (m)) ? '@' : 'O') -h19_setmodes(new) -register new; +void h19_clear(void); +void h19_clreol(void); +void h19_clreos(void); +void h19_delchar(int); +void h19_delline(int); +void h19_end(void); +void h19_inschar(char); +void h19_insline(int); +void h19_move(int, int); +void h19_putc(char); +void h19_scroll_up(int); +void h19_scroll_down(int); +void h19_setmodes(int); +void h19_start(void); +void h19_write(const char *, int); + +void +h19_setmodes(int new) { - register diff; + int diff; diff = new ^ tt.tt_modes; if (diff & WWM_REV) @@ -93,7 +112,8 @@ register new; tt.tt_modes = new; } -h19_insline(n) +void +h19_insline(int n) { while (--n >= 0) { ttesc('L'); @@ -101,7 +121,8 @@ h19_insline(n) } } -h19_delline(n) +void +h19_delline(int n) { while (--n >= 0) { ttesc('M'); @@ -109,8 +130,8 @@ h19_delline(n) } } -h19_putc(c) -register char c; +void +h19_putc(char c) { if (tt.tt_nmodes != tt.tt_modes) (*tt.tt_setmodes)(tt.tt_nmodes); @@ -121,9 +142,8 @@ register char c; tt.tt_col = NCOL - 1; } -h19_write(p, n) -register char *p; -register n; +void +h19_write(const char *p, int n) { if (tt.tt_nmodes != tt.tt_modes) (*tt.tt_setmodes)(tt.tt_nmodes); @@ -135,8 +155,8 @@ register n; tt.tt_col = NCOL - 1; } -h19_move(row, col) -register char row, col; +void +h19_move(int row, int col) { if (tt.tt_row == row) { if (tt.tt_col == col) @@ -176,7 +196,8 @@ out: tt.tt_row = row; } -h19_start() +void +h19_start(void) { if (gen_VS) ttxputs(gen_VS); @@ -187,7 +208,8 @@ h19_start() tt.tt_nmodes = tt.tt_modes = 0; } -h19_end() +void +h19_end(void) { if (tt.tt_insert) H19_SETINSERT(0); @@ -196,23 +218,26 @@ h19_end() ttesc('v'); } -h19_clreol() +void +h19_clreol(void) { ttesc('K'); } -h19_clreos() +void +h19_clreos(void) { ttesc('J'); } -h19_clear() +void +h19_clear(void) { ttesc('E'); } -h19_inschar(c) -register char c; +void +h19_inschar(char c) { if (tt.tt_nmodes != tt.tt_modes) (*tt.tt_setmodes)(tt.tt_nmodes); @@ -225,27 +250,31 @@ register char c; tt.tt_col = NCOL - 1; } -h19_delchar(n) +void +h19_delchar(int n) { while (--n >= 0) ttesc('N'); } -h19_scroll_down(n) +void +h19_scroll_down(int n) { h19_move(NROW - 1, 0); while (--n >= 0) ttctrl('j'); } -h19_scroll_up(n) +void +h19_scroll_up(int n) { h19_move(0, 0); while (--n >= 0) ttesc('I'); } -tt_h19() +int +tt_h19(void) { float cpms = (float) wwbaud / 10000; /* char per ms */ diff --git a/usr.bin/window/tth29.c b/usr.bin/window/tth29.c index 0b9a2fa452..b230407c4a 100644 --- a/usr.bin/window/tth29.c +++ b/usr.bin/window/tth29.c @@ -1,3 +1,5 @@ +/* $NetBSD: tth29.c,v 1.6 2003/08/07 11:17:31 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,12 +30,17 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tth29.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/tth29.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/tth29.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)tth29.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: tth29.c,v 1.6 2003/08/07 11:17:31 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" #include "char.h" @@ -58,10 +61,12 @@ kC|h29|heath-29|z29|zenith-29:\ * */ -h29_setmodes(new) -register new; +void h29_setmodes(int); + +void +h29_setmodes(int new) { - register modes = '0'; + int modes = '0'; if (new & WWM_REV) modes += 0x01; @@ -84,7 +89,8 @@ register new; tt.tt_modes = new; } -tt_h29() +int +tt_h29(void) { if (tt_h19() < 0) return -1; diff --git a/usr.bin/window/ttinit.c b/usr.bin/window/ttinit.c index 10ba13c81c..67a5cfe4aa 100644 --- a/usr.bin/window/ttinit.c +++ b/usr.bin/window/ttinit.c @@ -1,3 +1,5 @@ +/* $NetBSD: ttinit.c,v 1.9 2003/08/13 15:21:07 itojun Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,25 +30,29 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttinit.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/ttinit.c,v 1.2.12.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/ttinit.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ttinit.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: ttinit.c,v 1.9 2003/08/13 15:21:07 itojun Exp $"); +#endif +#endif /* not lint */ + +#include +#include #include "ww.h" #include "tt.h" -#include -int tt_h19(); -int tt_h29(); -int tt_f100(); -int tt_tvi925(); -int tt_wyse75(); -int tt_wyse60(); -int tt_zapple(); -int tt_zentec(); -int tt_generic(); +struct tt tt; +char tt_strings[1024]; /* string buffer */ +char *tt_strp; /* pointer for it */ +char *tt_ob; +char *tt_obp; +char *tt_obe; + struct tt_tab tt_tab[] = { { "h19", 3, tt_h19 }, { "h29", 3, tt_h29 }, @@ -62,15 +64,16 @@ struct tt_tab tt_tab[] = { { "zapple", 6, tt_zapple }, { "zentec", 6, tt_zentec }, { "generic", 0, tt_generic }, - 0 + { 0, 0, 0 } }; -ttinit() +int +ttinit(void) { int i; - register struct tt_tab *tp; - register char *p, *q; - register char *t; + struct tt_tab *tp; + char *p, *q; + char *t; tt_strp = tt_strings; diff --git a/usr.bin/window/ttoutput.c b/usr.bin/window/ttoutput.c index 111e0ac780..2e1281a1f2 100644 --- a/usr.bin/window/ttoutput.c +++ b/usr.bin/window/ttoutput.c @@ -1,3 +1,5 @@ +/* $NetBSD: ttoutput.c,v 1.9 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,15 +30,20 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttoutput.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/ttoutput.c,v 1.1.1.1.14.2 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/ttoutput.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ttoutput.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: ttoutput.c,v 1.9 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include #include - +#include #include "ww.h" #include "tt.h" @@ -49,10 +52,11 @@ * We need this because stdio fails on non-blocking writes. */ -ttflush() +void +ttflush(void) { - register char *p; - register n = tt_obp - tt_ob; + char *p; + int n = tt_obp - tt_ob; if (n == 0) return; @@ -83,16 +87,15 @@ ttflush() tt_obp = tt_ob; } -ttputs(s) -register char *s; +void +ttputs(const char *s) { while (*s) ttputc(*s++); } -ttwrite(s, n) - register char *s; - register n; +void +ttwrite(const char *s, int n) { switch (n) { case 0: @@ -132,13 +135,13 @@ ttwrite(s, n) break; default: while (n > 0) { - register m; + int m; while ((m = tt_obe - tt_obp) == 0) ttflush(); if ((m = tt_obe - tt_obp) > n) m = n; - bcopy(s, tt_obp, m); + memmove(tt_obp, s, m); tt_obp += m; s += m; n -= m; diff --git a/usr.bin/window/tttermcap.c b/usr.bin/window/tttermcap.c index a39fc1b6ad..bdf1da2042 100644 --- a/usr.bin/window/tttermcap.c +++ b/usr.bin/window/tttermcap.c @@ -1,3 +1,5 @@ +/* $NetBSD: tttermcap.c,v 1.9 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,34 +30,40 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tttermcap.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/tttermcap.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/tttermcap.c,v 1.3 2005/02/28 13:57:05 joerg Exp $ */ -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)tttermcap.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: tttermcap.c,v 1.9 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ +#include +#include +#include #include "tt.h" -char *tgetstr(); -char *tgoto(); - -tttputc(c) +int +tttputc(int c) { ttputc(c); + return (0); } -ttxputc(c) +int +ttxputc(int c) { *tt_strp++ = c; + return (0); } struct tt_str * -tttgetstr(str) - char *str; +tttgetstr(const char *str) { - register struct tt_str *s; + struct tt_str *s; if ((str = tgetstr(str, &tt_strp)) == 0) return 0; @@ -71,10 +75,9 @@ tttgetstr(str) } struct tt_str * -ttxgetstr(str) - char *str; +ttxgetstr(const char *str) { - register struct tt_str *s; + struct tt_str *s; char buf[100]; char *bufp = buf; @@ -89,30 +92,30 @@ ttxgetstr(str) return s; } -tttgoto(s, col, row) - struct tt_str *s; +void +tttgoto(struct tt_str *s, int col, int row) { - register char *p = s->ts_str; + const char *p = s->ts_str; ttputs(tgoto(p, col, row)); for (p += s->ts_n; *--p == 0;) ttputc(0); } -ttpgoto(s, col, row, n) - struct tt_str *s; +void +ttpgoto(struct tt_str *s, int col, int row, int n) { tputs(tgoto(s->ts_str, col, row), n, tttputc); } -ttstrcmp(a, b) - register struct tt_str *a, *b; +int +ttstrcmp(struct tt_str *a, struct tt_str *b) { int n, r; - if (r = bcmp(a->ts_str, b->ts_str, - (n = a->ts_n - b->ts_n) < 0 ? a->ts_n : b->ts_n)) + if ((r = memcmp(a->ts_str, b->ts_str, + (n = a->ts_n - b->ts_n) < 0 ? a->ts_n : b->ts_n))) return r; return n; } diff --git a/usr.bin/window/tttvi925.c b/usr.bin/window/tttvi925.c index 47d172025b..602f7be9f9 100644 --- a/usr.bin/window/tttvi925.c +++ b/usr.bin/window/tttvi925.c @@ -1,3 +1,5 @@ +/* $NetBSD: tttvi925.c,v 1.6 2003/08/07 11:17:32 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,12 +30,17 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)tttvi925.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/tttvi925.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/tttvi925.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)tttvi925.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: tttvi925.c,v 1.6 2003/08/07 11:17:32 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" @@ -53,7 +56,8 @@ short tvi925_frame[16] = { 'b'|G, 'f'|G, 'h'|G, 'd'|G }; -tt_tvi925() +int +tt_tvi925(void) { if (tt_generic() < 0) diff --git a/usr.bin/window/ttwyse60.c b/usr.bin/window/ttwyse60.c index b467d6a74a..b818a6bcee 100644 --- a/usr.bin/window/ttwyse60.c +++ b/usr.bin/window/ttwyse60.c @@ -1,12 +1,10 @@ +/* $NetBSD: ttwyse60.c,v 1.6 2003/08/07 11:17:32 agc Exp $ */ + /* * Copyright 1987 by David C. Elliott, MIPS Computer Systems. * * Unlimited redistribution allowed as long as this notice * is kept intact. - * - * @(#)ttwyse60.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/ttwyse60.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/ttwyse60.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ /* @@ -24,11 +22,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -45,6 +39,15 @@ * SUCH DAMAGE. */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ttwyse60.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: ttwyse60.c,v 1.6 2003/08/07 11:17:32 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" @@ -59,7 +62,8 @@ short wyse60_frame[16] = { extern struct tt_str *gen_AS; extern struct tt_str *gen_AE; -tt_wyse60() +int +tt_wyse60(void) { static struct tt_str ae = { "\033H\003", 3 }; static struct tt_str as = { "\033H\002", 3 }; diff --git a/usr.bin/window/ttwyse75.c b/usr.bin/window/ttwyse75.c index d84c21ba90..d8037b6e7b 100644 --- a/usr.bin/window/ttwyse75.c +++ b/usr.bin/window/ttwyse75.c @@ -1,12 +1,10 @@ +/* $NetBSD: ttwyse75.c,v 1.6 2003/08/07 11:17:32 agc Exp $ */ + /* * Copyright 1987 by David C. Elliott, MIPS Computer Systems. * * Unlimited redistribution allowed as long as this notice * is kept intact. - * - * @(#)ttwyse75.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/ttwyse75.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/ttwyse75.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ /* @@ -24,11 +22,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -45,6 +39,15 @@ * SUCH DAMAGE. */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ttwyse75.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: ttwyse75.c,v 1.6 2003/08/07 11:17:32 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" @@ -59,7 +62,8 @@ short wyse75_frame[16] = { extern struct tt_str *gen_AS; extern struct tt_str *gen_AE; -tt_wyse75() +int +tt_wyse75(void) { static struct tt_str ae = { "\033(B", 3 }; static struct tt_str as = { "\033(0", 3 }; diff --git a/usr.bin/window/ttzapple.c b/usr.bin/window/ttzapple.c index c2b6d4c444..98d339a47f 100644 --- a/usr.bin/window/ttzapple.c +++ b/usr.bin/window/ttzapple.c @@ -1,3 +1,5 @@ +/* $NetBSD: ttzapple.c,v 1.9 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,14 +30,18 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttzapple.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/ttzapple.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/ttzapple.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ttzapple.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: ttzapple.c,v 1.9 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ +#include #include "ww.h" #include "tt.h" #include "char.h" @@ -69,7 +71,32 @@ int zz_lastc; /* for checkpointing */ int zz_sum; -zz_setmodes(new) +void zz_checkpoint(void); +void zz_checksum(char *, int); +void zz_clear(void); +void zz_clreol(void); +void zz_clreos(void); +void zz_compress(int); +void zz_delchar(int); +void zz_delline(int); +void zz_end(void); +void zz_insline(int); +void zz_insspace(int); +void zz_move(int, int); +void zz_put_token(int, const char *, int); +void zz_putc(char); +void zz_reset(void); +int zz_rint(char *, int); +void zz_scroll_down(int); +void zz_scroll_up(int); +void zz_setmodes(int); +void zz_setscroll(int, int); +void zz_set_token(int, char *, int); +void zz_start(void); +void zz_write(const char *, int); + +void +zz_setmodes(int new) { if (new & WWM_REV) { if ((tt.tt_modes & WWM_REV) == 0) @@ -80,7 +107,8 @@ zz_setmodes(new) tt.tt_modes = new; } -zz_insline(n) +void +zz_insline(int n) { if (n == 1) ttesc('a'); @@ -90,7 +118,8 @@ zz_insline(n) } } -zz_delline(n) +void +zz_delline(int n) { if (n == 1) ttesc('d'); @@ -100,8 +129,8 @@ zz_delline(n) } } -zz_putc(c) - char c; +void +zz_putc(char c) { if (tt.tt_nmodes != tt.tt_modes) zz_setmodes(tt.tt_nmodes); @@ -110,9 +139,8 @@ zz_putc(c) tt.tt_col = 0, tt.tt_row++; } -zz_write(p, n) - register char *p; - register n; +void +zz_write(const char *p, int n) { if (tt.tt_nmodes != tt.tt_modes) zz_setmodes(tt.tt_nmodes); @@ -122,10 +150,10 @@ zz_write(p, n) tt.tt_col = 0, tt.tt_row++; } -zz_move(row, col) - register row, col; +void +zz_move(int row, int col) { - register x; + int x; if (tt.tt_row == row) { same_row: @@ -218,7 +246,8 @@ out: tt.tt_row = row; } -zz_start() +void +zz_start(void) { ttesc('T'); ttputc(TOKEN_MAX + ' '); @@ -234,7 +263,8 @@ zz_start() zz_setmodes(0); } -zz_reset() +void +zz_reset(void) { zz_setscroll(0, NROW - 1); tt.tt_modes = WWM_REV; @@ -242,7 +272,8 @@ zz_reset() tt.tt_col = tt.tt_row = -10; } -zz_end() +void +zz_end(void) { ttesc('T'); ttputc(' '); @@ -251,23 +282,27 @@ zz_end() zz_ecc = 0; } -zz_clreol() +void +zz_clreol(void) { ttesc('2'); } -zz_clreos() +void +zz_clreos(void) { ttesc('3'); } -zz_clear() +void +zz_clear(void) { ttesc('4'); tt.tt_col = tt.tt_row = 0; } -zz_insspace(n) +void +zz_insspace(int n) { if (n == 1) ttesc('i'); @@ -277,7 +312,8 @@ zz_insspace(n) } } -zz_delchar(n) +void +zz_delchar(int n) { if (n == 1) ttesc('c'); @@ -287,20 +323,22 @@ zz_delchar(n) } } -zz_scroll_down(n) +void +zz_scroll_down(int n) { - if (n == 1) + if (n == 1) { if (tt.tt_row == NROW - 1) ttctrl('j'); else ttesc('f'); - else { + } else { ttesc('F'); ttputc(n + ' '); } } -zz_scroll_up(n) +void +zz_scroll_up(int n) { if (n == 1) ttesc('r'); @@ -310,7 +348,8 @@ zz_scroll_up(n) } } -zz_setscroll(top, bot) +void +zz_setscroll(int top, int bot) { ttesc('?'); ttputc(top + ' '); @@ -321,8 +360,8 @@ zz_setscroll(top, bot) int zz_debug = 0; -zz_set_token(t, s, n) - char *s; +void +zz_set_token(int t, char *s, int n) { if (tt.tt_nmodes != tt.tt_modes) zz_setmodes(tt.tt_nmodes); @@ -340,9 +379,8 @@ zz_set_token(t, s, n) s[n - 1] &= ~0x80; } -/*ARGSUSED*/ -zz_put_token(t, s, n) - char *s; +void +zz_put_token(int t, const char *s __unused, int n __unused) { if (tt.tt_nmodes != tt.tt_modes) zz_setmodes(tt.tt_nmodes); @@ -356,16 +394,16 @@ zz_put_token(t, s, n) ttputc(t + 0x81); } -zz_rint(p, n) - char *p; +int +zz_rint(char *p, int n) { - register i; - register char *q; + int i; + char *q; if (!zz_ecc) return n; for (i = n, q = p; --i >= 0;) { - register c = (unsigned char) *p++; + int c = (unsigned char) *p++; if (zz_lastc == 0) { switch (c) { @@ -412,18 +450,18 @@ zz_rint(p, n) return q - (p - n); } -zz_checksum(p, n) - register char *p; - register n; +void +zz_checksum(char *p, int n) { while (--n >= 0) { - register c = *p++ & 0x7f; + int c = *p++ & 0x7f; c ^= zz_sum; - zz_sum = c << 1 | c >> 11 & 1; + zz_sum = c << 1 | (c >> 11 & 1); } } -zz_compress(flag) +void +zz_compress(int flag) { if (flag) tt.tt_checksum = 0; @@ -431,7 +469,8 @@ zz_compress(flag) tt.tt_checksum = zz_checksum; } -zz_checkpoint() +void +zz_checkpoint(void) { static char x[] = { ctrl('['), 'V', 0, 0 }; @@ -443,7 +482,8 @@ zz_checkpoint() zz_sum = 0; } -tt_zapple() +int +tt_zapple(void) { tt.tt_insspace = zz_insspace; tt.tt_delchar = zz_delchar; diff --git a/usr.bin/window/ttzentec.c b/usr.bin/window/ttzentec.c index 1fce95df25..33d666d88b 100644 --- a/usr.bin/window/ttzentec.c +++ b/usr.bin/window/ttzentec.c @@ -1,3 +1,5 @@ +/* $NetBSD: ttzentec.c,v 1.6 2003/08/07 11:17:33 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,12 +30,17 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)ttzentec.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/ttzentec.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/ttzentec.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)ttzentec.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: ttzentec.c,v 1.6 2003/08/07 11:17:33 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" @@ -56,7 +59,8 @@ short zentec_frame[16] = { 'k'|G, 'u'|G, 'w'|G, 'n'|G }; -tt_zentec() +int +tt_zentec(void) { if (tt_generic() < 0) return -1; diff --git a/usr.bin/window/value.h b/usr.bin/window/value.h index 329012f677..99d51c802f 100644 --- a/usr.bin/window/value.h +++ b/usr.bin/window/value.h @@ -1,3 +1,5 @@ +/* $NetBSD: value.h,v 1.6 2008/07/25 06:53:43 gmcgarry Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,8 +32,6 @@ * SUCH DAMAGE. * * @(#)value.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/value.h,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/value.h,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ struct value { @@ -52,4 +48,5 @@ struct value { #define V_STR 2 #define V_ERR 3 -#define val_free(v) ((v).v_type == V_STR ? str_free((v).v_str) : 0) +#define val_free(v) (((v).v_type == V_STR && (v).v_str) ? \ + str_free((v).v_str) : (void)0) diff --git a/usr.bin/window/var.c b/usr.bin/window/var.c index 1c30fda431..74cd3422b9 100644 --- a/usr.bin/window/var.c +++ b/usr.bin/window/var.c @@ -1,3 +1,5 @@ +/* $NetBSD: var.c,v 1.10 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,26 +30,30 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)var.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/var.c,v 1.2.6.2 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/var.c,v 1.3 2005/02/28 13:57:05 joerg Exp $ */ -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)var.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: var.c,v 1.10 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ +#include +#include #include "value.h" +#define EXTERN #include "var.h" -#include "mystring.h" +#undef EXTERN +#include "window_string.h" struct var * -var_set1(head, name, v) -struct var **head; -char *name; -struct value *v; +var_set1(struct var **head, const char *name, struct value *v) { - register struct var **p; - register struct var *r; + struct var **p; + struct var *r; struct value val; /* do this first, easier to recover */ @@ -81,10 +83,7 @@ struct value *v; } struct var * -var_setstr1(head, name, str) -struct var **head; -char *name; -char *str; +var_setstr1(struct var **head, const char *name, char *str) { struct value v; @@ -94,10 +93,7 @@ char *str; } struct var * -var_setnum1(head, name, num) -struct var **head; -char *name; -int num; +var_setnum1(struct var **head, const char *name, int num) { struct value v; @@ -106,12 +102,11 @@ int num; return var_set1(head, name, &v); } -var_unset1(head, name) -struct var **head; -char *name; +int +var_unset1(struct var **head, const char *name) { - register struct var **p; - register struct var *r; + struct var **p; + struct var *r; if (*(p = var_lookup1(head, name)) == 0) return -1; @@ -127,11 +122,9 @@ char *name; } struct var ** -var_lookup1(p, name) -register struct var **p; -register char *name; +var_lookup1(struct var **p, const char *name) { - register cmp; + int cmp; while (*p != 0) { if ((cmp = strcmp(name, (*p)->r_name)) < 0) @@ -144,10 +137,8 @@ register char *name; return p; } -var_walk1(r, func, a) -register struct var *r; -int (*func)(); -long a; +int +var_walk1(struct var *r, int (*func) (void *, struct var *), void *a) { if (r == 0) return 0; diff --git a/usr.bin/window/var.h b/usr.bin/window/var.h index 8106a9fd14..7e7bad8842 100644 --- a/usr.bin/window/var.h +++ b/usr.bin/window/var.h @@ -1,3 +1,5 @@ +/* $NetBSD: var.h,v 1.8 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,10 +32,12 @@ * SUCH DAMAGE. * * @(#)var.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/var.h,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/var.h,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#ifndef EXTERN +#define EXTERN extern +#endif + struct var { struct var *r_left; struct var *r_right; @@ -45,10 +45,13 @@ struct var { struct value r_val; }; -struct var *var_set1(); -struct var *var_setstr1(); -struct var *var_setnum1(); -struct var **var_lookup1(); +struct var **var_lookup1(struct var **, const char *); +struct var *var_set1(struct var **, const char *, struct value *); +struct var *var_setnum1(struct var **, const char *, int); +struct var *var_setstr1(struct var **, const char *, char *); +int var_unset1(struct var **, const char *); +int var_walk1(struct var *, int (*func)(void *, struct var *), + void *); #define var_set(n, v) var_set1(&var_head, n, v) #define var_setstr(n, s) var_setstr1(&var_head, n, s) @@ -57,4 +60,4 @@ struct var **var_lookup1(); #define var_lookup(n) (*var_lookup1(&var_head, n)) #define var_walk(f, a) var_walk1(var_head, f, a) -struct var *var_head; /* secret, shhh */ +EXTERN struct var *var_head; /* secret, shhh */ diff --git a/usr.bin/window/win.c b/usr.bin/window/win.c index 68580b74f8..ed0efff5a8 100644 --- a/usr.bin/window/win.c +++ b/usr.bin/window/win.c @@ -1,3 +1,5 @@ +/* $NetBSD: win.c,v 1.14 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,14 +30,21 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)win.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/win.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/win.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)win.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: win.c,v 1.14 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + +#include #include "defs.h" #include "char.h" +#include "window_string.h" /* * Higher level routines for dealing with windows. @@ -61,12 +66,9 @@ * Open a user window. */ struct ww * -openwin(id, row, col, nrow, ncol, nline, label, haspty, hasframe, shf, sh) -char *label; -char haspty, hasframe; -char *shf, **sh; +openwin(int id, int row, int col, int nrow, int ncol, int nline, char *label, int type, int uflags, char *shf, char **sh) { - register struct ww *w; + struct ww *w; if (id < 0 && (id = findid()) < 0) return 0; @@ -75,14 +77,15 @@ char *shf, **sh; error("Illegal window position."); return 0; } - w = wwopen(haspty ? WWO_PTY : WWO_SOCKET, nrow, ncol, row, col, nline); + w = wwopen(type, 0, nrow, ncol, row, col, nline); if (w == 0) { error("Can't open window: %s.", wwerror()); return 0; } w->ww_id = id; window[id] = w; - w->ww_hasframe = hasframe; + CLR(w->ww_uflags, WWU_ALLFLAGS); + SET(w->ww_uflags, uflags); w->ww_alt = w->ww_w; if (label != 0 && setlabel(w, label) < 0) error("No memory for label."); @@ -92,7 +95,7 @@ char *shf, **sh; * addwin() puts w at the top, so we don't waste an * insert and delete operation. */ - setselwin(NULL); + setselwin((struct ww *)0); addwin(w, 0); setselwin(w); if (wwspawn(w, shf, sh) < 0) { @@ -103,9 +106,10 @@ char *shf, **sh; return w; } -findid() +int +findid(void) { - register i; + int i; for (i = 0; i < NWINDOW && window[i] != 0; i++) ; @@ -117,15 +121,15 @@ findid() } struct ww * -findselwin() +findselwin(void) { - register struct ww *w, *s = 0; - register i; + struct ww *w, *s = 0; + int i; for (i = 0; i < NWINDOW; i++) if ((w = window[i]) != 0 && w != selwin && (s == 0 || - !isfg(w) && (w->ww_order < s->ww_order || isfg(s)))) + (!isfg(w) && (w->ww_order < s->ww_order || isfg(s))))) s = w; return s; } @@ -133,11 +137,11 @@ findselwin() /* * Close a user window. Close all if w == 0. */ -closewin(w) -register struct ww *w; +void +closewin(struct ww *w) { char didit = 0; - register i; + int i; if (w != 0) { closewin1(w); @@ -150,14 +154,15 @@ register struct ww *w; didit++; } if (didit) { - if (selwin == 0) + if (selwin == 0) { if (lastselwin != 0) { setselwin(lastselwin); lastselwin = 0; - } else if (w = findselwin()) + } else if ((w = findselwin())) setselwin(w); + } if (lastselwin == 0 && selwin) - if (w = findselwin()) + if ((w = findselwin())) lastselwin = w; reframe(); } @@ -167,20 +172,15 @@ register struct ww *w; * Open an information (display) window. */ struct ww * -openiwin(nrow, label) -char *label; +openiwin(int nrow, const char *label) { - register struct ww *w; + struct ww *w; - if ((w = wwopen(0, nrow, wwncol, 2, 0, 0)) == 0) + if ((w = wwopen(WWT_INTERNAL, 0, nrow, wwncol, 2, 0, 0)) == 0) return 0; - w->ww_mapnl = 1; - w->ww_hasframe = 1; - w->ww_nointr = 1; - w->ww_noupdate = 1; - w->ww_unctrl = 1; + SET(w->ww_wflags, WWW_MAPNL | WWW_NOINTR | WWW_NOUPDATE | WWW_UNCTRL); + SET(w->ww_uflags, WWU_HASFRAME | WWU_CENTER); w->ww_id = -1; - w->ww_center = 1; (void) setlabel(w, label); addwin(w, 1); reframe(); @@ -190,15 +190,15 @@ char *label; /* * Close an information window. */ -closeiwin(w) -struct ww *w; +void +closeiwin(struct ww *w) { closewin1(w); reframe(); } -closewin1(w) -register struct ww *w; +void +closewin1(struct ww *w) { if (w == selwin) selwin = 0; @@ -219,9 +219,8 @@ register struct ww *w; * But anything to make it faster. * Always reframe() if doreframe is true. */ -front(w, doreframe) -register struct ww *w; -char doreframe; +void +front(struct ww *w, char doreframe) { if (w->ww_back != (isfg(w) ? framewin : fgwin) && !wwvisible(w)) { deletewin(w); @@ -236,9 +235,8 @@ char doreframe; * Add a window at the top of normal windows or foreground windows. * For normal windows, we put it behind the current window. */ -addwin(w, fg) -register struct ww *w; -char fg; +void +addwin(struct ww *w, char fg) { if (fg) { wwadd(w, framewin); @@ -252,32 +250,33 @@ char fg; /* * Delete a window. */ -deletewin(w) -register struct ww *w; +void +deletewin(struct ww *w) { if (fgwin == w) fgwin = w->ww_back; wwdelete(w); } -reframe() +void +reframe(void) { - register struct ww *w; + struct ww *w; wwunframe(framewin); for (w = wwhead.ww_back; w != &wwhead; w = w->ww_back) - if (w->ww_hasframe) { + if (ISSET(w->ww_uflags, WWU_HASFRAME)) { wwframe(w, framewin); labelwin(w); } } -labelwin(w) -register struct ww *w; +void +labelwin(struct ww *w) { int mode = w == selwin ? WWM_REV : 0; - if (!w->ww_hasframe) + if (!ISSET(w->ww_uflags, WWU_HASFRAME)) return; if (w->ww_id >= 0) { char buf[2]; @@ -289,7 +288,7 @@ register struct ww *w; if (w->ww_label) { int col; - if (w->ww_center) { + if (ISSET(w->ww_uflags, WWU_CENTER)) { col = (w->ww_w.nc - strlen(w->ww_label)) / 2; col = MAX(3, col); } else @@ -298,26 +297,27 @@ register struct ww *w; } } -stopwin(w) - register struct ww *w; +void +stopwin(struct ww *w) { - if (w->ww_pty >= 0 && w->ww_ispty && wwstoptty(w->ww_pty) < 0) + if (w->ww_pty >= 0 && w->ww_type == WWT_PTY && wwstoptty(w->ww_pty) < 0) error("Can't stop output: %s.", wwerror()); else - w->ww_stopped = 1; + SET(w->ww_pflags, WWP_STOPPED); } -startwin(w) - register struct ww *w; +void +startwin(struct ww *w) { - if (w->ww_pty >= 0 && w->ww_ispty && wwstarttty(w->ww_pty) < 0) + if (w->ww_pty >= 0 && w->ww_type == WWT_PTY && + wwstarttty(w->ww_pty) < 0) error("Can't start output: %s.", wwerror()); else - w->ww_stopped = 0; + CLR(w->ww_pflags, WWP_STOPPED); } -sizewin(w, nrow, ncol) -register struct ww *w; +void +sizewin(struct ww *w, int nrow, int ncol) { struct ww *back = w->ww_back; @@ -330,41 +330,39 @@ register struct ww *w; reframe(); } -waitnl(w) -struct ww *w; +void +waitnl(struct ww *w) { (void) waitnl1(w, "[Type any key to continue]"); } -more(w, always) -register struct ww *w; -char always; +int +more(struct ww *w, char always) { int c; - char uc = w->ww_unctrl; + int uc = ISSET(w->ww_wflags, WWW_UNCTRL); if (!always && w->ww_cur.r < w->ww_w.b - 2) return 0; c = waitnl1(w, "[Type escape to abort, any other key to continue]"); - w->ww_unctrl = 0; + CLR(w->ww_wflags, WWW_UNCTRL); wwputs("\033E", w); - w->ww_unctrl = uc; + SET(w->ww_wflags, uc); return c == ctrl('[') ? 2 : 1; } -waitnl1(w, prompt) -register struct ww *w; -char *prompt; +int +waitnl1(struct ww *w, const char *prompt) { - char uc = w->ww_unctrl; + int uc = ISSET(w->ww_wflags, WWW_UNCTRL); - w->ww_unctrl = 0; + CLR(w->ww_wflags, WWW_UNCTRL); front(w, 0); wwprintf(w, "\033Y%c%c\033sA%s\033rA ", w->ww_w.nr - 1 + ' ', ' ', prompt); /* print on last line */ wwcurtowin(w); while (wwpeekc() < 0) wwiomux(); - w->ww_unctrl = uc; + SET(w->ww_wflags, uc); return wwgetc(); } diff --git a/usr.bin/window/window.1 b/usr.bin/window/window.1 index a4174d059c..3a460f4567 100644 --- a/usr.bin/window/window.1 +++ b/usr.bin/window/window.1 @@ -1,3 +1,5 @@ +.\" $NetBSD: window.1,v 1.16 2009/03/10 21:18:35 joerg Exp $ +.\" .\" Copyright (c) 1985, 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -12,11 +14,7 @@ .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors +.\" 3. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" @@ -33,8 +31,6 @@ .\" SUCH DAMAGE. .\" .\" @(#)window.1 8.2 (Berkeley) 12/30/93 -.\" $FreeBSD: src/usr.bin/window/window.1,v 1.5.2.6 2002/06/21 15:30:19 charnier Exp $ -.\" $DragonFly: src/usr.bin/window/window.1,v 1.3 2006/02/17 19:39:17 swildner Exp $ .\" .Dd December 30, 1993 .Dt WINDOW 1 @@ -50,20 +46,22 @@ .Op Fl e Ar escape-char .Op Fl c Ar command .Sh DESCRIPTION -The .Nm -utility implements a window environment on +implements a window environment on .Tn ASCII terminals. .Pp A window is a rectangular portion of the physical terminal -screen associated with a set of processes. Its size and -position can be changed by the user at any time. Processes +screen associated with a set of processes. +Its size and position can be changed by the user at any time. +Processes communicate with their window in the same way they normally interact with a terminal\-through their standard input, output, -and diagnostic file descriptors. The window program handles the +and diagnostic file descriptors. +The window program handles the details of redirecting input and output to and from the -windows. At any one time, only one window can receive +windows. +At any one time, only one window can receive input from the keyboard, but all windows can simultaneously send output to the display. .Pp @@ -73,7 +71,8 @@ starts up, the commands (see long commands below) contained in the file .Pa .windowrc in the user's home directory are -executed. If it does not exist, two equal sized windows spanning +executed. +If it does not exist, two equal sized windows spanning the terminal screen are created by default. .Pp The command line options are @@ -83,7 +82,8 @@ Turn on terse mode (see .Ic terse command below). .It Fl f -Fast. Don't perform any startup action. +Fast. +Don't perform any startup action. .It Fl d Ignore .Pa .windowrc @@ -106,30 +106,38 @@ as a long command (see below) before doing anything else. .El .Pp -Windows can overlap and are framed as necessary. Each window -is named by one of the digits ``1'' to ``9''. This one-character +Windows can overlap and are framed as necessary. +Each window +is named by one of the digits +.Dq 1 +to +.Dq 9 . +This one-character identifier, as well as a user definable label string, are displayed -with the window on the top edge of its frame. A window can be -designated to be in the +with the window on the top edge of its frame. +A window can be designated to be in the .Ar foreground , in which case it will always be on top of all normal, non-foreground windows, and can be covered -only by other foreground windows. A window need not be completely -within the edges of the terminal screen. Thus a large window +only by other foreground windows. +A window need not be completely within the edges of the terminal screen. +Thus a large window (possibly larger than the screen) may be positioned to show only a portion of its full size. .Pp -Each window has a cursor and a set of control functions. Most intelligent -terminal operations such as line and -character deletion and insertion are supported. Display modes +Each window has a cursor and a set of control functions. +Most intelligent terminal operations such as line and +character deletion and insertion are supported. +Display modes such as underlining and reverse video are available if they are -supported by the terminal. In addition, -similar to terminals with multiple pages of memory, +supported by the terminal. +In addition, similar to terminals with multiple pages of memory, each window has a text buffer which can have more lines than the window itself. .Ss Process Environment With each newly created window, a shell program is spawned with its -process environment tailored to that window. Its standard input, +process environment tailored to that window. +Its standard input, output, and diagnostic file descriptors are bound to one end of either a pseudo-terminal (see .Xr pty 4 ) @@ -141,7 +149,8 @@ If a pseudo-terminal is used, then its special characters and modes (see .Xr stty 1 ) are copied from the physical -terminal. A +terminal. +A .Xr termcap 5 entry tailored to this window is created and passed as environment (see @@ -152,9 +161,11 @@ The termcap entry contains the window's size and characteristics as well as information from the physical terminal, such as the existence of underline, reverse video, and other display modes, and the codes produced by the terminal's function keys, -if any. In addition, the window size attributes of the pseudo-terminal +if any. +In addition, the window size attributes of the pseudo-terminal are set to reflect the size of this window, and updated whenever -it is changed by the user. In particular, the editor +it is changed by the user. +In particular, the editor .Xr vi 1 uses this information to redraw its display. @@ -162,11 +173,14 @@ this information to redraw its display. During normal execution, .Nm can be in one of two states: -conversation mode and command mode. In conversation mode, the +conversation mode and command mode. +In conversation mode, the terminal's real cursor is placed at the cursor position of a particular window--called the current window--and input from the keyboard is sent -to the process in that window. The current window is always -on top of all other windows, except those in foreground. In addition, +to the process in that window. +The current window is always +on top of all other windows, except those in foreground. +In addition, it is set apart by highlighting its identifier and label in reverse video. .Pp Typing @@ -174,7 +188,8 @@ Typing escape character (normally .Ic ^P ) in conversation -mode switches it into command mode. In command mode, the top line of +mode switches it into command mode. +In command mode, the top line of the terminal screen becomes the command prompt window, and .Nm interprets input from the keyboard as commands to manipulate windows. @@ -189,14 +204,18 @@ below). .Ss Short Commands Below, .Ar \&# -represents one of the digits ``1'' to ``9'' +represents one of the digits +.Dq 1 +to +.Dq 9 corresponding to the windows 1 to 9. .Ic ^X means .No control\- Ns Ar X , where .Ar X -is any character. In particular, +is any character. +In particular, .Ic ^^ is .Li control\-^ . @@ -214,18 +233,18 @@ Select window .Ar # but stay in command mode. .It Ic ^^ -Select the previous window and return to conversation -mode. This is useful for toggling between two windows. +Select the previous window and return to conversation mode. +This is useful for toggling between two windows. .It Ic escape Return to conversation mode. .It Ic ^P Return to conversation mode and write .Ic ^P -to the -current window. Thus, typing two +to the current window. +Thus, typing two .Ic ^P Ns 's -in conversation -mode sends one to the current window. If the +in conversation mode sends one to the current window. +If the .Nm escape is changed to some other character, that character takes the place of @@ -243,24 +262,37 @@ Confirmation is requested. Suspend .Nm . .It Ic w -Create a new window. The user is prompted for the positions +Create a new window. +The user is prompted for the positions of the upper left and lower right corners of the window. -The cursor is placed on the screen and the keys ``h'', ``j'', -``k'', and ``l'' +The cursor is placed on the screen and the keys +.Dq h , +.Dq j , +.Dq k , +and +.Dq l move the cursor left, down, up, and right, respectively. -The keys ``H'', ``J'', ``K'', and ``L'' move the cursor to the respective -limits of the screen. Typing a number before the movement keys -repeats the movement that number of times. Return enters the cursor position -as the upper left corner of the window. The lower right corner -is entered in the same manner. During this process, +The keys +.Dq H , +.Dq J , +.Dq K , +and +.Dq L +move the cursor to the respective limits of the screen. +Typing a number before the movement keys +repeats the movement that number of times. +Return enters the cursor position +as the upper left corner of the window. +The lower right corner is entered in the same manner. +During this process, the placement of the new window is indicated by a rectangular box drawn on the screen, corresponding to where the new window -will be framed. Typing escape at any point -cancels this command. +will be framed. +Typing escape at any point cancels this command. .Pp This window becomes the current window, -and is given the first available ID. The default buffer size -is used (see +and is given the first available ID. +The default buffer size is used (see .Ar default_nline command below). .Pp @@ -271,19 +303,19 @@ Close window The process in the window is sent the hangup signal (see .Xr kill 1 ) . -.Xr Csh 1 +.Xr csh 1 should handle this signal correctly and cause no problems. .It Ic m Ns Ar # Move window .Ar # -to another location. A box in the shape -of the window is drawn on +to another location. +A box in the shape of the window is drawn on the screen to indicate the new position of the window, and the same keys as those for the .Ic w -command are used to position the box. The -window can be moved partially off-screen. +command are used to position the box. +The window can be moved partially off-screen. .It Ic M Ns Ar # Move window .Ar # @@ -292,9 +324,9 @@ to its previous position. Change the size of window .Ar # . The user is prompted -to enter the new lower right corner of the window. A box -is drawn to indicate the new window size. The same -keys used in +to enter the new lower right corner of the window. +A box is drawn to indicate the new window size. +The same keys used in .Ic w and .Ic m @@ -324,17 +356,18 @@ Move the cursor of the current window up by one line. .It Ic l Move the cursor of the current window right by one column. .It Ic y -Yank. The user is prompted to enter two points within the current -window. Then the content of the current window between those two points +Yank. +The user is prompted to enter two points within the current window. +Then the content of the current window between those two points is saved in the yank buffer. .It Ic p -Put. The content of the yank buffer is written to the current -window as input. +Put. +The content of the yank buffer is written to the current window as input. .It Ic ^S Stop output in the current window. .It Ic ^Q Start output in the current window. -.It Ic : +.It Ic \&: Enter a line to be executed as long commands. Normal line editing characters (erase character, erase word, erase line) @@ -343,46 +376,69 @@ are supported. .Ss Long Commands Long commands are a sequence of statements parsed much like a programming language, with a syntax -similar to that of C. Numeric and string expressions and variables +similar to that of C. +Numeric and string expressions and variables are supported, as well as conditional statements. .Pp -There are two data types: string and number. A string is a sequence -of letters or digits beginning with a letter. ``_'' and ``.'' are -considered letters. Alternately, non-alphanumeric characters can -be included in strings by quoting them in ``"'' or escaping them -with ``\\''. In addition, the ``\\'' sequences of C are supported, -both inside and outside quotes (e.g., ``\\n'' is a new line, -``\\r'' a carriage return). For example, these are legal strings: -abcde01234, "&#$^*&#", ab"$#"cd, ab\\$\\#cd, "/usr/ucb/window". +There are two data types: string and number. +A string is a sequence +of letters or digits beginning with a letter. +.Dq _ +and +.Dq \&\. +are considered letters. +Alternatively, non-alphanumeric characters can +be included in strings by quoting them in double +.Pq Dq \&" +quotes or escaping them with backslash +.Pq Dq \e . +In addition, the +.Dq \e +sequences of C are supported, +both inside and outside quotes (e.g., +.Dq \en +is a new line, +.Dq \er +a carriage return). +For example, these are legal strings: +abcde01234, "\*[Am]#$^*\*[Am]#", ab"$#"cd, ab\\$\\#cd, "/usr/ucb/window". .Pp A number is an integer value in one of three forms: -a decimal number, an octal number preceded by ``0'', -or a hexadecimal number preceded by ``0x'' or ``0X''. The natural -machine integer size is used (i.e., the signed integer type -of the C compiler). As in C, a non-zero number represents -a boolean true. +a decimal number, an octal number preceded by +.Dq 0 , +or a hexadecimal number preceded by +.Dq 0x +or +.Dq 0X . +The natural machine integer size is used (i.e., the signed integer type +of the C compiler). +As in C, a non-zero number represents a boolean true. .Pp -The character ``#'' begins a comment which terminates at the +The character +.Dq # +begins a comment which terminates at the end of the line. .Pp -A statement is either a conditional or an expression. Expression -statements are terminated with a new line or ``;''. To continue -an expression on the next line, terminate the first line with ``\\''. +A statement is either a conditional or an expression. +Expression statements are terminated with a new line or +.Dq \&; . +To continue +an expression on the next line, terminate the first line with +.Dq \e . .Ss Conditional Statement -The .Nm -utility has a single control structure: +has a single control structure: the fully bracketed if statement in the form .Pp .Bd -literal -offset indent -compact -if then -\t +if \*[Lt]expr\*[Gt] then +\t\*[Lt]statement\*[Gt] \t... -elsif then -\t +elsif \*[Lt]expr\*[Gt] then +\t\*[Lt]statement\*[Gt] \t... else -\t +\t\*[Lt]statement\*[Gt] \t... endif .Ed @@ -393,22 +449,25 @@ and .Ic elsif parts are optional, and the latter can be repeated any number of times. - +\*[Lt]Expr\*[Gt] must be numeric. .Ss Expressions Expressions in .Nm are similar to those in the C language, with most C operators supported on numeric -operands. In addition, some are overloaded to operate on strings. +operands. +In addition, some are overloaded to operate on strings. .Pp When an expression is used as a statement, its value is discarded -after evaluation. Therefore, only expressions with side +after evaluation. +Therefore, only expressions with side effects (assignments and function calls) are useful as statements. .Pp Single valued (no arrays) variables are supported, of both -numeric and string values. Some variables are predefined. They -are listed below. +numeric and string values. +Some variables are predefined. +They are listed below. .Pp The operators in order of increasing precedence: .Bl -tag -width Fl @@ -417,7 +476,8 @@ The operators in order of increasing precedence: .Ic = .Aq Va expr2 .Xc -Assignment. The variable of name +Assignment. +The variable of name .Aq Va expr1 , which must be string valued, is assigned the result of @@ -438,8 +498,8 @@ if evaluates true (non-zero numeric value); returns the value of .Aq Va expr3 -otherwise. Only -one of +otherwise. +Only one of .Aq Va expr2 and .Aq Va expr3 @@ -452,7 +512,9 @@ be numeric. .Ic \&|\&| .Aq Va expr2 .Xc -Logical or. Numeric values only. Short circuit evaluation is supported +Logical or. +Numeric values only. +Short circuit evaluation is supported (i.e., if .Aq Va expr1 evaluates true, then @@ -460,28 +522,32 @@ evaluates true, then is not evaluated). .It Xo .Aq Va expr1 -.Ic \&&\&& +.Ic \&\*[Am]\&\*[Am] .Aq Va expr2 .Xc -Logical and with short circuit evaluation. Numeric values only. +Logical and with short circuit evaluation. +Numeric values only. .It Xo .Aq Va expr1 .Ic \&| .Aq Va expr2 .Xc -Bitwise or. Numeric values only. +Bitwise or. +Numeric values only. .It Xo .Aq Va expr1 .Ic ^ .Aq Va expr2 .Xc -Bitwise exclusive or. Numeric values only. +Bitwise exclusive or. +Numeric values only. .It Xo .Aq Va expr1 -.Ic \&& +.Ic \&\*[Am] .Aq Va expr2 .Xc -Bitwise and. Numeric values only. +Bitwise and. +Numeric values only. .It Xo .Aq Va expr1 .Ic == @@ -490,30 +556,32 @@ Bitwise and. Numeric values only. .Ic != .Aq expr2 .Xc -Comparison (equal and not equal, respectively). The boolean -result (either 1 or 0) of the comparison is returned. The -operands can be numeric or string valued. One string operand +Comparison (equal and not equal, respectively). +The boolean result (either 1 or 0) of the comparison is returned. +The operands can be numeric or string valued. +One string operand forces the other to be converted to a string in necessary. .It Xo .Aq Va expr1 -.Ic < +.Ic \*[Lt] .Aq Va expr2 , .Aq Va expr1 -.Ic > +.Ic \*[Gt] .Aq Va expr2 , .Aq Va expr1 -.Ic <= +.Ic \*[Le] .Aq Va expr2 , .Xc Less than, greater than, less than or equal to, -greater than or equal to. Both numeric and string values, with +greater than or equal to. +Both numeric and string values, with automatic conversion as above. .It Xo .Aq Va expr1 -.Ic << +.Ic \*[Lt]\*[Lt] .Aq Va expr2 , .Aq Va expr1 -.Ic >> +.Ic \*[Gt]\*[Gt] .Aq Va expr2 .Xc If both operands are numbers, @@ -521,7 +589,8 @@ If both operands are numbers, is bit shifted left (or right) by .Aq Va expr2 -bits. If +bits. +If .Aq Va expr1 is a string, then its first (or last) @@ -539,7 +608,10 @@ in place of its value). .Ic - .Aq Va expr2 .Xc -Addition and subtraction on numbers. For ``+'', if one +Addition and subtraction on numbers. +For +.Dq + , +if one argument is a string, then the other is converted to a string, and the result is the concatenation of the two strings. .It Xo @@ -553,7 +625,8 @@ and the result is the concatenation of the two strings. .Ic \&% .Aq Va expr2 .Xc -Multiplication, division, modulo. Numbers only. +Multiplication, division, modulo. +Numbers only. .It Xo .Ic \- Ns Aq Va expr , .Ic ~ Ns Aq Va expr , @@ -562,16 +635,21 @@ Multiplication, division, modulo. Numbers only. .Ic \&$? Ns Aq Va expr .Xc The first three are unary minus, bitwise complement and logical complement -on numbers only. The operator, ``$'', takes +on numbers only. +The operator, +.Dq $ , +takes .Aq Va expr and returns -the value of the variable of that name. If +the value of the variable of that name. +If .Aq Va expr is numeric with value .Ar n and it appears within an alias macro (see below), -then it refers to the nth argument of the alias invocation. ``$?'' +then it refers to the nth argument of the alias invocation. +.Dq $? tests for the existence of the variable .Aq Va expr , and returns 1 @@ -585,42 +663,49 @@ must be a string that is the unique prefix of the name of a builtin .Nm function -or the full name of a user defined alias macro. In the case of a builtin -function, +or the full name of a user defined alias macro. +In the case of a builtin function, .Aq Ar arglist can be in one of two forms: .Bd -literal -offset indent -, , ... -argname1 = , argname2 = , ... +\*[Lt]expr1\*[Gt], \*[Lt]expr2\*[Gt], ... +argname1 = \*[Lt]expr1\*[Gt], argname2 = \*[Lt]expr2\*[Gt], ... .Ed .Pp The two forms can in fact be intermixed, but the result is -unpredictable. Most arguments can be omitted; default values will -be supplied for them. The +unpredictable. +Most arguments can be omitted; default values will +be supplied for them. +The .Ar argnames can be unique prefixes -of the argument names. The commas separating +of the argument names. +The commas separating arguments are used only to disambiguate, and can usually be omitted. .Pp -Only the first argument form is valid for user defined aliases. Aliases -are defined using the +Only the first argument form is valid for user defined aliases. +Aliases are defined using the .Ic alias -builtin function (see below). Arguments -are accessed via a variant of the variable mechanism (see ``$'' operator -above). +builtin function (see below). +Arguments +are accessed via a variant of the variable mechanism (see +.Dq $ +operator above). .Pp Most functions return value, but some are used for side effect -only and so must be used as statements. When a function or an alias is used +only and so must be used as statements. +When a function or an alias is used as a statement, the parentheses surrounding -the argument list may be omitted. Aliases return no value. +the argument list may be omitted. +Aliases return no value. .El .Ss Builtin Functions -The arguments are listed by name in their natural -order. Optional arguments are in square brackets +The arguments are listed by name in their natural order. +Optional arguments are in square brackets .Sq Op . Arguments that have no names are in angle brackets -.Sq <> . +.Sq \*[Lt]\*[Gt] . An argument meant to be a boolean flag (often named .Ar flag ) can be one of @@ -635,19 +720,21 @@ with obvious meanings, or it can be a numeric expression, in which case a non-zero value is true. .Bl -tag -width Fl -.It Ic alias Ns Po -.Bq Aq Ar string , -.Bq Aq Ar string\-list -.Pc +.It Xo +.Ic alias Ns Po Bq Aq Ar string , +.Bq Aq Ar string\-list Pc +.Xc If no argument is given, all currently defined alias macros are -listed. Otherwise, +listed. +Otherwise, .Aq Ar string is defined as an alias, with expansion -.Aq Ar string\-list > . +.Aq Ar string\-list \*[Gt] . The previous definition of .Aq Ar string , -if any, is returned. Default for +if any, is returned. +Default for .Aq Ar string\-list is no change. .It Ic close Ns Pq Aq Ar window\-list @@ -657,7 +744,8 @@ If .Aq Ar window\-list is the word .Ar all , -than all windows are closed. No value is returned. +than all windows are closed. +No value is returned. .It Ic cursormodes Ns Pq Bq Ar modes Set the window cursor to .Ar modes . @@ -672,8 +760,9 @@ or of the mode bits defined as the variables (blinking), and .Ar m_grp -(graphics, terminal dependent). Return -value is the previous modes. Default is no change. +(graphics, terminal dependent). +Return value is the previous modes. +Default is no change. For example, .Li cursor($m_rev$m_blk) sets the window cursors to blinking @@ -682,15 +771,17 @@ reverse video. Set the default buffer size to .Ar nline . Initially, it is -48 lines. Returns the old default buffer size. Default is -no change. Using a very large buffer can slow the program down -considerably. +48 lines. +Returns the old default buffer size. +Default is no change. +Using a very large buffer can slow the program down considerably. .It Ic default_shell Ns Pq Bq Aq Ar string\-list Set the default window shell program to .Aq Ar string\-list . Returns -the first string in the old shell setting. Default is no change. Initially, -the default shell is taken from the environment variable +the first string in the old shell setting. +Default is no change. +Initially, the default shell is taken from the environment variable .Ev SHELL . .It Ic default_smooth Ns Pq Bq Ar flag Set the default value of the @@ -698,8 +789,8 @@ Set the default value of the argument to the command .Nm -(see below). The argument -is a boolean flag (one of +(see below). +The argument is a boolean flag (one of .Ar on , .Ar off , .Ar yes , @@ -707,7 +798,8 @@ is a boolean flag (one of .Ar true , .Ar false , or a number, -as described above). Default is no change. +as described above). +Default is no change. The old value (as a number) is returned. The initial value is 1 (true). .It Xo @@ -719,18 +811,20 @@ Write the list of strings, to .Nm , separated -by spaces and terminated with a new line. The strings are only +by spaces and terminated with a new line. +The strings are only displayed in the window, the processes in the window are not involved (see .Ic write -below). No value is returned. Default -is the current window. +below). +No value is returned. +Default is the current window. .It Ic escape Ns Pq Bq Ar escapec Set the escape character to .Ar escape-char . Returns the old -escape character as a one-character string. Default is no -change. +escape character as a one-character string. +Default is no change. .Ar Escapec can be a string of a single character, or in the form @@ -745,8 +839,9 @@ Move .Nm in or out of foreground. .Ar Flag -is a boolean value. The old foreground flag -is returned. Default for +is a boolean value. +The old foreground flag is returned. +Default for .Nm is the current window, default for @@ -761,21 +856,24 @@ Set the label of to .Ar label . Returns the old -label as a string. Default for +label as a string. +Default for .Nm is the current window, default for .Ar label -is no change. To turn -off a label, set it to an empty string (""). +is no change. +To turn off a label, set it to an empty string (""). .It Ic list Ns Pq -No arguments. List the identifiers and labels of all windows. No -value is returned. +No arguments. +List the identifiers and labels of all windows. +No value is returned. .It Ic select Ns Pq Bq Ar window Make .Nm -the current window. The previous current window -is returned. Default is no change. +the current window. +The previous current window is returned. +Default is no change. .It Ic source Ns Pq Ar filename Read and execute the long commands in .Ar filename . @@ -790,7 +888,8 @@ sounding the terminal's bell. can take on the same values as in .Ar foreground -above. Returns the old terse flag. +above. +Returns the old terse flag. Default is no change. .It Ic unalias Ns Pq Ar alias Undefine @@ -807,7 +906,9 @@ Returns -1 if does not exist, 0 otherwise. .It Ic variables Ns Pq -No arguments. List all variables. No value is returned. +No arguments. +List all variables. +No value is returned. .It Xo .Ic window Ns ( Bq Ar row , .Bq Ar column , @@ -831,8 +932,9 @@ and size If .Ar nline is specified, -then that many lines are allocated for the text buffer. Otherwise, -the default buffer size is used. Default values for +then that many lines are allocated for the text buffer. +Otherwise, the default buffer size is used. +Default values for .Ar row , .Ar column , .Ar nrow , @@ -856,10 +958,11 @@ allocate pseudo-terminal for this window rather than socketpair (default true), and map new line characters in this window to carriage return and line feed (default true if socketpair is used, false otherwise). Normally, a window is automatically closed when its process -exits. Setting +exits. +Setting .Ar keepopen -to true (default false) prevents this -action. When +to true (default false) prevents this action. +When .Ar smooth is true, the screen is updated more frequently (for this window) to produce a more terminal-like behavior. @@ -873,8 +976,8 @@ is a list of strings that will be used as the shell program to place in the window (default is the program specified by .Ar default_shell , -see above). The created window's identifier -is returned as a number. +see above). +The created window's identifier is returned as a number. .It Xo .Ic write Ns ( Bq Ar window , .Bq Aq Ar string\-list ) @@ -884,20 +987,22 @@ Send the list of strings, to .Nm , separated -by spaces but not terminated with a new line. The strings are actually -given to the window as input. No value is returned. Default -is the current window. +by spaces but not terminated with a new line. +The strings are actually given to the window as input. +No value is returned. +Default is the current window. .El .Ss Predefined Variables -These variables are for information only. Redefining them does -not affect the internal operation of +These variables are for information only. +Redefining them does not affect the internal operation of .Nm . .Bl -tag -width modes .It Ar baud The baud rate as a number between 50 and 38400. .It Ar modes The display modes (reverse video, underline, blinking, graphics) -supported by the physical terminal. The value of +supported by the physical terminal. +The value of .Ar modes is the bitwise or of some of the one bit values, .Ar m_blk , @@ -923,15 +1028,14 @@ The number of columns on the physical screen. .It Ar nrow The number of rows on the physical screen. .It Ar term -The terminal type. The standard name, found in the second name -field of the terminal's +The terminal type. +The standard name, found in the second name field of the terminal's .Ev TERMCAP entry, is used. .El .Sh ENVIRONMENT -The .Nm -utility utilizes these environment variables: +uses these environment variables: .Ev HOME , .Ev SHELL , .Ev TERM , diff --git a/usr.bin/window/wwend.c b/usr.bin/window/window_string.h similarity index 64% copy from usr.bin/window/wwend.c copy to usr.bin/window/window_string.h index 2aec04efc6..493580fa8a 100644 --- a/usr.bin/window/wwend.c +++ b/usr.bin/window/window_string.h @@ -1,3 +1,5 @@ +/* $NetBSD: window_string.h,v 1.8 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -33,36 +31,45 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)wwend.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwend.c,v 1.2.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwend.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ + * @(#)string.h 8.1 (Berkeley) 6/6/93 */ -#include -#include +#ifndef _W_STRING_H_ +#define _W_STRING_H_ + +#include + +#ifndef EXTERN +#define EXTERN extern +#endif + +#define STR_DEBUG + +char *str_cat(const char *, const char *); +char *str_cpy(const char *); +char *str_itoa(int); +int str_match(const char *, const char *, int); +char *str_ncpy(const char *, int); + +#define str_cmp(a, b) strcmp(a, b) + +#ifdef STR_DEBUG +struct string { + struct string *s_forw; + struct string *s_back; + char s_data[1]; +}; + +EXTERN struct string str_head; -#include "ww.h" -#include "tt.h" +#define str_offset ((unsigned)str_head.s_data - (unsigned)&str_head) +#define str_stos(s) ((struct string *)((unsigned)(s) - str_offset)) -/*ARGSUSED*/ -wwend(exit) -{ - if (tt.tt_checkpoint) { - (void) alarm(0); - wwdocheckpoint = 0; - } - xxend(); - (void) signal(SIGIO, SIG_DFL); - (void) wwsettty(0, &wwoldtty); -#ifdef TERMINFO - if (exit) - wwterminfoend(); +char *str_alloc(size_t); +void str_free(char *); +#else +#define str_free(s) free(s) +#define str_alloc(s) malloc(s) #endif -} -void -wwquit() -{ - wwend(1); - exit(1); -} +#endif /* _W_STRING_H_ */ diff --git a/usr.bin/window/windowrc b/usr.bin/window/windowrc index 57c695a722..e18e01748b 100644 --- a/usr.bin/window/windowrc +++ b/usr.bin/window/windowrc @@ -1,3 +1,5 @@ +# $NetBSD: windowrc,v 1.3 1999/02/15 04:54:37 hubertf Exp $ + # Copyright (c) 1983, 1993 # The Regents of the University of California. All rights reserved. # @@ -29,6 +31,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # +# $NetBSD: windowrc,v 1.3 1999/02/15 04:54:37 hubertf Exp $ # @(#)windowrc 8.1 (Berkeley) 6/6/93 # diff --git a/usr.bin/window/ww.h b/usr.bin/window/ww.h index 65c213c875..8bcbd25c85 100644 --- a/usr.bin/window/ww.h +++ b/usr.bin/window/ww.h @@ -1,3 +1,5 @@ +/* $NetBSD: ww.h,v 1.18 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,20 +32,33 @@ * SUCH DAMAGE. * * @(#)ww.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/ww.h,v 1.3.12.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/ww.h,v 1.4 2004/09/03 20:38:01 dillon Exp $ */ +#ifndef __WW_H__ +#define __WW_H__ + +#include #ifdef OLD_TTY #include #else #include #endif #include -#include +#include +#include +#include + +#ifndef EXTERN +#define EXTERN extern +#endif #define NWW 30 /* maximum number of windows */ +/* Macros to clear/set/test flags. */ +#define SET(t, f) (t) |= (f) +#define CLR(t, f) (t) &= ~(f) +#define ISSET(t, f) ((t) & (f)) + /* a rectangle */ struct ww_dim { int nr; /* number of rows */ @@ -64,15 +75,25 @@ struct ww_pos { /* the window structure */ struct ww { + int ww_flags; + /* general flags and states */ - char ww_state; /* state of window */ - char ww_oflags; /* wwopen flags */ + int ww_state; /* state of window */ +#define WWS_INITIAL 0 /* just opened */ +#define WWS_HASPROC 1 /* has process on pty */ +#define WWS_DEAD 3 /* child died */ +#define ww_oflags ww_flags +#define WWO_REVERSE 0x0001 /* make it all reverse video */ +#define WWO_GLASS 0x0002 /* make it all glass */ +#define WWO_FRAME 0x0004 /* this is a frame window */ +#define WWO_ALLFLAGS 0x0007 /* information for overlap */ struct ww *ww_forw; /* doubly linked list, for overlapping info */ struct ww *ww_back; - char ww_index; /* the window index, for wwindex[] */ - char ww_order; /* the overlapping order */ + unsigned char ww_index; /* the window index, for wwindex[] */ +#define WWX_NOBODY NWW + int ww_order; /* the overlapping order */ /* sizes and positions */ struct ww_dim ww_w; /* window size and pos */ @@ -87,18 +108,23 @@ struct ww { short *ww_nvis; /* how many ww_buf chars are visible per row */ /* information for wwwrite() and company */ - char ww_wstate; /* state for outputting characters */ + int ww_wstate; /* state for outputting characters */ char ww_modes; /* current display modes */ - char ww_insert; /* insert mode */ - char ww_mapnl; /* map \n to \r\n */ - char ww_noupdate; /* don't do updates in wwwrite() */ - char ww_unctrl; /* expand control characters */ - char ww_nointr; /* wwwrite() not interruptable */ - char ww_hascursor; /* has fake cursor */ +#define ww_wflags ww_flags +#define WWW_INSERT 0x0008 /* insert mode */ +#define WWW_MAPNL 0x0010 /* map \n to \r\n */ +#define WWW_NOUPDATE 0x0020 /* don't do updates in wwwrite() */ +#define WWW_UNCTRL 0x0040 /* expand control characters */ +#define WWW_NOINTR 0x0080 /* wwwrite() not interruptable */ +#define WWW_HASCURSOR 0x0100 /* has fake cursor */ /* things for the window process and io */ - char ww_ispty; /* ww_pty is really a pty, not socket pair */ - char ww_stopped; /* output stopped */ + int ww_type; +#define WWT_PTY 0 /* pty */ +#define WWT_SOCKET 1 /* socket pair */ +#define WWT_INTERNAL 2 +#define ww_pflags ww_flags +#define WWP_STOPPED 0x0200 /* output stopped */ int ww_pty; /* file descriptor of pty or socket pair */ int ww_socket; /* other end of socket pair */ int ww_pid; /* pid of process, if WWS_HASPROC true */ @@ -109,10 +135,12 @@ struct ww { char *ww_obq; /* current write position in ww_ob */ /* things for the user, they really don't belong here */ - char ww_id; /* the user window id */ - char ww_center; /* center the label */ - char ww_hasframe; /* frame it */ - char ww_keepopen; /* keep it open after the process dies */ + int ww_id; /* the user window id */ +#define ww_uflags ww_flags +#define WWU_CENTER 0x0400 /* center the label */ +#define WWU_HASFRAME 0x0800 /* frame it */ +#define WWU_KEEPOPEN 0x1000 /* keep it open after the process dies */ +#define WWU_ALLFLAGS 0x1c00 char *ww_label; /* the user supplied label */ struct ww_dim ww_alt; /* alternate position and size */ }; @@ -128,7 +156,6 @@ struct ww_tty { #else struct termios ww_termios; #endif - int ww_fflags; }; union ww_char { @@ -168,11 +195,6 @@ struct ww_update { #define WWM_USR 0x20 /* user specified mode */ #define WWM_GLS 0x40 /* window only, glass, i.e., transparent */ - /* ww_state values */ -#define WWS_INITIAL 0 /* just opened */ -#define WWS_HASPROC 1 /* has process on pty */ -#define WWS_DEAD 3 /* child died */ - /* flags for ww_fmap */ #define WWF_U 0x01 #define WWF_R 0x02 @@ -182,16 +204,6 @@ struct ww_update { #define WWF_LABEL 0x40 #define WWF_TOP 0x80 - /* flags to wwopen() */ -#define WWO_PTY 0x01 /* want pty */ -#define WWO_SOCKET 0x02 /* want socket pair */ -#define WWO_REVERSE 0x04 /* make it all reverse video */ -#define WWO_GLASS 0x08 /* make it all glass */ -#define WWO_FRAME 0x10 /* this is a frame window */ - - /* special ww_index value */ -#define WWX_NOBODY NWW - /* error codes */ #define WWE_NOERR 0 #define WWE_SYS 1 /* system error */ @@ -206,44 +218,44 @@ struct ww_update { #define WWU_TOUCHED 0x01 /* touched */ /* the window structures */ -struct ww wwhead; -struct ww *wwindex[NWW + 1]; /* last location is for wwnobody */ -struct ww wwnobody; +EXTERN struct ww wwhead; +EXTERN struct ww *wwindex[NWW + 1]; /* last location is for wwnobody */ +EXTERN struct ww wwnobody; /* tty things */ -struct ww_tty wwoldtty; /* the old (saved) terminal settings */ -struct ww_tty wwnewtty; /* the new (current) terminal settings */ -struct ww_tty wwwintty; /* the terminal settings for windows */ -char *wwterm; /* the terminal name */ -char wwtermcap[1024]; /* place for the termcap */ +EXTERN struct ww_tty wwoldtty; /* the old (saved) terminal settings */ +EXTERN struct ww_tty wwnewtty; /* the new (current) terminal settings */ +EXTERN struct ww_tty wwwintty; /* the terminal settings for windows */ +EXTERN char *wwterm; /* the terminal name */ +EXTERN char wwtermcap[1024]; /* place for the termcap */ /* generally useful variables */ -int wwnrow, wwncol; /* the screen size */ -char wwavailmodes; /* actually supported modes */ -char wwcursormodes; /* the modes for the fake cursor */ -char wwwrap; /* terminal has auto wrap around */ -int wwdtablesize; /* result of getdtablesize() call */ -char **wwsmap; /* the screen map */ -union ww_char **wwos; /* the old (current) screen */ -union ww_char **wwns; /* the new (desired) screen */ -union ww_char **wwcs; /* the checkpointed screen */ -char *wwtouched; /* wwns changed flags */ -struct ww_update *wwupd; /* for display update */ -int wwospeed; /* output baud rate, copied from wwoldtty */ -int wwbaud; /* wwospeed converted into actual number */ -int wwcursorrow, wwcursorcol; /* where we want the cursor to be */ -int wwerrno; /* error number */ +EXTERN int wwnrow, wwncol; /* the screen size */ +EXTERN char wwavailmodes; /* actually supported modes */ +EXTERN char wwcursormodes; /* the modes for the fake cursor */ +EXTERN char wwwrap; /* terminal has auto wrap around */ +EXTERN int wwdtablesize; /* result of getdtablesize() call */ +EXTERN unsigned char **wwsmap; /* the screen map */ +EXTERN union ww_char **wwos; /* the old (current) screen */ +EXTERN union ww_char **wwns; /* the new (desired) screen */ +EXTERN union ww_char **wwcs; /* the checkpointed screen */ +EXTERN char *wwtouched; /* wwns changed flags */ +EXTERN struct ww_update *wwupd; /* for display update */ +EXTERN int wwospeed; /* output baud rate, copied from wwoldtty */ +EXTERN int wwbaud; /* wwospeed converted into actual number */ +EXTERN int wwcursorrow, wwcursorcol; /* where we want the cursor to be */ +EXTERN int wwerrno; /* error number */ /* statistics */ -int wwnflush, wwnwr, wwnwre, wwnwrz, wwnwrc; -int wwnwwr, wwnwwra, wwnwwrc; -int wwntokdef, wwntokuse, wwntokbad, wwntoksave, wwntokc; -int wwnupdate, wwnupdline, wwnupdmiss; -int wwnupdscan, wwnupdclreol, wwnupdclreos, wwnupdclreosmiss, wwnupdclreosline; -int wwnread, wwnreade, wwnreadz; -int wwnreadc, wwnreadack, wwnreadnack, wwnreadstat, wwnreadec; -int wwnwread, wwnwreade, wwnwreadz, wwnwreadd, wwnwreadc, wwnwreadp; -int wwnselect, wwnselecte, wwnselectz; +EXTERN int wwnflush, wwnwr, wwnwre, wwnwrz, wwnwrc; +EXTERN int wwnwwr, wwnwwra, wwnwwrc; +EXTERN int wwntokdef, wwntokuse, wwntokbad, wwntoksave, wwntokc; +EXTERN int wwnupdate, wwnupdline, wwnupdmiss; +EXTERN int wwnupdscan, wwnupdclreol, wwnupdclreos, wwnupdclreosmiss, wwnupdclreosline; +EXTERN int wwnread, wwnreade, wwnreadz; +EXTERN int wwnreadc, wwnreadack, wwnreadnack, wwnreadstat, wwnreadec; +EXTERN int wwnwread, wwnwreade, wwnwreadz, wwnwreadd, wwnwreadc, wwnwreadp; +EXTERN int wwnselect, wwnselecte, wwnselectz; /* quicky macros */ #define wwsetcursor(r,c) (wwcursorrow = (r), wwcursorcol = (c)) @@ -254,28 +266,27 @@ int wwnselect, wwnselecte, wwnselectz; #define wwupdate() wwupdate1(0, wwnrow); /* things for handling input */ -void wwrint(); /* interrupt handler */ -struct ww *wwcurwin; /* window to copy input into */ -char *wwib; /* input (keyboard) buffer */ -char *wwibe; /* wwib + sizeof buffer */ -char *wwibp; /* current read position in buffer */ -char *wwibq; /* current write position in buffer */ -#define wwmaskc(c) ((c) & 0xff) +EXTERN struct ww *wwcurwin; /* window to copy input into */ +EXTERN char *wwib; /* input (keyboard) buffer */ +EXTERN char *wwibe; /* wwib + sizeof buffer */ +EXTERN char *wwibp; /* current read position in buffer */ +EXTERN char *wwibq; /* current write position in buffer */ +#define wwmaskc(c) ((c) & 0x7f) #define wwgetc() (wwibp < wwibq ? wwmaskc(*wwibp++) : -1) #define wwpeekc() (wwibp < wwibq ? wwmaskc(*wwibp) : -1) #define wwungetc(c) (wwibp > wwib ? *--wwibp = (c) : -1) /* things for short circuiting wwiomux() */ -char wwintr; /* interrupting */ -char wwsetjmp; /* want a longjmp() from wwrint() and wwchild() */ -jmp_buf wwjmpbuf; /* jmpbuf for above */ +EXTERN char wwintr; /* interrupting */ +EXTERN char wwsetjmp; /* want a longjmp() from wwrint() and wwchild() */ +EXTERN jmp_buf wwjmpbuf; /* jmpbuf for above */ #define wwinterrupt() wwintr #define wwsetintr() do { wwintr = 1; if (wwsetjmp) longjmp(wwjmpbuf, 1); } \ while (0) #define wwclrintr() (wwintr = 0) /* checkpointing */ -int wwdocheckpoint; +EXTERN int wwdocheckpoint; /* the window virtual terminal */ #define WWT_TERM "window-v2" @@ -293,22 +304,89 @@ int wwdocheckpoint; #define WWT_IMEI "im=\\E@:ei=\\EO:ic=:mi:" /* XXX, ic for emacs bug */ #define WWT_IC "ic=\\EP:" #define WWT_DC "dc=\\EN:" -char wwwintermcap[1024]; /* terminal-specific but window-independent +EXTERN char wwwintermcap[1024]; /* terminal-specific but window-independent part of the window termcap */ #ifdef TERMINFO /* where to put the temporary terminfo directory */ -char wwterminfopath[1024]; +EXTERN char wwterminfopath[1024]; #endif - /* our functions */ -struct ww *wwopen(); -void wwchild(); -void wwalarm(); -void wwquit(); -char **wwalloc(); -char *wwerror(); +struct ww *wwopen(int, int, int, int, int, int, int); +void wwadd(struct ww *, struct ww *); +void wwaddcap(const char *, char **); +void wwaddcap1(const char *, char **); +void wwalarm(int); +char **wwalloc(int, int, int, int, int); +void wwbell(void); +void wwbox(struct ww *, int, int, int, int); +void wwcheckpoint(void); +void wwchild(int); +void wwclose(struct ww *); +void wwclreol1(struct ww *, int, int, char); +void wwclreos(struct ww *, int, int); +void wwcopyscreen(union ww_char **s1, union ww_char **s2); +void wwcursor(struct ww *, int); +void wwdelchar(struct ww *, int, int); +void wwdelete(struct ww *); +void wwdelete1(struct ww *, int, int, int, int); +void wwdelline(struct ww *, int); +void wwdumpns(void); +void wwdumpnvis(struct ww *); +void wwdumpos(void); +void wwdumpsmap(void); +void wwdumpwin(struct ww *); +void wwend(int); +int wwenviron(struct ww *); +const char * + wwerror(void); +void wwflush(void); +void wwframe(struct ww *, struct ww *); +void wwframec(struct ww *, int, int, char); +void wwfree(char **, int); +int wwgetpty(struct ww *); +int wwgettty(int, struct ww_tty *); +int wwgetttysize(int, int *, int *); +void wwgets(char *, int, struct ww *); +int wwinit(void); +void wwinschar(struct ww *, int, int, char, char); +void wwinsline(struct ww *, int); +void wwiomux(void); +void wwlabel(struct ww *, struct ww *, int, char *, int); +void wwmove(struct ww *, int, int); +void wwprintf(struct ww *, const char *, ...) + __attribute__((__format__(__printf__, 2, 3))); +void wwputc(char, struct ww *); +void wwputs(const char *, struct ww *); +void wwredraw(void); +void wwredrawwin1(struct ww *,int, int, int); +void wwquit(int); +void wwreset(void); +void wwrint(void); +void wwscroll(struct ww *, int); +int wwscroll1(struct ww *, int, int, int, int); +void wwsetcursormodes(int); +int wwsettty(int, struct ww_tty *); +int wwsetttysize(int, int, int); +int wwsize(struct ww *, int, int); +int wwspawn(struct ww *, char *, char **); +void wwstart(void); +void wwstart1(void); +int wwstarttty(int); +int wwstoptty(int); +void wwsuspend(void); +void wwunframe(struct ww *); +void wwupdate1(int, int); +int wwvisible(struct ww *); +void wwvprintf(struct ww *, const char *, va_list); +int wwwrite(struct ww *, const char *, int); +#ifdef TERMINFO +int wwterminfoinit(void); +int wwterminfoend(void); +#endif #undef MIN #undef MAX #define MIN(x, y) ((x) > (y) ? (y) : (x)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) + +#endif /* __WW_H__ */ diff --git a/usr.bin/window/wwadd.c b/usr.bin/window/wwadd.c index fbfd4bc4de..d505e7afd9 100644 --- a/usr.bin/window/wwadd.c +++ b/usr.bin/window/wwadd.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwadd.c,v 1.7 2003/08/07 11:17:35 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,23 +30,27 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwadd.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwadd.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwadd.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwadd.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwadd.c,v 1.7 2003/08/07 11:17:35 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" /* * Stick w1 behind w2. */ -wwadd(w1, w2) -register struct ww *w1; -struct ww *w2; +void +wwadd(struct ww *w1, struct ww *w2) { - register i; - register struct ww *w; + int i; + struct ww *w; w1->ww_order = w2->ww_order + 1; w1->ww_back = w2; @@ -59,9 +61,9 @@ struct ww *w2; for (w = w1->ww_forw; w != &wwhead; w = w->ww_forw) w->ww_order++; for (i = w1->ww_i.t; i < w1->ww_i.b; i++) { - register j; - register char *smap = wwsmap[i]; - register char *win = w1->ww_win[i]; + int j; + unsigned char *smap = wwsmap[i]; + char *win = w1->ww_win[i]; union ww_char *ns = wwns[i]; union ww_char *buf = w1->ww_buf[i]; int nvis = 0; diff --git a/usr.bin/window/wwalloc.c b/usr.bin/window/wwalloc.c index 8d862b6b02..09637b9246 100644 --- a/usr.bin/window/wwalloc.c +++ b/usr.bin/window/wwalloc.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwalloc.c,v 1.6 2003/08/07 11:17:36 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,20 +30,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwalloc.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwalloc.c,v 1.2.6.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwalloc.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwalloc.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwalloc.c,v 1.6 2003/08/07 11:17:36 agc Exp $"); +#endif +#endif /* not lint */ + #include #include "ww.h" char ** -wwalloc(row, col, nrow, ncol, size) +wwalloc(int row, int col, int nrow, int ncol, int size) { - register char *p, **pp; - register int i; + char *p, **pp; + int i; /* fast, call malloc only once */ pp = (char **) @@ -65,8 +68,8 @@ wwalloc(row, col, nrow, ncol, size) return pp - row; } -wwfree(p, row) -register char **p; +void +wwfree(char **p, int row) { free((char *)(p + row)); } diff --git a/usr.bin/window/wwbox.c b/usr.bin/window/wwbox.c index 7dfcfe6d95..40e7a79282 100644 --- a/usr.bin/window/wwbox.c +++ b/usr.bin/window/wwbox.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwbox.c,v 1.6 2003/08/07 11:17:36 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,22 +30,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwbox.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwbox.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwbox.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwbox.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwbox.c,v 1.6 2003/08/07 11:17:36 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" -wwbox(w, r, c, nr, nc) -register struct ww *w; -register r, c; -int nr, nc; +void +wwbox(struct ww *w, int r, int c, int nr, int nc) { - register r1, c1; - register i; + int r1, c1; + int i; r1 = r + nr - 1; c1 = c + nc - 1; diff --git a/usr.bin/window/wwchild.c b/usr.bin/window/wwchild.c index 2079be535d..1e4cee78e2 100644 --- a/usr.bin/window/wwchild.c +++ b/usr.bin/window/wwchild.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwchild.c,v 1.8 2006/12/18 20:04:55 christos Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,30 +30,34 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwchild.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwchild.c,v 1.1.1.1.14.2 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwchild.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ -#include "ww.h" -#include -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwchild.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwchild.c,v 1.8 2006/12/18 20:04:55 christos Exp $"); +#endif +#endif /* not lint */ + #include #include +#include +#include "ww.h" void -wwchild() +wwchild(int dummy __unused) { int olderrno; - register struct ww **wp; - union wait w; + struct ww **wp; + int status; int pid; char collected = 0; olderrno = errno; while ((pid = - wait3((int *)&w, WNOHANG|WUNTRACED, NULL)) > 0) { + wait3(&status, WNOHANG|WUNTRACED, (struct rusage *)0)) > 0) { for (wp = wwindex; wp < &wwindex[NWW]; wp++) { if (*wp && (*wp)->ww_state == WWS_HASPROC && (*wp)->ww_pid == pid) { diff --git a/usr.bin/window/wwclose.c b/usr.bin/window/wwclose.c index 08c859f7e7..ac5f25da8e 100644 --- a/usr.bin/window/wwclose.c +++ b/usr.bin/window/wwclose.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwclose.c,v 1.6 2003/08/07 11:17:36 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,16 +30,23 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwclose.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwclose.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwclose.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwclose.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwclose.c,v 1.6 2003/08/07 11:17:36 agc Exp $"); +#endif +#endif /* not lint */ + +#include +#include #include "ww.h" -wwclose(w) -register struct ww *w; +void +wwclose(struct ww *w) { wwindex[w->ww_index] = 0; if (w->ww_pty >= 0) diff --git a/usr.bin/window/wwclreol.c b/usr.bin/window/wwclreol.c index dd7052d898..d9e5a105e7 100644 --- a/usr.bin/window/wwclreol.c +++ b/usr.bin/window/wwclreol.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwclreol.c,v 1.7 2003/08/07 11:17:37 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,12 +30,17 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwclreol.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwclreol.c,v 1.2.12.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwclreol.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwclreol.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwclreol.c,v 1.7 2003/08/07 11:17:37 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" @@ -45,18 +48,16 @@ * Clear w to the end of line. * If cleared is true, then the screen line has already been cleared. */ -wwclreol1(w, row, col, cleared) -register struct ww *w; -int row, col; -char cleared; +void +wwclreol1(struct ww *w, int row, int col, char cleared) { - register i; + int i; /* * Clear the buffer right off */ { - register union ww_char *buf; + union ww_char *buf; buf = &w->ww_buf[row][col]; for (i = w->ww_b.r - col; --i >= 0;) @@ -77,8 +78,9 @@ char cleared; * Now fix wwns. */ { - register union ww_char *s; - register char *smap, *win; + union ww_char *s; + unsigned char *smap; + char *win; i = col; smap = &wwsmap[row][i]; diff --git a/usr.bin/window/wwclreos.c b/usr.bin/window/wwclreos.c index 18027ca51d..c8cb430767 100644 --- a/usr.bin/window/wwclreos.c +++ b/usr.bin/window/wwclreos.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwclreos.c,v 1.7 2003/08/07 11:17:37 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,24 +30,29 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwclreos.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwclreos.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwclreos.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwclreos.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwclreos.c,v 1.7 2003/08/07 11:17:37 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" -wwclreos(w, row, col) -register struct ww *w; +void +wwclreos(struct ww *w, int row, int col) { - register i; + int i; wwclreol(w, row, col); for (i = row + 1; i < w->ww_b.b; i++) wwclreol(w, i, w->ww_b.l); /* XXX */ - if (!w->ww_noupdate) + if (!ISSET(w->ww_wflags, WWW_NOUPDATE)) wwupdate1(w->ww_i.t, w->ww_i.b); } diff --git a/usr.bin/window/wwcursor.c b/usr.bin/window/wwcursor.c index e6f313056a..d68b1d06cd 100644 --- a/usr.bin/window/wwcursor.c +++ b/usr.bin/window/wwcursor.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwcursor.c,v 1.7 2003/08/07 11:17:37 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,27 +30,32 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwcursor.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwcursor.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwcursor.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwcursor.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwcursor.c,v 1.7 2003/08/07 11:17:37 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" -wwcursor(w, on) -register struct ww *w; +void +wwcursor(struct ww *w, int on) { - register char *win; + char *win; if (on) { - if (w->ww_hascursor) + if (ISSET(w->ww_wflags, WWW_HASCURSOR)) return; - w->ww_hascursor = 1; + SET(w->ww_wflags, WWW_HASCURSOR); } else { - if (!w->ww_hascursor) + if (!ISSET(w->ww_wflags, WWW_HASCURSOR)) return; - w->ww_hascursor = 0; + CLR(w->ww_wflags, WWW_HASCURSOR); } if (wwcursormodes != 0) { win = &w->ww_win[w->ww_cur.r][w->ww_cur.c]; @@ -71,18 +74,19 @@ register struct ww *w; } } -wwsetcursormodes(new) -register new; +void +wwsetcursormodes(int new) { - register i; - register struct ww *w; - register old = wwcursormodes; + int i; + struct ww *w; + int old = wwcursormodes; new &= wwavailmodes; if (new == wwcursormodes) return; for (i = 0; i < NWW; i++) - if (wwindex[i] != 0 && (w = wwindex[i])->ww_hascursor) { + if (wwindex[i] != 0 && + ISSET((w = wwindex[i])->ww_wflags, WWW_HASCURSOR)) { wwcursor(w, 0); wwcursormodes = new; wwcursor(w, 1); diff --git a/usr.bin/window/wwdata.c b/usr.bin/window/wwdata.c index a7279452e4..7a3054473f 100644 --- a/usr.bin/window/wwdata.c +++ b/usr.bin/window/wwdata.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwdata.c,v 1.5 2003/08/07 11:17:37 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,9 +30,13 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwdata.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwdata.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwdata.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwdata.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwdata.c,v 1.5 2003/08/07 11:17:37 agc Exp $"); +#endif +#endif /* not lint */ diff --git a/usr.bin/window/wwdelchar.c b/usr.bin/window/wwdelchar.c index 02beb7fa0e..ed70f9d064 100644 --- a/usr.bin/window/wwdelchar.c +++ b/usr.bin/window/wwdelchar.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwdelchar.c,v 1.7 2003/08/07 11:17:38 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,26 +30,32 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwdelchar.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwdelchar.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwdelchar.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwdelchar.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwdelchar.c,v 1.7 2003/08/07 11:17:38 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" +#include "xx.h" -wwdelchar(w, row, col) -register struct ww *w; +void +wwdelchar(struct ww *w, int row, int col) { - register i; + int i; int nvis; /* * First, shift the line. */ { - register union ww_char *p, *q; + union ww_char *p, *q; p = &w->ww_buf[row][col]; q = p + 1; @@ -74,10 +78,10 @@ register struct ww *w; * Now find out how much is actually changed, and fix wwns. */ { - register union ww_char *buf; - register char *win; - register union ww_char *ns; - register char *smap; + union ww_char *buf; + char *win; + union ww_char *ns; + unsigned char *smap; char touched; nvis = 0; @@ -111,7 +115,7 @@ register struct ww *w; * Can/Should we use delete character? */ if (tt.tt_delchar != 0 && nvis > (wwncol - col) / 2) { - register union ww_char *p, *q; + union ww_char *p, *q; xxdelchar(row, col); p = &wwos[row][col]; diff --git a/usr.bin/window/wwdelete.c b/usr.bin/window/wwdelete.c index 3344cb9294..9bdfc5b38b 100644 --- a/usr.bin/window/wwdelete.c +++ b/usr.bin/window/wwdelete.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwdelete.c,v 1.7 2003/08/07 11:17:38 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,27 +30,32 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwdelete.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwdelete.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwdelete.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwdelete.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwdelete.c,v 1.7 2003/08/07 11:17:38 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" /* * Pull w free from the cover list. */ -wwdelete(w) -register struct ww *w; +void +wwdelete(struct ww *w) { - register i; + int i; for (i = w->ww_i.t; i < w->ww_i.b; i++) { - register j; - register char *smap = wwsmap[i]; - register union ww_char *ns = wwns[i]; - register int nchanged = 0; + int j; + unsigned char *smap = wwsmap[i]; + union ww_char *ns = wwns[i]; + int nchanged = 0; for (j = w->ww_i.l; j < w->ww_i.r; j++) if (smap[j] == w->ww_index) { @@ -65,7 +68,7 @@ register struct ww *w; } { - register struct ww *wp; + struct ww *wp; for (wp = w->ww_forw; wp != &wwhead; wp = wp->ww_forw) wp->ww_order--; @@ -80,8 +83,8 @@ register struct ww *w; w->ww_forw = w->ww_back = 0; } -wwdelete1(w, t, b, l, r) -register struct ww *w; +void +wwdelete1(struct ww *w, int t, int b, int l, int r) { int i; int tt, bb, ll, rr; @@ -99,11 +102,11 @@ again: goto again; } for (i = tt; i < bb; i++) { - register j; - register char *smap = wwsmap[i]; - register union ww_char *ns = wwns[i]; - register char *win = w->ww_win[i]; - register union ww_char *buf = w->ww_buf[i]; + int j; + unsigned char *smap = wwsmap[i]; + union ww_char *ns = wwns[i]; + char *win = w->ww_win[i]; + union ww_char *buf = w->ww_buf[i]; int nvis = w->ww_nvis[i]; int nchanged = 0; diff --git a/usr.bin/window/wwdelline.c b/usr.bin/window/wwdelline.c index b1ad1e8c0b..604b000610 100644 --- a/usr.bin/window/wwdelline.c +++ b/usr.bin/window/wwdelline.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwdelline.c,v 1.6 2003/08/07 11:17:38 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,21 +30,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwdelline.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwdelline.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwdelline.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwdelline.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwdelline.c,v 1.6 2003/08/07 11:17:38 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" -wwdelline(w, row) -register struct ww *w; -int row; +void +wwdelline(struct ww *w, int row) { - register i; - register union ww_char **cpp, **cqq; - register union ww_char *cp; + int i; + union ww_char **cpp, **cqq; + union ww_char *cp; int row1, row2; char deleted; int visible; diff --git a/usr.bin/window/wwdump.c b/usr.bin/window/wwdump.c index 734f61ced6..c83d5d69cc 100644 --- a/usr.bin/window/wwdump.c +++ b/usr.bin/window/wwdump.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwdump.c,v 1.8 2003/08/07 11:17:38 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,24 +30,28 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwdump.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwdump.c,v 1.2.6.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwdump.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwdump.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwdump.c,v 1.8 2003/08/07 11:17:38 agc Exp $"); +#endif +#endif /* not lint */ + #include #include - #include "ww.h" #include "tt.h" static char cmap[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; -wwdumpwin(w) -register struct ww *w; +void +wwdumpwin(struct ww *w) { - register i, j; + int i, j; tt.tt_nmodes = 0; (*tt.tt_clear)(); @@ -60,10 +62,10 @@ register struct ww *w; } } -wwdumpnvis(w) -register struct ww *w; +void +wwdumpnvis(struct ww *w) { - register i; + int i; char buf[20]; tt.tt_nmodes = 0; @@ -75,9 +77,10 @@ register struct ww *w; } } -wwdumpsmap() +void +wwdumpsmap(void) { - register i, j; + int i, j; tt.tt_nmodes = 0; (*tt.tt_clear)(); @@ -88,9 +91,10 @@ wwdumpsmap() } } -wwdumpns() +void +wwdumpns(void) { - register i, j; + int i, j; (*tt.tt_clear)(); for (i = 0; i < wwnrow; i++) { @@ -102,9 +106,10 @@ wwdumpns() } } -wwdumpos() +void +wwdumpos(void) { - register i, j; + int i, j; (*tt.tt_clear)(); for (i = 0; i < wwnrow; i++) { diff --git a/usr.bin/window/wwend.c b/usr.bin/window/wwend.c index 2aec04efc6..82658294de 100644 --- a/usr.bin/window/wwend.c +++ b/usr.bin/window/wwend.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwend.c,v 1.8 2006/12/18 20:04:55 christos Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,36 +30,40 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwend.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwend.c,v 1.2.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwend.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ -#include -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwend.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwend.c,v 1.8 2006/12/18 20:04:55 christos Exp $"); +#endif +#endif /* not lint */ +#include +#include #include "ww.h" #include "tt.h" +#include "xx.h" -/*ARGSUSED*/ -wwend(exit) +void +wwend(int quit __unused) { if (tt.tt_checkpoint) { (void) alarm(0); wwdocheckpoint = 0; } xxend(); - (void) signal(SIGIO, SIG_DFL); (void) wwsettty(0, &wwoldtty); #ifdef TERMINFO - if (exit) + if (quit) wwterminfoend(); #endif } void -wwquit() +wwquit(int dummy __unused) { wwend(1); exit(1); diff --git a/usr.bin/window/wwenviron.c b/usr.bin/window/wwenviron.c index 912366a6a7..18dceae0d6 100644 --- a/usr.bin/window/wwenviron.c +++ b/usr.bin/window/wwenviron.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwenviron.c,v 1.9 2003/08/07 11:17:39 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,37 +30,45 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwenviron.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwenviron.c,v 1.2.6.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwenviron.c,v 1.3 2006/01/12 13:43:11 corecode Exp $ */ -#include - -#include "ww.h" +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwenviron.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwenviron.c,v 1.9 2003/08/07 11:17:39 agc Exp $"); +#endif +#endif /* not lint */ +#include #if !defined(OLD_TTY) && !defined(TIOCSCTTY) && !defined(TIOCNOTTY) #include #endif +#include #include +#include +#include +#include +#include "ww.h" /* * Set up the environment of this process to run in window 'wp'. */ -wwenviron(wp) -register struct ww *wp; +int +wwenviron(struct ww *wp) { - register i; + int i; #ifndef TIOCSCTTY int pgrp = getpid(); #endif char buf[1024]; + sigset_t nsigset; #ifndef TIOCSCTTY if ((i = open("/dev/tty", 0)) < 0) goto bad; - if (ioctl(i, TIOCNOTTY, NULL) < 0) + if (ioctl(i, TIOCNOTTY, (char *)0) < 0) goto bad; (void) close(i); #endif @@ -83,11 +89,12 @@ register struct ww *wp; (void) ioctl(0, TIOCSCTTY, 0); #else (void) ioctl(0, TIOCSPGRP, (char *)&pgrp); - (void) setpgrp(pgrp, pgrp); + (void) setpgid(pgrp, pgrp); #endif /* SIGPIPE is the only one we ignore */ (void) signal(SIGPIPE, SIG_DFL); - (void) sigsetmask(0); + sigemptyset(&nsigset); + sigprocmask(SIG_SETMASK, &nsigset, (sigset_t *)0); /* * Two conditions that make destructive setenv ok: * 1. setenv() copies the string, @@ -95,11 +102,9 @@ register struct ww *wp; */ (void) sprintf(buf, "%sco#%d:li#%d:%s", WWT_TERMCAP, wp->ww_w.nc, wp->ww_w.nr, wwwintermcap); - if (setenv("TERMCAP", buf, 1) == -1) - err(1, "setenv: cannot set TERMCAP=%s", buf); + (void) setenv("TERMCAP", buf, 1); (void) sprintf(buf, "%d", wp->ww_id + 1); - if (setenv("WINDOW_ID", buf, 1) == -1) - err(1, "setenv: cannot set WINDOW_ID=%s", buf); + (void) setenv("WINDOW_ID", buf, 1); return 0; bad: wwerrno = WWE_SYS; diff --git a/usr.bin/window/wwerror.c b/usr.bin/window/wwerror.c index 4bcc12d976..fd505b74b6 100644 --- a/usr.bin/window/wwerror.c +++ b/usr.bin/window/wwerror.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwerror.c,v 1.7 2003/08/07 11:17:39 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,20 +30,24 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwerror.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwerror.c,v 1.1.1.1.14.2 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwerror.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwerror.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwerror.c,v 1.7 2003/08/07 11:17:39 agc Exp $"); +#endif +#endif /* not lint */ + #include +#include #include "ww.h" -char * -wwerror() +const char * +wwerror(void) { - char *strerror(); - switch (wwerrno) { case WWE_NOERR: return "No error"; diff --git a/usr.bin/window/wwflush.c b/usr.bin/window/wwflush.c index 0373e74108..f5c35dc798 100644 --- a/usr.bin/window/wwflush.c +++ b/usr.bin/window/wwflush.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwflush.c,v 1.10 2006/12/18 20:04:55 christos Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,21 +30,28 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwflush.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwflush.c,v 1.2.6.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwflush.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwflush.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwflush.c,v 1.10 2006/12/18 20:04:55 christos Exp $"); +#endif +#endif /* not lint */ + #include #include - +#include #include "ww.h" #include "tt.h" +#include "xx.h" -wwflush() +void +wwflush(void) { - register row, col; + int row, col; if ((row = wwcursorrow) < 0) row = 0; @@ -64,9 +69,14 @@ wwflush() xxflush(1); } -wwcheckpoint() +void +wwcheckpoint(void) { - int s = sigblock(sigmask(SIGALRM) | sigmask(SIGIO)); + sigset_t nsigset, osigset; + + sigemptyset(&nsigset); + sigaddset(&nsigset, SIGALRM); + sigprocmask(SIG_BLOCK, &nsigset, &osigset); tt.tt_ack = 0; do { @@ -76,7 +86,7 @@ wwcheckpoint() #endif (void) alarm(3); for (wwdocheckpoint = 0; !wwdocheckpoint && tt.tt_ack == 0;) - (void) sigpause(s); + sigsuspend(&osigset); } while (tt.tt_ack == 0); (void) alarm(0); wwdocheckpoint = 0; @@ -90,21 +100,22 @@ wwcheckpoint() wwcopyscreen(wwos, wwcs); (void) alarm(3); } - (void) sigsetmask(s); + + sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); } -wwcopyscreen(s1, s2) - register union ww_char **s1, **s2; +void +wwcopyscreen(union ww_char **s1, union ww_char **s2) { - register i; - register s = wwncol * sizeof **s1; + int i; + int s = wwncol * sizeof **s1; for (i = wwnrow; --i >= 0;) - bcopy((char *) *s1++, (char *) *s2++, s); + memmove((char *) *s2++, (char *) *s1++, s); } void -wwalarm() +wwalarm(int dummy __unused) { wwdocheckpoint = 1; } diff --git a/usr.bin/window/wwframe.c b/usr.bin/window/wwframe.c index 15853555d0..a67c71b47f 100644 --- a/usr.bin/window/wwframe.c +++ b/usr.bin/window/wwframe.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwframe.c,v 1.7 2003/08/07 11:17:39 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,33 +30,35 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwframe.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwframe.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwframe.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwframe.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwframe.c,v 1.7 2003/08/07 11:17:39 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" #define frameok(w, r, c) (w1 = wwindex[wwsmap[r][c]], \ w1->ww_fmap || w1->ww_order > (w)->ww_order) -wwframe(w, wframe) -register struct ww *w; -struct ww *wframe; +void +wwframe(struct ww *w, struct ww *wframe) { - register r, c; + int r, c; char a1, a2, a3; char b1, b2, b3; - register char *smap; - register code; - register struct ww *w1; + int code; + struct ww *w1; if (w->ww_w.t > 0) { r = w->ww_w.t - 1; c = w->ww_i.l - 1; - smap = &wwsmap[r + 1][c + 1]; a1 = 0; a2 = 0; b1 = 0; @@ -69,7 +69,7 @@ struct ww *wframe; a3 = 1; b3 = 1; } else { - a3 = w->ww_index == *smap++; + a3 = w->ww_index == wwsmap[r + 1][c + 1]; b3 = frameok(w, r, c + 1); } if (b2) { @@ -93,7 +93,6 @@ struct ww *wframe; if (w->ww_w.b < wwnrow) { r = w->ww_w.b; c = w->ww_i.l - 1; - smap = &wwsmap[r - 1][c + 1]; a1 = 0; a2 = 0; b1 = 0; @@ -104,7 +103,7 @@ struct ww *wframe; a3 = 1; b3 = 1; } else { - a3 = w->ww_index == *smap++; + a3 = w->ww_index == wwsmap[r - 1][c + 1]; b3 = frameok(w, r, c + 1); } if (b2) { @@ -194,13 +193,11 @@ struct ww *wframe; } } -wwframec(f, r, c, code) -register struct ww *f; -register r, c; -char code; +void +wwframec(struct ww *f, int r, int c, char code) { char oldcode; - register char *smap; + unsigned char *smap; if (r < f->ww_i.t || r >= f->ww_i.b || c < f->ww_i.l || c >= f->ww_i.r) return; @@ -208,7 +205,7 @@ char code; smap = &wwsmap[r][c]; { - register struct ww *w; + struct ww *w; w = wwindex[*smap]; if (w->ww_order > f->ww_order) { @@ -219,7 +216,7 @@ char code; } if (f->ww_fmap != 0) { - register char *fmap; + char *fmap; fmap = &f->ww_fmap[r][c]; oldcode = *fmap; @@ -230,14 +227,14 @@ char code; } else oldcode = 0; { - register char *win = &f->ww_win[r][c]; + char *win = &f->ww_win[r][c]; if (*win == WWM_GLS && *smap == f->ww_index) f->ww_nvis[r]++; *win &= ~WWM_GLS; } if (oldcode != code && (code & WWF_LABEL) == 0) { - register short frame; + short frame; frame = tt.tt_frame[code & WWF_MASK]; f->ww_buf[r][c].c_w = frame; diff --git a/usr.bin/window/wwgets.c b/usr.bin/window/wwgets.c index 1eb9805dfa..f60e40212d 100644 --- a/usr.bin/window/wwgets.c +++ b/usr.bin/window/wwgets.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwgets.c,v 1.9 2003/08/07 11:17:40 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,27 +30,31 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwgets.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwgets.c,v 1.3.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwgets.c,v 1.3 2005/05/07 23:20:43 corecode Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwgets.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwgets.c,v 1.9 2003/08/07 11:17:40 agc Exp $"); +#endif +#endif /* not lint */ + +#include #include "ww.h" #include "char.h" static void rub(int, struct ww *); -wwgets(buf, n, w) -char *buf; -int n; -register struct ww *w; +void +wwgets(char *buf, int n, struct ww *w) { - register char *p = buf; - register int c; - char uc = w->ww_unctrl; + char *p = buf; + int c; + int uc = ISSET(w->ww_wflags, WWW_UNCTRL); - w->ww_unctrl = 0; + CLR(w->ww_wflags, WWW_UNCTRL); for (;;) { wwcurtowin(w); while ((c = wwgetc()) < 0) @@ -92,22 +94,18 @@ register struct ww *w; if (p >= buf + n - 1) wwputc(ctrl('g'), w); else - if (isctrl(c)) - wwputs(unctrl(*p++ = c), w); - else - wwputc(*p++ = c, w); + wwputs(unctrl(*p++ = c), w); } } *p = 0; - w->ww_unctrl = uc; + SET(w->ww_wflags, uc); } static void -rub(c, w) -struct ww *w; +rub(int c, struct ww *w) { - register i; + int i; - for (i = isctrl(c) ? strlen(unctrl(c)) : 1; --i >= 0;) + for (i = strlen(unctrl(c)); --i >= 0;) (void) wwwrite(w, "\b \b", 3); } diff --git a/usr.bin/window/wwinit.c b/usr.bin/window/wwinit.c index 4903183819..d83f5caa87 100644 --- a/usr.bin/window/wwinit.c +++ b/usr.bin/window/wwinit.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwinit.c,v 1.19 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,38 +30,49 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwinit.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwinit.c,v 1.11.2.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwinit.c,v 1.3 2006/01/12 13:43:11 corecode Exp $ */ -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwinit.c 8.2 (Berkeley) 4/28/95"; +#else +__RCSID("$NetBSD: wwinit.c,v 1.19 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include +#include +#include #include #include - #include "ww.h" #include "tt.h" +#include "xx.h" #include "char.h" -wwinit() +int +wwinit(void) { - register i, j; + int i, j; char *kp; - int s; + sigset_t nsigset, osigset; - wwdtablesize = getdtablesize(); + wwdtablesize = 3; wwhead.ww_forw = &wwhead; wwhead.ww_back = &wwhead; - s = sigblock(sigmask(SIGIO) | sigmask(SIGCHLD) | sigmask(SIGALRM) | - sigmask(SIGHUP) | sigmask(SIGTERM)); - if (signal(SIGIO, wwrint) == BADSIG || - signal(SIGCHLD, wwchild) == BADSIG || - signal(SIGHUP, wwquit) == BADSIG || - signal(SIGTERM, wwquit) == BADSIG || - signal(SIGPIPE, SIG_IGN) == BADSIG) { + sigemptyset(&nsigset); + sigaddset(&nsigset, SIGCHLD); + sigaddset(&nsigset, SIGALRM); + sigaddset(&nsigset, SIGHUP); + sigaddset(&nsigset, SIGTERM); + sigprocmask(SIG_BLOCK, &nsigset, &osigset); + + if (signal(SIGCHLD, wwchild) == SIG_ERR || + signal(SIGHUP, wwquit) == SIG_ERR || + signal(SIGTERM, wwquit) == SIG_ERR || + signal(SIGPIPE, SIG_IGN) == SIG_ERR) { wwerrno = WWE_SYS; return -1; } @@ -100,6 +109,8 @@ wwinit() #define _POSIX_VDISABLE -1 #endif wwwintty.ww_termios.c_oflag &= ~OXTABS; + wwwintty.ww_termios.c_cflag &= ~CLOCAL; + wwwintty.ww_termios.c_cflag |= HUPCL; wwnewtty.ww_termios = wwoldtty.ww_termios; wwnewtty.ww_termios.c_iflag &= ~(ISTRIP | INLCR | IGNCR | ICRNL | IXON | IXOFF | IMAXBEL); @@ -109,10 +120,9 @@ wwinit() wwnewtty.ww_termios.c_lflag = 0; for (i = 0; i < NCCS; i++) wwnewtty.ww_termios.c_cc[i] = _POSIX_VDISABLE; - wwnewtty.ww_termios.c_cc[VMIN] = 0; + wwnewtty.ww_termios.c_cc[VMIN] = 1; wwnewtty.ww_termios.c_cc[VTIME] = 0; #endif - wwnewtty.ww_fflags = wwoldtty.ww_fflags | FASYNC; if (wwsettty(0, &wwnewtty) < 0) goto bad; @@ -125,11 +135,16 @@ wwinit() goto bad; } #ifdef OLD_TTY - ospeed = wwoldtty.ww_sgttyb.sg_ospeed; - switch (ospeed) { + wwospeed = wwoldtty.ww_sgttyb.sg_ospeed; +#else + wwospeed = cfgetospeed(&wwoldtty.ww_termios); + wwbaud = wwospeed; +#endif + switch (wwospeed) { default: case B0: - goto bad; + wwbaud = 9600; + break; case B50: wwbaud = 50; break; @@ -194,11 +209,6 @@ wwinit() break; #endif } -#else - if ((wwbaud = cfgetospeed(&wwoldtty.ww_termios)) == B0) - goto bad; -#endif - wwospeed = ospeed; if (xxinit() < 0) goto bad; @@ -208,7 +218,7 @@ wwinit() wwwrap = tt.tt_wrap; if (wwavailmodes & WWM_REV) - wwcursormodes = WWM_REV | wwavailmodes & WWM_BLK; + wwcursormodes = WWM_REV | (wwavailmodes & WWM_BLK); else if (wwavailmodes & WWM_UL) wwcursormodes = WWM_UL; @@ -217,7 +227,9 @@ wwinit() wwibe = wwib + 512; wwibq = wwibp = wwib; - if ((wwsmap = wwalloc(0, 0, wwnrow, wwncol, sizeof (char))) == 0) + wwsmap = (unsigned char **) + wwalloc(0, 0, wwnrow, wwncol, sizeof (unsigned char)); + if (wwsmap == 0) goto bad; for (i = 0; i < wwnrow; i++) for (j = 0; j < wwncol; j++) @@ -273,7 +285,7 @@ wwinit() wwaddcap1(WWT_DIM, &kp); if (wwavailmodes & WWM_USR) wwaddcap1(WWT_USR, &kp); - if (tt.tt_insline && tt.tt_delline || tt.tt_setscroll) + if ((tt.tt_insline && tt.tt_delline) || tt.tt_setscroll) wwaddcap1(WWT_ALDL, &kp); if (tt.tt_inschar) wwaddcap1(WWT_IMEI, &kp); @@ -282,10 +294,10 @@ wwinit() if (tt.tt_delchar) wwaddcap1(WWT_DC, &kp); wwaddcap("kb", &kp); - wwaddcap2("ku", &kp); - wwaddcap2("kd", &kp); - wwaddcap2("kl", &kp); - wwaddcap2("kr", &kp); + wwaddcap("ku", &kp); + wwaddcap("kd", &kp); + wwaddcap("kl", &kp); + wwaddcap("kr", &kp); wwaddcap("kh", &kp); if ((j = tgetnum("kn")) >= 0) { char cap[32]; @@ -305,49 +317,47 @@ wwinit() * since tt_init() has already made its own copy of it and * wwterm now points to the copy. */ - if (setenv("TERM", WWT_TERM, 1) == -1) - err(1, "setenv: cannot set TERM=%s", WWT_TERM); + (void) setenv("TERM", WWT_TERM, 1); #ifdef TERMINFO if (wwterminfoinit() < 0) goto bad; #endif if (tt.tt_checkpoint) - if (signal(SIGALRM, wwalarm) == BADSIG) { + if (signal(SIGALRM, wwalarm) == SIG_ERR) { wwerrno = WWE_SYS; goto bad; } - fcntl(0, F_SETOWN, getpid()); - /* catch typeahead before ASYNC was set */ - (void) kill(getpid(), SIGIO); wwstart1(); - (void) sigsetmask(s); + + sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); return 0; + bad: /* * Don't bother to free storage. We're supposed * to exit when wwinit fails anyway. */ - (void) signal(SIGIO, SIG_DFL); (void) wwsettty(0, &wwoldtty); - (void) sigsetmask(s); + + sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); return -1; } -wwaddcap(cap, kp) - register char *cap; - register char **kp; +void +wwaddcap(const char *cap, char **kp) { char tbuf[512]; char *tp = tbuf; - register char *str, *p; + char *str; + const char *p; if ((str = tgetstr(cap, &tp)) != 0) { - while (*(*kp)++ = *cap++) + while ((*(*kp)++ = *cap++)) ; (*kp)[-1] = '='; while (*str) { - for (p = unctrl(*str++); *(*kp)++ = *p++;) + for (p = unctrl(*str++); (*(*kp)++ = *p++);) ; (*kp)--; } @@ -356,54 +366,29 @@ wwaddcap(cap, kp) } } -wwaddcap1(cap, kp) - register char *cap; - register char **kp; +void +wwaddcap1(const char *cap, char **kp) { - while (*(*kp)++ = *cap++) + while ((*(*kp)++ = *cap++)) ; (*kp)--; } -wwaddcap2(cap, kp) - register char *cap; - register char **kp; -{ - char tbuf[512]; - char *tp = tbuf; - register char *str, *p; - - if ((str = tgetstr(cap, &tp)) != 0) { - /* we don't support vt100's application key mode, remap */ - if (str[0] == ctrl('[') && str[1] == 'O') - str[1] = '['; - while (*(*kp)++ = *cap++) - ; - (*kp)[-1] = '='; - while (*str) { - for (p = unctrl(*str++); *(*kp)++ = *p++;) - ; - (*kp)--; - } - *(*kp)++ = ':'; - **kp = 0; - } -} - -wwstart() +void +wwstart(void) { - register i; + int i; (void) wwsettty(0, &wwnewtty); - signal(SIGIO, wwrint); for (i = 0; i < wwnrow; i++) wwtouched[i] = WWU_TOUCHED; wwstart1(); } -wwstart1() +void +wwstart1(void) { - register i, j; + int i, j; for (i = 0; i < wwnrow; i++) for (j = 0; j < wwncol; j++) { @@ -420,9 +405,10 @@ wwstart1() * Reset data structures and terminal from an unknown state. * Restoring wwos has been taken care of elsewhere. */ -wwreset() +void +wwreset(void) { - register i; + int i; xxreset(); for (i = 0; i < wwnrow; i++) diff --git a/usr.bin/window/wwinschar.c b/usr.bin/window/wwinschar.c index 3d3412fce0..aea243843d 100644 --- a/usr.bin/window/wwinschar.c +++ b/usr.bin/window/wwinschar.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwinschar.c,v 1.7 2003/08/07 11:17:40 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,20 +30,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwinschar.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwinschar.c,v 1.2.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwinschar.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwinschar.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwinschar.c,v 1.7 2003/08/07 11:17:40 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" +#include "xx.h" -wwinschar(w, row, col, c, m) -register struct ww *w; -unsigned char c, m; +void +wwinschar(struct ww *w, int row, int col, char c, char m) { - register i; + int i; int nvis; short x = c | m << WWC_MSHIFT; @@ -53,7 +56,7 @@ unsigned char c, m; * First, shift the line. */ { - register union ww_char *p, *q; + union ww_char *p, *q; p = &w->ww_buf[row][w->ww_b.r]; q = p - 1; @@ -76,10 +79,10 @@ unsigned char c, m; * Now find out how much is actually changed, and fix wwns. */ { - register union ww_char *buf; - register char *win; - register union ww_char *ns; - register char *smap; + union ww_char *buf; + char *win; + union ww_char *ns; + unsigned char *smap; char touched; nvis = 0; @@ -113,7 +116,7 @@ unsigned char c, m; * Can/Should we use delete character? */ if ((tt.tt_inschar || tt.tt_insspace) && nvis > (wwncol - col) / 2) { - register union ww_char *p, *q; + union ww_char *p, *q; if (tt.tt_inschar) xxinschar(row, col, c, m); diff --git a/usr.bin/window/wwinsline.c b/usr.bin/window/wwinsline.c index 2db3b6a6a8..17c97af8a0 100644 --- a/usr.bin/window/wwinsline.c +++ b/usr.bin/window/wwinsline.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwinsline.c,v 1.6 2003/08/07 11:17:40 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,21 +30,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwinsline.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwinsline.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwinsline.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwinsline.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwinsline.c,v 1.6 2003/08/07 11:17:40 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" -wwinsline(w, row) -register struct ww *w; -int row; +void +wwinsline(struct ww *w, int row) { - register i; - register union ww_char **cpp, **cqq; - register union ww_char *cp; + int i; + union ww_char **cpp, **cqq; + union ww_char *cp; int row1, row2; char deleted; int visible; diff --git a/usr.bin/window/wwiomux.c b/usr.bin/window/wwiomux.c index ecf87bdb32..f75474d6af 100644 --- a/usr.bin/window/wwiomux.c +++ b/usr.bin/window/wwiomux.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwiomux.c,v 1.14 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,42 +30,54 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwiomux.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwiomux.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwiomux.c,v 1.3 2008/05/19 10:19:49 corecode Exp $ */ -#include "ww.h" -#include +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwiomux.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwiomux.c,v 1.14 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include -#include #if !defined(OLD_TTY) && !defined(TIOCPKT_DATA) #include #endif +#include +#include +#include #include +#include +#include +#include +#include "ww.h" /* * Multiple window output handler. * The idea is to copy window outputs to the terminal, via the * display package. We try to give wwcurwin highest priority. * The only return conditions are when there is keyboard input - * and when a child process dies, which are serviced by signal - * catchers (wwrint() and wwchild()). + * and when a child process dies. * When there's nothing to do, we sleep in a select(). - * This can be done better with interrupt driven io. But that's - * not supported on ptys, yet. * The history of this routine is interesting. */ -wwiomux() +void +wwiomux(void) { - register struct ww *w; - fd_set imask; - register n; - register char *p; - char c; - struct timeval tv; + struct ww *w; + nfds_t nfd; + int i; + int volatile dostdin; /* avoid longjmp clobbering */ + char volatile c; /* avoid longjmp clobbering */ + char *p; + int millis; char noblock = 0; + static struct pollfd *pfd = NULL; + static nfds_t maxfds = 0; + + c = 0; /* XXXGCC -Wuninitialized */ for (;;) { if (wwinterrupt()) { @@ -75,19 +85,48 @@ wwiomux() return; } - FD_ZERO(&imask); - n = -1; + nfd = 0; + for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw) { + if (w->ww_pty < 0 || w->ww_obq >= w->ww_obe) + continue; + nfd++; + } + + if (maxfds <= ++nfd) { /* One more for the fd=0 case below */ + struct pollfd *npfd = pfd == NULL ? + malloc(sizeof(*pfd) * nfd) : + realloc(pfd, sizeof(*pfd) * nfd); + if (npfd == NULL) { + warn("will retry"); + if (pfd) + free(pfd); + pfd = NULL; + maxfds = 0; + return; + } + pfd = npfd; + maxfds = nfd; + } + + nfd = 0; for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw) { if (w->ww_pty < 0) continue; if (w->ww_obq < w->ww_obe) { - if (w->ww_pty > n) - n = w->ww_pty; - FD_SET(w->ww_pty, &imask); + pfd[nfd].fd = w->ww_pty; + pfd[nfd++].events = POLLIN; } - if (w->ww_obq > w->ww_obp && !w->ww_stopped) + if (w->ww_obq > w->ww_obp && + !ISSET(w->ww_pflags, WWP_STOPPED)) noblock = 1; } + if (wwibq < wwibe) { + dostdin = nfd; + pfd[nfd].fd = 0; + pfd[nfd++].events = POLLIN; + } else { + dostdin = -1; + } if (!noblock) { if (wwcurwin != 0) @@ -101,39 +140,37 @@ wwiomux() wwclrintr(); return; } - /* - * Defensive code. If somebody else (for example, - * wall) clears the ASYNC flag on us, we will block - * forever. So we need a finite timeout and set - * the flag again. Anything more clever will probably - * need even more system calls. (This is a bug - * in the kernel.) - * I don't like this one bit. - */ - (void) fcntl(0, F_SETFL, wwnewtty.ww_fflags); - tv.tv_sec = 30; - tv.tv_usec = 0; + /* XXXX */ + millis = 30000; } else { - tv.tv_sec = 0; - tv.tv_usec = 10000; + millis = 10; } wwnselect++; - n = select(n + 1, &imask, NULL, NULL, &tv); + i = poll(pfd, nfd, millis); wwsetjmp = 0; noblock = 0; - if (n < 0) + if (i < 0) wwnselecte++; - else if (n == 0) + else if (i == 0) wwnselectz++; - else + else { + if (dostdin != -1 && (pfd[dostdin].revents & POLLIN) != 0) + wwrint(); + + nfd = 0; for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw) { - if (w->ww_pty < 0 || - !FD_ISSET(w->ww_pty, &imask)) + int n; + + if (w->ww_pty < 0) + continue; + if (w->ww_pty != pfd[nfd].fd) + continue; + if ((pfd[nfd++].revents & POLLIN) == 0) continue; wwnwread++; p = w->ww_obq; - if (w->ww_ispty) { + if (w->ww_type == WWT_PTY) { if (p == w->ww_ob) { w->ww_obp++; w->ww_obq++; @@ -150,7 +187,7 @@ wwiomux() wwnwreadz++; (void) close(w->ww_pty); w->ww_pty = -1; - } else if (!w->ww_ispty) { + } else if (w->ww_type != WWT_PTY) { wwnwreadd++; wwnwreadc += n; w->ww_obq += n; @@ -162,18 +199,19 @@ wwiomux() } else { wwnwreadp++; if (*p & TIOCPKT_STOP) - w->ww_stopped = 1; + SET(w->ww_pflags, WWP_STOPPED); if (*p & TIOCPKT_START) - w->ww_stopped = 0; + CLR(w->ww_pflags, WWP_STOPPED); if (*p & TIOCPKT_FLUSHWRITE) { - w->ww_stopped = 0; + CLR(w->ww_pflags, WWP_STOPPED); w->ww_obq = w->ww_obp = w->ww_ob; } } - if (w->ww_ispty) + if (w->ww_type == WWT_PTY) *p = c; } + } /* * Try the current window first, if there is output * then process it and go back to the top to try again. @@ -183,8 +221,9 @@ wwiomux() * dies down. */ if ((w = wwcurwin) != 0 && w->ww_pty >= 0 && - w->ww_obq > w->ww_obp && !w->ww_stopped) { - n = wwwrite(w, w->ww_obp, w->ww_obq - w->ww_obp); + w->ww_obq > w->ww_obp && + !ISSET(w->ww_pflags, WWP_STOPPED)) { + int n = wwwrite(w, w->ww_obp, w->ww_obq - w->ww_obp); if ((w->ww_obp += n) == w->ww_obq) w->ww_obq = w->ww_obp = w->ww_ob; noblock = 1; @@ -192,8 +231,8 @@ wwiomux() } for (w = wwhead.ww_forw; w != &wwhead; w = w->ww_forw) if (w->ww_pty >= 0 && w->ww_obq > w->ww_obp && - !w->ww_stopped) { - n = wwwrite(w, w->ww_obp, + !ISSET(w->ww_pflags, WWP_STOPPED)) { + int n = wwwrite(w, w->ww_obp, w->ww_obq - w->ww_obp); if ((w->ww_obp += n) == w->ww_obq) w->ww_obq = w->ww_obp = w->ww_ob; diff --git a/usr.bin/window/wwlabel.c b/usr.bin/window/wwlabel.c index b2146c340b..8a54d2d8f1 100644 --- a/usr.bin/window/wwlabel.c +++ b/usr.bin/window/wwlabel.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwlabel.c,v 1.8 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,12 +30,17 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwlabel.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwlabel.c,v 1.3.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwlabel.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwlabel.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwlabel.c,v 1.8 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "char.h" @@ -46,22 +49,19 @@ * at 1 line above w and 'where' columns from it's left edge. * Gross, but it works. */ -wwlabel(w, f, where, l, mode) -struct ww *w; -struct ww *f; -char *l; +void +wwlabel(struct ww *w, struct ww *f, int where, char *l, int mode) { int row; - register j; + int j; int jj; - register char *win; - register union ww_char *buf; - register union ww_char *ns; - register char *fmap; - register char *smap; + char *win; + union ww_char *buf; + union ww_char *ns; + char *fmap; + unsigned char *smap; char touched; - unsigned char *p; - static unsigned char cbuf[2]; + const char *p; if (f->ww_fmap == 0) return; @@ -79,14 +79,8 @@ char *l; jj = MIN(w->ww_i.r, f->ww_i.r); j = w->ww_i.l + where; - while (j < jj && *l) { - if (isctrl(*l)) - p = unctrl(*l); - else { - cbuf[0] = *l; - p = cbuf; - } - for (l++; j < jj && *p; j++, p++) { + while (j < jj && *l) + for (p = unctrl(*l++); j < jj && *p; j++, p++) { /* can't label if not already framed */ if (win[j] & WWM_GLS) continue; @@ -99,6 +93,5 @@ char *l; } fmap[j] |= WWF_LABEL; } - } wwtouched[row] = touched; } diff --git a/usr.bin/window/wwmisc.c b/usr.bin/window/wwmisc.c index b7db34fd93..c48e04b10f 100644 --- a/usr.bin/window/wwmisc.c +++ b/usr.bin/window/wwmisc.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwmisc.c,v 1.7 2003/08/07 11:17:41 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,12 +30,17 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwmisc.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwmisc.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwmisc.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwmisc.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwmisc.c,v 1.7 2003/08/07 11:17:41 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" #include "char.h" @@ -45,15 +48,15 @@ /* * Sufficient but not necessary test for total visibility. */ -wwvisible(w) -register struct ww *w; +int +wwvisible(struct ww *w) { - register i; - register nvis = 0; + int i; + int nvis = 0; for (i = w->ww_i.t; i < w->ww_i.b; i++) nvis += w->ww_nvis[i]; - if (w->ww_hascursor + if (ISSET(w->ww_wflags, WWW_HASCURSOR) && w->ww_cur.r >= w->ww_i.t && w->ww_cur.r < w->ww_i.b && w->ww_cur.c >= w->ww_i.l && w->ww_cur.c < w->ww_i.r && wwsmap[w->ww_cur.r][w->ww_cur.c] == w->ww_index) @@ -61,7 +64,8 @@ register struct ww *w; return nvis == w->ww_i.nr * w->ww_i.nc; } -wwbell() +void +wwbell(void) { ttputc(ctrl('g')); } diff --git a/usr.bin/window/wwmove.c b/usr.bin/window/wwmove.c index b0d351b062..e6d17ed874 100644 --- a/usr.bin/window/wwmove.c +++ b/usr.bin/window/wwmove.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwmove.c,v 1.7 2003/08/07 11:17:42 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,22 +30,27 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwmove.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwmove.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwmove.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwmove.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwmove.c,v 1.7 2003/08/07 11:17:42 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" /* * Move a window. Should be unattached. */ -wwmove(w, row, col) -register struct ww *w; +void +wwmove(struct ww *w, int row, int col) { - register dr, dc; - register i; + int dr, dc; + int i; dr = row - w->ww_w.t; dc = col - w->ww_w.l; @@ -82,9 +85,9 @@ register struct ww *w; } w->ww_nvis -= dr; for (i = w->ww_i.t; i < w->ww_i.b; i++) { - register j = w->ww_i.l; - register char *win = &w->ww_win[i][j]; - register char *smap = &wwsmap[i][j]; + int j = w->ww_i.l; + char *win = &w->ww_win[i][j]; + unsigned char *smap = &wwsmap[i][j]; int nvis = 0; for (; j < w->ww_i.r; j++, win++, smap++) diff --git a/usr.bin/window/wwopen.c b/usr.bin/window/wwopen.c index e5fe407a13..9825f9b533 100644 --- a/usr.bin/window/wwopen.c +++ b/usr.bin/window/wwopen.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwopen.c,v 1.12 2003/08/07 11:17:42 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,27 +30,33 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwopen.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwopen.c,v 1.2.12.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwopen.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ -#include "ww.h" +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwopen.c 8.2 (Berkeley) 4/28/95"; +#else +__RCSID("$NetBSD: wwopen.c,v 1.12 2003/08/07 11:17:42 agc Exp $"); +#endif +#endif /* not lint */ + #include #include #include #include +#include +#include "ww.h" struct ww * -wwopen(flags, nrow, ncol, row, col, nline) +wwopen(int type, int oflags, int nrow, int ncol, int row, int col, int nline) { - register struct ww *w; - register i, j; + struct ww *w; + int i, j; char m; short nvis; - w = (struct ww *)calloc(sizeof (struct ww), 1); + w = (struct ww *)calloc(1, sizeof (struct ww)); if (w == 0) { wwerrno = WWE_NOMEM; goto bad; @@ -95,13 +99,16 @@ wwopen(flags, nrow, ncol, row, col, nline) w->ww_cur.r = w->ww_w.t; w->ww_cur.c = w->ww_w.l; - if (flags & WWO_PTY) { + w->ww_type = type; + switch (type) { + case WWT_PTY: if (wwgetpty(w) < 0) goto bad; - w->ww_ispty = 1; - } else if (flags & WWO_SOCKET) { + break; + case WWT_SOCKET: + { int d[2]; - if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, d) < 0) { + if (socketpair(AF_LOCAL, SOCK_STREAM, PF_UNSPEC, d) < 0) { wwerrno = WWE_SYS; goto bad; } @@ -109,14 +116,18 @@ wwopen(flags, nrow, ncol, row, col, nline) (void) fcntl(d[1], F_SETFD, 1); w->ww_pty = d[0]; w->ww_socket = d[1]; + break; + } } - if (flags & (WWO_PTY|WWO_SOCKET)) { + if (type != WWT_INTERNAL) { if ((w->ww_ob = malloc(512)) == 0) { wwerrno = WWE_NOMEM; goto bad; } w->ww_obe = w->ww_ob + 512; w->ww_obp = w->ww_obq = w->ww_ob; + if (w->ww_pty >= wwdtablesize) + wwdtablesize = w->ww_pty + 1; } w->ww_win = wwalloc(w->ww_w.t, w->ww_w.l, @@ -124,18 +135,18 @@ wwopen(flags, nrow, ncol, row, col, nline) if (w->ww_win == 0) goto bad; m = 0; - if (flags & WWO_GLASS) + if (oflags & WWO_GLASS) m |= WWM_GLS; - if (flags & WWO_REVERSE) + if (oflags & WWO_REVERSE) { if (wwavailmodes & WWM_REV) m |= WWM_REV; - else - flags &= ~WWO_REVERSE; + else oflags &= ~WWO_REVERSE; + } for (i = w->ww_w.t; i < w->ww_w.b; i++) for (j = w->ww_w.l; j < w->ww_w.r; j++) w->ww_win[i][j] = m; - if (flags & WWO_FRAME) { + if (oflags & WWO_FRAME) { w->ww_fmap = wwalloc(w->ww_w.t, w->ww_w.l, w->ww_w.nr, w->ww_w.nc, sizeof (char)); if (w->ww_fmap == 0) @@ -165,7 +176,8 @@ wwopen(flags, nrow, ncol, row, col, nline) w->ww_nvis[i] = nvis; w->ww_state = WWS_INITIAL; - w->ww_oflags = flags; + CLR(w->ww_oflags, WWO_ALLFLAGS); + SET(w->ww_oflags, oflags); return wwindex[w->ww_index] = w; bad: if (w != 0) { diff --git a/usr.bin/window/wwprintf.c b/usr.bin/window/wwprintf.c index b6d068972e..27baeae821 100644 --- a/usr.bin/window/wwprintf.c +++ b/usr.bin/window/wwprintf.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwprintf.c,v 1.6 2003/08/07 11:17:42 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,23 +30,33 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwprintf.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwprintf.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwprintf.c,v 1.3 2004/01/24 22:40:58 joerg Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwprintf.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwprintf.c,v 1.6 2003/08/07 11:17:42 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" -#include -/*VARARGS2*/ -wwprintf(struct ww *w, char *fmt, ...) +void +wwprintf(struct ww *w, const char *fmt, ...) { - char buf[1024]; va_list ap; va_start(ap, fmt); - /* buffer can overflow */ - (void) wwwrite(w, buf, vsprintf(buf, fmt, ap)); + (void) wwvprintf(w, fmt, ap); va_end(ap); } + +void +wwvprintf(struct ww *w, const char *fmt, va_list ap) +{ + char buf[1024]; + + (void) wwwrite(w, buf, vsnprintf(buf, sizeof(buf), fmt, ap)); +} diff --git a/usr.bin/window/wwpty.c b/usr.bin/window/wwpty.c index de66ebb558..ea926f6e92 100644 --- a/usr.bin/window/wwpty.c +++ b/usr.bin/window/wwpty.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwpty.c,v 1.8 2003/08/07 11:17:42 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,59 +30,38 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwpty.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwpty.c,v 1.2.2.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwpty.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ -#include -#include - -#include "ww.h" +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwpty.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwpty.c,v 1.8 2003/08/07 11:17:42 agc Exp $"); +#endif +#endif /* not lint */ #if !defined(OLD_TTY) && !defined(TIOCPKT) #include #endif +#include +#include +#include "ww.h" -wwgetpty(w) -register struct ww *w; +int +wwgetpty(struct ww *w) { - register char c, *p; - int tty; int on = 1; -#define PTY "/dev/XtyXX" -#define _PT 5 -#define _PQRS 8 -#define _0_9 9 + int result, tty; - (void) strcpy(w->ww_ttyname, PTY); - for (c = 'p'; c <= 'u'; c++) { - w->ww_ttyname[_PT] = 'p'; - w->ww_ttyname[_PQRS] = c; - w->ww_ttyname[_0_9] = '0'; - if (access(w->ww_ttyname, 0) < 0) - break; - for (p = "0123456789abcdefghijklmnopqrstuv"; *p; p++) { - w->ww_ttyname[_PT] = 'p'; - w->ww_ttyname[_0_9] = *p; - if ((w->ww_pty = open(w->ww_ttyname, 2)) < 0) - continue; - w->ww_ttyname[_PT] = 't'; - if ((tty = open(w->ww_ttyname, 2)) < 0) { - (void) close(w->ww_pty); - continue; - } - (void) close(tty); - if (ioctl(w->ww_pty, TIOCPKT, (char *)&on) < 0) { - (void) close(w->ww_pty); - continue; - } - (void) fcntl(w->ww_pty, F_SETFD, 1); - return 0; - } + result = openpty(&w->ww_pty, &tty, w->ww_ttyname, NULL, NULL); + if (result < 0) { + w->ww_pty = -1; + wwerrno = WWE_NOPTY; + return -1; + } else { + (void) ioctl(w->ww_pty, TIOCPKT, (char *)&on); + (void) fcntl(w->ww_pty, F_SETFD, 1); + return 0; } - w->ww_pty = -1; - wwerrno = WWE_NOPTY; - return -1; } diff --git a/usr.bin/window/wwputc.c b/usr.bin/window/wwputc.c index 34fe1bfd1e..0d8619c4d0 100644 --- a/usr.bin/window/wwputc.c +++ b/usr.bin/window/wwputc.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwputc.c,v 1.6 2003/08/07 11:17:43 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,17 +30,21 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwputc.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwputc.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwputc.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwputc.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwputc.c,v 1.6 2003/08/07 11:17:43 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" -wwputc(c, w) -char c; -struct ww *w; +void +wwputc(char c, struct ww *w) { (void) wwwrite(w, &c, sizeof c); } diff --git a/usr.bin/window/wwputs.c b/usr.bin/window/wwputs.c index b6ec2409e6..408189d2a9 100644 --- a/usr.bin/window/wwputs.c +++ b/usr.bin/window/wwputs.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwputs.c,v 1.7 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,19 +30,23 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwputs.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwputs.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwputs.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwputs.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwputs.c,v 1.7 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" -wwputs(s, w) -register char *s; -struct ww *w; +void +wwputs(const char *s, struct ww *w) { - register char *p = s; + const char *p = s; while (*p++) ; diff --git a/usr.bin/window/wwredraw.c b/usr.bin/window/wwredraw.c index ff523dfa21..45e80d7853 100644 --- a/usr.bin/window/wwredraw.c +++ b/usr.bin/window/wwredraw.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwredraw.c,v 1.6 2003/08/07 11:17:43 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,19 +30,26 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwredraw.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwredraw.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwredraw.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwredraw.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwredraw.c,v 1.6 2003/08/07 11:17:43 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" +#include "xx.h" -wwredraw() +void +wwredraw(void) { - register i, j; - register union ww_char *os; + int i, j; + union ww_char *os; xxclear(); for (i = 0; i < wwnrow; i++) { diff --git a/usr.bin/window/wwredrawwin.c b/usr.bin/window/wwredrawwin.c index c7ff064740..055f5235c3 100644 --- a/usr.bin/window/wwredrawwin.c +++ b/usr.bin/window/wwredrawwin.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwredrawwin.c,v 1.7 2003/08/07 11:17:44 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,24 +30,28 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwredrawwin.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwredrawwin.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwredrawwin.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwredrawwin.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwredrawwin.c,v 1.7 2003/08/07 11:17:44 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" -wwredrawwin1(w, row1, row2, offset) -register struct ww *w; -int row1, row2, offset; +void +wwredrawwin1(struct ww *w, int row1, int row2, int offset) { int row; - register col; - register char *smap; - register union ww_char *buf; - register char *win; - register union ww_char *ns; + int col; + unsigned char *smap; + union ww_char *buf; + char *win; + union ww_char *ns; int x; int nchanged; diff --git a/usr.bin/window/wwrint.c b/usr.bin/window/wwrint.c index fedb6909bb..94266b1cd9 100644 --- a/usr.bin/window/wwrint.c +++ b/usr.bin/window/wwrint.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwrint.c,v 1.7 2003/08/07 11:17:44 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,17 +30,20 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwrint.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwrint.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwrint.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwrint.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwrint.c,v 1.7 2003/08/07 11:17:44 agc Exp $"); +#endif +#endif /* not lint */ + +#include #include "ww.h" #include "tt.h" -#if defined(OLD_TTY) || defined(VMIN_BUG) -#include -#endif /* * Tty input interrupt handler. @@ -55,21 +56,12 @@ * It should be completely safe. */ void -wwrint() +wwrint(void) { - register n; + int n; - if (wwibp == wwibq) - wwibp = wwibq = wwib; wwnread++; -#if defined(OLD_TTY) || defined(VMIN_BUG) - /* we have set c_cc[VMIN] to 0 */ - (void) fcntl(0, F_SETFL, O_NONBLOCK|wwnewtty.ww_fflags); -#endif n = read(0, wwibq, wwibe - wwibq); -#if defined(OLD_TTY) || defined(VMIN_BUG) - (void) fcntl(0, F_SETFL, wwnewtty.ww_fflags); -#endif if (n > 0) { if (tt.tt_rint) n = (*tt.tt_rint)(wwibq, n); diff --git a/usr.bin/window/wwscroll.c b/usr.bin/window/wwscroll.c index d66fbe9866..bff11107ed 100644 --- a/usr.bin/window/wwscroll.c +++ b/usr.bin/window/wwscroll.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwscroll.c,v 1.7 2003/08/07 11:17:44 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,21 +30,28 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwscroll.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwscroll.c,v 1.1.1.1.14.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwscroll.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwscroll.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwscroll.c,v 1.7 2003/08/07 11:17:44 agc Exp $"); +#endif +#endif /* not lint */ + +#include + #include "ww.h" #include "tt.h" +#include "xx.h" -wwscroll(w, n) -register struct ww *w; -int n; +void +wwscroll(struct ww *w, int n) { - register dir; - register top; + int dir; + int top; if (n == 0) return; @@ -77,12 +82,10 @@ int n; * Don't adjust ww_scroll. * And don't redraw 'leaveit' lines. */ -wwscroll1(w, row1, row2, dir, leaveit) -register struct ww *w; -int row1, row2, dir; -int leaveit; +int +wwscroll1(struct ww *w, int row1, int row2, int dir, int leaveit) { - register i; + int i; int row1x, row2x; int nvis; int nvismax; @@ -117,8 +120,8 @@ int leaveit; if (nvis < nvismax / 2) goto no_scroll; /* not worth it */ if ((dir > 0 ? tt.tt_scroll_down == 0 : tt.tt_scroll_up == 0) || - (tt.tt_scroll_top != row1x || tt.tt_scroll_bot != row2x - 1) && - tt.tt_setscroll == 0) + ((tt.tt_scroll_top != row1x || tt.tt_scroll_bot != row2x - 1) && + tt.tt_setscroll == 0)) if (tt.tt_delline == 0 || tt.tt_insline == 0) goto no_scroll; xxscroll(dir, row1x, row2x); @@ -127,8 +130,8 @@ int leaveit; * Fix up the old screen. */ { - register union ww_char *tmp; - register union ww_char **cpp, **cqq; + union ww_char *tmp; + union ww_char **cpp, **cqq; if (dir > 0) { cpp = &wwos[row1x]; @@ -159,8 +162,8 @@ no_scroll: */ if (dir > 0) { { - register union ww_char *tmp; - register union ww_char **cpp, **cqq; + union ww_char *tmp; + union ww_char **cpp, **cqq; cpp = &wwns[row1x]; cqq = cpp + 1; @@ -170,7 +173,7 @@ no_scroll: *cpp = tmp; } if (scrolled) { - register char *p, *q; + char *p, *q; p = &wwtouched[row1x]; q = p + 1; @@ -178,7 +181,7 @@ no_scroll: *p++ = *q++; *p |= WWU_TOUCHED; } else { - register char *p; + char *p; p = &wwtouched[row1x]; for (i = row2x - row1x; --i >= 0;) @@ -188,8 +191,8 @@ no_scroll: wwredrawwin1(w, row2x - 1, row2 - leaveit, dir); } else { { - register union ww_char *tmp; - register union ww_char **cpp, **cqq; + union ww_char *tmp; + union ww_char **cpp, **cqq; cpp = &wwns[row2x]; cqq = cpp - 1; @@ -199,7 +202,7 @@ no_scroll: *cqq = tmp; } if (scrolled) { - register char *p, *q; + char *p, *q; p = &wwtouched[row2x]; q = p - 1; @@ -207,7 +210,7 @@ no_scroll: *--p = *--q; *q |= WWU_TOUCHED; } else { - register char *p; + char *p; p = &wwtouched[row1x]; for (i = row2x - row1x; --i >= 0;) @@ -218,7 +221,7 @@ no_scroll: } } else { if (scrolled) { - register char *p; + char *p; p = &wwtouched[row1x]; for (i = row2x - row1x; --i >= 0;) diff --git a/usr.bin/window/wwsize.c b/usr.bin/window/wwsize.c index 1f9c5713e0..23bbe1a25a 100644 --- a/usr.bin/window/wwsize.c +++ b/usr.bin/window/wwsize.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwsize.c,v 1.9 2006/05/02 22:24:05 christos Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,23 +30,28 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwsize.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwsize.c,v 1.2.6.1 2001/05/17 09:45:01 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwsize.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwsize.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwsize.c,v 1.9 2006/05/02 22:24:05 christos Exp $"); +#endif +#endif /* not lint */ + #include #include "ww.h" /* * Resize a window. Should be unattached. */ -wwsize(w, nrow, ncol) -register struct ww *w; +int +wwsize(struct ww *w, int nrow, int ncol) { - register i, j; - int nline; + int i, j; + int nline = 0; union ww_char **buf = 0; char **win = 0; short *nvis = 0; @@ -169,14 +172,14 @@ register struct ww *w; /* * Put cursor back. */ - if (w->ww_hascursor) { - w->ww_hascursor = 0; + if (ISSET(w->ww_wflags, WWW_HASCURSOR)) { + CLR(w->ww_wflags, WWW_HASCURSOR); wwcursor(w, 1); } /* * Fool with pty. */ - if (w->ww_ispty && w->ww_pty >= 0) + if (w->ww_type == WWT_PTY && w->ww_pty >= 0) (void) wwsetttysize(w->ww_pty, nrow, ncol); return 0; bad: @@ -186,7 +189,5 @@ bad: wwfree(fmap, w->ww_w.t); if (buf != 0) wwfree((char **)buf, w->ww_b.t); - if (nvis != 0) - free((char *)(nvis + w->ww_w.t)); return -1; } diff --git a/usr.bin/window/wwspawn.c b/usr.bin/window/wwspawn.c index e1df53efd8..4038275603 100644 --- a/usr.bin/window/wwspawn.c +++ b/usr.bin/window/wwspawn.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwspawn.c,v 1.10 2006/12/18 20:04:55 christos Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,32 +30,39 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwspawn.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwspawn.c,v 1.4.2.1 2001/05/17 09:45:02 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwspawn.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwspawn.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwspawn.c,v 1.10 2006/12/18 20:04:55 christos Exp $"); +#endif +#endif /* not lint */ + #include #include - #include "ww.h" /* * There is a dead lock with vfork and closing of pseudo-ports. * So we have to be sneaky about error reporting. */ -wwspawn(wp, file, argv) -register struct ww *wp; -char *file; -char **argv; +int +wwspawn(struct ww *wp, char *file, char **argv) { int pid; int ret; - char erred = 0; - int s; + char volatile erred; + sigset_t nsigset, osigset; + + erred = 0; + + sigemptyset(&nsigset); + sigaddset(&nsigset, SIGCHLD); + sigprocmask(SIG_BLOCK, &nsigset, &osigset); - s = sigblock(sigmask(SIGCHLD)); switch (pid = vfork()) { case -1: wwerrno = WWE_SYS; @@ -78,7 +83,9 @@ char **argv; ret = pid; } } - (void) sigsetmask(s); + + sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); + if (wp->ww_socket >= 0) { (void) close(wp->ww_socket); wp->ww_socket = -1; diff --git a/usr.bin/window/wwsuspend.c b/usr.bin/window/wwsuspend.c index d36b74162c..96e30c559e 100644 --- a/usr.bin/window/wwsuspend.c +++ b/usr.bin/window/wwsuspend.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwsuspend.c,v 1.6 2003/08/07 11:17:45 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,17 +30,23 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwsuspend.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwsuspend.c,v 1.2.6.1 2001/05/17 09:45:02 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwsuspend.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwsuspend.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwsuspend.c,v 1.6 2003/08/07 11:17:45 agc Exp $"); +#endif +#endif /* not lint */ + +#include #include "ww.h" #include "tt.h" -#include -wwsuspend() +void +wwsuspend(void) { sig_t oldsig; diff --git a/usr.bin/window/wwterminfo.c b/usr.bin/window/wwterminfo.c index 48520b59cb..de38f13efb 100644 --- a/usr.bin/window/wwterminfo.c +++ b/usr.bin/window/wwterminfo.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwterminfo.c,v 1.5 2003/08/07 11:17:45 agc Exp $ */ + /* * Copyright (c) 1982, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,18 +30,29 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwterminfo.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwterminfo.c,v 1.3.6.2 2001/05/17 19:40:13 eric Exp $ - * $DragonFly: src/usr.bin/window/wwterminfo.c,v 1.3 2006/01/12 13:43:11 corecode Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwterminfo.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwterminfo.c,v 1.5 2003/08/07 11:17:45 agc Exp $"); +#endif +#endif /* not lint */ + #ifdef TERMINFO -#include "ww.h" +#include +#include +#include + #include +#include #include +#include #include "local.h" +#include "ww.h" /* * Terminfo support @@ -56,6 +65,7 @@ /* * Initialize the working terminfo directory */ +int wwterminfoinit() { FILE *fp; @@ -63,13 +73,12 @@ wwterminfoinit() /* make the directory */ (void) sprintf(wwterminfopath, "%swwinXXXXXX", _PATH_TMP); - if (mkdtemp(wwterminfopath) < 0 || - chmod(wwterminfopath, 00755) < 0) { + if (mkdtemp(wwterminfopath) == NULL) || + chmod(wwterminfopath, 0755) < 0) { wwerrno = WWE_SYS; return -1; } - if (setenv("TERMINFO", wwterminfopath, 1) == -1) - err(1, "setenv: cannot set TERMINFO=%s", wwterminfopath); + (void) setenv("TERMINFO", wwterminfopath, 1); /* make a termcap entry and turn it into terminfo */ (void) sprintf(buf, "%s/cap", wwterminfopath); if ((fp = fopen(buf, "w")) == NULL) { @@ -89,24 +98,25 @@ wwterminfoinit() /* * Delete the working terminfo directory at shutdown */ +int wwterminfoend() { - char *args[4]; - args[0] = _PATH_RM; - args[1] = "-rf"; - args[2] = wwterminfopath; - args[3] = NULL; - switch (vfork()) { + int pstat; + pid_t pid; + + pid = vfork(); + switch (pid) { case -1: /* can't really do (or say) anything about errors */ return -1; case 0: - execv(args[0], args); - _exit(0); - default: - wait(NULL); - return 0; + execl(_PATH_RM, _PATH_RM, "-rf", wwterminfopath, 0); + _exit(1); } + pid = waitpid(pid, &pstat, 0); + if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0) + return -1; + return 0; } #endif /* TERMINFO */ diff --git a/usr.bin/window/wwtty.c b/usr.bin/window/wwtty.c index 59a6cc67e2..ef2475cc8f 100644 --- a/usr.bin/window/wwtty.c +++ b/usr.bin/window/wwtty.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwtty.c,v 1.7 2003/08/07 11:17:46 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,21 +30,26 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwtty.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwtty.c,v 1.1.1.1.14.1 2001/05/17 09:45:02 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwtty.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ -#include "ww.h" +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwtty.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwtty.c,v 1.7 2003/08/07 11:17:46 agc Exp $"); +#endif +#endif /* not lint */ + #include -#include #if !defined(OLD_TTY) && !defined(TIOCGWINSZ) #include #endif +#include +#include "ww.h" -wwgettty(d, t) -register struct ww_tty *t; +int +wwgettty(int d, struct ww_tty *t) { #ifdef OLD_TTY if (ioctl(d, TIOCGETP, (char *)&t->ww_sgttyb) < 0) @@ -63,8 +66,6 @@ register struct ww_tty *t; if (tcgetattr(d, &t->ww_termios) < 0) goto bad; #endif - if ((t->ww_fflags = fcntl(d, F_GETFL, 0)) < 0) - goto bad; return 0; bad: wwerrno = WWE_SYS; @@ -76,8 +77,8 @@ bad: * 'o' is the current modes. We set the line discipline only if * it changes, to avoid unnecessary flushing of typeahead. */ -wwsettty(d, t) -register struct ww_tty *t; +int +wwsettty(int d, struct ww_tty *t) { #ifdef OLD_TTY int i; @@ -106,8 +107,6 @@ register struct ww_tty *t; if (tcsetattr(d, TCSADRAIN, &t->ww_termios) < 0) goto bad; #endif - if (fcntl(d, F_SETFL, t->ww_fflags) < 0) - goto bad; return 0; bad: wwerrno = WWE_SYS; @@ -119,8 +118,8 @@ bad: * on the control side of pseudoterminals. */ -wwgetttysize(d, r, c) - int *r, *c; +int +wwgetttysize(int d, int *r, int *c) { struct winsize winsize; @@ -135,7 +134,8 @@ wwgetttysize(d, r, c) return 0; } -wwsetttysize(d, r, c) +int +wwsetttysize(int d, int r, int c) { struct winsize winsize; @@ -149,13 +149,14 @@ wwsetttysize(d, r, c) return 0; } -wwstoptty(d) +int +wwstoptty(int d) { #if !defined(OLD_TTY) && defined(TCOOFF) /* not guaranteed to work on the pty side */ if (tcflow(d, TCOOFF) < 0) #else - if (ioctl(d, TIOCSTOP, NULL) < 0) + if (ioctl(d, TIOCSTOP, (char *)0) < 0) #endif { wwerrno = WWE_SYS; @@ -164,13 +165,14 @@ wwstoptty(d) return 0; } -wwstarttty(d) +int +wwstarttty(int d) { #if !defined(OLD_TTY) && defined(TCOON) /* not guaranteed to work on the pty side */ if (tcflow(d, TCOON) < 0) #else - if (ioctl(d, TIOCSTART, NULL) < 0) + if (ioctl(d, TIOCSTART, (char *)0) < 0) #endif { wwerrno = WWE_SYS; diff --git a/usr.bin/window/wwunframe.c b/usr.bin/window/wwunframe.c index 34be86102c..a241cbfc4f 100644 --- a/usr.bin/window/wwunframe.c +++ b/usr.bin/window/wwunframe.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwunframe.c,v 1.7 2003/08/07 11:17:46 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,25 +30,30 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwunframe.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwunframe.c,v 1.1.1.1.14.1 2001/05/17 09:45:02 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwunframe.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwunframe.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwunframe.c,v 1.7 2003/08/07 11:17:46 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" -wwunframe(w) -register struct ww *w; +void +wwunframe(struct ww *w) { int i; for (i = w->ww_i.t; i < w->ww_i.b; i++) { - register j; - register char *win = w->ww_win[i]; - register char *fmap = w->ww_fmap ? w->ww_fmap[i] : 0; - register char *smap = wwsmap[i]; - register union ww_char *ns = wwns[i]; + int j; + char *win = w->ww_win[i]; + char *fmap = w->ww_fmap ? w->ww_fmap[i] : 0; + unsigned char *smap = wwsmap[i]; + union ww_char *ns = wwns[i]; int nchanged = 0; for (j = w->ww_i.l; j < w->ww_i.r; j++) { diff --git a/usr.bin/window/wwupdate.c b/usr.bin/window/wwupdate.c index acfbdcec8e..f0759167a3 100644 --- a/usr.bin/window/wwupdate.c +++ b/usr.bin/window/wwupdate.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwupdate.c,v 1.6 2003/08/07 11:17:46 agc Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,19 +30,26 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwupdate.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwupdate.c,v 1.1.1.1.14.1 2001/05/17 09:45:02 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwupdate.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwupdate.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwupdate.c,v 1.6 2003/08/07 11:17:46 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" +#include "xx.h" -wwupdate1(top, bot) +void +wwupdate1(int top, int bot) { int i; - register j; + int j; char *touched; struct ww_update *upd; char check_clreos = 0; @@ -52,8 +57,8 @@ wwupdate1(top, bot) wwnupdate++; { - register char *t1 = wwtouched + top, *t2 = wwtouched + bot; - register n; + char *t1 = wwtouched + top, *t2 = wwtouched + bot; + int n; while (!*t1++) if (t1 == t2) @@ -77,7 +82,7 @@ wwupdate1(top, bot) * If we can't clreos then we try for clearing * the whole screen. */ - if (check_clreos = n * 10 > (wwnrow - st) * 9) { + if ((check_clreos = n * 10 > (wwnrow - st) * 9)) { scan_top = st; scan_bot = wwnrow; } @@ -88,10 +93,10 @@ wwupdate1(top, bot) for (i = scan_top, touched = &wwtouched[i], upd = &wwupd[i]; i < scan_bot; i++, touched++, upd++) { - register gain = 0; - register best_gain = 0; - register best_col; - register union ww_char *ns, *os; + int gain = 0; + int best_gain = 0; + int best_col = 0; + union ww_char *ns, *os; if (wwinterrupt()) return; @@ -127,11 +132,11 @@ wwupdate1(top, bot) upd->gain = gain; } if (check_clreos) { - register struct ww_update *u; - register gain = 0; - register best_gain = 0; - int best_row; - register simple_gain = 0; + struct ww_update *u; + int gain = 0; + int best_gain = 0; + int best_row = 0; + int simple_gain = 0; char didit = 0; /* @@ -143,7 +148,7 @@ wwupdate1(top, bot) * undefined when u->best_gain is 0 so we can't use it. */ for (j = scan_bot - 1, u = wwupd + j; j >= top; j--, u--) { - register g = gain + u->best_gain; + int g = gain + u->best_gain; if (g > best_gain) { best_gain = g; @@ -173,7 +178,7 @@ wwupdate1(top, bot) wwnupdclreosline += wwnrow - i; u = wwupd + i; while (i < scan_bot) { - register union ww_char *os = &wwos[i][j]; + union ww_char *os = &wwos[i][j]; for (j = wwncol - j; --j >= 0;) os++->c_w = ' '; @@ -187,7 +192,7 @@ wwupdate1(top, bot) simple: for (i = top, touched = &wwtouched[i], upd = &wwupd[i]; i < bot; i++, touched++, upd++) { - register union ww_char *os, *ns; + union ww_char *os, *ns; char didit; if (!*touched) @@ -205,10 +210,10 @@ simple: ns = wwns[i]; os = wwos[i]; for (j = 0; j < wwncol;) { - register char *p, *q; + char *p, *q; char m; int c; - register n; + int n; char buf[512]; /* > wwncol */ union ww_char lastc; diff --git a/usr.bin/window/wwwrite.c b/usr.bin/window/wwwrite.c index 28c5576985..6cfe5cfd79 100644 --- a/usr.bin/window/wwwrite.c +++ b/usr.bin/window/wwwrite.c @@ -1,3 +1,5 @@ +/* $NetBSD: wwwrite.c,v 1.9 2009/04/14 08:50:06 lukem Exp $ */ + /* * Copyright (c) 1983, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,19 +30,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)wwwrite.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/wwwrite.c,v 1.2.14.1 2001/05/17 09:45:02 obrien Exp $ - * $DragonFly: src/usr.bin/window/wwwrite.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)wwwrite.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: wwwrite.c,v 1.9 2009/04/14 08:50:06 lukem Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "tt.h" +#include "xx.h" #include "char.h" #define UPDATE() \ - if (!w->ww_noupdate && w->ww_cur.r >= 0 && w->ww_cur.r < wwnrow && \ - wwtouched[w->ww_cur.r]) \ + if (!ISSET(w->ww_wflags, WWW_NOUPDATE) && w->ww_cur.r >= 0 && \ + w->ww_cur.r < wwnrow && wwtouched[w->ww_cur.r]) \ wwupdate1(w->ww_cur.r, w->ww_cur.r + 1) /* @@ -56,23 +60,23 @@ * p and q. Essentially, we implement a stack of depth 2, * to avoid recursion, which might be a better idea. */ -wwwrite(w, p, n) -register struct ww *w; -register unsigned char *p; -int n; +int +wwwrite(struct ww *w, const char *p, int n) { - char hascursor; - unsigned char *savep = p; - unsigned char *q = p + n; - char *r = 0; - char *s; + int hascursor; + const char *savep = p; + const char *q = p + n; + const char *r = 0; + const char *s = 0; #ifdef lint s = 0; /* define it before possible use */ #endif - if (hascursor = w->ww_hascursor) + hascursor = ISSET(w->ww_wflags, WWW_HASCURSOR); + if (hascursor) wwcursor(w, 0); - while (p < q && !w->ww_stopped && (!wwinterrupt() || w->ww_nointr)) { + while (p < q && !ISSET(w->ww_pflags, WWP_STOPPED) && + (!wwinterrupt() || ISSET(w->ww_wflags, WWW_NOINTR))) { if (r && !*p) { p = r; q = s; @@ -80,16 +84,18 @@ int n; continue; } if (w->ww_wstate == 0 && - (isprt(*p) || w->ww_unctrl && isunctrl(*p))) { - register i; - register union ww_char *bp; + (isprt(*p) || + (ISSET(w->ww_wflags, WWW_UNCTRL) && isunctrl(*p)))) { + int i; + union ww_char *bp; int col, col1; - if (w->ww_insert) { /* this is very slow */ + if (ISSET(w->ww_wflags, WWW_INSERT)) { + /* this is very slow */ if (*p == '\t') { p++; w->ww_cur.c += 8 - - (w->ww_cur.c - w->ww_w.l & 7); + ((w->ww_cur.c - w->ww_w.l) & 7); goto chklf; } if (!isprt(*p)) { @@ -111,7 +117,7 @@ int n; q = s; r = 0; } else if (*p == '\t') { - register tmp = 8 - (i - w->ww_w.l & 7); + int tmp = 8 - ((i - w->ww_w.l) & 7); p++; i += tmp; bp += tmp; @@ -119,7 +125,8 @@ int n; bp++->c_w = *p++ | w->ww_modes << WWC_MSHIFT; i++; - } else if (w->ww_unctrl && isunctrl(*p)) { + } else if (ISSET(w->ww_wflags, WWW_UNCTRL) && + isunctrl(*p)) { r = p + 1; s = q; p = unctrl(*p); @@ -131,9 +138,10 @@ int n; w->ww_cur.c = i; if (w->ww_cur.r >= w->ww_i.t && w->ww_cur.r < w->ww_i.b) { - register union ww_char *ns = wwns[w->ww_cur.r]; - register char *smap = &wwsmap[w->ww_cur.r][col]; - register char *win = w->ww_win[w->ww_cur.r]; + union ww_char *ns = wwns[w->ww_cur.r]; + unsigned char *smap = + &wwsmap[w->ww_cur.r][col]; + char *win = w->ww_win[w->ww_cur.r]; int nchanged = 0; bp = w->ww_buf[w->ww_cur.r]; @@ -153,7 +161,7 @@ int n; case 0: switch (*p++) { case '\n': - if (w->ww_mapnl) + if (ISSET(w->ww_wflags, WWW_MAPNL)) crlf: w->ww_cur.c = w->ww_w.l; lf: @@ -191,7 +199,7 @@ int n; w->ww_wstate = 0; switch (*p++) { case '@': - w->ww_insert = 1; + SET(w->ww_wflags, WWW_INSERT); break; case 'A': up: @@ -244,7 +252,7 @@ int n; wwdelchar(w, w->ww_cur.r, w->ww_cur.c); break; case 'O': - w->ww_insert = 0; + CLR(w->ww_wflags, WWW_INSERT); break; case 'P': wwinschar(w, w->ww_cur.r, w->ww_cur.c, ' ', 0); diff --git a/usr.bin/window/xx.c b/usr.bin/window/xx.c index 1de9abbb77..5e66e17e29 100644 --- a/usr.bin/window/xx.c +++ b/usr.bin/window/xx.c @@ -1,3 +1,5 @@ +/* $NetBSD: xx.c,v 1.7 2003/08/07 11:17:46 agc Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,20 +30,27 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)xx.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/xx.c,v 1.2.12.1 2001/05/17 09:45:02 obrien Exp $ - * $DragonFly: src/usr.bin/window/xx.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)xx.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: xx.c,v 1.7 2003/08/07 11:17:46 agc Exp $"); +#endif +#endif /* not lint */ + #include #include - -#include "ww.h" +#define EXTERN #include "xx.h" +#undef EXTERN +#include "defs.h" #include "tt.h" -xxinit() +int +xxinit(void) { if (ttinit() < 0) return -1; @@ -63,7 +68,8 @@ xxinit() return 0; } -xxstart() +void +xxstart(void) { (*tt.tt_start)(); if (tt.tt_ntoken > 0) @@ -71,7 +77,8 @@ xxstart() xxreset1(); /* might be a restart */ } -xxreset() +void +xxreset(void) { if (tt.tt_ntoken > 0) ccreset(); @@ -79,9 +86,10 @@ xxreset() (*tt.tt_reset)(); } -xxreset1() +void +xxreset1(void) { - register struct xx *xp, *xq; + struct xx *xp, *xq; for (xp = xx_head; xp != 0; xp = xq) { xq = xp->link; @@ -91,7 +99,8 @@ xxreset1() xxbufp = xxbuf; } -xxend() +void +xxend(void) { if (tt.tt_scroll_top != 0 || tt.tt_scroll_bot != tt.tt_nrow - 1) /* tt.tt_setscroll is known to be defined */ @@ -108,9 +117,9 @@ xxend() } struct xx * -xxalloc() +xxalloc(void) { - register struct xx *xp; + struct xx *xp; if (xxbufp > xxbufe) abort(); @@ -128,16 +137,17 @@ xxalloc() return xp; } -xxfree(xp) - register struct xx *xp; +void +xxfree(struct xx *xp) { xp->link = xx_freelist; xx_freelist = xp; } -xxmove(row, col) +void +xxmove(int row, int col) { - register struct xx *xp = xx_tail; + struct xx *xp = xx_tail; if (xp == 0 || xp->cmd != xc_move) { xp = xxalloc(); @@ -147,13 +157,14 @@ xxmove(row, col) xp->arg1 = col; } -xxscroll(dir, top, bot) +void +xxscroll(int dir, int top, int bot) { - register struct xx *xp = xx_tail; + struct xx *xp = xx_tail; if (xp != 0 && xp->cmd == xc_scroll && xp->arg1 == top && xp->arg2 == bot && - (xp->arg0 < 0 && dir < 0 || xp->arg0 > 0 && dir > 0)) { + ((xp->arg0 < 0 && dir < 0) || (xp->arg0 > 0 && dir > 0))) { xp->arg0 += dir; return; } @@ -164,9 +175,10 @@ xxscroll(dir, top, bot) xp->arg2 = bot; } -xxinschar(row, col, c, m) +void +xxinschar(int row, int col, int c, int m) { - register struct xx *xp; + struct xx *xp; xp = xxalloc(); xp->cmd = xc_inschar; @@ -176,9 +188,10 @@ xxinschar(row, col, c, m) xp->arg3 = m; } -xxinsspace(row, col) +void +xxinsspace(int row, int col) { - register struct xx *xp = xx_tail; + struct xx *xp = xx_tail; if (xp != 0 && xp->cmd == xc_insspace && xp->arg0 == row && col >= xp->arg1 && col <= xp->arg1 + xp->arg2) { @@ -192,9 +205,10 @@ xxinsspace(row, col) xp->arg2 = 1; } -xxdelchar(row, col) +void +xxdelchar(int row, int col) { - register struct xx *xp = xx_tail; + struct xx *xp = xx_tail; if (xp != 0 && xp->cmd == xc_delchar && xp->arg0 == row && xp->arg1 == col) { @@ -208,37 +222,40 @@ xxdelchar(row, col) xp->arg2 = 1; } -xxclear() +void +xxclear(void) { - register struct xx *xp; + struct xx *xp; xxreset1(); xp = xxalloc(); xp->cmd = xc_clear; } -xxclreos(row, col) +void +xxclreos(int row, int col) { - register struct xx *xp = xxalloc(); + struct xx *xp = xxalloc(); xp->cmd = xc_clreos; xp->arg0 = row; xp->arg1 = col; } -xxclreol(row, col) +void +xxclreol(int row, int col) { - register struct xx *xp = xxalloc(); + struct xx *xp = xxalloc(); xp->cmd = xc_clreol; xp->arg0 = row; xp->arg1 = col; } -xxwrite(row, col, p, n, m) - char *p; +void +xxwrite(int row, int col, char *p, int n, int m) { - register struct xx *xp; + struct xx *xp; if (xxbufp + n + 1 > xxbufe) xxflush(0); @@ -249,7 +266,7 @@ xxwrite(row, col, p, n, m) xp->arg2 = n; xp->arg3 = m; xp->buf = xxbufp; - bcopy(p, xxbufp, n); + memmove(xxbufp, p, n); xxbufp += n; *xxbufp++ = char_sep; } diff --git a/usr.bin/window/xx.h b/usr.bin/window/xx.h index ebb98d6ccd..c4d9caf2e9 100644 --- a/usr.bin/window/xx.h +++ b/usr.bin/window/xx.h @@ -1,3 +1,5 @@ +/* $NetBSD: xx.h,v 1.7 2003/08/07 11:17:47 agc Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,10 +32,12 @@ * SUCH DAMAGE. * * @(#)xx.h 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/xx.h,v 1.1.1.1.14.1 2001/05/17 09:45:02 obrien Exp $ - * $DragonFly: src/usr.bin/window/xx.h,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#ifndef EXTERN +#define EXTERN extern +#endif + struct xx { enum { xc_move, xc_scroll, xc_inschar, xc_insspace, xc_delchar, xc_clear, xc_clreos, xc_clreol, xc_write } cmd; @@ -49,12 +49,29 @@ struct xx { struct xx *link; }; -struct xx *xxalloc(); +EXTERN struct xx *xx_head, *xx_tail; +EXTERN struct xx *xx_freelist; -struct xx *xx_head, *xx_tail; -struct xx *xx_freelist; - -char *xxbuf, *xxbufp, *xxbufe; -int xxbufsize; +EXTERN char *xxbuf, *xxbufp, *xxbufe; +EXTERN int xxbufsize; #define char_sep '\0' + +struct xx *xxalloc(void); +void xxclear(void); +void xxclreol(int, int); +void xxclreos(int, int); +void xxdelchar(int, int); +void xxend(void); +void xxflush(int); +void xxflush_scroll(struct xx *); +void xxfree(struct xx *); +int xxinit(void); +void xxinschar(int, int, int, int); +void xxinsspace(int, int); +void xxmove(int, int); +void xxreset(void); +void xxreset1(void); +void xxscroll(int, int, int); +void xxstart(void); +void xxwrite(int, int, char *, int, int); diff --git a/usr.bin/window/xxflush.c b/usr.bin/window/xxflush.c index 8dd2f2f703..71feef53a7 100644 --- a/usr.bin/window/xxflush.c +++ b/usr.bin/window/xxflush.c @@ -1,3 +1,5 @@ +/* $NetBSD: xxflush.c,v 1.6 2003/08/07 11:17:47 agc Exp $ */ + /* * Copyright (c) 1989, 1993 * The Regents of the University of California. All rights reserved. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -32,20 +30,25 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. - * - * @(#)xxflush.c 8.1 (Berkeley) 6/6/93 - * $FreeBSD: src/usr.bin/window/xxflush.c,v 1.1.1.1.14.1 2001/05/17 09:45:02 obrien Exp $ - * $DragonFly: src/usr.bin/window/xxflush.c,v 1.2 2003/06/17 04:29:34 dillon Exp $ */ +#include +#ifndef lint +#if 0 +static char sccsid[] = "@(#)xxflush.c 8.1 (Berkeley) 6/6/93"; +#else +__RCSID("$NetBSD: xxflush.c,v 1.6 2003/08/07 11:17:47 agc Exp $"); +#endif +#endif /* not lint */ + #include "ww.h" #include "xx.h" #include "tt.h" -xxflush(intr) - register intr; +void +xxflush(int intr) { - register struct xx *xp, *xq; + struct xx *xp, *xq; for (xp = xx_head; xp != 0 && !(intr && wwinterrupt()); xp = xq) { switch (xp->cmd) { @@ -96,10 +99,10 @@ xxflush(intr) ttflush(); } -xxflush_scroll(xp) - register struct xx *xp; +void +xxflush_scroll(struct xx *xp) { - register struct xx *xq; + struct xx *xq; top: if (xp->arg0 == 0) -- 2.41.0