Raise WARNS to 6.
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 <bsd.prog.mk>
* 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.
*
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
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
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.
+/* $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.
* 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.
*
* 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
#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;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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",
+/* $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.
* 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.
*
* 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 $
*/
/*
* using unctrl() by wwwrite() if ww_unctrl is set.
*/
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-
-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)
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <unistd.h>
#include "defs.h"
#include "char.h"
-docmd()
+int checkproc(struct ww *);
+
+void
+docmd(void)
{
- register c;
+ int c;
struct ww *w;
char out = 0;
}
struct ww *
-getwin()
+getwin(void)
{
int c;
struct ww *w = 0;
return w;
}
-checkproc(w)
-struct ww *w;
+int
+checkproc(struct ww *w)
{
if (w->ww_state != WWS_HASPROC) {
error("No process in window.");
return 0;
}
-setcmd(new)
-char new;
+void
+setcmd(char new)
{
if (new && !incmd) {
if (!terse)
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;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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;
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;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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",
": 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",
0
};
-c_help()
+int help_print(struct ww *, const char *, const char **);
+
+void
+c_help(void)
{
struct ww *w;
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)
return more(w, 1) == 2 ? -1 : 0;
}
-c_quit()
+void
+c_quit(void)
{
char oldterse = terse;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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)
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);
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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];
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.");
}
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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;
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;
/*
* 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;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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();
}
}
-#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());
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
+}
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <stdlib.h>
+#include <unistd.h>
#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;
};
struct yb *yb_head, *yb_tail;
-c_yank()
+void
+c_yank(void)
{
struct ww *w = selwin;
int col1, row1;
}
break;
}
- if (row2 < row1 || row2 == row1 && col2 < col1) {
+ if (row2 < row1 || (row2 == row1 && col2 < col1)) {
r = row1;
c = col1;
row1 = row2;
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;
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;
}
}
-unyank()
+void
+unyank(void)
{
struct yb *yp, *yq;
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;
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)
yb_head = yb_tail = yp;
}
-c_put()
+void
+c_put(void)
{
struct yb *yp;
+/* $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.
* 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.
*
* 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 <stdio.h>
+#include <sys/cdefs.h>
+#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 <fcntl.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-
-#include "ww.h"
+#include "defs.h"
#include "tt.h"
+ /* special */
int cc_trace = 0;
FILE *cc_trace_fp;
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 */
#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; \
#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 */
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;
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] =
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);
return -1;
}
-ccstart()
+void
+ccstart(void)
{
- int ccflush();
-
ttflush();
tt_obp = tt_ob = cc_buffer;
tt_obe = tt_ob + cc_bufsize;
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();
}
}
-ccflush()
+void
+ccflush(void)
{
int bufsize = tt_obp - tt_ob;
int n;
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
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++;
}
}
-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;
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;
}
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;
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);
#ifndef cc_weight
p->weight = cc_weight;
#endif
- p->time = time;
+ p->time = time0;
p->bcount = 1;
p->ccount = 0;
p->flag = 0;
#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) {
#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;
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 */
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);
}
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++)
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
#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;
}
}
-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
do {
int score;
- register struct cc_undo *undop;
+ struct cc_undo *undop;
int ccount;
#ifdef STATS
int ncover;
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;
continue;
undo:
while (--undop >= undop1)
- if (*undop->pos = x = undop->val)
+ if ((*undop->pos = x = undop->val))
x->ccount++;
undop++;
}
#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++;
}
}
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) {
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;
}
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <fcntl.h>
#include <stdlib.h>
-
-#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;
return 0;
}
-cx_free()
+void
+cx_free(void)
{
struct context *xp;
cx.x_type = 0;
}
-cx_beginfile(filename)
-char *filename;
+int
+cx_beginfile(char *filename)
{
if (cx_alloc() < 0)
return -1;
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;
return 0;
}
-cx_end()
+void
+cx_end(void)
{
switch (cx.x_type) {
case X_BUF:
+/* $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.
* 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.
*
* 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 <stdio.h>
+#ifndef EXTERN
+#define EXTERN extern
+#endif
+
struct context {
struct context *x_link; /* nested contexts */
char x_type; /* tag for union */
#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 */
+/* $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.
* 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.
*
* 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 <sys/time.h>
+#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 *);
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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;
if (terse)
wwbell();
else {
- wwprintf(cmdwin, fmt, a, b, c, d, e, f, g, h);
+ wwvprintf(cmdwin, fmt, ap);
wwputs(" ", cmdwin);
}
return;
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;
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)
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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[];
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;
return 0;
}
-dosource(filename)
-char *filename;
+int
+dosource(char *filename)
{
if (cx_beginfile(filename) < 0)
return -1;
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;
+/* $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.
* 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.
*
* 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;
};
#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 *);
+/* $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.
* 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.
*
* 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 <stdio.h>
-#include <string.h> /* System string definitions. */
-
+#include <sys/cdefs.h>
+#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 <string.h>
+#include <unistd.h>
#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 },
{ "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;
*pp = a->v_str;
*pp = 0;
shf = *(sh = argv);
- if (*sh = strrchr(shf, '/'))
+ if ((*sh = strrchr(shf, '/')))
(*sh)++;
else
*sh = shf;
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;
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;
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;
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;
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;
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];
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;
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;
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;
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) {
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;
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;
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) {
}
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:
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:
return def;
}
/*NOTREACHED*/
+ return (0);
}
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <sys/types.h>
+#include <sys/time.h>
#include <sys/resource.h>
-
-#include <stdio.h>
-#include <string.h> /* System string definitions. */
-
+#include <string.h>
#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;
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);
}
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--;
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++)
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);
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;
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);
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;
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++)
}
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;
}
}
-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);
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);
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;
+/* $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.
* 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.
*
* 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 $
*/
/*
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <err.h>
#include <paths.h>
-#include <locale.h>
#include <stdio.h>
-#include <string.h> /* System string definitions. */
-#include "mystring.h" /* Local string definitions. */
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#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;
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)
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;
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();
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 */
}
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <sys/param.h>
+#include <unistd.h>
#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 */
+/* $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.
* 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.
*
* 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);
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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;
}
}
-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:
}
}
-p_if(flag)
-char flag;
+int
+p_if(char flag)
{
struct value t;
char true = 0;
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:
return 0;
}
-p_convstr(v)
-register struct value *v;
+int
+p_convstr(struct value *v)
{
if (v->v_type != V_NUM)
return 0;
return 0;
}
-p_synerror()
+void
+p_synerror(void)
{
if (!cx.x_synerred) {
cx.x_synerred = cx.x_erred = 1;
}
}
-/*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.");
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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;
}
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
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;
}
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 {
p_memerror();
a->a_flags &= ~A_INUSE;
}
+ }
+ }
if (p_abort()) {
val_free(*v);
v->v_type = V_ERR;
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();
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;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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"
/*
* * / %
* unary - + ~ !
*/
-p_expr(v, flag)
-register struct value *v;
-char flag;
+int
+p_expr(struct value *v, char flag)
{
struct value t;
int ret;
/*
* ? :
*/
-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;
/*
* ||
*/
-p_expr1(v, flag)
-register struct value *v;
-char flag;
+int
+p_expr1(struct value *v, char flag)
{
char true = 0;
/*
* &&
*/
-p_expr2(v, flag)
-register struct value *v;
-char flag;
+int
+p_expr2(struct value *v, char flag)
{
char true = 1;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <string.h>
+#include "defs.h"
#include "parser.h"
/*
* + - 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)
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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:
*
* 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) {
+/* $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.
* 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.
*
* 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 <ctype.h>
+#include <sys/cdefs.h>
+#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 <stdlib.h>
-#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:
return EOF;
}
/*NOTREACHED*/
+ return(0); /* XXX: placate gcc */
}
-s_ungetc(c)
+int
+s_ungetc(int c)
{
if (c == EOF)
return EOF;
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();
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;
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;
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;
}
break;
default:
- if (isalnum(c) || c == '_' || c == '.') {
- if (p < buf + sizeof buf - 1)
- *p++ = c;
- break;
- }
(void) s_ungetc(c);
case EOF:
*p = 0;
&& 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
return cx.x_token;
}
-s_gettok1()
+int
+s_gettok1(void)
{
- register c;
- register n;
+ int c;
+ int n;
c = s_getc(); /* got \ */
switch (c) {
+/* $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.
* 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.
*
* 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 <stdio.h>
+#include <sys/cdefs.h>
+#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 <stdlib.h>
#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);
}
/*
* 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);
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <stdio.h>
#include <stdlib.h>
-#include <string.h> /* System string definitions. */
-
-#include "mystring.h" /* Local string definitions. */
+#include <string.h>
+#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;
}
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;
}
* 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)
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)
+/* $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.
* 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.
*
* 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)
+/* $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.
* 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.
*
* 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 <unistd.h>
+
+#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 */
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.
* 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)
* 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)))
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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"
};
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 };
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <stdlib.h>
+#include <string.h>
+#include <termcap.h>
#include "ww.h"
#include "tt.h"
char PC, *BC, *UP;
+short ospeed;
/* normal frame */
short gen_frame[16] = {
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)
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) {
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) {
tt.tt_modes = new;
}
-gen_insline(n)
+void
+gen_insline(int n)
{
if (tt.tt_modes) /* for concept 100 */
gen_setmodes(0);
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);
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);
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;
tt.tt_row = row;
}
-gen_start()
+void
+gen_start(void)
{
if (gen_VS)
ttxputs(gen_VS);
tt.tt_nmodes = tt.tt_modes = 0;
}
-gen_end()
+void
+gen_end(void)
{
if (tt.tt_insert)
gen_setinsert(0);
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);
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);
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);
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)
ttxputs(gen_SF);
}
-gen_scroll_up(n)
+void
+gen_scroll_up(int n)
{
gen_move(tt.tt_scroll_top, 0);
if (gen_SRn)
ttxputs(gen_SR);
}
-gen_setscroll(top, bot)
+void
+gen_setscroll(int top, int bot)
{
tttgoto(gen_CS, bot, top);
tt.tt_scroll_top = top;
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");
/*
* 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;
*/
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) {
* 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;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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"
int h19_msp10c;
#define PAD(ms10) { \
- register i; \
+ int i; \
for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \
ttputc('\0'); \
}
#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)
tt.tt_modes = new;
}
-h19_insline(n)
+void
+h19_insline(int n)
{
while (--n >= 0) {
ttesc('L');
}
}
-h19_delline(n)
+void
+h19_delline(int n)
{
while (--n >= 0) {
ttesc('M');
}
}
-h19_putc(c)
-register char c;
+void
+h19_putc(char c)
{
if (tt.tt_nmodes != tt.tt_modes)
(*tt.tt_setmodes)(tt.tt_nmodes);
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);
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)
tt.tt_row = row;
}
-h19_start()
+void
+h19_start(void)
{
if (gen_VS)
ttxputs(gen_VS);
tt.tt_nmodes = tt.tt_modes = 0;
}
-h19_end()
+void
+h19_end(void)
{
if (tt.tt_insert)
H19_SETINSERT(0);
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);
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 */
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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"
*
*/
-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;
tt.tt_modes = new;
}
-tt_h29()
+int
+tt_h29(void)
{
if (tt_h19() < 0)
return -1;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <stdlib.h>
+#include <string.h>
#include "ww.h"
#include "tt.h"
-#include <stdlib.h>
-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 },
{ "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;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <errno.h>
#include <string.h>
-
+#include <unistd.h>
#include "ww.h"
#include "tt.h"
* 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;
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:
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;
+/* $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.
* 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.
*
* 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 <stdlib.h>
+#include <sys/cdefs.h>
+#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 <stdlib.h>
+#include <string.h>
+#include <termcap.h>
#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;
}
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;
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;
}
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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"
'b'|G, 'f'|G, 'h'|G, 'd'|G
};
-tt_tvi925()
+int
+tt_tvi925(void)
{
if (tt_generic() < 0)
+/* $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 $
*/
/*
* 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.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+#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"
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 };
+/* $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 $
*/
/*
* 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.
*
* SUCH DAMAGE.
*/
+#include <sys/cdefs.h>
+#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"
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 };
+/* $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.
* 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.
*
* 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 <stdio.h>
+#include <sys/cdefs.h>
+#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 <stdio.h>
#include "ww.h"
#include "tt.h"
#include "char.h"
/* 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)
tt.tt_modes = new;
}
-zz_insline(n)
+void
+zz_insline(int n)
{
if (n == 1)
ttesc('a');
}
}
-zz_delline(n)
+void
+zz_delline(int n)
{
if (n == 1)
ttesc('d');
}
}
-zz_putc(c)
- char c;
+void
+zz_putc(char c)
{
if (tt.tt_nmodes != tt.tt_modes)
zz_setmodes(tt.tt_nmodes);
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);
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:
tt.tt_row = row;
}
-zz_start()
+void
+zz_start(void)
{
ttesc('T');
ttputc(TOKEN_MAX + ' ');
zz_setmodes(0);
}
-zz_reset()
+void
+zz_reset(void)
{
zz_setscroll(0, NROW - 1);
tt.tt_modes = WWM_REV;
tt.tt_col = tt.tt_row = -10;
}
-zz_end()
+void
+zz_end(void)
{
ttesc('T');
ttputc(' ');
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');
}
}
-zz_delchar(n)
+void
+zz_delchar(int n)
{
if (n == 1)
ttesc('c');
}
}
-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');
}
}
-zz_setscroll(top, bot)
+void
+zz_setscroll(int top, int bot)
{
ttesc('?');
ttputc(top + ' ');
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);
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);
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) {
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;
tt.tt_checksum = zz_checksum;
}
-zz_checkpoint()
+void
+zz_checkpoint(void)
{
static char x[] = { ctrl('['), 'V', 0, 0 };
zz_sum = 0;
}
-tt_zapple()
+int
+tt_zapple(void)
{
tt.tt_insspace = zz_insspace;
tt.tt_delchar = zz_delchar;
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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"
'k'|G, 'u'|G, 'w'|G, 'n'|G
};
-tt_zentec()
+int
+tt_zentec(void)
{
if (tt_generic() < 0)
return -1;
+/* $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.
* 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.
*
* 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 {
#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)
+/* $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.
* 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.
*
* 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 <stdlib.h>
+#include <sys/cdefs.h>
+#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 <stdlib.h>
+#include <string.h>
#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 */
}
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;
}
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;
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;
}
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)
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;
+/* $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.
* 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.
*
* 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;
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)
#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 */
+/* $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.
* 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.
*
* 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 <sys/cdefs.h>
+#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 <string.h>
#include "defs.h"
#include "char.h"
+#include "window_string.h"
/*
* Higher level routines for dealing with windows.
* 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;
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.");
* 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) {
return w;
}
-findid()
+int
+findid(void)
{
- register i;
+ int i;
for (i = 0; i < NWINDOW && window[i] != 0; i++)
;
}
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;
}
/*
* 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);
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();
}
* 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();
/*
* 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;
* 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);
* 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);
/*
* 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];
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
}
}
-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;
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();
}
+.\" $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.
.\"
.\" 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.
.\"
.\" 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
.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
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
.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
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 )
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
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.
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
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.
.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\-^ .
.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
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
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 #
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
.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)
.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 <expr> then
-\t<statement>
+if \*[Lt]expr\*[Gt] then
+\t\*[Lt]statement\*[Gt]
\t...
-elsif <expr> then
-\t<statement>
+elsif \*[Lt]expr\*[Gt] then
+\t\*[Lt]statement\*[Gt]
\t...
else
-\t<statement>
+\t\*[Lt]statement\*[Gt]
\t...
endif
.Ed
.Ic elsif
parts are optional, and the latter can
be repeated any number of times.
-<Expr>
+\*[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
.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
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
.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
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 ==
.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,
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)
.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
.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 ,
.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
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
-<expr1>, <expr2>, ...
-argname1 = <expr1>, argname2 = <expr2>, ...
+\*[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
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
.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 .
(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
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
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 ,
.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
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
.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
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 .
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
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 ,
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 ,
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.
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 )
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 ,
.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 ,
+/* $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.
* 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.
*
* 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 <signal.h>
-#include <stdlib.h>
+#ifndef _W_STRING_H_
+#define _W_STRING_H_
+
+#include <stddef.h>
+
+#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_ */
+# $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.
#
# 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
#
+/* $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.
* 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.
*
* 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 <sys/types.h>
#ifdef OLD_TTY
#include <sgtty.h>
#else
#include <termios.h>
#endif
#include <setjmp.h>
-#include <machine/endian.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#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 */
/* 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 positi