aboutsummaryrefslogtreecommitdiffstats
path: root/tools/node_modules/expresso/deps/jscoverage/js/editline
diff options
context:
space:
mode:
Diffstat (limited to 'tools/node_modules/expresso/deps/jscoverage/js/editline')
-rw-r--r--tools/node_modules/expresso/deps/jscoverage/js/editline/Makefile.ref143
-rw-r--r--tools/node_modules/expresso/deps/jscoverage/js/editline/README83
-rw-r--r--tools/node_modules/expresso/deps/jscoverage/js/editline/editline.3175
-rw-r--r--tools/node_modules/expresso/deps/jscoverage/js/editline/editline.c1368
-rw-r--r--tools/node_modules/expresso/deps/jscoverage/js/editline/editline.h135
-rw-r--r--tools/node_modules/expresso/deps/jscoverage/js/editline/sysunix.c182
-rw-r--r--tools/node_modules/expresso/deps/jscoverage/js/editline/unix.h82
7 files changed, 2168 insertions, 0 deletions
diff --git a/tools/node_modules/expresso/deps/jscoverage/js/editline/Makefile.ref b/tools/node_modules/expresso/deps/jscoverage/js/editline/Makefile.ref
new file mode 100644
index 0000000..c902c88
--- /dev/null
+++ b/tools/node_modules/expresso/deps/jscoverage/js/editline/Makefile.ref
@@ -0,0 +1,143 @@
+# -*- Mode: makefile -*-
+#
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla Communicator client code, released
+# March 31, 1998.
+#
+# The Initial Developer of the Original Code is
+# Simmule Turner and Rich Salz.
+# Portions created by the Initial Developer are Copyright (C) 1998
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+#
+# Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
+#
+# This software is not subject to any license of the American Telephone
+# and Telegraph Company or of the Regents of the University of California.
+#
+# Permission is granted to anyone to use this software for any purpose on
+# any computer system, and to alter it and redistribute it freely, subject
+# to the following restrictions:
+# 1. The authors are not responsible for the consequences of use of this
+# software, no matter how awful, even if they arise from flaws in it.
+# 2. The origin of this software must not be misrepresented, either by
+# explicit claim or by omission. Since few users ever read sources,
+# credits must appear in the documentation.
+# 3. Altered versions must be plainly marked as such, and must not be
+# misrepresented as being the original software. Since few users
+# ever read sources, credits must appear in the documentation.
+# 4. This notice may not be removed or altered.
+#
+
+#
+# Unix makefile for editline library.
+#
+
+## Set your options:
+## -DANSI_ARROWS ANSI arrows keys work like emacs.
+## -DHAVE_STDLIB Have <stdlib.h>.
+## -DHAVE_TCGETATTR Have tcgetattr(), tcsetattr().
+## -DHAVE_TERMIO Have "struct termio" and <termio.h>
+## (If neither of above two, we use <sgttyb.h> and BSD ioctl's)
+## -DHIDE Make static functions static (non debug).
+## -DHIST_SIZE=n History size.
+## -DNEED_STRDUP Don't have strdup().
+## -DUNIQUE_HISTORY Don't save command if same as last one.
+## -DUSE_DIRENT Use <dirent.h>, not <sys/dir.h>?
+## -DUSE_TERMCAP Use the termcap library for terminal size
+## see LDFLAGS, below, if you set this.
+## -DNEED_PERROR Don't have perror() (used in testit)
+
+## If you have -DUSE_TERMCAP, set this as appropriate:
+#LDFLAGS = -ltermlib
+#LDFLAGS = -ltermcap
+
+DEFS = -DANSI_ARROWS -DHAVE_TCGETATTR -DHIDE -DUSE_DIRENT -DSYS_UNIX \
+ -DHAVE_STDLIB -DUNIQUE_HISTORY
+
+DEPTH = ..
+
+include $(DEPTH)/config.mk
+
+LOCAL_OBJDIR = $(OBJDIR)/editline
+
+#
+# Default IEEE libm
+#
+CFLAGS += -DXP_UNIX $(OPTIMIZER) $(OS_CFLAGS) $(DEFINES) $(INCLUDES) \
+ -DJSFILE $(XCFLAGS) $(DEFS)
+
+INCFILES = editline.h
+.INIT: $(INCFILES)
+.KEEP_STATE:
+EDITLINE_CFILES = editline.c sysunix.c
+
+EDITLINE_OBJS = $(addprefix $(LOCAL_OBJDIR)/, $(EDITLINE_CFILES:.c=.o))
+
+LIBRARY = $(LOCAL_OBJDIR)/libedit.a
+
+all: $(LIBRARY)
+
+export:
+
+# make objects to depen on $(LOCAL_OBJDIR) only when it exists
+$(EDITLINE_OBJS) : $(filter-out $(wildcard $(LOCAL_OBJDIR)), $(LOCAL_OBJDIR))
+
+$(LOCAL_OBJDIR) :
+ mkdir -p $@
+
+$(LOCAL_OBJDIR)/%: %.c
+ $(CC) -o $@ $(CFLAGS) $*.c $(LDFLAGS)
+
+$(LOCAL_OBJDIR)/%.o: %.c
+ $(CC) -o $@ -c $(CFLAGS) $*.c
+
+$(LOCAL_OBJDIR)/%.o: %.s
+ $(AS) -o $@ $(ASFLAGS) $*.s
+
+$(LIBRARY): $(EDITLINE_OBJS)
+ $(AR) rv $@ $?
+ $(RANLIB) $@
+
+#libedit.a : $(EDITLINE_OBJS)
+# $(AR) cru $(LOCAL_OBJDIR)/libedit.a $(EDITLINE_OBJS)
+# $(RANLIB) $(LOCAL_OBJDIR)/libedit.a
+
+clean:
+ rm -rf $(EDITLINE_OBJS) $(EDITLINE_OBJS:.o=.d)
+
+clobber: clean
+ rm -rf $(LIBRARY) $(DEPENDENCIES)
+ if test -d $(LOCAL_OBJDIR); then rmdir $(LOCAL_OBJDIR); fi
+
+SUFFIXES: .i
+%.i: %.c
+ $(CC) -C -E $(CFLAGS) $< > $*.i
diff --git a/tools/node_modules/expresso/deps/jscoverage/js/editline/README b/tools/node_modules/expresso/deps/jscoverage/js/editline/README
new file mode 100644
index 0000000..53ec359
--- /dev/null
+++ b/tools/node_modules/expresso/deps/jscoverage/js/editline/README
@@ -0,0 +1,83 @@
+The files in this directory provide simple line-editing and history
+support for the standalone javascript engine, through the 'editline'
+library.
+
+editline has only been enabled for those platforms on which it is
+known to build; to try it on a different platform, define JS_EDITLINE
+before building. Line editing (and js.c) is not a supported feature
+of the javascript library, so your mileage my vary.
+
+The editline API is a compatible subset of the FSF readline API; if
+you have readline installed and would like to link to that instead,
+define JS_READLINE. Note that the readline library is distributed
+under the GPL, so any resulting binaries are not legally
+distributable.
+
+The editline files used here have been modified to work with the js
+build system and to quiet some compiler warnings, and also to remove
+filename-completion support.
+
+If anyone knows of a more recent version of these files, or a site on
+which they are being maintained, please let me know!
+
+Mike McCabe, mccabe@netscape.com
+
+
+The original README file distributed with the editline library follows.
+
+
+
+This is a line-editing library. It can be linked into almost any
+program to provide command-line editing and recall.
+
+It is call-compatible with the FSF readline library, but it is a
+fraction of the size (and offers fewer features). It does not use
+standard I/O. It is distributed under a "C News-like" copyright.
+
+Configuration is done in the Makefile. Type "make testit" to get
+a small slow shell for testing.
+
+An earlier version was distributed with Byron's rc. Principal
+changes over that version include:
+ Faster.
+ Is eight-bit clean (thanks to brendan@cs.widener.edu)
+ Written in K&R C, but ANSI compliant (gcc all warnings)
+ Propagates EOF properly; rc trip test now passes
+ Doesn't need or use or provide memmove.
+ More robust
+ Calling sequence changed to be compatible with readline.
+ Test program, new manpage, better configuration
+ More system-independant; includes Unix and OS-9 support.
+
+This contains some changes since the posting to comp.sources.misc:
+ Bugfix for completion on absolute pathnames.
+ Better handling of M-n versus showing raw 8bit chars.
+ Better signal handling.
+ Now supports termios/termio/sgttyb ioctl's.
+ Add M-m command to toggle how 8bit data is displayed.
+
+There is one known bug:
+ History-searching redraws the line wrong if the text
+ retrieved is shorter then the prompt.
+
+Enjoy,
+ Rich $alz
+ <rsalz@osf.org>
+
+ Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
+
+ This software is not subject to any license of the American Telephone
+ and Telegraph Company or of the Regents of the University of California.
+
+ Permission is granted to anyone to use this software for any purpose on
+ any computer system, and to alter it and redistribute it freely, subject
+ to the following restrictions:
+ 1. The authors are not responsible for the consequences of use of this
+ software, no matter how awful, even if they arise from flaws in it.
+ 2. The origin of this software must not be misrepresented, either by
+ explicit claim or by omission. Since few users ever read sources,
+ credits must appear in the documentation.
+ 3. Altered versions must be plainly marked as such, and must not be
+ misrepresented as being the original software. Since few users
+ ever read sources, credits must appear in the documentation.
+ 4. This notice may not be removed or altered.
diff --git a/tools/node_modules/expresso/deps/jscoverage/js/editline/editline.3 b/tools/node_modules/expresso/deps/jscoverage/js/editline/editline.3
new file mode 100644
index 0000000..21a72ca
--- /dev/null
+++ b/tools/node_modules/expresso/deps/jscoverage/js/editline/editline.3
@@ -0,0 +1,175 @@
+.TH EDITLINE 3
+.SH NAME
+editline \- command-line editing library with history
+.SH SYNOPSIS
+.nf
+.B "char *"
+.B "readline(prompt)"
+.B " char *prompt;"
+
+.B "void"
+.B "add_history(line)"
+.B " char *line;"
+.fi
+.SH DESCRIPTION
+.I Editline
+is a library that provides an line-editing interface with text recall.
+It is intended to be compatible with the
+.I readline
+library provided by the Free Software Foundation, but much smaller.
+The bulk of this manual page describes the user interface.
+.PP
+The
+.I readline
+routine returns a line of text with the trailing newline removed.
+The data is returned in a buffer allocated with
+.IR malloc (3),
+so the space should be released with
+.IR free (3)
+when the calling program is done with it.
+Before accepting input from the user, the specified
+.I prompt
+is displayed on the terminal.
+.PP
+The
+.I add_history
+routine makes a copy of the specified
+.I line
+and adds it to the internal history list.
+.SS "User Interface"
+A program that uses this library provides a simple emacs-like editing
+interface to its users.
+A line may be edited before it is sent to the calling program by typing either
+control characters or escape sequences.
+A control character, shown as a caret followed by a letter, is typed by
+holding down the ``control'' key while the letter is typed.
+For example, ``^A'' is a control-A.
+An escape sequence is entered by typing the ``escape'' key followed by one or
+more characters.
+The escape key is abbreviated as ``ESC.''
+Note that unlike control keys, case matters in escape sequences; ``ESC\ F''
+is not the same as ``ESC\ f''.
+.PP
+An editing command may be typed anywhere on the line, not just at the
+beginning.
+In addition, a return may also be typed anywhere on the line, not just at
+the end.
+.PP
+Most editing commands may be given a repeat count,
+.IR n ,
+where
+.I n
+is a number.
+To enter a repeat count, type the escape key, the number, and then
+the command to execute.
+For example, ``ESC\ 4\ ^f'' moves forward four characters.
+If a command may be given a repeat count then the text ``[n]'' is given at the
+end of its description.
+.PP
+The following control characters are accepted:
+.RS
+.nf
+.ta \w'ESC DEL 'u
+^A Move to the beginning of the line
+^B Move left (backwards) [n]
+^D Delete character [n]
+^E Move to end of line
+^F Move right (forwards) [n]
+^G Ring the bell
+^H Delete character before cursor (backspace key) [n]
+^I Complete filename (tab key); see below
+^J Done with line (return key)
+^K Kill to end of line (or column [n])
+^L Redisplay line
+^M Done with line (alternate return key)
+^N Get next line from history [n]
+^P Get previous line from history [n]
+^R Search backward (forward if [n]) through history for text;
+\& must start line if text begins with an uparrow
+^T Transpose characters
+^V Insert next character, even if it is an edit command
+^W Wipe to the mark
+^X^X Exchange current location and mark
+^Y Yank back last killed text
+^[ Start an escape sequence (escape key)
+^]c Move forward to next character ``c''
+^? Delete character before cursor (delete key) [n]
+.fi
+.RE
+.PP
+The following escape sequences are provided.
+.RS
+.nf
+.ta \w'ESC DEL 'u
+ESC\ ^H Delete previous word (backspace key) [n]
+ESC\ DEL Delete previous word (delete key) [n]
+ESC\ SP Set the mark (space key); see ^X^X and ^Y above
+ESC\ \. Get the last (or [n]'th) word from previous line
+ESC\ \? Show possible completions; see below
+ESC\ < Move to start of history
+ESC\ > Move to end of history
+ESC\ b Move backward a word [n]
+ESC\ d Delete word under cursor [n]
+ESC\ f Move forward a word [n]
+ESC\ l Make word lowercase [n]
+ESC\ m Toggle if 8bit chars display normally or with ``M\-'' prefix
+ESC\ u Make word uppercase [n]
+ESC\ y Yank back last killed text
+ESC\ v Show library version
+ESC\ w Make area up to mark yankable
+ESC\ nn Set repeat count to the number nn
+ESC\ C Read from environment variable ``_C_'', where C is
+\& an uppercase letter
+.fi
+.RE
+.PP
+The
+.I editline
+library has a small macro facility.
+If you type the escape key followed by an uppercase letter,
+.IR C ,
+then the contents of the environment variable
+.I _C_
+are read in as if you had typed them at the keyboard.
+For example, if the variable
+.I _L_
+contains the following:
+.RS
+^A^Kecho '^V^[[H^V^[[2J'^M
+.RE
+Then typing ``ESC L'' will move to the beginning of the line, kill the
+entire line, enter the echo command needed to clear the terminal (if your
+terminal is like a VT-100), and send the line back to the shell.
+.PP
+The
+.I editline
+library also does filename completion.
+Suppose the root directory has the following files in it:
+.RS
+.nf
+.ta \w'core 'u
+bin vmunix
+core vmunix.old
+.fi
+.RE
+If you type ``rm\ /v'' and then the tab key.
+.I Editline
+will then finish off as much of the name as possible by adding ``munix''.
+Because the name is not unique, it will then beep.
+If you type the escape key and a question mark, it will display the
+two choices.
+If you then type a period and a tab, the library will finish off the filename
+for you:
+.RS
+.nf
+.RI "rm /v[TAB]" munix .TAB old
+.fi
+.RE
+The tab key is shown by ``[TAB]'' and the automatically-entered text
+is shown in italics.
+.SH "BUGS AND LIMITATIONS"
+Cannot handle lines more than 80 columns.
+.SH AUTHORS
+Simmule R. Turner <uunet.uu.net!capitol!sysgo!simmy>
+and Rich $alz <rsalz@osf.org>.
+Original manual page by DaviD W. Sanderson <dws@ssec.wisc.edu>.
diff --git a/tools/node_modules/expresso/deps/jscoverage/js/editline/editline.c b/tools/node_modules/expresso/deps/jscoverage/js/editline/editline.c
new file mode 100644
index 0000000..8ca93b3
--- /dev/null
+++ b/tools/node_modules/expresso/deps/jscoverage/js/editline/editline.c
@@ -0,0 +1,1368 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Simmule Turner and Rich Salz.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
+ *
+ * This software is not subject to any license of the American Telephone
+ * and Telegraph Company or of the Regents of the University of California.
+ *
+ * Permission is granted to anyone to use this software for any purpose on
+ * any computer system, and to alter it and redistribute it freely, subject
+ * to the following restrictions:
+ * 1. The authors are not responsible for the consequences of use of this
+ * software, no matter how awful, even if they arise from flaws in it.
+ * 2. The origin of this software must not be misrepresented, either by
+ * explicit claim or by omission. Since few users ever read sources,
+ * credits must appear in the documentation.
+ * 3. Altered versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software. Since few users
+ * ever read sources, credits must appear in the documentation.
+ * 4. This notice may not be removed or altered.
+ */
+
+
+/*
+** Main editing routines for editline library.
+*/
+#include "editline.h"
+#include <signal.h>
+#include <ctype.h>
+#include <unistd.h>
+
+/*
+** Manifest constants.
+*/
+#define SCREEN_WIDTH 80
+#define SCREEN_ROWS 24
+#define NO_ARG (-1)
+#define DEL 127
+#define CTL(x) ((x) & 0x1F)
+#define ISCTL(x) ((x) && (x) < ' ')
+#define UNCTL(x) ((x) + 64)
+#define META(x) ((x) | 0x80)
+#define ISMETA(x) ((x) & 0x80)
+#define UNMETA(x) ((x) & 0x7F)
+#if !defined(HIST_SIZE)
+#define HIST_SIZE 20
+#endif /* !defined(HIST_SIZE) */
+
+/*
+** Command status codes.
+*/
+typedef enum _STATUS {
+ CSdone, CSeof, CSmove, CSdispatch, CSstay, CSsignal
+} STATUS;
+
+/*
+** The type of case-changing to perform.
+*/
+typedef enum _CASE {
+ TOupper, TOlower
+} CASE;
+
+/*
+** Key to command mapping.
+*/
+typedef struct _KEYMAP {
+ CHAR Key;
+ STATUS (*Function)();
+} KEYMAP;
+
+/*
+** Command history structure.
+*/
+typedef struct _HISTORY {
+ int Size;
+ int Pos;
+ CHAR *Lines[HIST_SIZE];
+} HISTORY;
+
+/*
+** Globals.
+*/
+int rl_eof;
+int rl_erase;
+int rl_intr;
+int rl_kill;
+int rl_quit;
+
+STATIC CHAR NIL[] = "";
+STATIC CONST CHAR *Input = NIL;
+STATIC CHAR *Line;
+STATIC CONST char *Prompt;
+STATIC CHAR *Yanked;
+STATIC char *Screen;
+STATIC char NEWLINE[]= CRLF;
+STATIC HISTORY H;
+STATIC int Repeat;
+STATIC int End;
+STATIC int Mark;
+STATIC int OldPoint;
+STATIC int Point;
+STATIC int PushBack;
+STATIC int Pushed;
+STATIC int Signal;
+FORWARD KEYMAP Map[32];
+FORWARD KEYMAP MetaMap[16];
+STATIC SIZE_T Length;
+STATIC SIZE_T ScreenCount;
+STATIC SIZE_T ScreenSize;
+STATIC char *backspace;
+STATIC int TTYwidth;
+STATIC int TTYrows;
+
+/* Display print 8-bit chars as `M-x' or as the actual 8-bit char? */
+int rl_meta_chars = 0;
+
+/*
+** Declarations.
+*/
+STATIC CHAR *editinput();
+#if defined(USE_TERMCAP)
+#include <stdlib.h>
+#include <curses.h>
+#include <term.h>
+#endif /* defined(USE_TERMCAP) */
+
+/*
+** TTY input/output functions.
+*/
+
+STATIC void
+TTYflush()
+{
+ if (ScreenCount) {
+ (void)write(1, Screen, ScreenCount);
+ ScreenCount = 0;
+ }
+}
+
+STATIC void
+TTYput(c)
+ CHAR c;
+{
+ Screen[ScreenCount] = c;
+ if (++ScreenCount >= ScreenSize - 1) {
+ ScreenSize += SCREEN_INC;
+ RENEW(Screen, char, ScreenSize);
+ }
+}
+
+STATIC void
+TTYputs(p)
+ CHAR *p;
+{
+ while (*p)
+ TTYput(*p++);
+}
+
+STATIC void
+TTYshow(c)
+ CHAR c;
+{
+ if (c == DEL) {
+ TTYput('^');
+ TTYput('?');
+ }
+ else if (ISCTL(c)) {
+ TTYput('^');
+ TTYput(UNCTL(c));
+ }
+ else if (rl_meta_chars && ISMETA(c)) {
+ TTYput('M');
+ TTYput('-');
+ TTYput(UNMETA(c));
+ }
+ else
+ TTYput(c);
+}
+
+STATIC void
+TTYstring(p)
+ CHAR *p;
+{
+ while (*p)
+ TTYshow(*p++);
+}
+
+STATIC unsigned int
+TTYget()
+{
+ CHAR c;
+
+ TTYflush();
+ if (Pushed) {
+ Pushed = 0;
+ return PushBack;
+ }
+ if (*Input)
+ return *Input++;
+ return read(0, &c, (SIZE_T)1) == 1 ? c : EOF;
+}
+
+#define TTYback() (backspace ? TTYputs((CHAR *)backspace) : TTYput('\b'))
+
+STATIC void
+TTYbackn(n)
+ int n;
+{
+ while (--n >= 0)
+ TTYback();
+}
+
+STATIC void
+TTYinfo()
+{
+ static int init;
+#if defined(USE_TERMCAP)
+ char *term;
+ char buff[2048];
+ char *bp, *p;
+#endif /* defined(USE_TERMCAP) */
+#if defined(TIOCGWINSZ)
+ struct winsize W;
+#endif /* defined(TIOCGWINSZ) */
+
+ if (init) {
+#if defined(TIOCGWINSZ)
+ /* Perhaps we got resized. */
+ if (ioctl(0, TIOCGWINSZ, &W) >= 0
+ && W.ws_col > 0 && W.ws_row > 0) {
+ TTYwidth = (int)W.ws_col;
+ TTYrows = (int)W.ws_row;
+ }
+#endif /* defined(TIOCGWINSZ) */
+ return;
+ }
+ init++;
+
+ TTYwidth = TTYrows = 0;
+#if defined(USE_TERMCAP)
+ bp = &buff[0];
+ if ((term = getenv("TERM")) == NULL)
+ term = "dumb";
+ if (tgetent(buff, term) < 0) {
+ TTYwidth = SCREEN_WIDTH;
+ TTYrows = SCREEN_ROWS;
+ return;
+ }
+ p = tgetstr("le", &bp);
+ backspace = p ? strdup(p) : NULL;
+ TTYwidth = tgetnum("co");
+ TTYrows = tgetnum("li");
+#endif /* defined(USE_TERMCAP) */
+
+#if defined(TIOCGWINSZ)
+ if (ioctl(0, TIOCGWINSZ, &W) >= 0) {
+ TTYwidth = (int)W.ws_col;
+ TTYrows = (int)W.ws_row;
+ }
+#endif /* defined(TIOCGWINSZ) */
+
+ if (TTYwidth <= 0 || TTYrows <= 0) {
+ TTYwidth = SCREEN_WIDTH;
+ TTYrows = SCREEN_ROWS;
+ }
+}
+
+
+STATIC void
+reposition()
+{
+ int i;
+ CHAR *p;
+
+ TTYput('\r');
+ TTYputs((CONST CHAR *)Prompt);
+ for (i = Point, p = Line; --i >= 0; p++)
+ TTYshow(*p);
+}
+
+STATIC void
+left(Change)
+ STATUS Change;
+{
+ TTYback();
+ if (Point) {
+ if (ISCTL(Line[Point - 1]))
+ TTYback();
+ else if (rl_meta_chars && ISMETA(Line[Point - 1])) {
+ TTYback();
+ TTYback();
+ }
+ }
+ if (Change == CSmove)
+ Point--;
+}
+
+STATIC void
+right(Change)
+ STATUS Change;
+{
+ TTYshow(Line[Point]);
+ if (Change == CSmove)
+ Point++;
+}
+
+STATIC STATUS
+ring_bell()
+{
+ TTYput('\07');
+ TTYflush();
+ return CSstay;
+}
+
+STATIC STATUS
+do_macro(c)
+ unsigned int c;
+{
+ CHAR name[4];
+
+ name[0] = '_';
+ name[1] = c;
+ name[2] = '_';
+ name[3] = '\0';
+
+ if ((Input = (CHAR *)getenv((char *)name)) == NULL) {
+ Input = NIL;
+ return ring_bell();
+ }
+ return CSstay;
+}
+
+STATIC STATUS
+do_forward(move)
+ STATUS move;
+{
+ int i;
+ CHAR *p;
+
+ i = 0;
+ do {
+ p = &Line[Point];
+ for ( ; Point < End && (*p == ' ' || !isalnum(*p)); Point++, p++)
+ if (move == CSmove)
+ right(CSstay);
+
+ for (; Point < End && isalnum(*p); Point++, p++)
+ if (move == CSmove)
+ right(CSstay);
+
+ if (Point == End)
+ break;
+ } while (++i < Repeat);
+
+ return CSstay;
+}
+
+STATIC STATUS
+do_case(type)
+ CASE type;
+{
+ int i;
+ int end;
+ int count;
+ CHAR *p;
+
+ (void)do_forward(CSstay);
+ if (OldPoint != Point) {
+ if ((count = Point - OldPoint) < 0)
+ count = -count;
+ Point = OldPoint;
+ if ((end = Point + count) > End)
+ end = End;
+ for (i = Point, p = &Line[i]; i < end; i++, p++) {
+ if (type == TOupper) {
+ if (islower(*p))
+ *p = toupper(*p);
+ }
+ else if (isupper(*p))
+ *p = tolower(*p);
+ right(CSmove);
+ }
+ }
+ return CSstay;
+}
+
+STATIC STATUS
+case_down_word()
+{
+ return do_case(TOlower);
+}
+
+STATIC STATUS
+case_up_word()
+{
+ return do_case(TOupper);
+}
+
+STATIC void
+ceol()
+{
+ int extras;
+ int i;
+ CHAR *p;
+
+ for (extras = 0, i = Point, p = &Line[i]; i <= End; i++, p++) {
+ TTYput(' ');
+ if (ISCTL(*p)) {
+ TTYput(' ');
+ extras++;
+ }
+ else if (rl_meta_chars && ISMETA(*p)) {
+ TTYput(' ');
+ TTYput(' ');
+ extras += 2;
+ }
+ }
+
+ for (i += extras; i > Point; i--)
+ TTYback();
+}
+
+STATIC void
+clear_line()
+{
+ Point = -strlen(Prompt);
+ TTYput('\r');
+ ceol();
+ Point = 0;
+ End = 0;
+ Line[0] = '\0';
+}
+
+STATIC STATUS
+insert_string(p)
+ CHAR *p;
+{
+ SIZE_T len;
+ int i;
+ CHAR *new;
+ CHAR *q;
+
+ len = strlen((char *)p);
+ if (End + len >= Length) {
+ if ((new = NEW(CHAR, Length + len + MEM_INC)) == NULL)
+ return CSstay;
+ if (Length) {
+ COPYFROMTO(new, Line, Length);
+ DISPOSE(Line);
+ }
+ Line = new;
+ Length += len + MEM_INC;
+ }
+
+ for (q = &Line[Point], i = End - Point; --i >= 0; )
+ q[len + i] = q[i];
+ COPYFROMTO(&Line[Point], p, len);
+ End += len;
+ Line[End] = '\0';
+ TTYstring(&Line[Point]);
+ Point += len;
+
+ return Point == End ? CSstay : CSmove;
+}
+
+STATIC STATUS
+redisplay()
+{
+ TTYputs((CONST CHAR *)NEWLINE);
+ TTYputs((CONST CHAR *)Prompt);
+ TTYstring(Line);
+ return CSmove;
+}
+
+STATIC STATUS
+toggle_meta_mode()
+{
+ rl_meta_chars = ! rl_meta_chars;
+ return redisplay();
+}
+
+
+STATIC CHAR *
+next_hist()
+{
+ return H.Pos >= H.Size - 1 ? NULL : H.Lines[++H.Pos];
+}
+
+STATIC CHAR *
+prev_hist()
+{
+ return H.Pos == 0 ? NULL : H.Lines[--H.Pos];
+}
+
+STATIC STATUS
+do_insert_hist(p)
+ CHAR *p;
+{
+ if (p == NULL)
+ return ring_bell();
+ Point = 0;
+ reposition();
+ ceol();
+ End = 0;
+ return insert_string(p);
+}
+
+STATIC STATUS
+do_hist(move)
+ CHAR *(*move)();
+{
+ CHAR *p;
+ int i;
+
+ i = 0;
+ do {
+ if ((p = (*move)()) == NULL)
+ return ring_bell();
+ } while (++i < Repeat);
+ return do_insert_hist(p);
+}
+
+STATIC STATUS
+h_next()
+{
+ return do_hist(next_hist);
+}
+
+STATIC STATUS
+h_prev()
+{
+ return do_hist(prev_hist);
+}
+
+STATIC STATUS
+h_first()
+{
+ return do_insert_hist(H.Lines[H.Pos = 0]);
+}
+
+STATIC STATUS
+h_last()
+{
+ return do_insert_hist(H.Lines[H.Pos = H.Size - 1]);
+}
+
+/*
+** Return zero if pat appears as a substring in text.
+*/
+STATIC int
+substrcmp(text, pat, len)
+ char *text;
+ char *pat;
+ int len;
+{
+ char c;
+
+ if ((c = *pat) == '\0')
+ return *text == '\0';
+ for ( ; *text; text++)
+ if (*text == c && strncmp(text, pat, len) == 0)
+ return 0;
+ return 1;
+}
+
+STATIC CHAR *
+search_hist(search, move)
+ CHAR *search;
+ CHAR *(*move)();
+{
+ static CHAR *old_search;
+ int len;
+ int pos;
+ int (*match)();
+ char *pat;
+
+ /* Save or get remembered search pattern. */
+ if (search && *search) {
+ if (old_search)
+ DISPOSE(old_search);
+ old_search = (CHAR *)strdup((char *)search);
+ }
+ else {
+ if (old_search == NULL || *old_search == '\0')
+ return NULL;
+ search = old_search;
+ }
+
+ /* Set up pattern-finder. */
+ if (*search == '^') {
+ match = strncmp;
+ pat = (char *)(search + 1);
+ }
+ else {
+ match = substrcmp;
+ pat = (char *)search;
+ }
+ len = strlen(pat);
+
+ for (pos = H.Pos; (*move)() != NULL; )
+ if ((*match)((char *)H.Lines[H.Pos], pat, len) == 0)
+ return H.Lines[H.Pos];
+ H.Pos = pos;
+ return NULL;
+}
+
+STATIC STATUS
+h_search()
+{
+ static int Searching;
+ CONST char *old_prompt;
+ CHAR *(*move)();
+ CHAR *p;
+
+ if (Searching)
+ return ring_bell();
+ Searching = 1;
+
+ clear_line();
+ old_prompt = Prompt;
+ Prompt = "Search: ";
+ TTYputs((CONST CHAR *)Prompt);
+ move = Repeat == NO_ARG ? prev_hist : next_hist;
+ p = editinput();
+ Prompt = old_prompt;
+ Searching = 0;
+ TTYputs((CONST CHAR *)Prompt);
+ if (p == NULL && Signal > 0) {
+ Signal = 0;
+ clear_line();
+ return redisplay();
+ }
+ p = search_hist(p, move);
+ clear_line();
+ if (p == NULL) {
+ (void)ring_bell();
+ return redisplay();
+ }
+ return do_insert_hist(p);
+}
+
+STATIC STATUS
+fd_char()
+{
+ int i;
+
+ i = 0;
+ do {
+ if (Point >= End)
+ break;
+ right(CSmove);
+ } while (++i < Repeat);
+ return CSstay;
+}
+
+STATIC void
+save_yank(begin, i)
+ int begin;
+ int i;
+{
+ if (Yanked) {
+ DISPOSE(Yanked);
+ Yanked = NULL;
+ }
+
+ if (i < 1)
+ return;
+
+ if ((Yanked = NEW(CHAR, (SIZE_T)i + 1)) != NULL) {
+ COPYFROMTO(Yanked, &Line[begin], i);
+ Yanked[i] = '\0';
+ }
+}
+
+STATIC STATUS
+delete_string(count)
+ int count;
+{
+ int i;
+ CHAR *p;
+
+ if (count <= 0 || End == Point)
+ return ring_bell();
+
+ if (count == 1 && Point == End - 1) {
+ /* Optimize common case of delete at end of line. */
+ End--;
+ p = &Line[Point];
+ i = 1;
+ TTYput(' ');
+ if (ISCTL(*p)) {
+ i = 2;
+ TTYput(' ');
+ }
+ else if (rl_meta_chars && ISMETA(*p)) {
+ i = 3;
+ TTYput(' ');
+ TTYput(' ');
+ }
+ TTYbackn(i);
+ *p = '\0';
+ return CSmove;
+ }
+ if (Point + count > End && (count = End - Point) <= 0)
+ return CSstay;
+
+ if (count > 1)
+ save_yank(Point, count);
+
+ for (p = &Line[Point], i = End - (Point + count) + 1; --i >= 0; p++)
+ p[0] = p[count];
+ ceol();
+ End -= count;
+ TTYstring(&Line[Point]);
+ return CSmove;
+}
+
+STATIC STATUS
+bk_char()
+{
+ int i;
+
+ i = 0;
+ do {
+ if (Point == 0)
+ break;
+ left(CSmove);
+ } while (++i < Repeat);
+
+ return CSstay;
+}
+
+STATIC STATUS
+bk_del_char()
+{
+ int i;
+
+ i = 0;
+ do {
+ if (Point == 0)
+ break;
+ left(CSmove);
+ } while (++i < Repeat);
+
+ return delete_string(i);
+}
+
+STATIC STATUS
+kill_line()
+{
+ int i;
+
+ if (Repeat != NO_ARG) {
+ if (Repeat < Point) {
+ i = Point;
+ Point = Repeat;
+ reposition();
+ (void)delete_string(i - Point);
+ }
+ else if (Repeat > Point) {
+ right(CSmove);
+ (void)delete_string(Repeat - Point - 1);
+ }
+ return CSmove;
+ }
+
+ save_yank(Point, End - Point);
+ Line[Point] = '\0';
+ ceol();
+ End = Point;
+ return CSstay;
+}
+
+STATIC STATUS
+insert_char(c)
+ int c;
+{
+ STATUS s;
+ CHAR buff[2];
+ CHAR *p;
+ CHAR *q;
+ int i;
+
+ if (Repeat == NO_ARG || Repeat < 2) {
+ buff[0] = c;
+ buff[1] = '\0';
+ return insert_string(buff);
+ }
+
+ if ((p = NEW(CHAR, Repeat + 1)) == NULL)
+ return CSstay;
+ for (i = Repeat, q = p; --i >= 0; )
+ *q++ = c;
+ *q = '\0';
+ Repeat = 0;
+ s = insert_string(p);
+ DISPOSE(p);
+ return s;
+}
+
+STATIC STATUS
+meta()
+{
+ unsigned int c;
+ KEYMAP *kp;
+
+ if ((c = TTYget()) == EOF)
+ return CSeof;
+#if defined(ANSI_ARROWS)
+ /* Also include VT-100 arrows. */
+ if (c == '[' || c == 'O')
+ switch (c = TTYget()) {
+ default: return ring_bell();
+ case EOF: return CSeof;
+ case 'A': return h_prev();
+ case 'B': return h_next();
+ case 'C': return fd_char();
+ case 'D': return bk_char();
+ }
+#endif /* defined(ANSI_ARROWS) */
+
+ if (isdigit(c)) {
+ for (Repeat = c - '0'; (c = TTYget()) != EOF && isdigit(c); )
+ Repeat = Repeat * 10 + c - '0';
+ Pushed = 1;
+ PushBack = c;
+ return CSstay;
+ }
+
+ if (isupper(c))
+ return do_macro(c);
+ for (OldPoint = Point, kp = MetaMap; kp->Function; kp++)
+ if (kp->Key == c)
+ return (*kp->Function)();
+
+ return ring_bell();
+}
+
+STATIC STATUS
+emacs(c)
+ unsigned int c;
+{
+ STATUS s;
+ KEYMAP *kp;
+
+ if (rl_meta_chars && ISMETA(c)) {
+ Pushed = 1;
+ PushBack = UNMETA(c);
+ return meta();
+ }
+ for (kp = Map; kp->Function; kp++)
+ if (kp->Key == c)
+ break;
+ s = kp->Function ? (*kp->Function)() : insert_char((int)c);
+ if (!Pushed)
+ /* No pushback means no repeat count; hacky, but true. */
+ Repeat = NO_ARG;
+ return s;
+}
+
+STATIC STATUS
+TTYspecial(c)
+ unsigned int c;
+{
+ if (ISMETA(c))
+ return CSdispatch;
+
+ if (c == rl_erase || c == DEL)
+ return bk_del_char();
+ if (c == rl_kill) {
+ if (Point != 0) {
+ Point = 0;
+ reposition();
+ }
+ Repeat = NO_ARG;
+ return kill_line();
+ }
+ if (c == rl_eof && Point == 0 && End == 0)
+ return CSeof;
+ if (c == rl_intr) {
+ Signal = SIGINT;
+ return CSsignal;
+ }
+ if (c == rl_quit) {
+ Signal = SIGQUIT;
+ return CSeof;
+ }
+
+ return CSdispatch;
+}
+
+STATIC CHAR *
+editinput()
+{
+ unsigned int c;
+
+ Repeat = NO_ARG;
+ OldPoint = Point = Mark = End = 0;
+ Line[0] = '\0';
+
+ Signal = -1;
+ while ((c = TTYget()) != EOF)
+ switch (TTYspecial(c)) {
+ case CSdone:
+ return Line;
+ case CSeof:
+ return NULL;
+ case CSsignal:
+ return (CHAR *)"";
+ case CSmove:
+ reposition();
+ break;
+ case CSdispatch:
+ switch (emacs(c)) {
+ case CSdone:
+ return Line;
+ case CSeof:
+ return NULL;
+ case CSsignal:
+ return (CHAR *)"";
+ case CSmove:
+ reposition();
+ break;
+ case CSdispatch:
+ case CSstay:
+ break;
+ }
+ break;
+ case CSstay:
+ break;
+ }
+ return NULL;
+}
+
+STATIC void
+hist_add(p)
+ CHAR *p;
+{
+ int i;
+
+ if ((p = (CHAR *)strdup((char *)p)) == NULL)
+ return;
+ if (H.Size < HIST_SIZE)
+ H.Lines[H.Size++] = p;
+ else {
+ DISPOSE(H.Lines[0]);
+ for (i = 0; i < HIST_SIZE - 1; i++)
+ H.Lines[i] = H.Lines[i + 1];
+ H.Lines[i] = p;
+ }
+ H.Pos = H.Size - 1;
+}
+
+/*
+** For compatibility with FSF readline.
+*/
+/* ARGSUSED0 */
+void
+rl_reset_terminal(p)
+ char *p;
+{
+}
+
+void
+rl_initialize()
+{
+}
+
+char *
+readline(prompt)
+ CONST char *prompt;
+{
+ CHAR *line;
+ int s;
+
+ if (Line == NULL) {
+ Length = MEM_INC;
+ if ((Line = NEW(CHAR, Length)) == NULL)
+ return NULL;
+ }
+
+ TTYinfo();
+ rl_ttyset(0);
+ hist_add(NIL);
+ ScreenSize = SCREEN_INC;
+ Screen = NEW(char, ScreenSize);
+ Prompt = prompt ? prompt : (char *)NIL;
+ TTYputs((CONST CHAR *)Prompt);
+ if ((line = editinput()) != NULL) {
+ line = (CHAR *)strdup((char *)line);
+ TTYputs((CHAR *)NEWLINE);
+ TTYflush();
+ }
+ rl_ttyset(1);
+ DISPOSE(Screen);
+ DISPOSE(H.Lines[--H.Size]);
+ if (Signal > 0) {
+ s = Signal;
+ Signal = 0;
+ (void)kill(getpid(), s);
+ }
+ return (char *)line;
+}
+
+void
+add_history(p)
+ char *p;
+{
+ if (p == NULL || *p == '\0')
+ return;
+
+#if defined(UNIQUE_HISTORY)
+ if (H.Size && strcmp(p, H.Lines[H.Size - 1]) == 0)
+ return;
+#endif /* defined(UNIQUE_HISTORY) */
+ hist_add((CHAR *)p);
+}
+
+
+STATIC STATUS
+beg_line()
+{
+ if (Point) {
+ Point = 0;
+ return CSmove;
+ }
+ return CSstay;
+}
+
+STATIC STATUS
+del_char()
+{
+ return delete_string(Repeat == NO_ARG ? 1 : Repeat);
+}
+
+STATIC STATUS
+end_line()
+{
+ if (Point != End) {
+ Point = End;
+ return CSmove;
+ }
+ return CSstay;
+}
+
+STATIC STATUS
+accept_line()
+{
+ Line[End] = '\0';
+ return CSdone;
+}
+
+STATIC STATUS
+transpose()
+{
+ CHAR c;
+
+ if (Point) {
+ if (Point == End)
+ left(CSmove);
+ c = Line[Point - 1];
+ left(CSstay);
+ Line[Point - 1] = Line[Point];
+ TTYshow(Line[Point - 1]);
+ Line[Point++] = c;
+ TTYshow(c);
+ }
+ return CSstay;
+}
+
+STATIC STATUS
+quote()
+{
+ unsigned int c;
+
+ return (c = TTYget()) == EOF ? CSeof : insert_char((int)c);
+}
+
+STATIC STATUS
+wipe()
+{
+ int i;
+
+ if (Mark > End)
+ return ring_bell();
+
+ if (Point > Mark) {
+ i = Point;
+ Point = Mark;
+ Mark = i;
+ reposition();
+ }
+
+ return delete_string(Mark - Point);
+}
+
+STATIC STATUS
+mk_set()
+{
+ Mark = Point;
+ return CSstay;
+}
+
+STATIC STATUS
+exchange()
+{
+ unsigned int c;
+
+ if ((c = TTYget()) != CTL('X'))
+ return c == EOF ? CSeof : ring_bell();
+
+ if ((c = Mark) <= End) {
+ Mark = Point;
+ Point = c;
+ return CSmove;
+ }
+ return CSstay;
+}
+
+STATIC STATUS
+yank()
+{
+ if (Yanked && *Yanked)
+ return insert_string(Yanked);
+ return CSstay;
+}
+
+STATIC STATUS
+copy_region()
+{
+ if (Mark > End)
+ return ring_bell();
+
+ if (Point > Mark)
+ save_yank(Mark, Point - Mark);
+ else
+ save_yank(Point, Mark - Point);
+
+ return CSstay;
+}
+
+STATIC STATUS
+move_to_char()
+{
+ unsigned int c;
+ int i;
+ CHAR *p;
+
+ if ((c = TTYget()) == EOF)
+ return CSeof;
+ for (i = Point + 1, p = &Line[i]; i < End; i++, p++)
+ if (*p == c) {
+ Point = i;
+ return CSmove;
+ }
+ return CSstay;
+}
+
+STATIC STATUS
+fd_word()
+{
+ return do_forward(CSmove);
+}
+
+STATIC STATUS
+fd_kill_word()
+{
+ int i;
+
+ (void)do_forward(CSstay);
+ if (OldPoint != Point) {
+ i = Point - OldPoint;
+ Point = OldPoint;
+ return delete_string(i);
+ }
+ return CSstay;
+}
+
+STATIC STATUS
+bk_word()
+{
+ int i;
+ CHAR *p;
+
+ i = 0;
+ do {
+ for (p = &Line[Point]; p > Line && !isalnum(p[-1]); p--)
+ left(CSmove);
+
+ for (; p > Line && p[-1] != ' ' && isalnum(p[-1]); p--)
+ left(CSmove);
+
+ if (Point == 0)
+ break;
+ } while (++i < Repeat);
+
+ return CSstay;
+}
+
+STATIC STATUS
+bk_kill_word()
+{
+ (void)bk_word();
+ if (OldPoint != Point)
+ return delete_string(OldPoint - Point);
+ return CSstay;
+}
+
+STATIC int
+argify(line, avp)
+ CHAR *line;
+ CHAR ***avp;
+{
+ CHAR *c;
+ CHAR **p;
+ CHAR **new;
+ int ac;
+ int i;
+
+ i = MEM_INC;
+ if ((*avp = p = NEW(CHAR*, i))== NULL)
+ return 0;
+
+ for (c = line; isspace(*c); c++)
+ continue;
+ if (*c == '\n' || *c == '\0')
+ return 0;
+
+ for (ac = 0, p[ac++] = c; *c && *c != '\n'; ) {
+ if (isspace(*c)) {
+ *c++ = '\0';
+ if (*c && *c != '\n') {
+ if (ac + 1 == i) {
+ new = NEW(CHAR*, i + MEM_INC);
+ if (new == NULL) {
+ p[ac] = NULL;
+ return ac;
+ }
+ COPYFROMTO(new, p, i * sizeof (char **));
+ i += MEM_INC;
+ DISPOSE(p);
+ *avp = p = new;
+ }
+ p[ac++] = c;
+ }
+ }
+ else
+ c++;
+ }
+ *c = '\0';
+ p[ac] = NULL;
+ return ac;
+}
+
+STATIC STATUS
+last_argument()
+{
+ CHAR **av;
+ CHAR *p;
+ STATUS s;
+ int ac;
+
+ if (H.Size == 1 || (p = H.Lines[H.Size - 2]) == NULL)
+ return ring_bell();
+
+ if ((p = (CHAR *)strdup((char *)p)) == NULL)
+ return CSstay;
+ ac = argify(p, &av);
+
+ if (Repeat != NO_ARG)
+ s = Repeat < ac ? insert_string(av[Repeat]) : ring_bell();
+ else
+ s = ac ? insert_string(av[ac - 1]) : CSstay;
+
+ if (ac)
+ DISPOSE(av);
+ DISPOSE(p);
+ return s;
+}
+
+STATIC KEYMAP Map[32] = {
+ { CTL('@'), ring_bell },
+ { CTL('A'), beg_line },
+ { CTL('B'), bk_char },
+ { CTL('D'), del_char },
+ { CTL('E'), end_line },
+ { CTL('F'), fd_char },
+ { CTL('G'), ring_bell },
+ { CTL('H'), bk_del_char },
+ { CTL('J'), accept_line },
+ { CTL('K'), kill_line },
+ { CTL('L'), redisplay },
+ { CTL('M'), accept_line },
+ { CTL('N'), h_next },
+ { CTL('O'), ring_bell },
+ { CTL('P'), h_prev },
+ { CTL('Q'), ring_bell },
+ { CTL('R'), h_search },
+ { CTL('S'), ring_bell },
+ { CTL('T'), transpose },
+ { CTL('U'), ring_bell },
+ { CTL('V'), quote },
+ { CTL('W'), wipe },
+ { CTL('X'), exchange },
+ { CTL('Y'), yank },
+ { CTL('Z'), ring_bell },
+ { CTL('['), meta },
+ { CTL(']'), move_to_char },
+ { CTL('^'), ring_bell },
+ { CTL('_'), ring_bell },
+ { 0, NULL }
+};
+
+STATIC KEYMAP MetaMap[16]= {
+ { CTL('H'), bk_kill_word },
+ { DEL, bk_kill_word },
+ { ' ', mk_set },
+ { '.', last_argument },
+ { '<', h_first },
+ { '>', h_last },
+ { 'b', bk_word },
+ { 'd', fd_kill_word },
+ { 'f', fd_word },
+ { 'l', case_down_word },
+ { 'm', toggle_meta_mode },
+ { 'u', case_up_word },
+ { 'y', yank },
+ { 'w', copy_region },
+ { 0, NULL }
+};
+
diff --git a/tools/node_modules/expresso/deps/jscoverage/js/editline/editline.h b/tools/node_modules/expresso/deps/jscoverage/js/editline/editline.h
new file mode 100644
index 0000000..e820049
--- /dev/null
+++ b/tools/node_modules/expresso/deps/jscoverage/js/editline/editline.h
@@ -0,0 +1,135 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Simmule Turner and Rich Salz.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
+ *
+ * This software is not subject to any license of the American Telephone
+ * and Telegraph Company or of the Regents of the University of California.
+ *
+ * Permission is granted to anyone to use this software for any purpose on
+ * any computer system, and to alter it and redistribute it freely, subject
+ * to the following restrictions:
+ * 1. The authors are not responsible for the consequences of use of this
+ * software, no matter how awful, even if they arise from flaws in it.
+ * 2. The origin of this software must not be misrepresented, either by
+ * explicit claim or by omission. Since few users ever read sources,
+ * credits must appear in the documentation.
+ * 3. Altered versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software. Since few users
+ * ever read sources, credits must appear in the documentation.
+ * 4. This notice may not be removed or altered.
+ */
+
+/*
+** Internal header file for editline library.
+*/
+#include <stdio.h>
+#if defined(HAVE_STDLIB)
+#include <stdlib.h>
+#include <string.h>
+#endif /* defined(HAVE_STDLIB) */
+#if defined(SYS_UNIX)
+#include "unix.h"
+#endif /* defined(SYS_UNIX) */
+#if defined(SYS_OS9)
+#include "os9.h"
+#endif /* defined(SYS_OS9) */
+
+#if !defined(SIZE_T)
+#define SIZE_T unsigned int
+#endif /* !defined(SIZE_T) */
+
+typedef unsigned char CHAR;
+
+#if defined(HIDE)
+#define STATIC static
+#else
+#define STATIC /* NULL */
+#endif /* !defined(HIDE) */
+
+#if !defined(CONST)
+#if defined(__STDC__)
+#define CONST const
+#else
+#define CONST
+#endif /* defined(__STDC__) */
+#endif /* !defined(CONST) */
+
+
+#define MEM_INC 64
+#define SCREEN_INC 256
+
+#define DISPOSE(p) free((char *)(p))
+#define NEW(T, c) \
+ ((T *)malloc((unsigned int)(sizeof (T) * (c))))
+#define RENEW(p, T, c) \
+ (p = (T *)realloc((char *)(p), (unsigned int)(sizeof (T) * (c))))
+#define COPYFROMTO(new, p, len) \
+ (void)memcpy((char *)(new), (char *)(p), (int)(len))
+
+
+/*
+** Variables and routines internal to this package.
+*/
+extern int rl_eof;
+extern int rl_erase;
+extern int rl_intr;
+extern int rl_kill;
+extern int rl_quit;
+extern char *rl_complete();
+extern int rl_list_possib();
+extern void rl_ttyset();
+extern void rl_add_slash();
+
+#if !defined(HAVE_STDLIB)
+extern char *getenv();
+extern char *malloc();
+extern char *realloc();
+extern char *memcpy();
+extern char *strcat();
+extern char *strchr();
+extern char *strrchr();
+extern char *strcpy();
+extern char *strdup();
+extern int strcmp();
+extern int strlen();
+extern int strncmp();
+#endif /* !defined(HAVE_STDLIB) */
+
diff --git a/tools/node_modules/expresso/deps/jscoverage/js/editline/sysunix.c b/tools/node_modules/expresso/deps/jscoverage/js/editline/sysunix.c
new file mode 100644
index 0000000..17227ea
--- /dev/null
+++ b/tools/node_modules/expresso/deps/jscoverage/js/editline/sysunix.c
@@ -0,0 +1,182 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Simmule Turner and Rich Salz.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
+ *
+ * This software is not subject to any license of the American Telephone
+ * and Telegraph Company or of the Regents of the University of California.
+ *
+ * Permission is granted to anyone to use this software for any purpose on
+ * any computer system, and to alter it and redistribute it freely, subject
+ * to the following restrictions:
+ * 1. The authors are not responsible for the consequences of use of this
+ * software, no matter how awful, even if they arise from flaws in it.
+ * 2. The origin of this software must not be misrepresented, either by
+ * explicit claim or by omission. Since few users ever read sources,
+ * credits must appear in the documentation.
+ * 3. Altered versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software. Since few users
+ * ever read sources, credits must appear in the documentation.
+ * 4. This notice may not be removed or altered.
+ */
+
+
+/*
+** Unix system-dependant routines for editline library.
+*/
+#include "editline.h"
+
+#if defined(HAVE_TCGETATTR)
+#include <termios.h>
+
+void
+rl_ttyset(Reset)
+ int Reset;
+{
+ static struct termios old;
+ struct termios new;
+
+ if (Reset == 0) {
+ (void)tcgetattr(0, &old);
+ rl_erase = old.c_cc[VERASE];
+ rl_kill = old.c_cc[VKILL];
+ rl_eof = old.c_cc[VEOF];
+ rl_intr = old.c_cc[VINTR];
+ rl_quit = old.c_cc[VQUIT];
+
+ new = old;
+ new.c_cc[VINTR] = -1;
+ new.c_cc[VQUIT] = -1;
+ new.c_lflag &= ~(ECHO | ICANON);
+ new.c_iflag &= ~(ISTRIP | INPCK);
+ new.c_cc[VMIN] = 1;
+ new.c_cc[VTIME] = 0;
+ (void)tcsetattr(0, TCSADRAIN, &new);
+ }
+ else
+ (void)tcsetattr(0, TCSADRAIN, &old);
+}
+
+#else
+#if defined(HAVE_TERMIO)
+#include <termio.h>
+
+void
+rl_ttyset(Reset)
+ int Reset;
+{
+ static struct termio old;
+ struct termio new;
+
+ if (Reset == 0) {
+ (void)ioctl(0, TCGETA, &old);
+ rl_erase = old.c_cc[VERASE];
+ rl_kill = old.c_cc[VKILL];
+ rl_eof = old.c_cc[VEOF];
+ rl_intr = old.c_cc[VINTR];
+ rl_quit = old.c_cc[VQUIT];
+
+ new = old;
+ new.c_cc[VINTR] = -1;
+ new.c_cc[VQUIT] = -1;
+ new.c_lflag &= ~(ECHO | ICANON);
+ new.c_iflag &= ~(ISTRIP | INPCK);
+ new.c_cc[VMIN] = 1;
+ new.c_cc[VTIME] = 0;
+ (void)ioctl(0, TCSETAW, &new);
+ }
+ else
+ (void)ioctl(0, TCSETAW, &old);
+}
+
+#else
+#include <sgtty.h>
+
+void
+rl_ttyset(Reset)
+ int Reset;
+{
+ static struct sgttyb old_sgttyb;
+ static struct tchars old_tchars;
+ struct sgttyb new_sgttyb;
+ struct tchars new_tchars;
+
+ if (Reset == 0) {
+ (void)ioctl(0, TIOCGETP, &old_sgttyb);
+ rl_erase = old_sgttyb.sg_erase;
+ rl_kill = old_sgttyb.sg_kill;
+
+ (void)ioctl(0, TIOCGETC, &old_tchars);
+ rl_eof = old_tchars.t_eofc;
+ rl_intr = old_tchars.t_intrc;
+ rl_quit = old_tchars.t_quitc;
+
+ new_sgttyb = old_sgttyb;
+ new_sgttyb.sg_flags &= ~ECHO;
+ new_sgttyb.sg_flags |= RAW;
+#if defined(PASS8)
+ new_sgttyb.sg_flags |= PASS8;
+#endif /* defined(PASS8) */
+ (void)ioctl(0, TIOCSETP, &new_sgttyb);
+
+ new_tchars = old_tchars;
+ new_tchars.t_intrc = -1;
+ new_tchars.t_quitc = -1;
+ (void)ioctl(0, TIOCSETC, &new_tchars);
+ }
+ else {
+ (void)ioctl(0, TIOCSETP, &old_sgttyb);
+ (void)ioctl(0, TIOCSETC, &old_tchars);
+ }
+}
+#endif /* defined(HAVE_TERMIO) */
+#endif /* defined(HAVE_TCGETATTR) */
+
+void
+rl_add_slash(path, p)
+ char *path;
+ char *p;
+{
+ struct stat Sb;
+
+ if (stat(path, &Sb) >= 0)
+ (void)strcat(p, S_ISDIR(Sb.st_mode) ? "/" : " ");
+}
+
diff --git a/tools/node_modules/expresso/deps/jscoverage/js/editline/unix.h b/tools/node_modules/expresso/deps/jscoverage/js/editline/unix.h
new file mode 100644
index 0000000..c99b729
--- /dev/null
+++ b/tools/node_modules/expresso/deps/jscoverage/js/editline/unix.h
@@ -0,0 +1,82 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+ *
+ * ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is
+ * Simmule Turner and Rich Salz.
+ * Portions created by the Initial Developer are Copyright (C) 1998
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ * Copyright 1992,1993 Simmule Turner and Rich Salz. All rights reserved.
+ *
+ * This software is not subject to any license of the American Telephone
+ * and Telegraph Company or of the Regents of the University of California.
+ *
+ * Permission is granted to anyone to use this software for any purpose on
+ * any computer system, and to alter it and redistribute it freely, subject
+ * to the following restrictions:
+ * 1. The authors are not responsible for the consequences of use of this
+ * software, no matter how awful, even if they arise from flaws in it.
+ * 2. The origin of this software must not be misrepresented, either by
+ * explicit claim or by omission. Since few users ever read sources,
+ * credits must appear in the documentation.
+ * 3. Altered versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software. Since few users
+ * ever read sources, credits must appear in the documentation.
+ * 4. This notice may not be removed or altered.
+ */
+
+
+/*
+** Editline system header file for Unix.
+*/
+
+#define CRLF "\r\n"
+#define FORWARD STATIC
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined(USE_DIRENT)
+#include <dirent.h>
+typedef struct dirent DIRENTRY;
+#else
+#include <sys/dir.h>
+typedef struct direct DIRENTRY;
+#endif /* defined(USE_DIRENT) */
+
+#if !defined(S_ISDIR)
+#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif /* !defined(S_ISDIR) */
+