Index: trunk/minix/commands/elvis/.descr
===================================================================
--- trunk/minix/commands/elvis/.descr	(revision 9)
+++ 	(revision )
@@ -1,1 +1,0 @@
-Lightweight vi
Index: trunk/minix/commands/elvis/Doc.sh
===================================================================
--- trunk/minix/commands/elvis/Doc.sh	(revision 9)
+++ 	(revision )
@@ -1,3314 +1,0 @@
-echo x - cflags.ms
-sed '/^X/s///' > cflags.ms << '/'
-X.Go 9 "CFLAGS"
-X.PP
-X\*E uses many preprocessor symbols to control compilation.
-XSome of these control the sizes of buffers and such.
-XThe "-DNO_XXXX" options remove small sets of related features.
-X.PP
-XMost \*E users will probably want to keep all features available.
-XMinix-PC users, though, will have to sacrifice some sets because otherwise
-X\*E would be too bulky to compile.
-XThe "asld" phase of the compiler craps out.
-X.IP "-DM_SYSV, -Dbsd, -DTOS, -DCOHERENT, -Damiga"
-XThese flags tell the compiler that \*E is being compiled for
-XSystem-V UNIX, BSD UNIX, Atari TOS, Coherent, or AmigaDos, respectively.
-XFor other systems, the config.h file can generally figure it out automatically.
-X.IP -DRAINBOW
-XFor MS-DOS systems, this causes support for the DEC Rainbow to be compiled
-Xinto \*E.
-X.IP -DS5WINSIZE
-XSome versions of SysV UNIX don't support support the "winsize"
-Xstyle of screen-size testing,
-Xso elvis ignores window size changes by default.
-X.IP
-XHowever, many of the newer SysV systems defines "winsize" in the
-Xfile "/usr/include/sys/ptem.h".
-XIf your SysV system has "winsize" then you should add
-X-DS5SWINSIZE to the CFLAGS setting.
-X.IP -DTERMIOS
-XPOSIX is a SysV-derived specification which uses a terminal control
-Xpackage called "termios", instead of "termio".
-XSome other SysV systems may also use termios.
-XYou can make elvis uses termios instead of the more common termio
-Xby adding -DTERMIOS to CFLAGS.
-X(Note: This hasn't been tested very well.)
-X.IP -DNBUFS=\fInumber\fP
-X\*E keeps most of your text in a temporary file;
-Xonly a small amount is actually stored in RAM.
-XThis flag allows you to control how much of the file can be in RAM at any time.
-XThe default is 5 blocks, and the minimum is 3 blocks.
-X(See the -DBLKSIZE flag, below.)
-X.IP
-XMore RAM allows global changes to happen a little faster.
-X f you're just making many small changes in one section of a file, though,
-Xextra RAM won't help much.
-X.IP -DBLKSIZE=\fInumber\fP
-XThis controls the size of blocks that \*E uses internally.
-XThe value of BLKSIZE must be a power of two.
-XEvery time you double BLKSIZE, you quadruple the size of a text file that
-X\*E can handle, but you also cause the temporary file to grow faster.
-XFor MS-DOS, Coherent, and Minix-PC, the default value is 1024, which allows
-Xyou to edit files up to almost 512K bytes long.
-XFor all other systems, the default value is 2048, which allows you to edit
-Xfiles that are nearly 2 megabytes long.
-X.IP
-XThe BLKSIZE also determines the maximum line length, and a few other limits.
-XBLKSIZE should be either 256, 512, 1024, or 2048.
-XValues other than these can lead to strange behaviour.
-X.IP -DTMPDIR=\fIstring\fP
-XThis sets the default value of the "directory" option, which specifies where
-Xthe temporary files should reside.
-XThe value of TMPDIR must be a string, so be sure your value includes the
-Xquote characters on each end.
-X.IP "-DEXRC=\fIstr\fP, -DHMEXRC=\fIstr\fP, -DSYSEXRC=\fIstr\fP, -DEXINIT=\fIstr\fP"
-XThis lets you control the names of the initialization files.
-XTheir values must be strings, so be careful about quoting.
-X.IP
-XEXRC is the name of the initialization file in the current directory.
-XIts default value is ".exrc" on UNIX systems -- the same as the real vi.
-XSince that isn't a legal DOS filename, under DOS the default is "elvis.rc".
-XFor other systems, check the config.h file.
-X.IP
-XHMEXRC is the name of the initialization file in your home directory.
-XBy default, it is the same as EXRC.
-X\*E will automatically prepend the name of your home directory to HMEXRC
-Xat run time, so don't give a full path name.
-X.IP
-XSYSEXRC is the name of a system-wide initialization file.
-XIt has no default value;
-Xif you don't define a value for it, then
-Xthe code that supports SYSEXRC just isn't compiled.
-XThe value of SYSEXRC should be a full pathname, in quotes.
-X.IP
-XEXINIT is the name of an environment variable that can contain initialization
-Xcommands.
-XNormally, its value is "EXINIT".
-X.IP -DKEYWORDPRG=\fIstring\fP
-XThis flag determines the default value of the "keywordprg" option.
-XIts value must be a string, so be careful about quoting.
-XThe default value of this flag is "ref", which is a C reference program.
-X.IP "-DCC_COMMAND=\fIstring\fP -DMAKE_COMMAND=\fIstring\fP -DERRLIST=\fIstring\fP"
-XThese control the names of the C compiler, the "make" utility, and the
-Xerror output file, respectively.
-XThey are only used if -DNO_ERRLIST is not given.
-X.IP
-XThe default value of CC_COMMAND depends on the Operating System and compiler
-Xthat you use to compile elvis;
-Xfor UNIX, the default is "cc".
-XThe default values of MAKE_COMMAND and ERRLIST are "make" and "errlist",
-Xrespectively.
-X.IP -DMAXRCLEN=\fInumber\fP
-XThis determines how large a :@ macro command can be (measured in bytes).
-XThe default is 1000 bytes.
-XIf you increase this value significantly,
-Xthen you may need to allocate extra memory for the stack.
-XSee the "CHMEM" setting in the Makefile.
-X.IP -DSHELL=\fIstring\fP
-XThis is the default value of the "shell" option, and hence
-Xthe default shell used from within \*E.
-XThis only controls the default;
-Xthe value you give here may be overridden at run-time by setting
-Xan environment variable named SHELL (or COMSPEC for MS-DOS).
-XIts value must be a string constant, so be careful about quoting.
-X.IP -DTAGS=\fIstring\fP
-XThis sets the name of the "tags" file,
-Xwhich is used by the :tag command.
-XIts value must be a string constant, so be careful about quoting.
-X.IP "-DCS_IBMPC -DCS_LATIN1 -DCS_SPECIAL"
-XThe digraph table and flipcase option will normally start out empty.
-XHowever, if you add -DCS_IBMPC or -DCS_LATIN1 to your CFLAGS,
-Xthen they will start out filled with values that are appropriate for the
-XIBM PC character set or the ISO Latin-1 character set, respectively.
-X.IP
-XYou can also use -DCS_IBMPC and -DCS_SPECIAL together to get digraphs
-Xthat produce the PC's graphic characters.
-X.IP "-DDEBUG -DEBUG2"
-X-DDEBUG adds the ":debug" and ":validate" commands,
-Xand also adds many internal consistency checks.
-XIt increases the size of the ".text" segment by about 6K.
-X.IP
-X-DDEBUG2 causes a line to be appended to a file called "debug.out"
-Xeverytime any change is made to the edit buffer.
-X.IP -DCRUNCH
-XThis flag removes some non-critical code, so that \*E is smaller.
-XFor example, it removes a short-cut from the regexp package, so that
-Xtext searches are slower.
-XAlso, screen updates are not as efficient.
-XA couple of obscure features are disabled by this, too.
-X.IP -DNO_MKEXRC
-XThis removes the ":mkexrc" command,
-Xso you have to create any .exrc files manually.
-XThe size of the .text segment will be reduced by about 600 bytes.
-X.IP -DNO_CHARATTR
-XPermanently disables the charattr option.
-XThis reduces the size of your ".text" segment by about 850 bytes.
-X.IP -DNO_RECYCLE
-XNormally, \*E will recycle space (from the temporary file) which contains
-Xtotally obsolete text.
-XThis flag disables this recycling.
-XWithout recycling, the ".text" segment is about 1K smaller
-Xthan it would otherwise be,
-Xbut the tmp file grows much faster.
-XIf you have a lot of free space on your hard disk,
-Xbut \*E is too bulky to run with recycling,
-Xthen try it without recycling.
-X.IP
-XWhen using a version of \*E that has been compiled with -DNO_RECYCLE,
-Xyou should be careful to avoid making many small changes to a file
-Xbecause each individual change will cause the tmp file to grow by at least 1k.
-XHitting "x" thirty times counts as thirty changes,
-Xbut typing "30x" counts as one change.
-XAlso, you should occasionally do a ":w" followed by a ":e" to start with a
-Xfresh tmp file.
-X.IP
-XInterestingly, the real vi never recycles space from its temporary file.
-X.IP -DNO_SENTENCE
-XLeaves out the "(" and ")" visual mode commands.
-XAlso, the "[[", "]]", "{", and "}" commands will not recognize *roff macros.
-XThe sections and paragraphs options go away.
-XThis saves about 650 bytes in the ".text" segment.
-X.IP -DNO_CHARSEARCH
-XLeaves out the visual commands which locate a given character
-Xin the current line:
-X"f", "t", "F", "T", "," and ";".
-XThis saves about 900 bytes.
-X.IP -DNO_EXTENSIONS
-XLeaves out the "K" and "#" visual commands.
-XAlso, the arrow keys will no longer work in input mode.
-XRegular expressions will no longer recognize the \\{\\} operator.
-X(Other extensions are either inherent in the design of \*E,
-Xor are controlled by more specific flags,
-Xor are too tiny to be worth removing.)
-XThis saves about 250 bytes.
-X.IP -DNO_MAGIC
-XPermanently disables the "magic" option, so that most meta-characters
-Xin a regular expression are *NOT* recognized.
-XThis saves about 3k of space in the ".text" segment, because
-Xthe complex regular expression code can be replaced by much simpler code.
-X.IP -DNO_SHOWMODE
-XPermanently disables the "showmode" option, saving about 250 bytes.
-X.IP -DNO_CURSORSHAPE
-XNormally, \*E tries to adjust the shape of the cursor as a reminder
-Xof which mode you're in.
-XThe -DNO_CURSORSHAPE flag disables this, saving about 150 bytes.
-X.IP -DNO_DIGRAPH
-XTo allow entry of non-ASCII characters, \*E supports digraphs.
-XA digraph is a single (non-ASCII) character which is entered as a
-Xcombination of two other (ASCII) characters.
-XIf you don't need to input non-ASCII characters,
-Xor if your keyboard supports a better way of entering non-ASCII characters,
-Xthen you can disable the digraph code and save about 450 bytes.
-X.IP -DNO_ERRLIST
-X\*E adds a ":errlist" command, which is useful to programmers.
-XIf you don't need this feature, you can disable it via the -DNO_ERRLIST flag.
-XThis will reduce the .text segment by about 900 bytes, and the .bss segment
-Xby about 300 bytes.
-X.IP -DNO_ABBR
-XThe -DNO_ABBR flag disables the ":abbr" command,
-Xand reduces the size of \*E by about 250 bytes.
-X.IP -DNO_OPTCOLS
-XWhen \*E displays the current options settings via the ":set" command,
-Xthe options are normally sorted into columns.
-XThe -DNO_OPTCOLS flag causes the options to be sorted across the rows,
-Xwhich is much simpler for the computer.
-XThe -DNO_OPTCOLS flag will reduce the size of your .text segment by about
-X500 bytes.
-X.IP -DNO_MODELINES
-XThis removes all support for modelines.
-X.IP -DNO_TAG
-XThis disables tag lookup.
-XIt reduces the size of the .text segment by about 750 bytes.
-X.IP "-DNO_ALT_FKEY -DNO_CTRL_FKEY -DNO_SHIFT_FKEY -DNO_FKEY"
-XThese remove explicit support of function keys.
-X-DNO_ALT_FKEY removes support for the <alternate> versions function keys.
-X-DNO_CTRL_FKEY removes support for the <control> and <alternate> versions function keys.
-X-DNO_SHIFT_FKEY removes support for the <shift>, <control>, and <alternate> versions function keys.
-X-DNO_FKEY removes all support of function keys.
-X.IP
-X\*E's ":map" command normally allows you to use the special sequence "#<n>"
-Xto map function key <n>.
-XFor example, ":map #1 {!}fmt^M" will cause the <F1> key to reformat a paragraph.
-X\*E checks the :k1=: field in the termcap description of your terminal
-Xto figure out what code is sent by the <F1> key.
-XThis is handy because it allows you to create a .exrc file which maps function
-Xkeys the same way regardless of what type of terminal you use.
-X.IP
-XThat behaviour is standard; most implementations of the real vi supports it too.
-X\*E extends this to allow you to use "#1s" to refer to <shift>+<F1>,
-X"#1c" to refer to <control>+<F1>, and
-X"#1a" to refer to <alt>+<F1>.
-XThe termcap description for the terminal should have fields named
-X:s1=:c1=:a1=: respectively, to define the code sent by these key conbinations.
-X(You should also have :k2=:s2=:c2=:a2=: for the <F2> key, and so on.)
-X.IP
-XBut there may be problems.
-XThe terminfo database doesn't support :s1=:c1=:a1=:, so no terminfo terminal
-Xdescription could ever support shift/control/alt function keys;
-Xso you might as well add -DNO_SHIFT_FKEY to CFLAGS if you're using terminfo.
-X.IP
-XNote that, even if you have -DNO_FKEYS, you can still configure \*E to use
-Xyour function keys my mapping the literal character codes sent by the key.
-XYou just couldn't do it in a terminal-independent way.
-XTERM_925
-X.IP "-DTERM_AMIGA -DTERM_VT100 -DTERM_VT52 etc."
-XThe tinytcap.c file contains descriptions of several terminal types.
-XFor each system that uses tinytcap, a reasonable subset of the available
-Xdescriptions is actually compiled into \*E.
-XIf you wish to enlarge this subset, then you can add the appropriate -DTERM_XXX
-Xflag to your CFLAGS settings.
-X.IP
-XFor a list of the available terminal types, check the tinytcap.c file.
-X.IP -DINTERNAL_TAGS
-XNormally, \*E uses the "ref" program to perform tag lookup.
-XThis is more powerful than the real vi's tag lookup,
-Xbut it can be much slower.
-X.IP
-XIf you add -DINTERNAL_TAGS to your CFLAGS setting,
-Xthen \* will use its own internal tag lookup code, which is faster.
-X.IP -DPRSVDIR=\fIdirectory\fR
-XThis controls where preserved files will be placed.
-XAn appropriate default has been chosen for each Operating System,
-Xso you probably don't need to worry about it.
-X.IP -DFILEPERMS=\fInumber\fR
-XThis affects the attributes of files that are created by \*E;
-Xit is used as the second argument to the creat() function.
-XThe default is 0666 which (on UNIX systems at least) means that
-Xanybody can read or write the new file, but nobody can execute it.
-XOn UNIX systems, the creat() call modifies this via the umask setting.
-X.IP -DKEYBUFSIZE=\fInumber\fR
-XThis determines the size of the type-ahead buffer that elvis uses.
-XIt also limits the size of keymaps that it can handle.
-XThe default is 1000 characters, which should be plenty.
-/
-echo x - cutbufs.ms
-sed '/^X/s///' > cutbufs.ms << '/'
-X.Go 6 "CUT BUFFERS"
-X.PP
-XWhen \*E deletes text, it stores that text in a cut buffer.
-XThis happens in both visual mode and EX mode.
-XThere is no practical limit to how much text a cut buffer can hold.
-X.PP
-XThere are 36 cut buffers:
-X26 named buffers ("a through "z),
-X9 anonymous buffers ("1 through "9),
-Xand 1 extra cut buffer (".).
-X.PP
-XIn EX mode, the :move and :copy commands use a cut buffer to temporarily
-Xhold the text to be moved/copied.
-X.NH 2
-XPutting text into a Cut Buffer
-X.PP
-XIn visual mode, text is copied into a cut buffer when you use the
-Xd, y, c, C, s, or x commands.
-XThere are also a few others.
-X.PP
-XBy default, the text goes into the "1 buffer.
-XThe text that used to be in "1 gets shifted into "2,
-X"2 gets shifted into "3, and so on.
-XThe text that used to be in "9 is lost.
-XThis way, the last 9 things you deleted are still accessible.
-X.PP
-XYou can also put the text into a named buffer -- "a through "z.
-XTo do this, you should type the buffer's name
-X(two keystrokes: a double-quote and a lowercase letter)
-Xbefore the command that will cut the text.
-XWhen you do this, "1 through "9 are not affected by the cut.
-X.PP
-XYou can append text to one of the named buffers.
-XTo do this, type the buffer's name in uppercase
-X(a double-quote and an uppercase letter)
-Xbefore the d/y/c/C/s/x command.
-X.PP
-XThe ". buffer is special.
-XIt isn't affected by the d/y/c/C/s/x command.
-XInstead, it stores the text that you typed in
-Xthe last time you were in input mode.
-XIt is used to implement the . visual command,
-Xand ^A in input mode.
-X.PP
-XIn EX mode (also known as colon mode),
-Xthe :delete, :change, and :yank commands all copy text into a cut buffer.
-XLike the visual commands, these EX commands normally use the "1 buffer,
-Xbut you can use one of the named buffers by giving its name after the command.
-XFor example,
-X.sp 1
-X.ti +0.5i
-X:20,30y a
-X.sp
-X.LP
-Xwill copy lines 20 through 30 into cut buffer "a.
-X.PP
-XYou can't directly put text into the ". buffer, or the "2 through "9 buffers.
-X.NH 2
-XPasting from a Cut Buffer
-X.PP
-XThere are two styles of pasting:
-Xline-mode and character-mode.
-XIf a cut buffer contains whole lines (from a command like "dd")
-Xthen line-mode pasting is used;
-Xif it contains partial lines (from a command like "dw")
-Xthen character-mode pasting is used.
-XThe EX commands always cut whole lines.
-X.PP
-XCharacter-mode pasting causes the text to be inserted into the line that
-Xthe cursor is on.
-X.PP
-XLine-mode pasting inserts the text on a new line above or below the line
-Xthat the cursor is on.
-XIt doesn't affect the cursor's line at all.
-X.PP
-XIn visual mode, the p and P commands insert text from a cut buffer.
-XUppercase P will insert it before the cursor,
-Xand lowercase p will insert it after the cursor.
-XNormally, these commands will paste from the "1 buffer, but you can
-Xspecify any other buffer to paste from.
-XJust type its name (a double-quote and another character)
-Xbefore you type the P or p.
-X.PP
-XIn EX mode, the (pu)t command pastes text after a given line.
-XTo paste from a buffer other that "1,
-Xenter its name after the command.
-X.NH 2
-XMacros
-X.PP
-XThe contents of a named cut buffer can be executed as a series of
-Xex/vi commands.
-X.PP
-XTo put the instructions into the cut buffer, you must first insert
-Xthem into the file, and then delete them into a named cut buffer.
-X.PP
-XTo execute a cut buffer's contents as EX commands,
-Xyou should give the EX command "@" and the name of the buffer.
-XFor example, :@z will execute "z as a series of EX commands.
-X.PP
-XTo execute a cut buffer's contents as visual commands,
-Xyou should give the visual command "@" and the letter of the buffer's name.
-XThe visual "@" command is different from the EX "@" command.
-XThey interpret the cut buffer's contents differently.
-X.PP
-XThe visual @ command can be rather finicky.
-XEach character in the buffer is interpretted as a keystroke.
-XIf you load the instructions into the cut buffer via a "zdd command,
-Xthen the newline character at the end of the line will be executed just
-Xlike any other character, so the cursor would be moved down 1 line.
-XIf you don't want the cursor to move down 1 line at the end of each
-X@z command, then you should load the cut buffer by saying 0"zD instead.
-X.PP
-XAlthough cut buffers can hold any amount of text,
-X\*E can only \fIexecute\fR small buffers.
-XThe size limit is roughly 1000 characters, for either EX macros or VI macros.
-XIf a buffer is too large to execute, an error message is displayed.
-X.PP
-XYou can't nest :@ commands.
-XYou can't run :@ commands from your .exrc file,
-Xor any other :source file either.
-XSimilarly, you can't run a :source command from within an @ command.
-XHopefully, these restrictions will be lifted in a later version.
-X.NH 2
-XThe Effect of Switching Files
-X.PP
-XWhen \*E first starts up, all cut buffers are empty.
-XWhen you switch to a different file
-X(via the :n or :e commands perhaps)
-Xthe 9 anonymous cut buffers are emptied again,
-Xbut the other 27 buffers ("a through "z, and ".) retain their text.
-/
-echo x - differ.ms
-sed '/^X/s///' > differ.ms << '/'
-X.Go 7 "DIFFERENCES BETWEEN \*E & BSD VI/EX"
-X.PP
-X\*E is not 100% compatible with the real vi/ex.
-X\*E has many small extensions, some omissions, and a few features which
-Xare implemented in a slightly different manner.
-X.NH 2
-XExtensions
-X.IP "Save Configuration" 1i
-XThe :mkexrc command saves the current :set and :map configurations in
-Xthe ".exrc" file in your current directory.
-X.IP "Previous File" 1i
-XThe :N or :prev command moves backwards through the args list.
-X.IP "Center Current Row" 1i
-XIn visual command mode, the (lowercase) "zz" command will center the current
-Xline on the screen, like "z=".
-X.IP "Changing Repeat Count" 1i
-XThe default count value for . is the same as the previous command
-Xwhich . is meant to repeat.
-XHowever, you can supply a new count if you wish.
-XFor example, after "3dw", "." will delete 3 words,
-Xbut "5." will delete 5 words.
-X.IP "Previous Text" 1i
-XThe text which was most recently input
-X(via a "cw" command, or something similar)
-Xis saved in a cut buffer called ". (which
-Xis a pretty hard name to write in an English sentence).
-X.IP "Keyword Lookup" 1i
-XIn visual command mode, you can move the cursor onto a word and press
-Xshift-K to have \*E run a reference program to look that word up.
-XThis command alone is worth the price of admission!
-XSee the ctags and ref programs.
-X.IP "Increment/Decrement" 1i
-XIn visual command mode, you can move the cursor onto a number and
-Xthen hit ## or #+ to increment that number by 1.
-XTo increment it by a larger amount,
-Xtype in the increment value before hitting the initial #.
-XThe number can also be decremented or set by hitting #- or #=, respectively.
-X.IP "Input Mode" 1i
-XYou can backspace past the beginning of the line.
-X.IP "" 1i
-XThe arrow keys work in input mode.
-X.IP "" 1i
-XIf you type control-A, then the text that you input last time is inserted.
-XYou will remain in input mode, so you can backspace over part of it,
-Xor add more to it.
-X(This is sort of like control-@ on the real vi,
-Xexcept that control-A really works.)
-X.IP "" 1i
-XControl-P will insert the contents of the cut buffer.
-X.IP "" 1i
-XReal vi can only remember up to 128 characters of input,
-Xbut \*E can remember any amount.
-X.IP "" 1i
-XThe ^T and ^D keys can adjust the indent of a line no matter where
-Xthe cursor happens to be in that line.
-X.IP "" 1i
-XYou can save your file and exit \*E directly from input mode by hitting
-Xcontrol-Z twice.
-X.IP "" 1i
-X\*E supports digraphs as a way to enter non-ASCII characters.
-X.IP "Start in Input Mode" 1i
-XIf you ":set inputmode" in your .exrc file, then \*E will start up in
-Xinput mode instead of visual command mode.
-X.IP "Visible Fonts" 1i
-XWith ":set charattr", \*E can display "backslash-f" style character attributes on the
-Xscreen as you edit.
-XThe following example shows the recognized atributes:
-X.sp
-X.ti +0.5i
-Xnormal \\fBboldface\\fR \\fIitalics\\fR \\fUunderlined\\fR normal
-X.sp
-XNOTE: you must compile \*E without the -DNO_CHARATTR flag for
-Xthis to work.
-X.IP "File Syncing" 1i
-XAfter a crash, you can usually recover the altered form of the file
-Xfrom the temporary file that \*E uses -- unless the temporary file was
-Xcorrupted.
-X.IP "" 1i
-XUNIX systems use a delayed-write cache, which means that when \*E tries to
-Xwrite to the temporary file, the information might still be in RAM instead
-Xof on the disk.
-XA power failure at that time would cause the in-RAM information to be lost.
-XUNIX's sync() call will force all such information to disk.
-X.IP "" 1i
-XMS-DOS and Atari TOS don't write a file's length to disk until that file
-Xis closed.
-XConsequently, the temporary file would appear to be 0 bytes long if power
-Xfailed when we were editing.
-XTo avoid this problem, a sync() function has been written which will close
-Xthe temporary file and then immediately reopen it.
-X.IP "Cursor Shape" 1i
-X\*E changes the shape of the cursor to indicate which mode you're in,
-Xif your terminal's termcap entry includes the necessary capabilities.
-X.IP "Hide nroff Lines" 1i
-XTh ":set hideformat" option hides nroff format control lines.
-X(They are displayed on the screen as blank lines.)
-X.ne 7
-X.IP "Compiler Interface" 1i
-X\*E is clever enough to parse the error messages emitted by many compilers.
-XTo use this feature,
-Xyou should collect your compiler's error messages into a file called "errlist";
-X\*E will read this file,
-Xdetermine which source file caused the error messages,
-Xstart editing that file,
-Xmove the cursor to the line where the error was detected,
-Xand display the error message on the status line.
-XNifty!
-X.IP "Visible Text Selection" 1i
-XIn visual command mode, 'v' starts visibly selecting characters and
-X\&'V' starts visibly selecting whole lines.
-XThe character or line where the cursor is located becomes one
-Xendpoint of the selection.
-XYou can then use the standard cursor movement commands to move the cursor
-Xto the other endpoint, and then press one of the operator commands
-X(c/d/y/</>/!/=/\\).
-XThe operator will then immediately be applied to the selected text.
-X.IP "Pop-up Menu Operator" 1i
-XThe '\\' key is a new operator,
-Xsimilar in operation to the c/d/y/</>/! operators
-XIt conjures up a menu, from which you can select any of the other
-Xoperators plus a few other common commands.
-X.IP "Preset Filter Operator" 1i
-XThe '=' key is another new operator.
-XIt is similar to the '!' operator, except that while
-X\&'!' asks you to type in a filter command each time,
-X\&'=' assumes it should always run the command stored in the \fIequalprg\fR option.
-X.IP "Move to a Given Percentage" 1i
-XThe '%' movement key can now accept an optional count.
-XWithout a count, the '%' key still moves to a matching parenthesis
-Xlike it always did.
-XWith a count somewhere between 1 and 100, though, it moves the cursor to
-Xapproximately a given percentage of the way through the file.
-XFor example, typing "50%" will move the cursor to the middle of the file.
-X.IP "Regular Expressions"
-XIn regular expressions, several new forms of closure operators are supported:
-X\\{\fIn\fR}, \\{\fIn\fR,\fIm\fR}, \\+, and \\?.
-X.NH 2
-XOmissions
-X.PP
-XThe replace mode is a hack.
-XIt doesn't save the text that it overwrites.
-X.PP
-XLong lines are displayed differently -- where the real vi would
-Xwrap a long line onto several rows of the screen, \*E simply
-Xdisplays part of the line, and allows you to scroll the screen
-Xsideways to see the rest of it.
-X.PP
-XThe ":preserve" and ":recover" commands are missing.
-XSo is the -r flag.
-XI've never had a good reason to use ":preserve",
-Xand since ":recover" is used so rarely
-XI decided to implement it as a separate program.
-XThere's no need to load the recovery code into memory every
-Xtime you edit a file, I figured.
-X.PP
-XLISP support is missing.
-XHowever, the = key is still an operator that reformats lines of text.
-XBy default, it reformats lines by sending them through the \fIfmt\fP filter,
-Xbut you could write your own LISP beautifier and configure elvis to use it.
-XKey mappings could take care of most other differences.
-XAuto-indent is the only thing that is irrecoverably lost.
-X.PP
-XAutoindent mode acts a little different from the real vi, anyway.
-XIt doesn't handle ^^D or 0^D correctly.
-XOn the other hand, it \fIdoes\fP allow ^D and ^T to be used anywhere in the
-Xline, to adjust the indentation for the whole line.
-/
-echo x - environ.ms
-sed '/^X/s///' > environ.ms << '/'
-X.Go 11 "ENVIRONMENT VARIABLES"
-X.PP
-X\*E examines several environment variables when it starts up.
-XThe values of these variables are used internally for a variety
-Xof purposes.
-XYou don't need to define all of these;
-Xon most systems, \*E only requires TERM to be defined.
-XOn AmigaDOS, MS-DOS or TOS systems, even that is optional.
-X.SH
-XTERM, TERMCAP
-X.PP
-XTERM tells \*E the name of the termcap entry to use.
-XTERMCAP may contain either the entire termcap entry,
-Xor the full pathname of the termcap file to search through.
-X.PP
-XIf your version of \*E is using tinytcap instead of the full termcap library,
-Xthen the value of TERMCAP \fIcannot\fR contain any backslash escapes (\\E, \\r, etc.)
-Xor carat escapes (^[, ^M, etc.), because tinytcap doesn't understand them.
-XInstead, you should embed the actual control character into the string.
-X.SH
-XTMP, TEMP
-X.PP
-XThese only work for AmigaDOS, MS-DOS and Atari TOS.
-XEither of these variables may be used to set the "directory" option,
-Xwhich controls where temporary files are stored.
-XIf you define them both, then TMP is used, and TEMP is ignored.
-X.SH
-XLINES, COLUMNS
-X.PP
-XThe termcap entry for your terminal should specify the size of your screen.
-XIf you're using a windowing interface, then there is an ioctl() call which
-Xwill provide the size of the window; the ioctl() values will override the
-Xvalues in the termcap entry.
-XThe LINES and COLUMNS environment variables (if defined)
-Xwill override either of these sources.
-XThey, in turn, can be overridden by a ":set" command.
-X.PP
-XNormally, the LINES and COLUMNS variables shouldn't need to be defined.
-X.SH
-XEXINIT
-X.PP
-XThis variable's value may contain one or more colon-mode commands,
-Xwhich will be executed after all of the ".exrc" files
-Xbut before interactive editing begins.
-X.PP
-XTo put more than one command in EXINIT, you can separate the commands
-Xwith either a newline or a '|' character.
-X.SH
-XSHELL, COMSPEC
-X.PP
-XYou can use COMSPEC in MS-DOS, or SHELL in any other system,
-Xto specify which shell should be used for executing commands and
-Xexpanding wildcards.
-X.SH
-XHOME
-X.PP
-XThis variable should give the full pathname of your home directory.
-X\*E needs to know the name of your home directory so it can locate
-Xthe ".exrc" file there.
-X.SH
-XTAGPATH
-X.PP
-XThis variable is used by the "ref" program.
-XIt contains a list of directories that might contain a relevent "tags" file.
-XUnder AmigaDOS, MS-DOS or Atari TOS, the names of the directories should be separated by
-Xsemicolons (";").
-XUnder other operating systems, the names should be separated by colons (":").
-X.PP
-XIf you don't define TAGPATH, then "ref" will use a default list which includes
-Xthe current directory and a few other likely places.
-XSee the definition of DEFTAGPATH at the start of ref.c for an accurate list.
-/
-echo x - ex.ms
-sed '/^X/s///' > ex.ms << '/'
-X.Go 3 "COLON MODE COMMANDS"
-X.ID
-X.ps
-X.in 0.8i
-X.ta 2i 3.i
-X.\" NOTE: The following macro is used to output a single line of the
-X.\" command chart.  Its usage is:
-X.\"
-X.\"		.Cm <linespecs> <name> <arguments>...
-X.\"
-X.de Cm
-X.if "\\$1"0" \t\\$2\t\\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
-X.if "\\$1"1" \s-2[line]\s+2\t\\$2\t\\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
-X.if "\\$1"2" \s-2[line][,line]\s+2\t\\$2\t\\$3 \\$4 \\$5 \\$6 \\$7 \\$8 \\$9
-X..
-X.if t .ds Q ``
-X.if t .ds U ''
-X.if n .ds Q "
-X.if n .ds U "
-X\s+2LINES	COMMAND	ARGUMENTS\s-2
-X.Cm 0 ab[br] [short] [expanded form]
-X.Cm 1 a[ppend][!]
-X.Cm 0 ar[gs] [files]
-X.Cm 0 cc [files]
-X.Cm 0 cd[!] [directory]
-X.Cm 2 c[hange]
-X.Cm 0 chd[ir][!] [directory]
-X.Cm 2 co[py] line
-X.Cm 0 col[or] [when] [[\*Qlight\*U] color] [\*Qon\*U color]
-X.Cm 2 d[elete] [\*Ux]
-X.Cm 0 dig[raph][!] [XX [Y]]
-X.Cm 0 e[dit][!] [file]
-X.Cm 0 er[rlist][!] [errlist]
-X.Cm 0 f[ile] [file]
-X.Cm 2 g[lobal] /regexp/ command
-X.Cm 1 i[nsert]
-X.Cm 2 j[oin][!]
-X.Cm 2 l[ist]
-X.Cm 0 mak[e] [target]
-X.Cm 0 map[!] key mapped_to
-X.Cm 1 ma[rk]  \*Ux
-X.Cm 0 mk[exrc]
-X.Cm 2 m[ove] line
-X.Cm 0 n[ext][!] [files]
-X.Cm 0 N[ext][!]
-X.Cm 2 nu[mber]
-X.Cm 2 p[rint]
-X.Cm 1 pu[t] [\*Ux]
-X.Cm 0 q[uit][!]
-X.Cm 1 r[ead] file
-X.Cm 0 rew[ind][!]
-X.Cm 0 se[t] [options]
-X.Cm 0 so[urce] file
-X.Cm 2 s[ubstitute] /regexp/replacement/[p][g][c]
-X.Cm 0 ta[g][!] tagname
-X.Cm 0 una[bbr] [short]
-X.Cm 0 u[ndo]
-X.Cm 0 unm[ap][!] key
-X.Cm 0 ve[rsion]
-X.Cm 2 v[global] /regexp/ command
-X.Cm 0 vi[sual] [filename]
-X.Cm 0 wq 
-X.Cm 2 w[rite][!] [[>>]file]
-X.Cm 0 x[it][!]
-X.Cm 2 y[ank] [\*Ux]
-X.Cm 2 ! command
-X.Cm 2 < 
-X.Cm 2 = 
-X.Cm 2 > 
-X.Cm 2 & 
-X.Cm 0 @ "" \*Ux
-X.DE
-X.TA
-X.PP
-XTo use colon mode commands, you must switch from visual command
-Xmode to colon command mode.
-XThe visual mode commands to do this are ":" for a single colon command,
-Xor "Q" for many colon mode commands.
-X.NH 2
-XLine Specifiers
-X.PP
-XLine specifiers are always optional.
-XThe first line specifier of most commands usually defaults to the current line.
-XThe second line specifier usually defaults to be the same
-Xas the first line specifier.
-XExceptions are :write, :global, and :vglobal, which act on all lines of the
-Xfile by default, and :!, which acts on no lines by default.
-X.PP
-XLine specifiers consist of an absolute part and a relative part.
-XThe absolute part of a line specifier may be either an explicit line number,
-Xa mark, a dot to denote the current line, a dollar sign to denote the last
-Xline of the file, or a forward or backward search.
-X.PP
-XAn explicit line number is simply a decimal number, expressed as a
-Xstring of digits.
-X.PP
-XA mark is typed in as an apostrophe followed by a letter.
-XMarks must be set before they can be used.
-XYou can set a mark in visual command mode by typing "m" and a letter,
-Xor you can set it in colon command mode via the "mark" command.
-X.PP
-XA forward search is typed in as a regular expression surrounded by
-Xslash characters; searching begins at the default line.
-XA backward search is typed in as a regular expression surrounded by
-Xquestion marks; searching begins at the line before the default line.
-X.PP
-XIf you omit the absolute part, then the default line is used.
-X.PP
-XThe relative part of a line specifier is typed as a "+" or "-" character
-Xfollowed by a decimal number.
-XThe number is added to or subtracted from the absolute part
-Xof the line specifier to produce the final line number.
-X.PP
-XAs a special case, the % character may be used to specify all lines of the file.
-XIt is roughly equivelent to saying 1,$.
-XThis can be a handy shortcut.
-X.PP
-XSome examples:
-X.LD
-X.ps
-X.ta 0.5i 1.8i
-X	:p	print the current line
-X	:37p	print line 37
-X	:'gp	print the line which contains mark g
-X	:/foo/p	print the next line that contains "foo"
-X	:$p	print the last line of the file
-X	:20,30p	print lines 20 through 30
-X	:1,$p	print all lines of the file
-X	:%p	print all lines of the file
-X	:/foo/-2,+4p	print 5 lines around the next "foo"
-X.TA
-X.DE
-X.NH 2
-XText Entry Commands
-X.if n .ul 0
-X.ID
-X.ps
-X[line] append
-X[line][,line] change ["x]
-X[line] insert
-X.DE
-X.PP
-XThe \fBa\fRppend command inserts text after the specified line.
-X.PP
-XThe \fBi\fRnsert command inserts text before the specified line.
-X.PP
-XThe \fBc\fRhange command copies the range of lines into a cut buffer,
-Xdeletes them, and inserts new text where the old text used to be.
-X.PP
-XFor all of these commands, you indicate the end of the text you're
-Xinserting by hitting ^D or by entering a line which contains only a
-Xperiod.
-X.NH 2
-XCut & Paste Commands
-X.if n .ul 0
-X.ID
-X.ps
-X[line][,line] delete ["x]
-X[line][,line] yank ["x]
-X[line] put ["x]
-X[line][,line] copy line
-X[line][,line] to line
-X[line][,line] move line
-X.DE
-X.PP
-XThe \fBd\fRelete command copies the specified range of lines into a
-Xcut buffer, and then deletes them.
-X.PP
-XThe \fBy\fRank command copies the specified range of lines into a cut
-Xbuffer, but does *not* delete them.
-X.PP
-XThe \fBpu\fRt command inserts text from a cut buffer after the
-Xspecified line.
-X.PP
-XThe \fBco\fRpy and \fBt\fRo commands yank the specified range of lines and
-Xthen immediately paste them after some other line.
-X.PP
-XThe \fBm\fRove command deletes the specified range of lines and then
-Ximmediately pastes them after some other line.
-XIf the destination line comes after the deleted text,
-Xthen it will be adjusted automatically to account for the deleted lines.
-X.NH 2
-XDisplay Text Commands
-X.if n .ul 0
-X.ID
-X.ps
-X[line][,line] print
-X[line][,line] list
-X[line][,line] number
-X.DE
-X.PP
-XThe \fBp\fRrint command displays the specified range of lines.
-X.PP
-XThe \fBnu\fRmber command displays the lines, with line numbers.
-X.PP
-XThe \fBl\fRist command also displays them, but it is careful to make
-Xcontrol characters visible.
-X.NH 2
-XGlobal Operations Commands
-X.if n .ul 0
-X.ID
-X.ps
-X[line][,line] global /regexp/ command
-X[line][,line] vglobal /regexp/ command
-X.DE
-X.PP
-XThe \fBg\fRlobal command searches through the lines of the specified range
-X(or through the whole file if no range is specified)
-Xfor lines that contain a given regular expression.
-XIt then moves the cursor to each of these lines and
-Xruns some other command on them.
-X.PP
-XThe \fBv\fRglobal command is similar, but it searches for lines that \fIdon't\fR
-Xcontain the regular expression.
-X.NH 2
-XLine Editing Commands
-X.if n .ul 0
-X.ID
-X.ps
-X[line][,line] join[!]
-X[line][,line] ! program
-X[line][,line] <
-X[line][,line] >
-X[line][,line] substitute /regexp/replacement/[p][g][c]
-X[line][,line] &
-X.DE
-X.PP
-XThe \fBj\fRoin command catenates all lines in the specified range together
-Xto form one big line.
-XIf only a single line is specified, then the following line is catenated
-Xonto it.
-XThe normal ":join" inserts one or two spaces between the lines;
-Xthe ":join!" variation (with a '!') doesn't insert spaces.
-X.PP
-XThe \fB!\fR command runs an external filter program,
-Xand feeds the specified range of lines to it's stdin.
-XThe lines are then replaced by the output of the filter.
-XA typical example would be ":'a,'z!sort" to sort the lines 'a,'z.
-X.PP
-XThe \fB<\fR and \fB>\fR commands shift the specified range of lines left or right,
-Xnormally by the width of 1 tab character.
-XThe "shiftwidth" option determines the shifting amount.
-X.PP
-XThe \fBs\fRubstitute command finds the regular expression in each line,
-Xand replaces it with the replacement text.
-XThe "p" option causes the altered lines to be printed.
-XThe "g" option permits all instances of the regular expression
-Xto be found & replaced.
-X(Without "g", only the first occurrence in each line is replaced.)
-XThe "c" option asks for confirmation before each substitution.
-X.PP
-XThe \fB&\fR command repeats the previous substitution command.
-XActually, "&" is equivelent to "s//~/" with the same options as last time.
-XIt searches for the last regular expression that you specified for any purpose,
-Xand replaces it with the the same text
-Xthat was used in the previous substitution.
-X.NH 2
-XUndo Command
-X.if n .ul 0
-X.ID
-X.ps
-Xundo
-X.DE
-X.PP
-XThe \fBu\fRndo command restores the file to the state it was in before
-Xyour most recent command which changed text.
-X.NH 2
-XConfiguration & Status Commands
-X.if n .ul 0
-X.ID
-X.ps
-Xmap[!] [key mapped_to]
-Xunmap[!] key
-Xabbr [word expanded_form_of_word]
-Xunabbr word
-Xdigraph[!] [XX [Y]]
-Xset [options]
-Xmkexrc
-X[line] mark "x
-Xvisual
-Xversion
-X[line][,line] =
-Xfile [file]
-Xsource file
-X@ "x
-Xcolor [when] [["light"] color] ["on" color]
-X.DE
-X.PP
-XThe \fBma\fRp command allows you to configure \*E to recognize your function keys,
-Xand treat them as though they transmitted some other sequence of characters.
-XNormally this mapping is done only when in the visual command mode,
-Xbut with the [!] present it will map keys under input and replace modes as well.
-XWhen this command is given with no arguments,
-Xit prints a table showing all mappings currently in effect.
-XWhen called with two arguments, the first is the sequence that your
-Xfunction key really sends, and the second is the sequence that you want
-X\*E to treat it as having sent.
-XAs a special case, if the first argument is a number then \*E will map the
-Xcorresponding function key;
-Xfor example, ":map 7 dd" will cause the <F7> key to delete a line.
-X.PP
-XThe \fBunm\fRap command removes key definitions that were made via the map command.
-X.PP
-XThe \fBab\fRbr command is used to define/list a table of abbreviations.
-XThe table contains both the abbreviated form and the fully spelled-out form.
-XWhen you're in visual input mode, and you type in the abbreviated form,
-X\*E will replace the abbreviated form with the fully spelled-out form.
-XWhen this command is called without arguments, it lists the table;
-Xwith two or more arguments, the first argument is taken as the abbreviated
-Xform, and the rest of the command line is the fully-spelled out form.
-X.PP
-XThe \fBuna\fRbbr command deletes entries from the abbr table.
-X.PP
-XThe \fBdi\fRgraph command allows you to display the set of digraphs that \*E is
-Xusing, or add/remove a digraph.
-XTo list the set of digraphs, use the digraph command with no arguments.
-XTo add a digraph, you should give the digraph command two arguments.
-XThe first argument is the two ASCII characters that are to be combined;
-Xthe second is the non-ASCII character that they represent.
-XThe non-ASCII character's most significant bit is automatically set by the
-Xdigraph command, unless to append a ! to the command name.
-XRemoval of a digraph is similar to adding a digraph, except that you should
-Xleave off the second argument.
-X.PP
-XThe \fBse\fRt command allows you examine or set various options.
-XWith no arguments, it displays the values of options that have been changed.
-XWith the single argument "all" it displays the values of all options,
-Xregardless of whether they've been explicitly set or not.
-XOtherwise, the arguments are treated as options to be set.
-X.PP
-XThe \fBmk\fRexrc command saves the current configuration to a file
-Xcalled ".exrc" in the current directory.
-X.PP
-XThe mar\fBk\fR command defines a named mark to refer to a specific place
-Xin the file.
-XThis mark may be used later to specify lines for other commands.
-X.PP
-XThe \fBvi\fRsual command puts the editor into visual mode.
-XInstead of emulating ex, \*E will start emulating vi.
-X.PP
-XThe \fBve\fRrsion command tells you that what version of \*E this is.
-X.PP
-XThe \fB=\fR command tells you what line you specified, or,
-Xif you specified a range of lines, it will tell you both endpoints and
-Xthe number of lines included in the range.
-X.PP
-XThe \fBf\fRile command tells you the name of the file,
-Xwhether it has been modified,
-Xthe number of lines in the file,
-Xand the current line number.
-XYou can also use it to change the name of the current file.
-X.PP
-XThe \fBso\fRurce command reads a sequence of colon mode commands from a file,
-Xand interprets them.
-X.PP
-XThe \fB@\fR command executes the contents of a cut-buffer as EX commands.
-X.PP
-XThe \fBcol\fRor command only works under MS-DOS, or if you have an ANSI-compatible
-Xcolor terminal.
-XIt allows you to set the foreground and background colors
-Xfor different types of text:
-Xnormal, bold, italic, underlined, standout, pop-up menu, and visible selection.
-XBy default, it changes the "normal" colors;
-Xto change other colors, the first argument to the :color command should be
-Xthe first letter of the type of text you want.
-XThe syntax for the colors themselves is fairly intuitive.
-XFor example, ":color light cyan on blue" causes normal text to be displayed
-Xin light cyan on a blue background, and
-X":color b bright white" causes bold text to be displayed in bright white on
-Xa blue background.
-XThe background color always defaults to the current background color of
-Xnormal text.
-XYour first :color command \fImust\fP specify both the foreground and background
-Xfor normal text.
-X.NH 2
-XMultiple File Commands
-X.if n .ul 0
-X.ID
-X.ps
-Xargs [files]
-Xnext[!] [files]
-XNext[!]
-Xprevious[!]
-Xrewind[!]
-X.DE
-X.PP
-XWhen you invoke \*E from your shell's command line,
-Xany filenames that you give to \*E as arguments are stored in the args list.
-XThe \fBar\fRgs command will display this list, or define a new one.
-X.PP
-XThe \fBn\fRext command switches from the current file to the next one
-Xin the args list.
-XYou may specify a new args list here, too.
-X.PP
-XThe \fBN\fRext and \fBpre\fRvious commands
-X(they're really aliases for the same command)
-Xswitch from the current file to the preceding file in the args list.
-X.PP
-XThe \fBrew\fRind command switches from the current file to the first file
-Xin the args list.
-X.NH 2
-XSwitching Files
-X.if n .ul 0
-X.ID
-X.ps
-Xedit[!] [file]
-Xtag[!] tagname
-X.DE
-X.PP
-XThe \fBe\fRdit command allows to switch from the current file to some other file.
-XThis has nothing to do with the args list, by the way.
-X.PP
-XThe \fBta\fRg command looks up a given tagname in a file called "tags".
-XThis tells it which file the tag is in, and how to find it in that file.
-X\*E then switches to the tag's file and finds the tag.
-X.NH 2
-XWorking with a Compiler
-X.if n .ul 0
-X.ID
-X.ps
-Xcc [files]
-Xmake [target]
-Xerrlist[!] [errlist]
-X.DE
-X.PP
-XThe \fBcc\fR and \fBmak\fRe commands execute your compiler or "make" utility
-Xand redirect any error messages into a file called "errlist".
-XBy default, cc is run on the current file.
-X(You should write it before running cc.)
-XThe contents of the "errlist" file are then scanned for error messages.
-XIf an error message is found, then the cursor is moved to the line where
-Xthe error was detected,
-Xand the description of the error is displayed on the status line.
-X.PP
-XAfter you've fixed one error, the \fBer\fRrlist command will move
-Xthe cursor to the next error.
-XIn visual command mode,
-Xhitting `*' will do this, too.
-X.PP
-XYou can also create an "errlist" file from outside of \*E,
-Xand use "\*E -m" to start elvis and have the cursor moved to the
-Xfirst error.
-XNote that you don't need to supply a filename with "\*E -m" because
-Xthe error messages always say which source file an error is in.
-X.PP
-XNote:
-XWhen you use errlist repeatedly to fix several errors in a single file,
-Xit will attempt to adjust the reported line numbers to allow for lines
-Xthat you have inserted or deleted.
-XThese adjustments are made with the assumption that you will work though
-Xthe file from the beginning to the end.
-X.NH 2
-XExit Commands
-X.if n .ul 0
-X.ID
-X.ps
-Xquit[!]
-Xwq
-Xxit
-X.DE
-X.PP
-XThe \fBq\fRuit command exits from the editor without saving your file.
-X.PP
-XThe \fBwq\fR command writes your file out, then then exits.
-X.PP
-XThe \fBx\fRit command is similar to the \fBwq\fR command, except that
-X\fBx\fRit won't bother to write your file if you haven't modified it.
-X.NH 2
-XFile I/O Commands
-X.if n .ul 0
-X.ID
-X.ps
-X[line] read file
-X[line][,line] write[!] [[>>]file]
-X.DE
-X.PP
-XThe \fBr\fRead command gets text from another file and inserts it
-Xafter the specified line.
-XIt can also read the output of a program;
-Xsimply precede the program name by a '!' and use it in place of the file name.
-X.PP
-XThe \fBw\fRrite command writes the whole file, or just part of it,
-Xto some other file.
-XThe !, if present, will permit the lines to be written even if you've set
-Xthe readonly option.
-XIf you precede the filename by >> then the lines will be appended to the file.
-XYou can send the lines to the standard input of a program by replacing the
-Xfilename with a '!' followed by the command and its arguments.
-X.PP
-XNote: Be careful not to confuse ":w!filename" and ":w !command".
-XTo write to a program, you must have at least one blank before the '!'.
-X.NH 2
-XDirectory Commands
-X.if n .ul 0
-X.ID
-X.ps
-Xcd [directory]
-Xchdir [directory]
-Xshell
-X.DE
-X.PP
-XThe \fBcd\fR and \fBchd\fRir commands
-X(really two names for one command)
-Xswitch the current working directory.
-X.PP
-XThe \fBsh\fRell command starts an interactive shell.
-X.NH 2
-XDebugging Commands
-X.if n .ul 0
-X.ID
-X.ps
-X[line][,line] debug[!]
-Xvalidate[!]
-X.DE
-X.PP
-XThese commands are only available if you compile \*E with the -DDEBUG flag.
-X.PP
-XThe de\fBb\fRug command lists statistics for the blocks which contain
-Xthe specified range of lines.
-XIf the ! is present, then the contents of those blocks is displayed, too.
-X.PP
-XThe \fBva\fRlidate command checks certain variables for internal consistency.
-XNormally it doesn't output anything unless it detects a problem.
-XWith the !, though, it will always produce *some* output.
-/
-echo x - index.ms
-sed '/^X/s///' > index.ms << '/'
-X.XS 1
-XINTRODUCTION
-XWhat E\s-2LVIS\s+2 does,
-XCopyright,
-XHow to compile E\s-2LVIS\s+2,
-XOverview
-X.XA 2
-XVISUAL MODE COMMANDS
-XNormal interactive editing,
-XInput mode,
-XArrow keys,
-XDigraphs,
-XAbbreviations,
-XAuto-indentation
-X.XA 3
-XCOLON MODE COMMANDS
-XLine specifiers,
-XText entry,
-XCut & paste,
-XDisplay text,
-XGlobal operations,
-XLine editing,
-XUndo,
-XConfiguration & status,
-XMultiple files,
-XSwitching files,
-XWorking with a compiler,
-XExiting,
-XFile I/O,
-XDirectory & shell,
-XDebugging
-X.XA 4
-XREGULAR EXPRESSIONS
-XSyntax,
-XOptions,
-XSubstitutions,
-XExamples
-X.XA 5
-XOPTIONS
-XAutoindent,
-XAutoprint,
-Xetc.
-X.XA 6
-XCUT BUFFERS
-XPutting text into a cut buffer,
-XPasting from a cut buffer,
-XMacros,
-XThe effect of switching files
-X.XA 7
-XDIFFERENCES BETWEEN E\s-2LVIS\s+2 AND THE REAL VI/EX
-XExtensions,
-XOmissions
-X.XA 8
-XINTERNAL
-XFor programmers only,
-XThe temporary file,
-XImplementation of editing,
-XMarks and the cursor,
-XColon command interpretation,
-XScreen control,
-XPortability
-X.XA 9
-XCFLAGS
-X.XA 10
-XTERMCAP
-X.XA 11
-XENVIRONMENT VARIABLES
-X.XA 12
-XVERSIONS
-X.XA 13
-XQUESTIONS & ANSWERS
-X.XE
-X.PX
-X.sp 0.3i
-X.ce 1
-XUNIX-style "man" pages appear at the end of this manual.
-/
-echo x - internal.ms
-sed '/^X/s///' > internal.ms << '/'
-X.Go 8 "INTERNAL"
-X.PP
-XYou don't need to know the material in this section to use \*E.
-XYou only need it if you intend to modify \*E.
-X.PP
-XYou should also check out the CFLAGS, TERMCAP, ENVIRONMENT VARIABLES,
-XVERSIONS, and QUIESTIONS & ANSWERS sections of this manual.
-X.NH 2
-XThe temporary file
-X.PP
-XThe temporary file is divided into blocks of 1024 bytes each.
-XThe functions in "blk.c" maintain a cache of the five most recently used blocks,
-Xto minimize file I/O.
-X.PP
-XWhen \*E starts up, the file is copied into the temporary file
-Xby the function \fBtmpstart()\fR in "tmp.c".
-XSmall amounts of extra space are inserted into the temporary file to
-Xinsure that no text lines cross block boundaries.
-XThis speeds up processing and simplifies storage management.
-XThe extra space is filled with NUL characters.
-Xthe input file must not contain any NULs, to avoid confusion.
-XThis also limits lines to a length of 1023 characters or less.
-X.PP
-XThe data blocks aren't necessarily stored in sequence.
-XFor example, it is entirely possible that the data block containing
-Xthe first lines of text will be stored after the block containing the
-Xlast lines of text.
-X.PP
-XIn RAM, \*E maintains two lists: one that describes the "proper"
-Xorder of the disk blocks, and another that records the line number of
-Xthe last line in each block.
-XWhen \*E needs to fetch a given line of text, it uses these tables
-Xto locate the data block which contains that line.
-X.PP
-XBefore each change is made to the file, these lists are copied.
-XThe copies can be used to "undo" the change.
-XAlso, the first list
-X-- the one that lists the data blocks in their proper order --
-Xis written to the first data block of the temp file.
-XThis list can be used during file recovery.
-X.PP
-XWhen blocks are altered, they are rewritten to a \fIdifferent\fR block in the file,
-Xand the order list is updated accordingly.
-XThe original block is left intact, so that "undo" can be performed easily.
-X\*E will eventually reclaim the original block, when it is no longer needed.
-X.NH 2
-XImplementation of Editing
-X.PP
-XThere are three basic operations which affect text:
-X.ID
-X\(bu delete text	- delete(from, to)
-X\(bu add text	- add(at, text)
-X\(bu yank text	- cut(from, to)
-X.DE
-X.PP
-XTo yank text, all text between two text positions is copied into a cut buffer.
-XThe original text is not changed.
-XTo copy the text into a cut buffer,
-Xyou need only remember which physical blocks that contain the cut text,
-Xthe offset into the first block of the start of the cut,
-Xthe offset into the last block of the end of the cut,
-Xand what kind of cut it was.
-X(Cuts may be either character cuts or line cuts;
-Xthe kind of a cut affects the way it is later "put".)
-XYanking is implemented in the function \fBcut()\fR,
-Xand pasting is implemented in the function \fBpaste()\fR.
-XThese functions are defined in "cut.c".
-X.PP
-XTo delete text, you must modify the first and last blocks, and
-Xremove any reference to the intervening blocks in the header's list.
-XThe text to be deleted is specified by two marks.
-XThis is implemented in the function \fBdelete()\fR.
-X.PP
-XTo add text, you must specify
-Xthe text to insert (as a NUL-terminated string)
-Xand the place to insert it (as a mark).
-XThe block into which the text is to be inserted may need to be split into
-Xas many as four blocks, with new intervening blocks needed as well...
-Xor it could be as simple as modifying a single block.
-XThis is implemented in the function \fBadd()\fR.
-X.PP
-XThere is also a \fBchange()\fR function,
-Xwhich generally just calls delete() and add().
-XFor the special case where a single character is being replaced by another
-Xsingle character, though, change() will optimize things somewhat.
-XThe add(), delete(), and change() functions are all defined in "modify.c".
-X.PP
-XThe \fBinput()\fR function reads text from a user and inserts it into the file.
-XIt makes heavy use of the add(), delete(), and change() functions.
-XIt inserts characters one at a time, as they are typed.
-X.PP
-XWhen text is modified, an internal file-revision counter, called \fBchanges\fR,
-Xis incremented.
-XThis counter is used to detect when certain caches are out of date.
-X(The "changes" counter is also incremented when we switch to a different file,
-Xand also in one or two similar situations -- all related to invalidating caches.)
-X.NH 2
-XMarks and the Cursor
-X.PP
-XMarks are places within the text.
-XThey are represented internally as 32-bit values which are split
-Xinto two bitfields:
-Xa line number and a character index.
-XLine numbers start with 1, and character indexes start with 0.
-XLines can be up to 1023 characters long, so the character index is 10 bits
-Xwide and the line number fills the remaining 22 bits in the long int.
-X.PP
-XSince line numbers start with 1,
-Xit is impossible for a valid mark to have a value of 0L.
-X0L is therefore used to represent unset marks.
-X.PP
-XWhen you do the "delete text" change, any marks that were part of
-Xthe deleted text are unset, and any marks that were set to points
-Xafter it are adjusted.
-XMarks are adjusted similarly after new text is inserted.
-X.PP
-XThe cursor is represented as a mark.
-X.NH 2
-XColon Command Interpretation
-X.PP
-XColon commands are parsed, and the command name is looked up in an array
-Xof structures which also contain a pointer to the function that implements
-Xthe command, and a description of the arguments that the command can take.
-XIf the command is recognized and its arguments are legal,
-Xthen the function is called.
-X.PP
-XEach function performs its task; this may cause the cursor to be
-Xmoved to a different line, or whatever.
-X.NH 2
-XScreen Control
-X.PP
-XIn input mode or visual command mode,
-Xthe screen is redrawn by a function called \fBredraw()\fR.
-XThis function is called in the getkey() function before each keystroke is
-Xread in, if necessary.
-X.PP
-XRedraw() write to the screen via a package which looks like the "curses"
-Xlibrary, but isn't.
-XIt is actually much simpler.
-XMost curses operations are implemented as macros which copy characters
-Xinto a large I/O buffer, which is then written with a single large
-Xwrite() call as part of the refresh() operation.
-X.PP
-X(Note: Under MS-DOS, the pseudo-curses macros check to see whether you're
-Xusing the pcbios interface.  If you are, then the macros call functions
-Xin "pc.c" to implement screen updates.)
-X.PP
-XThe low-level functions which modify text (namely add(), delete(), and change())
-Xsupply redraw() with clues to help redraw() decide which parts of the
-Xscreen must be redrawn.
-XThe clues are given via a function called \fBredrawrange()\fR.
-X.PP
-XMost EX commands use the pseudo-curses package to perform their output,
-Xlike redraw().
-X.PP
-XThere is also a function called \fBmsg()\fR which uses the same syntax as printf().
-XIn EX mode, msg() writes message to the screen and automatically adds a
-Xnewline.
-XIn VI mode, msg() writes the message on the bottom line of the screen
-Xwith the "standout" character attribute turned on.
-X.NH 2
-XOptions
-X.PP
-XFor each option available through the ":set" command,
-X\*E contains a character array variable, named "o_\fIoption\fR".
-XFor example, the "lines" option uses a variable called "o_lines".
-X.PP
-XFor boolean options, the array has a dimension of 1.
-XThe first (and only) character of the array will be NUL if the
-Xvariable's value is FALSE, and some other value if it is TRUE.
-XTo check the value, just by dereference the array name,
-Xas in "if (*o_autoindent)".
-X.PP
-XFor number options, the array has a dimension of 3.
-XThe array is treated as three unsigned one-byte integers.
-XThe first byte is the current value of the option.
-XThe second and third bytes are the lower and upper bounds of that
-Xoption.
-X.PP
-XFor string options, the array usually has a dimension of about 60
-Xbut this may vary.
-XThe option's value is stored as a normal NUL-terminated string.
-X.PP
-XAll of the options are declared in "opts.c".
-XMost are initialized to their default values;
-Xthe \fBinitopts()\fR function is used to perform any environment-specific
-Xinitialization.
-X.NH 2
-XPortability
-X.PP
-XTo improve portability, \*E collects as many of the system-dependent
-Xdefinitions as possible into the "config.h" file.
-XThis file begins with some preprocessor instructions which attempt to
-Xdetermine which compiler and operating system you have.
-XAfter that, it conditionally defines some macros and constants for your system.
-X.PP
-XOne of the more significant macros is \fBttyread()\fR.
-XThis macro is used to read raw characters from the keyboard, possibly
-Xwith timeout.
-XFor UNIX systems, this basically reads bytes from stdin.
-XFor MSDOS, TOS, and OS9, ttyread() is a function defined in curses.c.
-XThere is also a \fBttywrite()\fR macro.
-X.PP
-XThe \fBtread()\fR and \fBtwrite()\fR macros are versions of read() and write() that are
-Xused for text files.
-XOn UNIX systems, these are equivelent to read() and write().
-XOn MS-DOS, these are also equivelent to read() and write(),
-Xsince DOS libraries are generally clever enough to convert newline characters
-Xautomatically.
-XFor Atari TOS, though, the MWC library is too stupid to do this,
-Xso we had to do the conversion explicitly.
-X.PP
-XOther macros may substitute index() for strchr(), or bcopy() for memcpy(),
-Xor map the "void" data type to "int", or whatever.
-X.PP
-XThe file "tinytcap.c" contains a set of functions that emulate the termcap
-Xlibrary for a small set of terminal types.
-XThe terminal-specific info is hard-coded into this file.
-XIt is only used for systems that don't support real termcap.
-XAnother alternative for screen control can be seen in
-Xthe "curses.h" and "pc.c" files.
-XHere, macros named VOIDBIOS and CHECKBIOS are used to indirectly call
-Xfunctions which perform low-level screen manipulation via BIOS calls.
-X.PP
-XThe stat() function must be able to come up with UNIX-style major/minor/inode
-Xnumbers that uniquely identify a file or directory.
-X.PP
-XPlease try to keep you changes localized,
-Xand wrap them in #if/#endif pairs,
-Xso that \*E can still be compiled on other systems.
-XAnd PLEASE let me know about it, so I can incorporate your changes into
-Xmy latest-and-greatest version of \*E.
-/
-echo x - intro.ms
-sed '/^X/s///' > intro.ms << '/'
-X.Go 1 "INTRODUCTION"
-X.PP
-X\*E is a clone of vi/ex, the standard UNIX editor.
-X\*E supports nearly all of the vi/ex commands,
-Xin both visual mode and colon mode.
-X.PP
-XLike vi/ex, \*E stores most of the text in a temporary file, instead of RAM.
-XThis allows it to edit files that are too large to fit
-Xin a single process' data space.
-XAlso, the edit buffer can survive a power failure or crash.
-X.PP
-X\*E runs under BSD UNIX, AT&T SysV UNIX, Minix, MS-DOS, Atari TOS,
-XCoherent, OS9/68000, VMS and AmigaDos.
-XThe next version is also expected to add MS-Windows, OS/2 and MacOS.
-XContact me before you start porting it to some other OS,
-Xbecause somebody else may have already done it for you.
-X.PP
-X\*E is freely redistributable, in either source form or executable form.
-XThere are no restrictions on how you may use it.
-X.NH 2
-XCompiling
-X.PP
-XSee the "Versions" section of this manual for instructions on how to compile
-X\*E.
-X.PP
-XIf you want to port \*E to another O.S. or compiler, then
-Xyou should start be reading the "Portability" part of the "Internal" section.
-X.NH 2
-XOverview of \*E
-X.PP
-XThe user interface of \*E/vi/ex is weird.
-XThere are two major command modes in \*E, and a few text input modes as well.
-XEach command mode has a command which allows you to switch to the other mode.
-X.PP
-XYou will probably use the \fIvisual command mode\fR
-Xmost of the time.
-XThis is the mode that \*E normally starts up in.
-X.PP
-XIn visual command mode, the entire screen is filled with lines of text
-Xfrom your file.
-XEach keystroke is interpretted as part of a visual command.
-XIf you start typing text, it will \fInot\fR be inserted,
-Xit will be treated as part of a command.
-XTo insert text, you must first give an "insert text" command.
-XThis will take some getting used to.
-X(An alternative exists.
-XLookup the "inputmode" option.)
-X.PP
-XThe \fIcolon mode\fR is quite different.
-X\*E displays a ":" character on the bottom line of the screen, as a prompt.
-XYou are then expected to type in a command line and hit the <Return> key.
-XThe set of commands recognized in the colon mode is different
-Xfrom visual mode's.
-/
-echo x - options.ms
-sed '/^X/s///' > options.ms << '/'
-X.Go 5 "OPTIONS"
-X.PP
-XOptions may be set or examined via the colon command "set".
-XThe values of options will affect the operation of later commands.
-X.PP
-XFor convenience, options have both a long descriptive name and a short name
-Xwhich is easy to type.
-XYou may use either name interchangably.
-XI like the short names, myself.
-X.PP
-XThere are three types of options: Boolean, string, and numeric.
-XBoolean options are made TRUE by giving the name of the option as an
-Xargument to the "set" command;
-Xthey are made FALSE by prefixing the name with "no".
-XFor example, "set autoindent" makes the autoindent option TRUE,
-Xand "set noautoindent" makes it FALSE.
-X\*E also allows boolean options to be toggled by prefixing the name with "neg".
-XSo, ":map g :set neglist^M" will cause the <g> key to alternately toggle the
-X"list" option on and off.
-X(The "neg" prefix is an extension; the real vi doesn't support it.)
-X.PP
-XTo change the value of a string or numeric option, pass the "set" command
-Xthe name of the option, followed by an "=" sign and the option's new value.
-XFor example, "set tabstop=8" will give the tabstop option a value of 8.
-XFor string options, you may enclose the new value in quotes.
-X.LD
-X.ta 1.9i 2.4i 3.8i
-X.ps +2
-X\fBNAMES	TYPE	DEFAULT	MEANING\fP
-X.ps
-Xautoindent, ai	Bool	noai	auto-indent during input
-Xautoprint, ap	Bool	ap	in EX, print the current line
-Xautotab, at	Bool	at	auto-indent allowed to use tabs?
-Xautowrite, aw	Bool	noaw	auto-write when switching files
-Xbeautify,  bf	Bool	nobf	strip control chars from file?
-Xcharattr, ca	Bool	noca	interpret \\fX sequences?
-Xcc, cc	Str	cc="cc -c"	name of the C compiler
-Xcolumns, co	Num	co=80	width of the screen
-Xdigraph, dig	Bool	nodig	recognize digraphs?
-Xdirectory, dir	Str	dir="/usr/tmp"	where tmp files are kept
-Xedcompatible, ed	Bool	noed	remember ":s//" options
-Xequalprg, ep	Bool	ep="fmt"	program to run for = operator
-Xerrorbells, eb	Bool	eb	ring bell on error
-Xexrc, exrc	Bool	noexrc	read "./.exrc" file?
-Xexrefresh, er	Bool	er	write lines indiviually in EX
-Xflash, vbell	Bool	flash	use visible alternative to bell
-Xflipcase, fc	Str	fc=""	non-ASCII chars flipped by ~
-Xhideformat, hf	Bool	hf	hide text formatter commands
-Xignorecase, ic	Bool	noic	upper/lowercase match in search
-Xinputmode, im	Bool	noim	start vi in insert mode?
-Xkeytime, kt	Num	kt=2	timeout for mapped key entry
-Xkeywordprg, kp	Str	kp="ref"	full pathname of shift-K prog
-Xlines, ln	Num	ln=25	number of lines on the screen
-Xlist, li	Bool	noli	display lines in "list" mode
-Xmagic, ma	Bool	ma	use regular expression in search
-Xmake, mk	Str	mk="make"	name of the "make" program
-Xmesg, ms	Bool	ms	allow messages from other users?
-Xmodelines, ml	Bool	noml	are modelines processed?
-Xmore, more	Bool	more	pause between messages?
-Xnovice, nov	Bool	nonovice	set options for ease of use
-Xparagraphs, para	Str	para="PPppIPLPQP"	names of "paragraph" nroff cmd
-Xprompt, pr	Bool	pr	show ':' prompt in \fIex\fR mode
-Xreadonly, ro	Bool	noro	prevent overwriting of orig file
-Xremap, rem	Bool	remap	allow key maps to call key maps
-Xreport, re	Num	re=5	report when 5 or more changes
-Xruler, ru	Bool	noru	display line/column numbers
-Xscroll, sc	Num	sc=12	scroll amount for ^U and ^D
-Xsections, sect	Str	sect="NHSHSSSEse"	names of "section" nroff cmd
-Xshell, sh	Str	sh="/bin/sh"	full pathname of the shell
-Xshowmatch, sm	Bool	nosm	show matching ()[]{}
-Xshowmode, smd	Bool	nosmd	say when we're in input mode
-Xshiftwidth, sw	Num	sw=8	shift amount for < and >
-Xsidescroll, ss	Num	ss=8	amount of sideways scrolling
-Xsync, sy	Bool	nosy	call sync() often
-Xtabstop, ts	Num	ts=8	width of tab characters
-Xtaglength, tl	Num	tl=0	significant chars in tag name
-Xterm, te	Str	te="$TERM"	name of the termcap entry
-Xterse, tr	Bool	notr	give shorter error messages
-Xtimeout, to	Bool	to	distinguish <esc> from <arrow>?
-Xwarn, wa	Bool	wa	warn for ! if file modified
-Xwindow, wi	Num	wi=24	lines to redraw after long move
-Xwrapmargin, wm	Num	wm=0	wrap long lines in input mode
-Xwrapscan, ws	Bool	ws	at EOF, searches wrap to line 1
-Xwriteany, wr	Bool	nowr	allow :w to clobber files
-X.DE
-X.TA
-X.ne 6
-X.IP "autoindent, ai"
-XDuring input mode, the autoindent option will cause each added line
-Xto begin with the same amount of leading whitespace as the line above it.
-XWithout autoindent, added lines are initially empty.
-X.IP "autoprint, ap"
-XThis option only affects EX mode.
-XIf the autoprint option on,
-Xand either the cursor has moved to a different line
-Xor the previous command modified the file,
-Xthen \*E will print the current line.
-X.IP "autotab, at"
-XThis option affects the behaviour of the autoindent mode.
-XIf autoindent is turned off, then autotab has no effect.
-X.IP
-XWhen autotab is turned on, elvis will use a mixture of spaces and tabs
-Xto create the proper amount of indentation.
-XThis is the default.
-X.IP
-XWhen autotab is turned off, elvis will only use spaces for auto-indent.
-X\*E will still insert a real tab character when you hit the <Tab> key, though;
-Xthe autotab option only affects \fIautomatic\fR indentation.
-X.IP "autowrite, aw"
-XWhen you're editing one file and decide to switch to another
-X\- via the :tag command, or :next command, perhaps \-
-Xif your current file has been modified,
-Xthen \*E will normally print an error message and refuse to switch.
-X.IP
-XHowever, if the autowrite option is on,
-Xthen \*E will write the modified version of the current file
-Xand successfully switch to the new file.
-X.IP "beautify, bf"
-XThis option causes all control characters to be deleted from the text file,
-Xat the time when you start editing it.
-XIf you're already editing a file when you turn on the beautify option,
-Xthen that file won't be affected.
-X.IP cc
-XThe :cc command runs the C compiler.
-XThis option should be set to the name of your compiler.
-X.IP "charattr, ca"
-XMany text formatting programs allow you to designate portions of
-Xyour text to be underlined, italicized, or boldface by embedding
-Xthe special strings \\fU, \\fI, and \\fB in your text.
-XThe special string \\fP marks the end of underlined or boldface text.
-X.IP
-X\*E normally treats those special strings just like any other text.
-X.IP
-XHowever, if the charattr option is on, then \*E will interpret
-Xthose special strings correctly,
-Xto display underlined or boldface text on the screen.
-X(This only works, of course, if your terminal can display
-Xunderlined and boldface, and if the TERMCAP entry says how to do it.)
-X.IP "columns, co"
-XThis option shows how wide your screen is.
-X.IP "digraph, dig"
-XThis option is used to enable/disable recognition of digraphs.
-XThe default value is nodigraph, which means that digraphs will not be
-Xrecognized.
-X.IP "directory, dir"
-X\*E stores text in temporary files.
-XThis option allows you to control which directory those temporary files will
-Xappear in.
-XThe default is /usr/tmp.
-X.IP
-XThis option can only be set in a .exrc file;
-Xafter that, \*E will have already started making temporary files
-Xin some other directory, so it would be too late.
-X.IP "edcompatible, ed"
-XThis option affects the behaviour of the ":s/regexp/text/options" command.
-XIt is normally off (:se noed) which causes all of the substitution options
-Xto be off unless explicitly given.
-X.IP
-XHowever, with edcompatible on (:se ed), the substitution command remembers
-Xwhich options you used last time.
-XThose same options will continue to be used until you change them.
-XIn edcompatible mode, when you explicitly give the name of a
-Xsubstitution option, you will toggle the state of that option.
-X.IP
-XThis all seems very strange to me, but its implementation was almost free
-Xwhen I added the ":&" command to repeat the previous substitution,
-Xso there it is.
-X.IP "equalprg, ep"
-XThis holds the name & arguments of the external filter program
-Xused the the visual = operator.
-XThe defualt value is "fmt",
-Xso the = operator will adjust line breaks in text.
-X.IP "errorbells, eb"
-X\*E normally rings a bell when you do something wrong.
-XThis option lets you disable the bell.
-X.IP exrc
-XThis option specifies whether a .exrc file in the current directory
-Xshould be executed.
-XBy default, this option is off (":set noexrc") which prevents elvis from
-Xexecuting .exrc in the current directory.
-XIf the .exrc file in your home directory turns this option on (":set exrc")
-Xthen the \*E will attempt to execute the .exrc file in the current directory.
-X.IP
-XThis option exist mainly for security reasons.
-XA mean-spirited person could do something like
-X.br
-X	echo >/tmp/.exrc '!rm -rf $HOME'
-X.br
-Xand then anybody who attempted to edit or view a file in the /tmp directory
-Xwould lose most of their files.
-XWith the exrc option turned off, this couldn't happen to you.
-X.IP "exrefresh, er"
-XThe EX mode of \*E writes many lines to the screen.
-XYou can make \*E either write each line to the screen separately,
-Xor save up many lines and write them all at once.
-X.IP
-XThe exrefresh option is normally on, so each line is written to the
-Xscreen separately.
-X.IP
-XYou may wish to turn the exrefresh option off (:se noer) if the
-X"write" system call is costly on your machine, or if you're using a
-Xwindowing environment.
-X(Windowing environments scroll text a lot faster when you write
-Xmany lines at once.)
-X.IP
-XThis option has no effect in visual command mode or input mode.
-X.IP "flash, vbell"
-XIf your termcap entry describes a visible alternative to ringing
-Xyour terminal's bell, then this option will say whether the visible
-Xversion gets used or not.
-XNormally it will be.
-X.IP
-XIf your termcap does NOT include a visible bell capability,
-Xthen the flash option will be off, and you can't turn it on.
-X.IP "flipcase, fc"
-XThe flipcase option allows you to control how the non-ASCII characters are
-Xaltered by the "~" command.
-X.IP
-XThe string is divided into pairs of characters.
-XWhen "~" is applied to a non-ASCII character,
-X\*E looks up the character in the flipcase string to see which pair it's in,
-Xand replaces it by the other character of the pair.
-X.IP "hideformat, hf"
-XMany text formatters require you to embed format commands in your text,
-Xon lines that start with a "." character.
-X\*E normally displays these lines like any other text,
-Xbut if the hideformat option is on,
-Xthen format lines are displayed as blank lines.
-X.IP "ignorecase, ic"
-XNormally, when \*E searches for text, it treats uppercase letters
-Xas being different for lowercase letters.
-X.IP
-XWhen the ignorecase option is on, uppercase and lowercase are treated as equal.
-X.IP "inputmode, im"
-XThis option allows you to have \*E start up in insert mode.
-XYou can still exit insert mode at any time by hitting the ESC key, as usual.
-XUsually, this option would be set in your ".exrc" file.
-X.IP "keytime, kt"
-XThe arrow keys of most terminals send a multi-character sequence.
-XIt takes a measurable amount of time for these sequences to be transmitted.
-XThe keytime option allows you to control the maximum amount of time
-Xto allow for an arrow key (or other mapped key) to be received in full.
-X.IP
-XOn most systems, the setting is the number of tenths of a second to allow
-Xbetween characters.
-XOn some other systems, the setting is in whole seconds.
-X.IP
-XTry to avoid setting keytime=1.
-XMost systems just count clock beats, so if you tried to read a character
-Xshortly before a clock beat, you could allow almost no time at all for
-Xreading the characters.
-XFor higher keytime settings, the difference is less critical.
-X.IP
-XIf your system's response time is poor, you might want to increase the keytime.
-XIn particular, I've found that when keystrokes must be sent through a network
-X(via X windows, rlogin, or telnet, for example) the keytime should be set to
-Xat least 1 second.
-X.IP
-XAs a special case,
-Xyou can set keytime to 0 to disable this time limit stuff altogether.
-XThe big problem here is:
-XIf your arrow keys' sequences start with an ESC,
-Xthen every time you hit your ESC key \*E will wait... and wait...
-Xto see if maybe that ESC was part of an arrow key's sequence.
-X.IP
-XNOTE: this option is a generalization of the timeout option of the real vi.
-X.IP "keywordprg, kp"
-X\*E has a special keyword lookup feature.
-XYou move the cursor onto a word, and hit shift-K,
-Xand \*E uses another program to look up the word
-Xand display information about it.
-X.IP
-XThis option says which program gets run.
-X.IP
-XThe default value of this option is "ref",
-Xwhich is a program that looks up the definition of a function in C.
-XIt looks up the function name in a file called "refs" which is created by ctags.
-X.IP
-XYou can subtitute other programs, such as an English dictionary program
-Xor the online manual.
-X\*E runs the program, using the keyword as its only argument.
-XThe program should write information to stdout.
-XThe program's exit status should be 0, unless you want \*E to print
-X"<<< failed >>>".
-X.IP "lines, ln"
-XThis option says how many lines you screen has.
-X.IP "list, li"
-XIn nolist mode (the default), \*E displays text in a "normal" manner
-X-- with tabs expanded to an appropriate number of spaces, etc.
-X.IP
-XHowever, sometimes it is useful to have tab characters displayed differently.
-XIn list mode, tabs are displayed as "^I",
-Xand a "$" is displayed at the end of each line.
-X.IP "magic, ma"
-XThe search mechanism in \*E can accept "regular expressions"
-X-- strings in which certain characters have special meaning.
-X.IP
-XThe magic option is normally on, which causes these characters to be treated
-Xspecially.
-X.IP
-XIf you turn the magic option off (:se noma),
-Xthen all characters except ^ and $ are treated literally.
-X^ and $ retain their special meanings regardless of the setting of magic.
-X.IP "make, mk"
-XThe :make command runs your "make" program.
-XThis option defines the name of your "make" program.
-X.IP mesg
-XWith the real vi, running under real UNIX,
-X":set nomesg" would prevent other users from sending you messages.
-X\*E ignores it, though.
-X.IP "modelines, ml"
-X\*E supports modelines.
-XModelines are lines near the beginning or end of your text file which
-Xcontain "ex:yowza:",
-Xwhere "yowza" is any EX command.
-XA typical "yowza" would be something like "set ts=5 ca kp=spell wm=15".
-XOther text may also appear on a modeline,
-Xso you can place the "ex:yowza:" in a comment:
-X.br
-X.ID
-X/* ex:set sw=4 ai: */
-X.DE
-X.IP
-XNormally these lines are ignored, for security reasons,
-Xbut if you have "set modelines" in your .exrc file
-Xthen "yowza" is executed.
-X.IP "novice, nov"
-XThe command ":set novice" is equivelent to ":set nomagic report=1 showmode".
-X.IP "paragraphs, pa"
-XThe { and } commands move the cursor forward or backward in increments
-Xof one paragraph.
-XParagraphs may be separated by blank lines, or by a "dot" command of
-Xa text formatter.
-XDifferent text formatters use different "dot" commands.
-XThis option allows you to configure \*E to work with your text formatter.
-X.IP
-XIt is assumed that your formatter uses commands that start with a
-X"." character at the front of a line,
-Xand then have a one- or two-character command name.
-X.IP
-XThe value of the paragraphs option is a string in which each pair
-Xof characters is one possible form of your text formatter's paragraph
-Xcommand.
-X.IP "more"
-XWhen \*E must display a sequence of messages at the bottom line of the screen
-Xin visual mode, it normally pauses after all but the last one, so you have
-Xtime to read them all.
-X.IP
-XIf you turn off the "more" option, then \*E will not pause.
-XThis means you can only read the last message, but it is usually the most
-Ximportant one anyway.
-X.IP "prompt, pr"
-XIf you ":set noprompt", then \*E will no longer emit a ':' when it
-Xexpects you to type in an \fIex\fR command.
-XThis is slightly useful if you're using an astonishingly slow UNIX machine,
-Xbut the rest of us can just ignore this one.
-X.IP "readonly, ro"
-XNormally, \*E will let you write back any file to which you have
-Xwrite permission.
-XIf you don't have write permission, then you can only write the changed
-Xversion of the file to a \fIdifferent\fP file.
-X.IP
-XIf you set the readonly option,
-Xthen \*E will pretend you don't have write permission to \fIany\fP file you edit.
-XIt is useful when you really only mean to use \*E to look at a file,
-Xnot to change it.
-XThis way you can't change it accidentally.
-X.IP
-XThis option is normally off, unless you use the "view" alias of \*E.
-X"View" is like "vi" except that the readonly option is on.
-X.IP "remap"
-XThe ":map" command allows you to convert one key sequence into another.
-XThe remap option allows you to specify what should happen if portions of
-Xthat other sequence are also in the map table.
-XIf remap is on, then those portions will also be mapped, just as if they
-Xhad been typed on the keyboard.
-XIf remap is off, then the matching portions will not be mapped.
-X.IP
-XFor example, if you enter the commands ":map A B" and ":map B C",
-Xthen when remap is on, A will be converted to C.
-XBut when remap is off, A will be converted only to B.
-X.IP "report, re"
-XCommands in \*E may affect many lines.
-XFor commands that affect a lot of lines, \*E will output a message saying
-Xwhat was done and how many lines were affected.
-XThis option allows you to define what "a lot of lines" means.
-XThe default is 5, so any command which affects 5 or more lines will cause
-Xa message to be shown.
-X.IP "ruler, ru"
-XThis option is normally off.
-XIf you turn it on, then \*E will constantly display the line/column numbers
-Xof the cursor, at the bottom of the screen.
-X.IP "scroll, sc"
-XThe ^U and ^D keys normally scroll backward or forward by half a screenful,
-Xbut this is adjustable.
-XThe value of this option says how many lines those keys should scroll by.
-XIf you invoke ^U or ^D with a count argument (for example, "33^D") then
-Xthis option's value is set to the count.
-X.IP "sections, se"
-XThe [[ and ]] commands move the cursor backward or forward in increments of
-X1 section.
-XSections may be delimited by a { character in column 1
-X(which is useful for C source code)
-Xor by means of a text formatter's "dot" commands.
-X.IP
-XThis option allows you to configure \*E to work with your text formatter's
-X"section" command, in exectly the same way that the paragraphs option makes
-Xit work with the formatter's "paragraphs" command.
-X.IP "shell, sh"
-XWhen \*E forks a shell
-X(perhaps for the :! or :shell commands)
-Xthis is the program that is uses as a shell.
-XThis is "/bin/sh" by default,
-Xunless you have set the SHELL (or COMSPEC, for MS-DOS) environment variable,
-Xit which case the default value is copied from the environment.
-X.IP "shiftwidth, sw"
-XThe < and > commands shift text left or right by some uniform number of columns.
-XThe shiftwidth option defines that "uniform number".
-XThe default is 8.
-X.IP "showmatch, sm"
-XWith showmatch set,
-Xin input mode every time you hit one of )}],
-X\*E will momentarily move the cursor to the matching ({[.
-X.IP "showmode, smd"
-XIn visual mode, it is easy to forget whether you're in the visual command mode
-Xor input/replace mode.
-XNormally, the showmode option is off, and you haven't a clue as to which mode
-Xyou're in.
-XIf you turn the showmode option on, though, a little message will appear in the
-Xlower right-hand corner of your screen, telling you which mode you're in.
-X.IP "sidescroll, ss"
-XFor long lines, \*E scrolls sideways.
-X(This is different from the real vi,
-Xwhich wraps a single long line onto several rows of the screen.)
-X.IP
-XTo minimize the number of scrolls needed,
-X\*E moves the screen sideways by several characters at a time.
-XThe value of this option says how many characters' widths to scroll at a time.
-X.IP
-XGenerally, the faster your screen can be redrawn,
-Xthe lower the value you will want in this option.
-X.IP "sync, sy"
-XIf the system crashes during an edit session, then most of your work
-Xcan be recovered from the temporary file that \*E uses to store
-Xchanges.
-XHowever, sometimes the OS will not copy changes to the
-Xhard disk immediately, so recovery might not be possible.
-XThe [no]sync option lets you control this.
-X.IP
-XIn nosync mode (which is the default, for UNIX), \*E lets the operating system
-Xcontrol when data is written to the disk.
-XThis is generally faster.
-X.IP
-XIn sync mode (which is the default for MS-DOS, AmigaDos, and Atari TOS),
-X\*E forces all changes out
-Xto disk every time you make a change.
-XThis is generally safer, but slower.
-XIt can also be a rather rude thing to do on a multi-user system.
-X.IP "tabstop, ts"
-XTab characters are normally 8 characters wide,
-Xbut you can change their widths by means of this option.
-X.IP "taglength, tl"
-XThis option allows you to specify how many characters of a tag's name
-Xmust match when performing tag lookup.
-XAs a special case, ":set taglength=0" means that all characters of a tag's
-Xname must match.
-X.IP
-XNote: some configurations of \*E don't support this option.
-X.IP "term, te"
-XThis read-only option shows the name of the termcap entry that
-X\*E is using for your terminal.
-X.IP "terse, tr"
-XThe real vi uses this option to select longer vs. shorter error messages.
-X\*E has only one set of error messages, though, so this option has no effect.
-X.IP "timeout, to"
-XThe command ":set notimeout" is equivelent to ":set keytime=0",
-Xand ":set timeout" is equivelent to ":set keytime=1".
-XThis affects the behaviour of the <Esc> key.
-XSee the discussion of the "keytime" option for more information.
-X.IP "warn, wa"
-XIf you have modified a file but not yet written it back to disk, then
-X\*E will normally print a warning before executing a ":!cmd" command.
-XHowever, in nowarn mode, this warning is not given.
-X.IP
-X\*E also normally prints a message after a successful search that
-Xwrapped at EOF.
-XThe [no]warn option can also disable this warning.
-X.IP "window, wi"
-XThis option controls how many lines are redrawn after a long move.
-X.IP
-XOn fast terminals, this is usually set to the number of rows that the
-Xterminal can display, minus one.
-XThis causes the entire screen to be filled with text around the cursor.
-X.IP
-XOn slow terminals, you may wish to reduce this value to about 7 or so.
-XThat way, if you're doing something like repeatedly hitting 'n' to search
-Xfor each occurrence of some string and trying to find a particular occurrence,
-Xthen you don't need to wait as long for \*E to redraw the screen after each
-Xsearch.
-X.IP "wrapmargin, wm"
-XNormally (with wrapmargin=0) \*E will let you type in extremely long
-Xlines, if you wish.
-X.IP
-XHowever, with warpmargin set to something other that 0 (wrapmargin=10
-Xis nice), \*E will automatically cause long lines to be "wrapped"
-Xon a word break for lines come too close to the right-hand margin.
-XFor example: On an 80-column screen, ":set wm=10" will cause lines to
-Xwrap when their length exceeds 70 columns.
-X.IP "wrapscan, ws"
-XNormally, when you search for something, \*E will find it no matter
-Xwhere it is in the file.
-X\*E starts at the cursor position, and searches forward.
-XIf \*E hits EOF without finding what you're looking for,
-Xthen it wraps around to continue searching from line 1.
-XIf you turn off the wrapscan option (:se nows),
-Xthen when \*E hits EOF during a search, it will stop and say so.
-X.IP "writeany, wr"
-XWith "writeany" turned off, elvis will prevent you from accidentally
-Xoverwriting a file.
-XFor example, if "foo" exists then ":w foo" will fail.
-XIf you turn on the "writeany" option, then ":w foo" will work.
-X.IP
-XRegardless of the setting of "writeany", though, ":w! foo" will work.
-XThe '!' forces the ":w" command to write the file unless the operating system
-Xwon't allow it.
-/
-echo x - question.ms
-sed '/^X/s///' > question.ms << '/'
-X.nr Qn 0 1
-X.de QQ
-X.sp
-X.IP \fB\\n+(Qn) 0.3i
-X..
-X.de AA
-X.IP \fR 0.75i
-X..
-X.Go 13 "QUESTIONS & ANSWERS"
-X.QQ
-XHow can I make elvis run faster under DOS?
-X.AA
-XThere are several things you can do.
-XThe first thing to do is get a good screen driver such as NANSI.SYS.
-XThis can speed up screen redrawing by as much as a factor of eight!
-XThe DOS-specific part of section 12 tells you how to do this.
-X.AA
-XYou might also consider reducing the size of the blocks that elvis uses.
-XYou'll need to recompile \*E to do this.
-XThe default BLKSIZE is 1024 byte for the DOS version of \*E, which means
-Xthat for each keystroke that you insert, elvis must shift an average of
-Xabout 500 bytes.
-XThat's a lot to ask from a little old 5MHz 8088.
-XA BLKSIZE of 512 bytes might be more appropriate.
-X.AA
-XIf you're \fIreally\fR desperate for more speed, you might want to make
-X\*E store its temporary files on a RAM disk.
-XHowever, this limits the size of the file you can edit, and it eliminates any
-Xchance you may have had to recover your work after a power failure
-Xor system crash, but it might be worth it; you decide.
-XTo do this, add ":set dir=R:\\" (or whatever your RAM disk's name is)
-Xto the \fIelvis.rc\fP file.
-X.AA
-XNext, consider turning off the "sync" option.
-XWhen the sync option is turned on, \*E will close the temporary file
-Xand reopen it after every change, in order to force DOS to update
-Xthe file's directory entry.
-XIf you put ":set nosync" into the \fIelvis.rc\fP file, then elvis will
-Xonly close the file when you start editing a different text file, or
-Xwhen you're exiting \*E.
-XConsequently, there is no chance that you'll be able to recover your
-Xchanges after a power failure... so if you're going to this, then you
-Xmight as well store the temp files on the RAM disk, too.
-X.QQ
-XWhere's the <Esc> key on a DEC keyboard?
-X.AA
-XI don't know.  Maybe the <F11> key?
-XYou could always use ":map!" to make some other key act like the <Esc> key.
-XIf all else fails, use <Control><[>.
-X.QQ
-XIs there a way to show which keys do what?
-X.AA
-XYes.  The command ":map" will show what each key does in command mode,
-Xand ":map!" (with an exclamation mark) shows what each key does in
-Xinput mode.
-X.AA
-XThe table is divided into three columns: the key's label, the characters
-Xthat it sends, and the characters that \*E pretends you typed.
-X.QQ
-XHow can I make \*E display long lines like the real vi?
-X.AA
-XYou can't yet.
-XThe next version of \*E shouldsupport this, though.
-X.QQ
-XI can't recover my text [under MS-DOS or Atari TOS].
-XAccording to the directory listing, the temporary file is 0 bytes long.
-XWhat went wrong?
-X.AA
-XMS-DOS and TOS only update a file's directory entry when the file is closed.
-XIf the system crashes while the file is still open, then the file's length
-Xis stored as 0 bytes.
-XThe ":set sync" option is supposed to prevent this;
-Xyou probably turned it off in the interest of speed, right?
-X.AA
-XUnder MS-DOS [I don't know about TOS], you should delete the empty
-Xtemporary file, and then run CHKDSK/F.
-XThis \fImight\fP find the data that belonged in the empty file,
-Xand place it in a new file with a name like "000001.CHK" -- something like that.
-XYou can then try to extract the text from that temporary file by giving the
-Xcommand "elvprsv -R 000001.chk >goodnews.txt".
-XIf you're lucky, then your text might be in GOODNEWS.TXT.
-X.QQ
-XWhat is the most current version of \*E?
-X.AA
-XEach version of \*E that is released to the public has a version number
-Xof the form "number point number".
-XAs I write this, the most current version of elvis is 1.5.
-X.AA
-XThe intermediate steps between one release and the next are labeled with
-Xthe \fInext\fP version number, with a letter appended.
-XFor example, after 1.4 was released, I started working on 1.5a.
-XI am currently working on 2.0a.
-XWhen \*E reaches a stable state, I'll call it 2.0 and release it.
-X.AA
-XSometimes a beta-test version of elvis will be available via anonymous FTP
-Xfrom m2xenix.psg.com, in the directory "pub/elvis/beta".
-X.QQ
-XI only got executables, but now I want the source code.
-XWhere can I get it?
-X.AA
-XIf you have access to the Internet, then you should be able to fetch it
-Xfrom one of the public archives such as \fBplains.nodak.edu\fP.
-XIt is accessible via anonymous FTP, or via an email server named
-X"archive-server@plains.nodak.edu".
-XElvis is located in the directory "/pub/Minix/all.contrib".
-X.AA
-XI will also offer it to the C Users' Group.
-XThey sell C source code for us$8 per diskette
-X(or slightly more outside  North  America).
-XTheir phone number is (913) 841-1631,
-Xand their address is:
-X.ID
-XThe C Users' Group
-XPO Box 3127
-XLawrence KS 66046-0127
-X.DE
-X.QQ
-XIs this shareware, or public domain, or what?
-X.AA
-XIt is not public domain; it is copyrighted by me, Steve Kirkendall.
-XHowever, this particular version is freely redistributable, in either
-Xsource form or executable form.
-X(I would prefer that you give copies away for free, complete with the
-Xfull source code... but I'm not going to force you.)
-X.AA
-XIt is not shareware; you aren't expected to send me anything.
-XYou can use it without guilt.
-X.AA
-XIt is not "copylefted."
-XI hold a copyright, but currently I have not added any of the usual restrictions
-Xthat you would find on copylefted software.
-XIf people start doing really obnoxious things to \*E, then I will start
-Xadding restrictions to subsequent versions, but earlier versions won't
-Xbe affected.
-X(So far, everybody has been pretty good about this so no restrictions
-Xhave been necessary.)
-X.QQ
-XCan I reuse parts of your source code?
-X.AA
-XYes.  Please be careful, though, to make sure that the code really is mine.
-XSome of the code was contributed by other people, and I don't have the
-Xauthority to give you permission to use it.
-XThe author's name can be found near the top of each source file.
-XIf it says "Steve Kirkendall" then you may use it;
-Xotherwise, you'd better contact the author first.
-X.AA
-XPlease don't remove my name from the source code.
-XIf you modify the source, please make a note of that fact in a comment
-Xnear the top of the source code.
-XAnd, finally, please mention my name in your documentation.
-X.QQ
-XCan \*E work with non-ASCII files?
-X.AA
-X\*E can't edit binary files because it can't handle the NUL character,
-Xand because of line-length limitations.
-XHowever, it is 8-bit clean so you should be able to edit any European
-Xextended ASCII file without any surprises.
-X.AA
-X\*E has also been modified to work with 16-bit character sets.
-XYongguang Zhang (ygz@cs.purdue.edu) has created a Chinese version of \*E
-Xthat uses 16-bit characters and runs under cxterm (Chinese X-term)
-Xon X-windows systems.
-XJunichiro Itoh (itojun@foretune.co.jp) has modified \*E to edit Japanese
-Xtext under MS-DOS.
-/
-echo x - regexp.ms
-sed '/^X/s///' > regexp.ms << '/'
-X.Go 4 "REGULAR EXPRESSIONS"
-X
-X.PP
-X\*E uses regular expressions for searching and substututions.
-XA regular expression is a text string in which some characters have
-Xspecial meanings.
-XThis is much more powerful than simple text matching.
-X.SH
-XSyntax
-X.PP
-X\*E' regexp package treats the following one- or two-character
-Xstrings (called meta-characters) in special ways:
-X.IP "\\\\\\\\(\fIsubexpression\fP\\\\\\\\)" 0.8i
-XThe \\( and \\) metacharacters are used to delimit subexpressions.
-XWhen the regular expression matches a particular chunk of text,
-X\*E will remember which portion of that chunk matched the \fIsubexpression\fP.
-XThe :s/regexp/newtext/ command makes use of this feature.
-X.IP "^" 0.8i
-XThe ^ metacharacter matches the beginning of a line.
-XIf, for example, you wanted to find "foo" at the beginning of a line,
-Xyou would use a regular expression such as /^foo/.
-XNote that ^ is only a metacharacter if it occurs
-Xat the beginning of a regular expression;
-Xanyplace else, it is treated as a normal character.
-X.IP "$" 0.8i
-XThe $ metacharacter matches the end of a line.
-XIt is only a metacharacter when it occurs at the end of a regular expression;
-Xelsewhere, it is treated as a normal character.
-XFor example, the regular expression /$$/ will search for a dollar sign at
-Xthe end of a line.
-X.IP "\\\\\\\\<" 0.8i
-XThe \\< metacharacter matches a zero-length string at the beginning of
-Xa word.
-XA word is considered to be a string of 1 or more letters and digits.
-XA word can begin at the beginning of a line
-Xor after 1 or more non-alphanumeric characters.
-X.IP "\\\\\\\\>" 0.8i
-XThe \\> metacharacter matches a zero-length string at the end of a word.
-XA word can end at the end of the line
-Xor before 1 or more non-alphanumeric characters.
-XFor example, /\\<end\\>/ would find any instance of the word "end",
-Xbut would ignore any instances of e-n-d inside another word
-Xsuch as "calendar".
-X.IP "\&." 0.8i
-XThe . metacharacter matches any single character.
-X.IP "[\fIcharacter-list\fP]" 0.8i
-XThis matches any single character from the \fIcharacter-list\fP.
-XInside the \fIcharacter-list\fP, you can denote a span of characters
-Xby writing only the first and last characters, with a hyphen between
-Xthem.
-XIf the \fIcharacter-list\fP is preceded by a ^ character, then the
-Xlist is inverted -- it will match character that \fIisn't\fP mentioned
-Xin the list.
-XFor example, /[a-zA-Z]/ matches any letter, and /[^ ]/ matches anything
-Xother than a blank.
-X.IP "\\\\\\\\{\fIn\fP\\\\\\\\}" 0.8i
-XThis is a closure operator,
-Xwhich means that it can only be placed after something that matches a
-Xsingle character.
-XIt controls the number of times that the single-character expression
-Xshould be repeated.
-X.IP "" 0.8i
-XThe \\{\fIn\fP\\} operator, in particular, means that the preceding
-Xexpression should be repeated exactly \fIn\fP times.
-XFor example, /^-\\{80\\}$/ matches a line of eighty hyphens, and
-X/\\<[a-zA-Z]\\{4\\}\\>/ matches any four-letter word.
-X.IP "\\\\\\\\{\fIn\fP,\fIm\fP\\\\\\\\}" 0.8i
-XThis is a closure operator which means that the preceding single-character
-Xexpression should be repeated between \fIn\fP and \fIm\fP times, inclusive.
-XIf the \fIm\fP is omitted (but the comma is present) then \fIm\fP is
-Xtaken to be inifinity.
-XFor example, /"[^"]\\{3,5\\}"/ matches any pair of quotes which contains
-Xthree, four, or five non-quote characters.
-X.IP "*" 0.8i
-XThe * metacharacter is a closure operator which means that the preceding
-Xsingle-character expression can be repeated zero or more times.
-XIt is equivelent to \\{0,\\}.
-XFor example, /.*/ matches a whole line.
-X.IP "\\\\\\\\+" 0.8i
-XThe \\+ metacharacter is a closure operator which means that the preceding
-Xsingle-character expression can be repeated one or more times.
-XIt is equivelent to \\{1,\\}.
-XFor example, /.\\+/ matches a whole line, but only if the line contains
-Xat least one character.
-XIt doesn't match empty lines.
-X.IP "\\\\\\\\?" 0.8i
-XThe \\? metacharacter is a closure operator which indicates that the
-Xpreceding single-character expression is optional -- that is, that it
-Xcan occur 0 or 1 times.
-XIt is equivelent to \\{0,1\\}.
-XFor example, /no[ -]\\?one/ matches "no one", "no-one", or "noone".
-X.PP
-XAnything else is treated as a normal character which must exactly match
-Xa character from the scanned text.
-XThe special strings may all be preceded by a backslash to
-Xforce them to be treated normally.
-X.SH
-XSubstitutions
-X.PP
-XThe :s command has at least two arguments: a regular expression,
-Xand a substitution string.
-XThe text that matched the regular expression is replaced by text
-Xwhich is derived from the substitution string.
-X.br
-X.ne 15 \" so we don't mess up the table
-X.PP
-XMost characters in the substitution string are copied into the
-Xtext literally but a few have special meaning:
-X.LD
-X.ta 0.75i 1.3i
-X	&	Insert a copy of the original text
-X	~	Insert a copy of the previous replacement text
-X	\\1	Insert a copy of that portion of the original text which
-X		matched the first set of \\( \\) parentheses
-X	\\2-\\9	Do the same for the second (etc.) pair of \\( \\)
-X	\\U	Convert all chars of any later & or \\# to uppercase
-X	\\L	Convert all chars of any later & or \\# to lowercase
-X	\\E	End the effect of \\U or \\L
-X	\\u	Convert the first char of the next & or \\# to uppercase
-X	\\l	Convert the first char of the next & or \\# to lowercase
-X.TA
-X.DE
-X.PP
-XThese may be preceded by a backslash to force them to be treated normally.
-XIf "nomagic" mode is in effect,
-Xthen & and ~ will be treated normally,
-Xand you must write them as \\& and \\~ for them to have special meaning.
-X.SH
-XOptions
-X.PP
-X\*E has two options which affect the way regular expressions are used.
-XThese options may be examined or set via the :set command.
-X.PP
-XThe first option is called "[no]magic".
-XThis is a boolean option, and it is "magic" (TRUE) by default.
-XWhile in magic mode, all of the meta-characters behave as described above.
-XIn nomagic mode, only ^ and $ retain their special meaning.
-X.PP
-XThe second option is called "[no]ignorecase".
-XThis is a boolean option, and it is "noignorecase" (FALSE) by default.
-XWhile in ignorecase mode, the searching mechanism will not distinguish between
-Xan uppercase letter and its lowercase form.
-XIn noignorecase mode, uppercase and lowercase are treated as being different.
-X.PP
-XAlso, the "[no]wrapscan" option affects searches.
-X.SH
-XExamples
-X.PP
-XThis example changes every occurence of "utilize" to "use":
-X.sp
-X.ti +1i
-X:%s/utilize/use/g
-X.PP
-XThis example deletes all whitespace that occurs at the end of a line anywhere
-Xin the file.
-X(The brackets contain a single space and a single tab.):
-X.sp
-X.ti +1i
-X:%s/[   ]\\+$//
-X.PP
-XThis example converts the current line to uppercase:
-X.sp
-X.ti +1i
-X:s/.*/\\U&/
-X.PP
-XThis example underlines each letter in the current line,
-Xby changing it into an "underscore backspace letter" sequence.
-X(The ^H is entered as "control-V backspace".):
-X.sp
-X.ti +1i
-X:s/[a-zA-Z]/_^H&/g
-X.PP
-XThis example locates the last colon in a line,
-Xand swaps the text before the colon with the text after the colon.
-XThe first \\( \\) pair is used to delimit the stuff before the colon,
-Xand the second pair delimit the stuff after.
-XIn the substitution text, \\1 and \\2 are given in reverse order
-Xto perform the swap:
-X.sp
-X.ti +1i
-X:s/\\(.*\\):\\(.*\\)/\\2:\\1/
-/
-echo x - termcap.ms
-sed '/^X/s///' > termcap.ms << '/'
-X.Go 10 "TERMCAP"
-X.PP
-X\*E uses fairly standard termcap fields for most things.
-XI invented the cursor shape names
-Xbut other than that there should be few surprises.
-X.SH
-XRequired numeric fields
-X.if n .ul 0
-X.ID
-X:co#:	number of columns on the screen (chars per line)
-X:li#:	number of lines on the screen
-X.DE
-X.SH
-XRequired string fields
-X.ID
-X.if n .ul 0
-X:ce=:	clear to end-of-line
-X:cl=:	home the cursor & clear the screen
-X:cm=:	move the cursor to a given row/column
-X:up=:	move the cursor up one line
-X.DE
-X.SH
-XBoolean fields
-X.if n .ul 0
-X.ID
-X:am:	auto margins - wrap when char is written in last column?
-X:xn:	brain-damaged auto margins - newline ignored after wrap
-X:pt:	physical tabs?
-X.DE
-X.SH
-XOptional string fields
-X.if n .ul 0
-X.ID
-X:al=:	insert a blank row on the screen
-X:dl=:	delete a row from the screen
-X:cd=:	clear to end of display
-X:ei=:	end insert mode
-X:ic=:	insert a blank character
-X:im=:	start insert mode
-X:dc=:	delete a character
-X:sr=:	scroll reverse (insert row at top of screen)
-X:vb=:	visible bell
-X:ti=:	terminal initialization string, to start full-screen mode
-X:te=:	terminal termination, to end full-screen mode
-X:ks=:	enables the cursor keypad
-X:ke=:	disables the cursor keypad
-X.DE
-X.SH
-XOptional strings received from the keyboard
-X.if n .ul 0
-X.ID
-X:kd=:	sequence sent by the <down arrow> key
-X:kl=:	sequence sent by the <left arrow> key
-X:kr=:	sequence sent by the <right arrow> key
-X:ku=:	sequence sent by the <up arrow> key
-X:kP=:	sequence sent by the <PgUp> key
-X:kN=:	sequence sent by the <PgDn> key
-X:kh=:	sequence sent by the <Home> key
-X:kH=:	sequence sent by the <End> key
-X:kI=:	sequence sent by the <Insert> key
-X.DE
-X.PP
-XOriginally, termcap didn't have any names for the <PgUp>, <PgDn>, <Home>,
-Xand <End> keys.
-XAlthough the capability names shown in the table above are the most common,
-Xthey are \fInot\fR universal.
-XSCO Xenix uses :PU=:PD=:HM=:EN=: for those keys.
-XAlso, if the four arrow keys happen to be part of a 3x3 keypad,
-Xthen the five non-arrow keys may be named :K1=: through :K5=:,
-Xso an IBM PC keyboard may be described using those names instead.
-X\*E can find any of these names.
-X.SH
-XOptional strings sent by function keys
-X.if n .ul 0
-X.ID
-X:k1=:...:k9=:k0=:	codes sent by <F1> through <F10> keys
-X:s1=:...:s9=:s0=:	codes sent by <Shift F1> ... <Shift F10>
-X:c1=:...:c9=:c0=:	codes sent by <Ctrl F1> ... <Ctrl F10>
-X:a1=:...:a9=:a0=:	codes sent by <Alt F1> ... <Alt F10>
-X.DE
-X.PP
-XNote that :k0=: is used to describe the <F10> key.
-XSome termcap documents recommend :ka=: or even :k;=: for describing
-Xthe <F10> key, but \*E doesn't support that.
-X.PP
-XAlso, the :s1=:..., :c1=:..., and :a1=:... codes are very non-standard.
-XThe terminfo library doesn't support them.
-X.SH
-XOptional fields that describe character attributes
-X.if n .ul 0
-X.ID
-X:so=:se=:	start/end standout mode (We don't care about :sg#:)
-X:us=:ue=:	start/end underlined mode
-X:md=:me=:	start/end boldface mode
-X:as=:ae=:	start/end alternate character set (italics)
-X:ug#:		visible gap left by :us=:ue=:md=:me=:as=:ae=:
-X.DE
-X.SH
-XOptional fields that affect the cursor's shape
-X.PP
-XThe :cQ=: string is used by \*E immediately before exiting to undo
-Xthe effects of the other cursor shape strings.
-XIf :cQ=: is not given, then all other cursor shape strings are ignored.
-X.ID
-X:cQ=:	normal cursor
-X:cX=:	cursor used for reading EX command
-X:cV=:	cursor used for reading VI commands
-X:cI=:	cursor used during VI input mode
-X:cR=:	cursor used during VI replace mode
-X.DE
-X.PP
-XIf the capabilities above aren't given, then \*E will try to use the
-Xfollowing values instead.
-X.ID
-X:ve=:	normal cursor, used as :cQ=:cX=:cI=:cR=:
-X:vs=:	gaudy cursor, used as :cV=:
-X.DE
-X.SH
-XAn example
-X.PP
-XHere's the termcap entry I use on my Minix-ST system.
-XSome of the fields in it have nothing to do with \*E.
-XSome can only work on my system;
-XI have modified my kernel's screen driver.
-X.sp
-X.LD
-X.ne 14
-Xmx|minix|minixst|ansi:\\
-X	:is=\\E[0~:co#80:li#25:bs:pt:\\
-X	:cm=\\E[%i%d;%dH:up=\\E[A:do=^J:nd=\\E[C:sr=\\EM:\\
-X	:cd=\\E[J:ce=\\E[K:cl=\\E[H\\E[J:\\
-X	:al=\\E[L:dl=\\E[M:ic=\\E[@:dc=\\E[P:im=:ei=:\\
-X	:so=\\E[7m:se=\\E[m:us=\\E[4m:ue=\\E[m:\\
-X	:md=\\E[1m:me=\\E[m:as=\\E[1;3m:ae=\\E[m:\\
-X	:ku=\\E[A:kd=\\E[B:kr=\\E[C:kl=\\E[D:\\
-X	:k1=\\E[1~:k2=\\E[2~:k3=\\E[3~:k4=\\E[4~:k5=\\E[5~:\\
-X	:k6=\\E[6~:k7=\\E[17~:k8=\\E[18~:k9=\\E[19~:k0=\\E[20~:\\
-X	:kU=\\E[36~:kQ=\\E[32~:kH=\\E[28~:\\
-X	:GV=3:GH=D:G1=?:G2=Z:G3=@:G4=Y:GC=E:GL=4:GR=C:GU=A:GD=B:\\
-X	:cQ=\\E[k:cX=\\E[2;0k:cV=\\E[16;0k:cI=\\E[k:cR=\\E[16;20k:
-X.DE
-/
-echo x - title.ms
-sed '/^X/s///' > title.ms << '/'
-X.de tE
-X.ps 80
-X.ce 1
-X\*E
-X..
-X.de nE
-X.ce 7
-X#######                                
-X#        #       #    #     #     #### 
-X#        #       #    #     #    #     
-X#####    #       #    #     #     #### 
-X#        #       #    #     #         #
-X#        #        #  #      #    #    #
-X#######  ######    ##       #     #### 
-X..
-X.sp |2i
-X.if t .tE
-X.if n .nE
-X.ps 10
-X.sp 1
-X.ce 2
-X- a clone of vi/ex -
-Xversion \*V
-X.sp |7.5i
-X.IP Author: 0.9i
-XSteve Kirkendall
-X.br
-X14407 SW Teal Blvd., Apt C
-X.br
-XBeaverton, OR 97005
-X.IP E-Mail: 0.9i
-Xkirkenda@cs.pdx.edu
-X.IP Phone: 0.9i
-X(503) 643-6980
-/
-echo x - ver.ms
-sed '/^X/s///' > ver.ms << '/'
-X.ds V 1.5j-betatest
-X.if t .ds E E\s-2LVIS\s+2
-X.if n .ds E Elvis
-X.\"
-X.\" usage: .Go <section#> <title>
-X.de Go
-X.ds LH "\\$1-\\\\n%
-X.ds RH "\\$1-\\\\n%
-X.ds CH "\\$2
-X.NH S \\$1
-X\\$2
-X.\"if !\\n%=1 .bp 1
-X.if n .ul 0
-X..
-/
-echo x - versions.ms
-sed '/^X/s///' > versions.ms << '/'
-X.Go 12 "VERSIONS"
-X.PP
-X\*E currently works under BSD UNIX, AT&T System-V UNIX, SCO XENIX,
-XMinix, Coherent, MS-DOS, Atari TOS, OS9/68k, VAX/VMS, and AmigaDos.
-XThis section of the manual provides special information that applies to each
-Xparticular version of \*E.
-X.PP
-XFor all versions except MS-DOS,
-Xthe file "Makefile.mix" should be copied to "Makefile",
-Xand then edited to select the correct set of options for your system.
-XThere is more information about this embedded in the file itself.
-X.NH 2
-XBSD UNIX
-X.PP
-XTemporary files are stored in /tmp.
-X.PP
-XYou should modify /etc/rc so that
-Xthe temp files are preserved when the system is rebooted.
-XFind a line in /etc/rc which reads
-X.br
-X.ti +0.5i
-Xex4.3preserve /tmp
-X.PP
-Xor something like that, and append the following line after it:
-X.br
-X.ti +0.5i
-Xelvprsv /tmp/elv*
-X.PP
-XIf you do not have permission to modify /etc/rc, don't fret.
-XThe above modification is only needed to allow you to recover your changes
-Xafter a system crash.
-XYou can still run \*E without that modification,
-Xand you can still recover your changes when \*E crashes
-Xor when your dialup modem looses the carrier signal, or something like that.
-XOnly a system crash or power failure could hurt you.
-X.PP
-XBoth \*E and the real Vi
-Xread initialization commands from a file called ".exrc",
-Xbut the commands in that file might work on one but not the other.
-XFor example, "set keywordprg=man" will work for \*E,
-Xbut Vi will complain because it doesn't have a "keywordprg" option.
-XIf the warning messages annoy you, then you can edit the config.h file
-Xto change the name of the initialization file ".exrc" to something else,
-Xsuch as ".elvisrc".
-X.PP
-XIf you use X windows, you may wish to add "-DCS_LATIN1" to CFLAGS.
-XThis will cause the digraph table and the flipcase option to have default
-Xvalues that are appropriate for the LATIN-1 character set.
-XThat's the standard character set for X.
-X.PP
-XThe default keyboard macro time-out value is larger for BSD than it is for
-Xsome other systems, because I've had trouble running \*E via rlogin or Xterm.
-XI guess it takes a while for those keystokes to squirt through the net.
-X.NH 2
-XSystem-V UNIX
-X.PP
-XMost SysV UNIX systems use terminfo instead of termcap,
-Xbut  the  terminfo  library  doesn't seem to have a standard name.
-XAs shipped, Elvis' Makefile.mix  is  configured  with "LIBS=-lterm".
-XYou may need to change it to "LIBS=-ltermcap" or "LIBS=-lterminfo"
-Xor even "LIBS=-lcurses".
-X.PP
-XThe /etc/rc file should be modified as described for BSD systems, above.
-XThe only difference is that SysV systems tend to have directories for
-Xinitialization, instead of a single large /etc/rc file.
-XEditor recovery is usually done somewhere in the /etc/rc2.d directory.
-X.PP
-XThe potential trouble with ".exrc" described above for BSD UNIX applies
-Xto System-V UNIX as well.
-X.PP
-X\*E uses control-C as the interrupt key, not Delete.
-X.NH 2
-XSCO Xenix
-X.PP
-XFor Xenix-386, you can use the generic System-V settings.
-XYou may wish to add "-DCS_IBMPC" to CFLAGS, to have the digraph table and
-Xflipcase option start up in a mode that is appropriate for the console.
-X
-XThere is a separate group of settings for use with Xenix-286.
-XIt already has "-DCS_IBMPC" in CFLAGS.
-X.PP
-XBecause Xenix is so similar to System-V, everything I said earlier about
-XSystem-V applies to the Xenix version too, except that editor recovery
-Xprobably belongs in a directory called /etc/rc.d/8.
-X.NH 2
-XMinix
-X.PP
-XThere are separate settings in Makefile.mix for Minix-PC and Minix-68k.
-XThe differences between these two are that
-Xthe 68k version uses ".o" for the object file extension where
-Xthe PC version uses ".s", and
-Xthe PC version has some extra flags in CFLAGS to reduce the size of \*E.
-XThe PC version also uses tinytcap (instead of the full termcap) to make it smaller.
-X.PP
-XMinix-PC users should read the CFLAGS section of this manual very carefully.
-XYou have some choices to make...
-X.PP
-XThe temporary files are stored in /usr/tmp.
-XThe /usr/tmp directory must exist before you run \*E,
-Xand it must be readable/writable by everybody.
-XWe use /usr/tmp instead of /tmp because
-Xafter a system crash or power failure,
-Xyou can recover the altered version of a file from the temporary file
-Xin /usr/tmp.
-XIf it was stored in /tmp, though, then it would be lost because /tmp is
-Xnormally located on the RAM disk.
-X.PP
-X\*E uses control-C as the interrupt key, not Delete.
-X.NH 2
-XCoherent
-X.PP
-X\*E was ported to Coherent by Esa Ahola.
-X.PP
-X\*E is too large to run under Coherent unless you eliminate some
-Xfeatures via the CFLAGS setting.
-XThe recommended settings, in Makefile.mix, produce a working version
-Xof \*E which emulates Vi faithfully, but lacks most of the extensions.
-XYou should read the CFLAGS section of this manual carefully.
-X.PP
-XYou can probably reduce the size of \*E by using tinytcap.c instead of -lterm.
-XThis would allow you to keep most features of \*E,
-Xat the expense of terminal independence.
-X(Tinytcap.c has ANSI escape sequences hard-coded into it.)
-XTo use tinytcap, just add "tinytcap.o" to the "EXTRA=" line in the Makefile,
-Xand remove "-lterm" from the "LIBS=" line.
-X.PP
-XThe temporary files are stored in /tmp.
-XYou should modify your /etc/rc file as described for BSD earlier.
-X.NH 2
-XMS-DOS
-X.PP
-X\*E was ported to MS-DOS by Guntram Blohm and Martin Patzel.
-XWillett Kempton added support for the DEC Rainbow.
-X.PP
-XIdeally, \*E should be compiled with Microsoft C 5.10 and the standard
-XMicrosoft Make utility,
-Xvia the command "make elvis.mak".
-XThis will compile \*E and all related utilities.
-X.PP
-XWith Microsoft C 6.00, you may have trouble compiling regexp.c.
-XIf so, try compiling it without optimization.
-X.PP
-XThe "Makefile.mix" file contains a set of suggested settings for compiling
-Xelvis with Turbo-C or Borland C.
-X(If you have Turbo-C, but not the Make utility,
-Xthen you can \fIalmost\fR use the "\*E.prj" file to compile \*E,
-Xbut you must explicitly force Turbo-C to compile it with the "medium" memory model.
-XMost of the related programs [ctags, ref, virec, refont, and wildcard] are
-Xonly one file long, so you should have no trouble compiling them.)
-XThe "alias.c" file is meant to be compiled once into an executable named
-X"ex.exe".
-XYou should then copy "ex.exe" to "vi.exe" and "view.exe".
-X.PP
-X\*E stores its temporary files in C:\\tmp.
-XIf this is not satisfactory, then you should edit the CFLAGS line of
-Xyour Makefile to change TMPDIR to something else before compiling.
-XYou can also control the name of the temp directory via an environment
-Xvariable named TMP or TEMP.
-XThe directory must exist before you can run \*E.
-X.PP
-XThe TERM environment variable determines how elvis will write to the screen.
-XIt can be set to any one of the following values:
-X.LD
-X.ta 1.5i 2.5i
-X	pcbios	Use BIOS calls on an IBM-PC clone.
-X	rainbow	Use DEC Rainbow interface.
-X	ansi	Use ANSI.SYS driver.
-X	nansi	User faster NANSI.SYS driver.
-X.DE
-X.PP
-XIf the TERM variable isn't set, then elvis will automatically select either
-Xthe "rainbow" interface (when run on a Rainbow) or "pcbios" (on an IBM clone).
-X.PP
-XYou may prefer to use NANSI.SYS for speed;
-Xor you may NEED to use ANSI.SYS for a non-clone, such as a lap-top.
-XIf so, you should
-Xinstall one of these drivers by adding "driver = nansi.sys" (or whatever)
-Xto your CONFIG.SYS file,
-Xand then you should define TERM to be "nansi" (or whatever) by adding
-X"set TERM=nansi" to your AUTOEXEC.BAT file.
-XYou must then reboot for these changes to take effect.
-XAfter that, \*E will notice the "TERM" setting and use the driver.
-X.PP
-XSince ".exrc" is not a valid DOS filename,
-Xthe name of the initialization file has been changed to "elvis.rc".
-XElvis will look for an "elvis.rc" file first in your home directory,
-Xand then in the current directory.
-XNote that you must set an environment variable named "HOME" to the
-Xfull pathname of your home directory, for Elvis to check there;
-Xif "HOME" isn't set, then Elvis will only look in the current directory.
-XTo set "HOME", you would typically add the following line to your
-XAUTOEXEC.BAT file:
-X.br
-X.ti +0.5i
-Xset HOME c:\\
-X.PP
-XAn extra program, called "wildcard", is needed for MS-DOS.
-XIt expands wildcard characters in file names.
-XIf \*E flashes a "Bad command or filename" message when it starts,
-Xthen you've probably lost the WILDCARD.EXE program somehow.
-X.PP
-X\*E can run under Windows, but only in full-screen mode.
-XAlso, Windows uses an environment variable called TEMP which interferes with
-Xelvis' usage of TEMP;
-Xto work around this, you can simply set an environment variable named
-XTMP (with no 'E') to the name of elvis' temporary directory.
-XWhen TEMP and TMP are both set, \*E uses TMP and ignored TEMP.
-X.NH 2
-XAtari TOS
-X.PP
-X\*E was ported to Atari TOS by Guntram Blohm and Martin Patzel.
-XIt is very similar to the MS-DOS version.
-XIt has been tested with the Mark Williams C compiler and also GNU-C.
-X.PP
-XThe TERM environment variable is ignored;
-Xthe ST port always assumes that TERM=vt52.
-XThe SHELL (not COMSPEC!) variable should be set to
-Xthe name of a line-oriented shell.
-X.PP
-XA simple shell in included with \*E.
-XIts source is in "shell.c", and the name of the executable is "shell.ttp".
-XThe file "profile.sh" should contain a set of instructions to be executed
-Xwhen the shell first starts up.
-XAn example of this file is included, but you will almost certainly want to
-Xedit it right away to match your configuration.
-X(If you already have a command-line shell,
-Xthen you'll probably want to continue using it.
-XThe shell that comes with \*E is very limited.)
-X.PP
-XCurrently, character attributes cannot be displayed on the screen.
-X.PP
-X\*E runs under MiNT (a free multi-tasking extension to TOS)
-Xbut it can be a CPU hog because of the way that \*E reads from the
-Xkeyboard with timeout.
-XAlso, \*E doesn't use any of the special features of MiNT.
-XI have received a set of patches that optimize \*E for MiNT,
-Xbut they arrived too late to integrate into this release.
-X.NH 2
-XOS9/68k
-X.PP
-X\*E was ported to OS9/68k by Peter Reinig.
-X.PP
-XThe Makefile is currently configured to install \*E and the related
-Xprograms in /dd/usr/cmds
-XIf this this is unacceptable, then you should change the BIN setting
-Xto some other directory.
-XSimilarly, it expects the source code to reside in /dd/usr/src/elvis;
-Xthe ODIR setting is used to control this.
-X.PP
-XTemporary files are stored in the /dd/tmp directory.
-XYour /dd/startup file may need to be modified
-Xto prevent it from deleting \*E' temporary files;
-Xmake /dd/startup run the \fIelvprsv\fR program before it wipes out /dd/tmp.
-X.PP
-XThe program in alias.c is linked repeatedly to produce the
-X"vi", "view", and "input" aliases for \*E.
-XSadly, the "ex" alias is impossible to implement under OS9
-Xbecause the shell has a built-in command by that name.
-X.PP
-XFor some purposes,
-Xyou must give `make' the "-b" option.
-XSpecifically, you need this for "make -b clean" and "make -b install".
-X.NH 2
-XVAX/VMS
-X.PP
-XJohn Campbell ported \*E to VAX/VMS.
-X.PP
-XA heavily laden VAX can take half an hour to compile elvis.
-XThis is normal.
-XDon't panic.
-X.PP
-XWhile running, elvis will create temporary files in SYS$SCRATCH.
-XEnter SHOW LOGICAL SYS$SCRATCH to see what actual directory you are using.
-XMany sites have SYS$SCRATCH equivalenced to SYS$LOGIN.
-XThe elvis temporary files look like the following on VMS while elvis is running:
-X.br
-X.ti 0.75i
-XELV_1123A.1;1       ELV_1123A.2;1       SO070202.;1
-X.PP
-XAlso, filtering commands (like !!dir and !}fmt) should work on VMS.
-XThis assumes, however, that you can create temporary mailboxes and that
-Xyour mailbox quota (a sysgen parameter) is at least 256 bytes for a
-Xsingle write to the mailbox.
-XThis is the default sysgen parameter,
-Xso there should be few people who experience filter problems.
-X.PP
-XAdditionally, an attempt was made to support the standard terminals on VMS:
-X"vt52", "vt100", "vt200", "vt300", "vt101", "vt102".
-XNon-standard terminals could be supported by setting your terminal type to
-XUNKNOWN (by entering SET TERM/UNKNOWN)
-Xand defining the logical name ELVIS_TERM.
-XWhatever ELVIS_TERM translates to, however, will have to be included in
-Xtinytcap.c.
-XNote that the upper/lowercase distinctions are significant,
-Xand that DCL will upshift characters that are not quoted strings, so
-Xenter DEFINE ELVIS_TERM "hp2621a".
-XAs distributed, it would probably not be a good idea to have more than the
-Xstandard terminals in tinytcap.c (else it wouldn't be tiny, would it?).
-XChanges here, of course, would require a recompilation to take effect.
-X.PP
-XIf you have a version of the "termcap" library and database on your system,
-Xthen you may wish to replace tinytcap with the real termcap.
-X.NH 2
-XAmigaDOS
-X.PP
-XMike Rieser and Dale Rahn ported \*E to AmigaDOS.
-X.PP
-XThe port was done using Manx Aztec C version 5.2b.
-X\*E uses about as much space as it can and still be small code and data.
-X\*E should also compile under DICE, though there may be a little trouble with
-Xsigned versus unsigned chars.
-X.PP
-XThe port has been done so the same binary will run under both versions of AmigaDOS.
-XUnder AmigaDOS 2.04, \*E supports all the documented features.
-XIt also uses an external program ref to do tag lookup.
-XSo, the accompanying programs: ref and ctags are recommended.
-XUnder AmigaDOS 1.2/1.3 \*E works, buts lacks the more advanced features.
-X.PP
-XFor the port to AmigaDOS 2.04, we tried to use as many Native AmigaDOS
-Xcalls as we could.
-XThis should increase Elvis's chances at being compiled with other compilers.
-XDICE seems to have a different default char type.
-XYou may need to use the UCHAR() macro in tio.c.
-XTo test it, try the :map command; if it looks right, things are cool.
-X.PP
-XFor the port to AmigaDOS 1.3, we tried to make sure the program was at
-Xleast usable.
-XMany features are missing, most notably running commands in subshells.
-XAlso, what we could get working, we used Aztec functions to support them,
-Xso this part is little more compiler dependent.
-X.PP
-XAztec is compatible with the SAS libcall #pragma.
-XI personally prefer using the includes that come from Commodore over the ones
-Xsupplied with Aztec, but for people with a straight Aztec installation,
-XI went with the default names for the Aztec pragmas.
-X.PP
-XOne include you'll need is <sys/types.h>.
-XIts a common include when porting software just make yourself one.
-XIts a two line file that saves a lot of hassle especially in the elvis source.
-XSo, make a directory where your includes are located called `sys'
-Xand in a file below that type:
-X.br
-X.ti +0.8i
-X/* sys/types.h */
-X.br
-X.ti +0.8i
-X#include <exec/types.h>
-X.PP
-XWhen setting environment variables (either local or global) for
-Xvariables that specify a directory, make sure the variable ends in `:'
-Xor `/'.
-XThis saved from having to change much of the way elvis works.
-XThe default temporary directory (if TEMP and TMP aren't specified) is "T:".
-XThe default if HOME directory (if no HOME environment variable is set) is "S:".
-X.PP
-XTo avoid conlict with other uses, \*E uses elvis.rc instead of .exrc or
-Xwhere it looks for macros.
-X.NH 2
-XOther Systems
-X.PP
-XFor Sun workstations, use the BSD configuration.
-XEarlier versions of elvis didn't link correctly due to a quirk in Sun's
-Xversion of the "make" utility, but this version of elvis has a work-around
-Xfor that quirk so you should have no trouble at all.
-X.PP
-XFor Linux, use the SysV settings.
-XYou can probably just remove the "-lterm" from the "LIBS= -lterm" line,
-Xsince linux keeps the termcap functions in the standard C library.
-X.PP
-XFor other UNIXoid systems, I suggest you start with the Minix-68k settings
-Xand then grow from that.
-XMinix is a nice starting point because it is a clone of Version 7 UNIX,
-Xwhich was the last common ancestor of BSD UNIX and SysV UNIX.
-XAny Operating System which claims any UNIX compatibility what so ever
-Xwill therefore support V7/Minix code.
-XYou may need to fiddle with #include directives or something, though.
-XMinix-68k is a better starting point than Minix-PC because the PC compiler
-Xhas some severe quirks.
-/
-echo x - visual.ms
-sed '/^X/s///' > visual.ms << '/'
-X.Go 2 "VISUAL MODE COMMANDS"
-X.PP
-XMost visual mode commands are one keystroke long.
-XThe following table lists the operation performed by each keystroke,
-Xand also denotes any options or arguments that it accepts.
-XNotes at the end of the table describe the notation used in this table.
-X.PP
-XIn addition to the keys listed here, your keyboard's "arrow" keys
-Xwill be interpretted as the appropriate cursor movement commands.
-XThe same goes for <PgUp> and <PgDn>, if your keyboard has them.
-XThe <Insert> key will toggle between insert mode and replace mode.
-XThere is a colon mode command (":map", to be described later)
-Xwhich will allow you to define other keys, such as function keys.
-X.PP
-XA tip: visual command mode looks a lot like text input mode.
-XIf you forget which mode you're in, just hit the <Esc> key.
-XIf \*E beeps, then you're in visual command mode.
-XIf \*E does not beep, then you were in input mode,
-Xbut by hitting <Esc> you will have switched to visual command mode.
-XSo, one way or another, after <Esc> \*E will be ready for a command.
-X.LD
-X.ta 0.7i 1.3i
-X\s+2COMMAND	DESCRIPTION\s-2
-X	^A	Search for next occurence of word at cursor (MOVE)(EXT)
-X	^B	Move toward the top of the file by 1 screenful
-X	^C	--- (usually sends SIGINT, to interupt a command)
-Xcount	^D	Scroll down <count> lines (default 1/2 screen)
-Xcount	^E	Scroll up <count> lines
-X	^F	Move toward the bottom of the file by 1 screenful
-X	^G	Show file status, and the current line #
-Xcount	^H	Move left, like h (MOVE)
-X	^I	---
-Xcount	^J	Move down (MOVE)
-X	^K	---
-X	^L	Redraw the screen
-Xcount	^M	Move to the front of the next line (MOVE)
-Xcount	^N	Move down (MOVE)
-X	^O	---
-Xcount	^P	Move up (MOVE)
-X	^Q	--- (typically XON, which restarts screen updates)
-X	^R	Redraw the screen
-X	^S	--- (typically XOFF, which stops screen updates)
-X	^T	---
-Xcount	^U	Scroll up <count> lines (default 1/2 screen)
-X	^V	---
-X	^W	---
-Xcount	^X	Move to a physical column number on the screen (MOVE) (EXT)
-Xcount	^Y	Scroll down <count> lines
-X	^Z	--- (sometimes sends SIGSUSP, to suspend execution)
-X	ESC	---
-X	^\\	--- (usually sends SIGQUIT, which is ignored)
-X	^]	If the cursor is on a tag name, go to that tag
-X	^^	Switch to the previous file, like ":e #"
-X	^_	---
-Xcount	SPC	Move right,like l (MOVE)
-X	! \s-2mv\s+2	Run the selected lines thru an external filter program
-X	" \s-2key\s+2	Select which cut buffer to use next
-Xcount	# \s-2+\s+2	Increment a number (EDIT) (EXT)
-X	$	Move to the rear of the current line (MOVE)
-Xcount	%	Move to matching (){}[] or to a given % of file (MOVE) (EXT)
-Xcount	&	Repeat the previous ":s//" command here (EDIT)
-X	' \s-2key\s+2	Move to a marked line (MOVE)
-Xcount	(	Move backward <count> sentences (MOVE)
-Xcount	)	Move forward <count> sentences (MOVE)
-X	*	Go to the next error in the errlist (EXT)
-Xcount	+	Move to the front of the next line (MOVE)
-Xcount	,	Repeat the previous [fFtT] but in the other direction (MOVE)
-Xcount	-	Move to the front of the preceding line (MOVE)
-Xcount	.	Repeat the previous "edit" command
-X	/ \s-2text\s+2	Search forward for a given regular expression (MOVE)
-X	0	If not part of count, move to 1st char of this line (MOVE)
-X	1	Part of count
-X	2	Part of count
-X	3	Part of count
-X	4	Part of count
-X	5	Part of count
-X	6	Part of count
-X	7	Part of count
-X	8	Part of count
-X	9	Part of count
-X	: \s-2text\s+2	Run single EX cmd
-Xcount	;	Repeat the previous [fFtT] cmd (MOVE)
-X	< \s-2mv\s+2	Shift text left (EDIT)
-X	= \s-2mv\s+2	Reformat
-X	> \s-2mv\s+2	Shift text right (EDIT)
-X	? \s-2text\s+2	Search backward for a given regular expression (MOVE)
-X	@ \s-2key\s+2	Execute the contents of a cut-buffer as VI commands
-Xcount	A \s-2inp\s+2	Append at end of the line (EDIT)
-Xcount	B	Move back Word (MOVE)
-X	C \s-2inp\s+2	Change text from the cursor through the end of the line (EDIT)
-X	D	Delete text from the cursor through the end of the line (EDIT)
-Xcount	E	Move end of Word (MOVE)
-Xcount	F \s-2key\s+2	Move leftward to a given character (MOVE)
-Xcount	G	Move to line #<count> (default is the bottom line) (MOVE)
-Xcount	H	Move to home row (the line at the top of the screen)
-Xcount	I \s-2inp\s+2	Insert at the front of the line (after indents) (EDIT)
-Xcount	J	Join lines, to form one big line (EDIT)
-X	K	Look up keyword (EXT)
-Xcount	L	Move to last row (the line at the bottom of the screen)
-X	M	Move to middle row
-X	N	Repeat previous search, but in the opposite direction (MOVE)
-Xcount	O \s-2inp\s+2	Open up a new line above the current line (EDIT)
-X	P	Paste text before the cursor (EDIT)
-X	Q	Quit to EX mode
-X	R \s-2inp\s+2	Overtype (EDIT)
-Xcount	S \s-2inp\s+2	Change lines, like <count>cc
-Xcount	T \s-2key\s+2	Move leftward *almost* to a given character (MOVE)
-X	U	Undo all recent changes to the current line
-X	V	Start marking lines for c/d/y/</>/!/\\ (EXT)
-Xcount	W	Move forward <count> Words (MOVE)
-Xcount	X	Delete the character(s) to the left of the cursor (EDIT)
-Xcount	Y	Yank text line(s) (copy them into a cut buffer)
-X	Z Z	Save the file & exit
-X	[ [	Move back 1 section (MOVE)
-X	\\ \s-2mv\s+2	Pop-up menu for modifying text (EXT)
-X	] ]	Move forward 1 section (MOVE)
-X	^	Move to the front of the current line (after indent) (MOVE)
-Xcount	_	Move to the current line
-X	` \s-2key\s+2	Move to a marked character (MOVE)
-Xcount	a \s-2inp\s+2	Insert text after the cursor (EDIT)
-Xcount	b	Move back <count> words (MOVE)
-X	c \s-2mv\s+2	Change text (EDIT)
-X	d \s-2mv\s+2	Delete text (EDIT)
-Xcount	e	Move forward to the end of the current word (MOVE)
-Xcount	f \s-2key\s+2	Move rightward to a given character (MOVE)
-X	g	---
-Xcount	h	Move left (MOVE)
-Xcount	i \s-2inp\s+2	Insert text at the cursor (EDIT)
-Xcount	j	Move down (MOVE)
-Xcount	k	Move up (MOVE)
-Xcount	l	Move right (MOVE)
-X	m \s-2key\s+2	Mark a line or character
-X	n	Repeat the previous search (MOVE)
-Xcount	o \s-2inp\s+2	Open a new line below the current line (EDIT)
-X	p	Paste text after the cursor (EDIT)
-X	q	---
-Xcount	r \s-2key\s+2	Replace <count> chars by a given character (EDIT)
-Xcount	s \s-2inp\s+2	Replace <count> chars with text from the user (EDIT)
-Xcount	t \s-2key\s+2	Move rightward *almost* to a given character (MOVE)
-X	u	Undo the previous edit command
-X	v	Start marking characters for c/d/y/</>/!/\\ (EXT)
-Xcount	w	Move forward <count> words (MOVE)
-Xcount	x	Delete the character that the cursor's on (EDIT)
-X	y \s-2mv\s+2	Yank text (copy it into a cut buffer)
-X	z \s-2key\s+2	Scroll current line to the screen's +=top -=bottom .=middle
-Xcount	{	Move back <count> paragraphs (MOVE)
-Xcount	|	Move to column <count> (the leftmost column is 1)
-Xcount	}	Move forward <count> paragraphs (MOVE)
-Xcount	~	Switch a character between uppercase & lowercase (EDIT)
-X	DEL	--- (usually mapped to shift-X, so it deletes one character)
-X.DE
-X.IP count
-XMany commands may be preceded by a count.  This is a sequence of digits
-Xrepresenting a decimal number.  For most commands that use a count,
-Xthe command is repeated <count> times.  The count is always optional,
-Xand usually defaults to 1.
-X.IP key
-XSome commands require two keystrokes.  The first key always determines
-Xwhich command is to be executed.  The second key is used as a parameter
-Xto the command.
-X.IP mv
-XSome commands (! < > c d y \\ =) operate on text between the cursor and some
-Xother position.
-XThere are three ways that you can specifify that other position.
-X.IP
-XThe first way is to follow the command keystroke with a movement command.
-XFor example, "dw" deletes a single word.
-X"d3w" and "3dw" both delete three words.
-X.IP
-XThe second way is to type the command keystroke twice.
-XThis causes whole lines to be acted upon.
-XFor example, ">>" indents the current line.
-X"3>>" indents the current line and the following two lines.
-X.IP
-XThe last way is to move the cursor to one end of the text,
-Xtype 'v' or 'V' to start marking,
-Xmove the cursor to the other end,
-Xand then type the desired command key.
-X.IP inp
-XMany commands allow the user to interactively enter text.
-XSee the discussion of "input mode" in the following section.
-X.IP (EXT)
-XThese commands are extensions -- the real vi doesn't have them.
-X.IP (EDIT)
-XThese commands affect text, and may be repeated by the "." command.
-X.IP (MOVE)
-XThese commands move the cursor, and may be used to specify the extent
-Xof a member of the "mv" class of commands.
-X.NH 2
-XInput Mode
-X.PP
-XYou can't type text into your file directly from visual command mode.
-XInstead, you must first give a command which will put you into input mode.
-XThe commands to do this are A/C/I/O/R/S/a/i/o/s.
-X.PP
-XThe S/s/C/c commands temporarily place a $ at the end of the text that
-Xthey are going to change.
-X.PP
-XIn input mode, all keystrokes are inserted into the text at the
-Xcursor's position, except for the following:
-X.ID
-X^A	insert a copy of the last input text
-X^D	delete one indent character
-X^H	(backspace) erase the character before the cursor
-X^L	redraw the screen
-X^M	(carriage return) insert a newline (^J, linefeed)
-X^O	execute next key as a visual command (limited!)
-X^P	insert the contents of the cut buffer
-X^R	redraw the screen, like ^L
-X^T	insert an indent character
-X^U	backspace to the beginning of the line
-X^V	insert the following keystroke, even if special
-X^W	backspace to the beginning of the current word
-X^Z^Z	write the file & exit \*E
-X^[	(ESCape) exit from input mode, back to command mode
-X.DE
-X.PP
-XAlso, on some systems, ^S may stop output, ^Q may restart output,
-Xand ^C may interupt execution.
-X^@ (the NUL character) cannot be inserted.
-X.PP
-XThe R visual command puts you in overtype mode,
-Xwhich is a slightly different form of input mode.
-XIn overtype mode, each time you insert a character,
-Xone of the old characters is deleted from the file.
-X.NH 2
-XArrow keys in Input Mode
-X.PP
-XThe arrow keys can be used to move the cursor in input mode.
-X(This is an extension; the real Vi doesn't support arrow keys in input mode.)
-XThe <PgUp>, <PgDn>, <Home>, and <End> keys work in input mode, too.
-XThe <Delete> key deletes a single character in input mode.
-XThe <Insert> key toggles between input mode and replace mode.
-X.PP
-XThe best thing about allowing arrow keys to work in input mode is that
-Xas long as you're in input mode,
-X\*E seems to have a fairly ordinary user interface.
-XWith most other text editors, you are always in either insert mode or
-Xreplace mode, and you can use the arrow keys at any time to move the cursor.
-XNow, \*E can act like that, too.
-XIn fact, with the new "inputmode" option and the "control-Z control-Z" input
-Xcommand, you may never have to go into visual command mode for simple edit
-Xsessions.
-X.NH 2
-XDigraphs
-X.PP
-X\*E supports digraphs as a way to enter non-ASCII characters.
-XA digraph is a character which is composed of two other characters.
-XFor example, an apostrophe and the letter i could be defined as a digraph
-Xwhich is to be stored & displayed as an accented i.
-X.PP
-XThere is no single standard for extended ASCII character sets.
-X\*E can be compiled to fill the digraph with values appropriate for
-Xeither the IBM PC character set, or the LATIN-1 character set used by
-XX windows, or neither.
-X(See the discussions of -DCS_IBMPC and -DCS_LATIN1 in the CFLAGS section
-Xof this manual.)
-XYou can view or edit the digraph table via the ":digraph" colon command.
-X.PP
-XDigraphs will not be recognized until you've entered ":set digraph".
-X.PP
-XTo actually use a digraph
-Xtype the first character, then hit <Backspace>, and then type the
-Xsecond character.
-X\*E will then substitute the non-ASCII character in their place.
-X.NH 2
-XAbbreviations
-X.PP
-X\*E can expand abbreviations for you.
-XYou define an abbreviation with the :abbr command,
-Xand then whenever you type in the abbreviated form while in input mode,
-X\*E will immediately replace it with the long form.
-XCOBOL programmers should find this useful. :-)
-X.PP
-X\*E doesn't perform the substitution until you type a non-alphanumeric
-Xcharacter to mark the end of the word.
-XIf you type a control-V before that non-alphanumeric character, then
-X\*E will not perform the substitution.
-X.NH 2
-XAuto-Indent
-X.PP
-XWith the ":set autoindent" option turned on,
-X\*E will automatically insert leading whitespace at the beginning of each
-Xnew line that you type in.
-XThe leading whitespace is copied from the preceding line.
-X.PP
-XTo add more leading whitespace, type control-T.
-XTo remove some whitespace, type control-D.
-X.PP
-XIf you ":set noautotab", then the whitespace generated by control-T will
-Xalways consist of spaces -- never tabs.
-XSome people seem to prefer this.
-X.PP
-X\*E' autoindent mode isn't 100% compatible with vi's.
-XIn \*E, 0^D and ^^D don't work,
-X^U can wipeout all indentation, 
-Xand sometimes \*E will use a different amount of indentation than vi would.
-/
Index: trunk/minix/commands/elvis/Knownbug.txt
===================================================================
--- trunk/minix/commands/elvis/Knownbug.txt	(revision 9)
+++ 	(revision )
@@ -1,68 +1,0 @@
-The following options are missing:
-	[no]optimize	- affects screen redrawing method
-	[no]redraw	- simulate character insertion by redrawing line
-	[no]slowopen	- don't use character insertion
-	tags="tags"	- list of tags, used as TAGPATH
-
-I'd like to improve the versatility of the options whose value is a command:
-cc, make, kp, and ep.  I'd like to add some notation that allows you to say
-where to insert the current filename or current word.
--------------------------------------------------------------------------------
-Currently, elvis is configured to look for | only in .exrc files.  It doesn't
-look for | in any interactively entered command lines, yet.
--------------------------------------------------------------------------------
-The 'p', '#', and 'l' flags aren't supported.  Also, ex commands don't accept
-counts; e.g., ":c5" can't be used to change five lines. 
--------------------------------------------------------------------------------
-The following have been reported, but have not been verified.  If you have
-experienced any of the following, and haven't reported it yet, then please
-report it now!  I need more information about these bugs.
-
-[Bugs that are not in this list should also be reported, of course.]
-
-- Under VMS on an 80-column screen, after scolling sideways to approximately
-  column 110, a ^L will not redraw the part of the line after the cursor.
-- On an Atari ST running under TOS: some ASCII keys seem to send '#' plus
-  another key.  (This is normal for non-ASCII keys like <F1> or <Help>, but
-  ASCII keys should always send a single ASCII character.)
--------------------------------------------------------------------------------
-BIG JOBS:
-  Desirable extension: merge input mode and visual command mode.
-  Display long lines by wrapping, like the real vi (if ":set sidescroll=0")
--------------------------------------------------------------------------------
-
-- In the ":w >>filename" command, elvis doesn't allow any whitespace between
-  the ">>" and "filename".
-
-- Elvis doesn't allow "backslash newline" inside a single EX command.
-
-- VMS intercepts the control-T character, which is normally used to increase
-  indentation.  The <Tab> key works, but it doesn't do quite the same thing.
-  (":map! ^I ^T" helps.)
-
-- Under VMS, file I/O is very slow.  Looking over the vmsio.c file, I get the
-  impression that it is rather over-done for elvis.  Its speed could
-  probably be inproved.
-
-- The errlist feature doesn't seem to work with the Borland compilers.  Perhaps
-  they write to stderr instead of stdout?  This will probably be easy to solve
-  once I modify the "cc" and "make" options, as described earlier.
-
-- The command ":0" should move the cursor to line 1.  Currently, it doesn't
-  move the cursor at all.
-
-- File preservation is still flakey.  On DOS/TOS/VMS systems, it is also more
-  complex that it should be.
-
-- The act of appending to a cut buffer (as in "Ayy) sets file modification
-  flag.  It shouldn't!
-
-- The .exrc file is limited to BLKSIZE bytes -- 2048 on most systems, but
-  1024 on Minicx-PC, Coherent, and MS-DOS.
-
-- I *still* haven't quite perfected the screen update code.  If you suspect
-  that the screen doesn't accurately reflect the contents of the edit buffer,
-  then you should try doing a control-L.
-
-  I'll be overhauling the screen update code soon to make it wrap long lines
-  like the real vi.  I expect to fix this bug then.
Index: trunk/minix/commands/elvis/Makedoc
===================================================================
--- trunk/minix/commands/elvis/Makedoc	(revision 9)
+++ 	(revision )
@@ -1,87 +1,0 @@
-# This is the Makefile for Elvis' "doc" directory.  It makes use of a
-# troff-like formatter called mroff.  Since you probably don't have mroff,
-# you'll need to edit this Makefile before you can fully use it.  It can
-# also use nroff, though, so you should be able to get something out of it.
-#
-# make		Use nroff to create an ASCII version of the manual.
-# make foo.doc	Use nroff to create an ASCII version of foo.man or foo.ms
-# make manual	Use MROFF to print a typeset manual on a laser printer
-# make foo.1200	Use MROFF to print a typeset version of foo.man or foo.ms
-# make foo.100	Use MROFF to print a draft-quality version of foo.man or foo.ms
-# make foo.more	Use MROFF to preview foo.man or foo.more on your terminal
-#
-
-###############################################################################
-# Definitions...
-
-MAN=	ctags.man elvis.man elvprsv.man elvrec.man fmt.man ref.man
-MS=	title.ms index.ms intro.ms visual.ms ex.ms regexp.ms options.ms\
-	cutbufs.ms differ.ms internal.ms cflags.ms termcap.ms environ.ms\
-	versions.ms question.ms
-ASC=	title.doc index.doc intro.doc visual.doc ex.doc regexp.doc options.doc\
-	cutbufs.doc differ.doc internal.doc cflags.doc termcap.doc environ.doc\
-	versions.doc question.doc\
-	ctags.doc elvis.doc elvprsv.doc elvrec.doc fmt.doc ref.doc
-MANUAL=	title.1200 index.1200 intro.1200 visual.1200 ex.1200 regexp.1200 options.1200\
-	cutbufs.1200 differ.1200 internal.1200 cflags.1200 termcap.1200 environ.1200\
-	versions.1200\
-	ctags.1200 elvis.1200 elvprsv.1200 elvrec.1200 fmt.1200 ref.1200
-VER=	ver.ms
-TROFF=	mroff
-NROFF=	nroff
-
-###############################################################################
-# Rules...
-
-.SUFFIXES: .tmp .100 .1200 .more .doc .man .ms .vga .vgas
-
-.ms.tmp:
-	$(TROFF) -ms $(VER) $< >tmp
-
-.man.tmp:
-	$(TROFF) -man $< >tmp
-
-.ms.more:
-	$(TROFF) -ms $(VER) $< | draft | more
-
-.man.more:
-	$(TROFF) -man $< | draft | more
-
-.ms.1200:
-	$(TROFF) -ms $(VER) $< | hp2 1200 | lp -og $(PRINTER)
-
-.man.1200:
-	$(TROFF) -man $< | hp2 1200 | lp -og $(PRINTER)
-
-.ms.100:
-	$(TROFF) -ms $(VER) $< | hp2 100 | lp -og $(PRINTER)
-
-.man.100:
-	$(TROFF) -man $< | hp2 100 | lp -og $(PRINTER)
-
-.ms.doc:
-	$(NROFF) -ms $(VER) $< >$@
-
-.man.doc:
-	$(NROFF) -man $< >$@
-
-.ms.vga:
-	$(TROFF) -ms $(VER) $< >/tmp/foo
-	-vga /tmp/foo
-	rm /tmp/foo
-
-.ms.vgas:
-	$(TROFF) -ms $(VER) $< >/tmp/foo
-	-vgas /tmp/foo
-	rm /tmp/foo
-
-#############################################################################
-# Targets...
-
-asc: $(ASC)
-	cat $(ASC) >asc
-
-manual: $(MANUAL)
-
-clean:
-	rm -f *.doc *.sh
Index: trunk/minix/commands/elvis/Makefile
===================================================================
--- trunk/minix/commands/elvis/Makefile	(revision 9)
+++ 	(revision )
@@ -1,92 +1,0 @@
-# Makefile for elvis
-#
-# Several groups of Makefile settings are included below.  Choose *ONE* group
-# of settings for your particular system, and leave the others commented out.
-# The meanings of these settings are:
-#	EXTRA	version-specific object files used in elvis
-#	CC	the C compiler command, possibly with "memory model" flags
-#	CFLAGS	compiler flags used to select compile-time options
-#	PROGS	the list of all programs
-#	SORT	if the "tags" file must be sorted, then SORT=-DSORT
-
-CC = exec cc
-PROGS=	elvis ctags ref elvrec fmt elvprsv
-
-#---- These settings are recommended for Minix-PC ----
-EXTRA=	tinytcap.o tinyprnt.o
-CFLAGS=	-O -w -D_POSIX_SOURCE -D_MINIX -DCRUNCH \
-	-DNO_MKEXRC -DNO_CURSORSHAPE -DNO_CHARATTR -DNO_SHOWMODE \
-	-DNO_MODELINE -DNO_OPTCOLS -DNO_DIGRAPH -DNO_EXTENSIONS \
-	-DNO_ERRLIST -DNO_FKEY -DNO_VISIBLE -DNO_COLOR -DNO_POPUP
-LDFLAGS=-i
-
-#---- These settings are recommended for Minix-ST ----
-#EXTRA=
-#CFLAGS=
-
-###########################################################################
-###     The rest of this Makefile contains no user-serviceable parts    ###
-###########################################################################
-
-OBJ=blk.o cmd1.o cmd2.o ctype.o curses.o cut.o ex.o input.o \
-   main.o misc.o modify.o move1.o move2.o move3.o move4.o move5.o \
-   opts.o recycle.o redraw.o regexp.o regsub.o system.o tio.o tmp.o \
-   unix.o vars.o vcmd.o vi.o
-
-all:	$(PROGS)
-
-elvis:	$(OBJ)
-	$(CC) $(LDFLAGS) -o elvis $(OBJ)
-	install -S 18kw elvis
-
-ctags:	ctags.c
-	$(CC) $(CFLAGS) $(SORT) $(LDFLAGS) -o ctags ctags.c
-	install -S 4kw $@
-
-ref:	ref.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o ref ref.c
-	install -S 4kw $@
-
-elvrec:	elvrec.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o elvrec elvrec.c
-	install -S 4kw $@
-
-fmt:	fmt.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o fmt fmt.c
-	install -S 4kw $@
-
-elvprsv:	elvprsv.c
-	$(CC) $(CFLAGS) $(LDFLAGS) -o elvprsv elvprsv.c ctype.o
-	install -S 4kw $@
-
-install:	/usr/bin/elvis \
-		/bin/elvis \
-		/usr/bin/ctags /usr/bin/ref /usr/bin/fmt \
-		/usr/bin/elvrec /usr/bin/elvprsv
-
-/usr/bin/elvis:	elvis
-	install -cs -o bin elvis $@
-
-/bin/elvis:	elvis
-	install -cs -o bin elvis $@
-
-/usr/bin/ctags:	ctags
-	install -cs -o bin ctags $@
-
-/usr/bin/ref:	ref
-	install -cs -o bin ref $@
-
-/usr/bin/fmt:	fmt
-	install -cs -o bin fmt $@
-
-/usr/bin/elvrec:	elvrec
-	install -cs -o root -m 4755 elvrec $@
-
-/usr/bin/elvprsv:	elvprsv
-	install -cs -o root -m 4755 elvprsv $@
-
-# Dependencies
-$(OBJ):	vi.h curses.h config.h regexp.h ctype.h
-
-clean:	
-	rm -f *.o ctags ref elvrec fmt elvprsv elvis
Index: trunk/minix/commands/elvis/Man.sh
===================================================================
--- trunk/minix/commands/elvis/Man.sh	(revision 9)
+++ 	(revision )
@@ -1,414 +1,0 @@
-echo x - ctags.man
-sed '/^X/s///' > ctags.man << '/'
-X.TH CTAGS 1
-X.SH NAME
-Xctags - Generates "tags" and (optionally) "refs" files
-X.SH SYNOPSIS
-X\fBctags\fP [\fB-stvra\fP] \fIfilesnames\fP...
-X.SH DESCRIPTION
-X\fIctags\fP generates the "tags" and "refs" files
-Xfrom a group of C source files.
-XThe "tags" file is used by Elvis' ":tag" command,
-Xcontrol-] command,
-Xand -t option.
-XThe "refs" file is sometimes used by the \fIref(1)\fP program.
-X.PP
-XEach C source file is scanned for #define statements and
-Xglobal function definitions.
-XThe name of the macro or function becomes the name of a tag.
-XFor each tag, a line is added to the "tags" file which contains:
-X.RS
-X.nf
-X       - the name of the tag
-X       - a tab character
-X       - the name of the file containing the tag
-X       - a tab character
-X       - a way to find the particular line within the file.
-X.RE
-X.fi
-X.PP
-XThe filenames list will typically be the names of all C source
-Xfiles in the current directory, like this:
-X.RS
-X.nf
-X$ ctags -stv *.[ch]
-X.RE
-X.fi
-X.SH OPTIONS
-X.IP \fB-t\fR
-XInclude typedefs.
-XA tag will be generated for each user-defined type.
-XAlso tags will be generated for struct and enum names.
-XTypes are considered to be global if they are defined in a header file,
-Xand static if they are defined in a C source file.
-X.IP \fB-v\fR
-XInclude variable declarations.
-XA tag will be generated for each variable, except for those that are declared
-Xinside the body of a function.
-X.IP \fB-s\fR
-XInclude static tags.
-X\fICtags\fR will normally put global tags in the "tags" file, and silently ignore
-Xthe static tags.
-XThis flag causes both global and static tags to be added.
-XThe name of a static tag is generated by prefixing the name of the declared
-Xitem with the name of the file where it is defined, with a colon in between.
-XFor example, "static foo(){}" in "bar.c" results in a tag named "bar.c:foo".
-X.IP \fB-r\fP
-XThis causes \fIctags\fP to generate both "tags" and "refs".
-XWithout \fB-r\fP, it would only generate "tags".
-X.IP \fB-a\fR
-XAppend to "tags", and maybe "refs".
-XNormally, \fIctags\fR overwrites these files each time it is invoked.
-XThis flag is useful when you have to many files in the current directory
-Xfor you to list them on a single command-line;
-Xit allows you to split the arguments among several invocations.
-X.SH FILES
-X.IP tags
-XA cross-reference that lists each tag name, the name of the source file that
-Xcontains it, and a way to locate a particular line in the source file.
-X.IP refs
-XThe "refs" file contains the definitions for each tag in the "tags" file,
-Xand very little else.
-XThis file can be useful, for example, when licensing restrictions prevent
-Xyou from making the source code to the standard C library readable by everybody,
-Xbut you still everybody to know what arguments the library functions need.
-X.SH BUGS
-X.PP
-X\fIctags\fR is sensitive to indenting and line breaks.
-XConsequently, it might not discover all of the tags in a file that
-Xis formatted in an unusual way.
-X.SH "SEE ALSO"
-Xelvis(1), refs(1)
-X.SH AUTHOR
-X.nf
-XSteve Kirkendall
-Xkirkenda@cs.pdx.edu
-X.fi
-/
-echo x - elvis.man
-sed '/^X/s///' > elvis.man << '/'
-X.TH ELVIS 1
-X.SH NAME
-Xelvis, ex, vi, view, input - The editor
-X.SH SYNOPSIS
-X\fBelvis\fP [\fIflags\fP] [\fB+\fP\fIcmd\fP] [\fIfiles\fP...]
-X.SH DESCRIPTION
-X\fIElvis\fP is a text editor which emulates \fIvi\fP/\fIex\fP.
-X.PP
-XOn systems which pass the program name as an argument, such as Unix and Minix,
-Xyou may also install \fIelvis\fP under the names "ex", "vi", "view", and "input".
-XThese extra names would normally be links to elvis;
-Xsee the "ln" shell command.
-X.PP
-XWhen \fIelvis\fP is invoked as "vi",
-Xit behaves exactly as though it was invoked as "elvis".
-XHowever, if you invoke \fIelvis\fP as "view",
-Xthen the readonly option is set as though you had given it the "-R" flag.
-XIf you invoke \fIelvis\fP as "ex",
-Xthen \fIelvis\fP will start up in the colon command mode
-Xinstead of the visual command mode,
-Xas though you had given it the "-e" flag.
-XIf you invoke \fIelvis\fP as "input" or "edit",
-Xthen \fIelvis\fP will start up in input mode,
-Xas though the "-i" flag was given.
-X.SH OPTIONS
-X.IP \fB-r\fP
-XTo the real vi, this flag means that a previous edit should be recovered.
-X\fIElvis\fP, though, has a separate program, called \fIelvrec(1)\fP, for recovering
-Xfiles.
-XWhen you invoke \fIelvis\fP with -r, \fIelvis\fP will tell you to run \fIelvrec\fP.
-X.IP \fB-R\fP
-XThis sets the "readonly" option,
-Xso you won't accidentally overwrite a file.
-X.IP "\fB-t\fP \fItag\fP"
-XThis causes \fIelvis\fP to start editing at the given tag.
-X.IP "\fB-m\fP [\fIfile\fP]"
-X\fIElvis\fP will search through \fIfile\fP for something that looks like
-Xan error message from a compiler.
-XIt will then begin editing the source file that caused the error,
-Xwith the cursor sitting on the line where the error was detected.
-XIf you don't explicitly name a \fIfile\fP, then "errlist" is assumed.
-X.IP \fB-e\fP
-X\fIElvis\fP will start up in colon command mode.
-X.IP \fB-v\fP
-X\fIElvis\fP will start up in visual command mode.
-X.IP \fB-i\fP
-X\fIElvis\fP will start up in input mode.
-X.IP "\fB-w\fR \fIwinsize\fR"
-XSets the "window" option's value to \fIwinsize\fR.
-X.IP "\fB+\fP\fIcommand\fP or \fB-c\fP \fIcommand\fP"
-XIf you use the +\fIcommand\fP parameter,
-Xthen after the first file is loaded
-X\fIcommand\fP is executed as an EX command.
-XA typical example would be "elvis +237 foo",
-Xwhich would cause \fIelvis\fP to start editing foo and
-Xthen move directly to line 237.
-XThe "-c \fIcommand\fP" variant was added for UNIX SysV compatibility.
-X.SH FILES
-X.IP /tmp/elv*
-XDuring editing,
-X\fIelvis\fP stores text in a temporary file.
-XFor UNIX, this file will usually be stored in the /tmp directory,
-Xand the first three characters will be "elv".
-XFor other systems, the temporary files may be stored someplace else;
-Xsee the version-specific section of the documentation.
-X.IP tags
-XThis is the database used by the \fI:tags\fP command and the \fB-t\fP option.
-XIt is usually created by the \fIctags(1)\fP program.
-X.IP ".exrc or elvis.rc"
-XOn UNIX-like systems, a file called ".exrc" in your home directory
-Xis executed as a series of \fIex\fR commands.
-XA file by the same name may be executed in the current directory, too.
-XOn non-UNIX systems, ".exrc" is usually an invalid file name;
-Xthere, the initialization file is called "elvis.rc" instead.
-X.SH "SEE ALSO"
-Xctags(1), ref(1), virec(1)
-X.PP
-X\fIElvis - A Clone of Vi/Ex\fP, the complete \fIelvis\fP documentation.
-X.SH BUGS
-XThere is no LISP support.
-XCertain other features are missing, too.
-X.PP
-XAuto-indent mode is not quite compatible with the real vi.
-XAmong other things, 0^D and ^^D don't do what you might expect.
-X.PP
-XLong lines are displayed differently.
-XThe real vi wraps long lines onto multiple rows of the screen,
-Xbut \fIelvis\fP scrolls sideways.
-X.SH AUTHOR
-X.nf
-XSteve Kirkendall
-Xkirkenda@cs.pdx.edu
-X.fi
-X.PP
-XMany other people have worked to port \fIelvis\fP to various operating systems.
-XTo see who deserves credit, run the \fI:version\fP command from within \fIelvis\fP,
-Xor look in the system-specific section of the complete documentation.
-/
-echo x - elvprsv.man
-sed '/^X/s///' > elvprsv.man << '/'
-X.TH ELVPRSV 1
-X.SH NAME
-Xelvprsv - Preserve the the modified version of a file after a crash.
-X.SH SYNOPSIS
-X.nf
-X\fB\fBelvprsv\fP ["-\fIwhy elvis died\fP"] /tmp/\fIfilename\fP...
-X\fB\fBelvprsv\fP -R /tmp/\fIfilename\fP...
-X.fi
-X.SH DESCRIPTION
-X.PP
-X\fIelvprsv\fP preserves your edited text after \fIelvis\fP dies.
-XThe text can be recovered later, via the \fIelvprsv\fP program.
-X.PP
-XFor UNIX-like systems,
-Xyou should never need to run this program from the command line.
-XIt is run automatically when \fIelvis\fP is about to die,
-Xand it should be run (via /etc/rc) when the computer is booted.
-XTHAT'S ALL!
-X.PP
-XFor non-UNIX systems such as MS-DOS, you can either use \fIelvprsv\fP
-Xthe same way as under UNIX systems (by running it from your AUTOEXEC.BAT file),
-Xor you can run it separately with the "-R" flag to recover the files
-Xin one step.
-X.PP
-XIf you're editing a file when \fIelvis\fP dies
-X(due to a bug, system crash, power failure, etc.)
-Xthen \fIelvprsv\fP will preserve the most recent version of your text.
-XThe preserved text is stored in a special directory; it does NOT overwrite
-Xyour text file automatically.
-X.PP
-X\fIelvprsv\fP will send mail to any user whose work it preserves,
-Xif your operating system normally supports mail.
-X.SH FILES
-X.IP /tmp/elv*
-XThe temporary file that \fIelvis\fP was using when it died.
-X.IP /usr/preserve/p*
-XThe text that is preserved by \fIelvprsv\fP.
-X.IP /usr/preserve/Index
-XA text file which lists the names of all preserved files, and the names
-Xof the /usr/preserve/p* files which contain their preserved text.
-X.SH BUGS
-X.PP
-XDue to the permissions on the /usr/preserve directory, on UNIX systems
-X\fIelvprsv\fP must be run as superuser.
-XThis is accomplished by making the \fIelvprsv\fP executable be owned by "root"
-Xand turning on its "set user id" bit.
-X.PP
-XIf you're editing a nameless buffer when \fIelvis\fP dies, then \fIelvprsv\fP will pretend
-Xthat the file was named "foo".
-X.SH AUTHOR
-X.nf
-XSteve Kirkendall
-Xkirkenda@cs.pdx.edu
-X.fi
-/
-echo x - elvrec.man
-sed '/^X/s///' > elvrec.man << '/'
-X.TH ELVREC 1
-X.SH NAME
-Xelvrec - Recover the modified version of a file after a crash
-X.SH SYNOPSIS
-X.nf
-X\fBelvrec\fP [\fIpreservedfile\fP [\fInewfile\fR]]
-X.fi
-X.SH DESCRIPTION
-X.PP
-XIf you're editing a file when \fIelvis\fP dies, the system crashes, or power fails,
-Xthe most recent version of your text will be preserved.
-XThe preserved text is stored in a special directory; it does NOT overwrite
-Xyour text file automatically.
-X.PP
-XThe \fIelvrec\fP program locates the preserved version of a given file,
-Xand writes it over the top of your text file -- or to a new file, if you prefer.
-XThe recovered file will have nearly all of your changes.
-X.PP
-XTo see a list of all recoverable files, run \fIelvrec\fP with no arguments.
-X.SH FILES
-X.IP /usr/preserve/p*
-XThe text that was preserved when \fIelvis\fP died.
-X.IP /usr/preserve/Index
-XA text file which lists the names of all preserved files, and the names
-Xof the /usr/preserve/p* files which contain their preserved text.
-X.SH BUGS
-X.PP
-X\fIelvrec\fP is very picky about filenames.
-XYou must tell it to recover the file using exactly the same pathname as
-Xwhen you were editing it.
-XThe simplest way to do this is to go into the same directory that you were
-Xediting, and invoke \fIelvrec\fP with the same filename as \fIelvis\fP.
-XIf that doesn't work, then try running \fIelvrec\fP with no arguments,
-Xto see exactly which pathname it is using for the desired file.
-X.PP
-XDue to the permissions on the /usr/preserve directory, on UNIX systems
-X\fIelvrec\fP must be run as superuser.
-XThis is accomplished by making the \fIelvrec\fP executable be owned by "root"
-Xand setting its "set user id" bit.
-X.PP
-XIf you're editing a nameless buffer when \fIelvis\fP dies, then \fIelvrec\fP
-Xwill pretend that the file was named "foo".
-X.SH AUTHOR
-X.nf
-XSteve Kirkendall
-Xkirkenda@cs.pdx.edu
-X.fi
-/
-echo x - fmt.man
-sed '/^X/s///' > fmt.man << '/'
-X.TH FMT 1
-X.SH NAME
-Xfmt - adjust line-length for paragraphs of text
-X.SH SYNOPSIS
-X\fBfmt\fP [\-\fIwidth\fP] [\fIfiles\fP]...
-X.SH DESCRIPTION
-X\fIfmt\fR is a simple text formatter.
-XIt inserts or deletes newlines, as necessary, to make all lines in a
-Xparagraph be approximately the same width.
-XIt preserves indentation and word spacing.
-X.PP
-XThe default line width is 72 characters.
-XYou can override this with the \-\fIwidth\fR flag.
-XIf you don't name any files on the command line,
-Xthen \fIfmt\fR will read from stdin.
-X.PP
-XIt is typically used from within \fIvi\fR to adjust the line breaks
-Xin a single paragraph.
-XTo do this, move the cursor to the top of the paragraph,
-Xtype "!}fmt", and
-Xhit <Return>.
-X.SH AUTHOR
-X.nf
-XSteve Kirkendall
-Xkirkenda@cs.pdx.edu
-X.fi
-/
-echo x - ref.man
-sed '/^X/s///' > ref.man << '/'
-X.TH REF 1
-X.SH NAME
-Xref - Display a C function header
-X.SH SYNOPSIS
-X\fBref\fR [-t] [-c \fIclass\fR]... [-f \fIfile\fR]... \fItag\fR
-X.SH DESCRIPTION
-X\fIref\fP quickly locates and displays the header of a function.
-XTo do this, \fIref\fR
-Xlooks in the "tags" file for the line that describes the function, and then 
-Xscans the source file for the function.
-XWhen it locates the function, it displays an introductory comment
-X(if there is one), the function's declaration, and the declarations of all
-Xarguments.
-X.SH "SEARCH METHOD"
-X.PP
-X\fIref\fR uses a fairly sophisticated tag look-up algorithm.
-XIf you supply a filename via \fB-f\fR \fIfile\fR, then elvis first scans
-Xthe tags file for a static tag from that file.
-XThis search is limited to the tags file in the current directory.
-X.PP
-XIf you supply a classname via \fB-c\fR \fIclass\fR, then elvis searches
-Xfor a tag from that class.
-XThis search is not limited to the current directory;
-XYou can supply a list of directories in the environment variable \fITAGPATH\fR,
-Xand \fIref\fR will search through the "tags" file in each directory until it finds
-Xa tag in the desired class.
-X.PP
-XIf that fails, \fIref\fR will then try to look up an ordinary global tag.
-XThis search checks all of the directories listed in \fITAGPATH\fR, too.
-X.PP
-XIf you've given the \fB-t\fR flag, then \fIref\fR will simply output the tag line that
-Xit found, and then exit.
-XWithout \fB-t\fR, though, \fIref\fR will search for the tag line.
-XIt will try to open the source file, which should be in the same directory
-Xas the tags file where the tag was discovered.
-XIf the source file doesn't exist, or is unreadable, then \fIref\fR will try to open
-Xa file called "\fIrefs\fR" in that directory.
-XEither way, \fIref\fR will try to locate the tag, and display whatever it finds.
-X.SH "INTERACTION WITH ELVIS"
-X.PP
-X\fIref\fP is used by \fIelvis\fR' shift-K command.
-XIf the cursor is located on a word such as "splat", in the file "foo.c",
-Xthen \fIelvis\fR will invoke \fIref\fR with the command "ref -f foo.c splat".
-X.PP
-XIf \fIelvis\fR has been compiled with the -DEXTERNAL_TAGS flag, then \fIelvis\fR will
-Xuse \fIref\fR \fB\fRto scan the tags files.
-XThis is slower than the built-in tag searching, but it allows \fIelvis\fR to access
-Xthe more sophisticated tag lookup provided by \fIref\fR.
-XOther than that, external tags should act exactly like internal tags.
-X.SH OPTIONS
-X.IP \fB-t\fR
-XOutput tag info, instead of the function header.
-X.IP "\fB-f\fR \fIfile\fR"
-XThe tag might be a static function in \fIfile\fR.
-XYou can use several -f flags to have \fIref\fR consider static tags from more than one file.
-X.IP "\fB-c\fR \fIclass\fR"
-XThe tag might be a member of class \fIclass\fR.
-XYou can use several -c flags to have \fIref\fR consider tags from more than one class.
-X.SH FILES
-X.IP \fBtags\fR
-XList of function names and their locations, generated by \fIctags\fR.
-X.IP \fBrefs\fR
-XFunction headers extracted from source files (optional).
-X.SH ENVIRONMENT
-X.IP \fBTAGPATH\fR
-XList of directories to be searched.
-XThe elements in the list are separated by either
-Xsemicolons (for MS-DOS, Atari TOS, and AmigaDos), or
-Xby colons (every other operating system).
-XFor each operating system, \fIref\fR has a built-in default which is probably
-Xadequate.
-X.SH NOTES
-X.PP
-XYou might want to generate a "tags" file the directory that contains the
-Xsource code for standard C library on your system.
-XIf licensing restrictions prevent you from making the library source readable
-Xby everybody, then you can have \fIctags\fR generate a "refs" file,
-Xand make "refs" readable by everybody.
-X.PP
-XIf your system doesn't come with the library source code, then perhaps you
-Xcan produce something workable from the \fIlint\fR libraries.
-X.SH "SEE ALSO"
-Xelvis(1), ctags(1)
-X.SH AUTHOR
-X.nf
-XSteve Kirkendall
-Xkirkenda@cs.pdx.edu
-X.fi
-/
Index: trunk/minix/commands/elvis/Readme.txt
===================================================================
--- trunk/minix/commands/elvis/Readme.txt	(revision 9)
+++ 	(revision )
@@ -1,31 +1,0 @@
-Elvis is a clone of vi/ex, the standard UNIX editor.  Elvis supports
-nearly all of the vi/ex commands, in both visual mode and colon mode.
-
-Elvis runs under BSD UNIX, AT&T SysV UNIX, SCO Xenix, Minix, MS-DOS
-(Turbo-C or MSC 5.1), Atari TOS, OS9/68000, Coherent, VMS, and AmigaDos.
-Ports to other operating systems are in progress; contact me before you
-start porting it to some other OS, because somebody else may have
-already done it for you.
-
-Elvis is freely redistributable, in either source form or executable
-form.  There are no restrictions on how you may use it.
-
-The file "elvisman.txt" contains the manual for elvis.  It is a plain
-ASCII file with nothing more exotic than a newline character.  It is
-formatted for 66-line, 80-column pages.  There may also be an archive of
-"*.ms" and "*.man" files, which contain the TROFF source text used to
-generate that manual.
-
-The file named "Makefile.mix" is used to compile elvis for all systems
-except VMS and possibly MS-DOS.  You should copy "Makefile.mix" to
-"Makefile", and then edit "Makefile" to select the appropriate group of
-settings for your system.
-
-
-Author: Steve Kirkendall
-	14407 SW Teal Blvd. #C
-	Beaverton, OR   97005
-
-E-mail:	kirkenda@cs.pdx.edu
-
-Phone:	(503) 643-6980
Index: trunk/minix/commands/elvis/blk.c
===================================================================
--- trunk/minix/commands/elvis/blk.c	(revision 9)
+++ 	(revision )
@@ -1,469 +1,0 @@
-/* blk.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the functions that get/put blocks from the temp file.
- * It also contains the "do" and "undo" functions.
- */
-
-#include "config.h"
-#include "vi.h"
-
-#ifndef NBUFS
-# define NBUFS	5		/* must be at least 3 -- more is better */
-#endif
-
-
-/*------------------------------------------------------------------------*/
-
-BLK		hdr;		/* buffer for the header block */
-
-static int	b4cnt;		/* used to count context of beforedo/afterdo */
-static struct _blkbuf
-{
-	BLK		buf;		/* contents of a text block */
-	unsigned short	logical;	/* logical block number */
-	int		dirty;		/* must the buffer be rewritten? */
-}
-		blk[NBUFS],	/* buffers for text[?] blocks */
-		*toonew,	/* buffer which shouldn't be recycled yet */
-		*newtoo,	/* another buffer which should be recycled */
-		*recycle = blk;	/* next block to be recycled */
-
-
-
-
-
-/* This function wipes out all buffers */
-void blkinit()
-{
-	int	i;
-
-	for (i = 0; i < NBUFS; i++)
-	{
-		blk[i].logical = 0;
-		blk[i].dirty = FALSE;
-	}
-	for (i = 0; i < MAXBLKS; i++)
-	{
-		hdr.n[i] = 0;
-	}
-}
-
-/* This function allocates a buffer and fills it with a given block's text */
-BLK *blkget(logical)
-	int	logical;	/* logical block number to fetch */
-{
-	REG struct _blkbuf	*this;	/* used to step through blk[] */
-	REG int	i;
-
-	/* if logical is 0, just return the hdr buffer */
-	if (logical == 0)
-	{
-		return &hdr;
-	}
-
-	/* see if we have that block in mem already */
-	for (this = blk; this < &blk[NBUFS]; this++)
-	{
-		if (this->logical == logical)
-		{
-			newtoo = toonew;
-			toonew = this;
-			return &this->buf;
-		}
-	}
-
-	/* choose a block to be recycled */
-	do
-	{
-		this = recycle++;
-		if (recycle == &blk[NBUFS])
-		{
-			recycle = blk;
-		}
-	} while (this == toonew || this == newtoo);
-
-	/* if it contains a block, flush that block */
-	blkflush(this);
-
-	/* fill this buffer with the desired block */
-	this->logical = logical;
-	if (hdr.n[logical])
-	{
-		/* it has been used before - fill it from tmp file */
-		lseek(tmpfd, (long)hdr.n[logical] * (long)BLKSIZE, 0);
-		if (read(tmpfd, this->buf.c, (unsigned)BLKSIZE) != BLKSIZE)
-		{
-			msg("Error reading back from tmp file!");
-		}
-	}
-	else
-	{
-		/* it is new - zero it */
-		for (i = 0; i < BLKSIZE; i++)
-		{
-			this->buf.c[i] = 0;
-		}
-	}
-
-	/* This isn't really a change, but it does potentially invalidate
-	 * the kinds of shortcuts that the "changes" variable is supposed
-	 * to protect us from... so count it as a change.
-	 */
-	changes++;
-
-	/* mark it as being "not dirty" */
-	this->dirty = 0;
-
-	/* return it */
-	newtoo = toonew;
-	toonew = this;
-	return &this->buf;
-}
-
-
-
-/* This function writes a block out to the temporary file */
-void blkflush(this)
-	REG struct _blkbuf	*this;	/* the buffer to flush */
-{
-	long		seekpos;	/* seek position of the new block */
-	unsigned short	physical;	/* physical block number */
-
-	/* if its empty (an orphan blkadd() maybe?) then make it dirty */
-	if (this->logical && !*this->buf.c)
-	{
-		blkdirty(&this->buf);
-	}
-
-	/* if it's an empty buffer or a clean version is on disk, quit */
-	if (!this->logical || hdr.n[this->logical] && !this->dirty)
-	{
-		return;
-	}
-
-	/* find a free place in the file */
-#ifndef NO_RECYCLE
-	seekpos = allocate();
-	lseek(tmpfd, seekpos, 0);
-#else
-	seekpos = lseek(tmpfd, 0L, 2);
-#endif
-	physical = seekpos / BLKSIZE;
-
-	/* put the block there */
-	if (write(tmpfd, this->buf.c, (unsigned)BLKSIZE) != BLKSIZE)
-	{
-		msg("Trouble writing to tmp file");
-	}
-	this->dirty = FALSE;
-
-	/* update the header so it knows we put it there */
-	hdr.n[this->logical] = physical;
-}
-
-
-/* This function sets a block's "dirty" flag or deletes empty blocks */
-void blkdirty(bp)
-	BLK	*bp;	/* buffer returned by blkget() */
-{
-	REG int		i, j;
-	REG char	*scan;
-	REG int		k;
-
-	/* find the buffer */
-	for (i = 0; i < NBUFS && bp != &blk[i].buf; i++)
-	{
-	}
-#ifdef DEBUG
-	if (i >= NBUFS)
-	{
-		msg("blkdirty() called with unknown buffer at 0x%lx", bp);
-		return;
-	}
-	if (blk[i].logical == 0)
-	{
-		msg("blkdirty called with freed buffer");
-		return;
-	}
-#endif
-
-	/* if this block ends with line# INFINITY, then it must have been
-	 * allocated unnecessarily during tmpstart().  Forget it.
-	 */
-	if (lnum[blk[i].logical] == INFINITY)
-	{
-#ifdef DEBUG
-		if (blk[i].buf.c[0])
-		{
-			msg("bkldirty called with non-empty extra BLK");
-		}
-#endif
-		blk[i].logical = 0;
-		blk[i].dirty = FALSE;
-		return;
-	}
-
-	/* count lines in this block */
-	for (j = 0, scan = bp->c; *scan && scan < bp->c + BLKSIZE; scan++)
-	{
-		if (*scan == '\n')
-		{
-			j++;
-		}
-	}
-
-	/* adjust lnum, if necessary */
-	k = blk[i].logical;
-	j += (lnum[k - 1] - lnum[k]);
-	if (j != 0)
-	{
-		nlines += j;
-		while (k < MAXBLKS && lnum[k] != INFINITY)
-		{
-			lnum[k++] += j;
-		}
-	}
-
-	/* if it still has text, mark it as dirty */
-	if (*bp->c)
-	{
-		blk[i].dirty = TRUE;
-	}
-	else /* empty block, so delete it */
-	{
-		/* adjust the cache */
-		k = blk[i].logical;
-		for (j = 0; j < NBUFS; j++)
-		{
-			if (blk[j].logical >= k)
-			{
-				blk[j].logical--;
-			}
-		}
-
-		/* delete it from hdr.n[] and lnum[] */
-		blk[i].logical = 0;
-		blk[i].dirty = FALSE;
-		while (k < MAXBLKS - 1)
-		{
-			hdr.n[k] = hdr.n[k + 1];
-			lnum[k] = lnum[k + 1];
-			k++;
-		}
-		hdr.n[MAXBLKS - 1] = 0;
-		lnum[MAXBLKS - 1] = INFINITY;
-	}
-}
-
-
-/* insert a new block into hdr, and adjust the cache */
-BLK *blkadd(logical)
-	int	logical;	/* where to insert the new block */
-{
-	REG int	i;
-
-	/* adjust hdr and lnum[] */
-	for (i = MAXBLKS - 1; i > logical; i--)
-	{
-		hdr.n[i] = hdr.n[i - 1];
-		lnum[i] = lnum[i - 1];
-	}
-	hdr.n[logical] = 0;
-	lnum[logical] = lnum[logical - 1];
-
-	/* adjust the cache */
-	for (i = 0; i < NBUFS; i++)
-	{
-		if (blk[i].logical >= logical)
-		{
-			blk[i].logical++;
-		}
-	}
-
-	/* return the new block, via blkget() */
-	return blkget(logical);
-}
-
-
-/* This function forces all dirty blocks out to disk */
-void blksync()
-{
-	int	i;
-
-	for (i = 0; i < NBUFS; i++)
-	{
-		/* blk[i].dirty = TRUE; */
-		blkflush(&blk[i]);
-	}
-	if (*o_sync)
-	{
-		sync();
-	}
-}
-
-/*------------------------------------------------------------------------*/
-
-static MARK	undocurs;	/* where the cursor should go if undone */
-static long	oldnlines;
-static long	oldlnum[MAXBLKS];
-
-
-/* This function should be called before each command that changes the text.
- * It defines the state that undo() will reset the file to.
- */
-void beforedo(forundo)
-	int		forundo;	/* boolean: is this for an undo? */
-{
-	REG int		i;
-	REG long	l;
-
-	/* if this is a nested call to beforedo, quit! Use larger context */
-	if (b4cnt++ > 0)
-	{
-		return;
-	}
-
-	/* force all block buffers to disk */
-	blksync();
-
-#ifndef NO_RECYCLE
-	/* perform garbage collection on blocks from tmp file */
-	garbage();
-#endif
-
-	/* force the header out to disk */
-	lseek(tmpfd, 0L, 0);
-	if (write(tmpfd, hdr.c, (unsigned)BLKSIZE) != BLKSIZE)
-	{
-		msg("Trouble writing header to tmp file ");
-	}
-
-	/* copy or swap oldnlines <--> nlines, oldlnum <--> lnum */
-	if (forundo)
-	{
-		for (i = 0; i < MAXBLKS; i++)
-		{
-			l = lnum[i];
-			lnum[i] = oldlnum[i];
-			oldlnum[i] = l;
-		}
-		l = nlines;
-		nlines = oldnlines;
-		oldnlines = l;
-	}
-	else
-	{
-		for (i = 0; i < MAXBLKS; i++)
-		{
-			oldlnum[i] = lnum[i];
-		}
-		oldnlines = nlines;
-	}
-
-	/* save the cursor position */
-	undocurs = cursor;
-
-	/* upon return, the calling function continues and makes changes... */
-}
-
-/* This function marks the end of a (nested?) change to the file */
-void afterdo()
-{
-	if (--b4cnt)
-	{
-		/* after abortdo(), b4cnt may decribe nested beforedo/afterdo
-		 * pairs incorrectly.  If it is decremented to often, then
-		 * keep b4cnt sane but don't do anything else.
-		 */
-		if (b4cnt < 0)
-			b4cnt = 0;
-
-		return;
-	}
-
-	/* make sure the cursor wasn't left stranded in deleted text */
-	if (markline(cursor) > nlines)
-	{
-		cursor = MARK_LAST;
-	}
-	/* NOTE: it is still possible that markidx(cursor) is after the
-	 * end of a line, so the Vi mode will have to take care of that
-	 * itself */
-
-	/* if a significant change has been made to this file, then set the
-	 * MODIFIED flag.
-	 */
-	if (significant)
-	{
-		setflag(file, MODIFIED);
-		setflag(file, UNDOABLE);
-	}	
-}
-
-/* This function cuts short the current set of changes.  It is called after
- * a SIGINT.
- */
-void abortdo()
-{
-	/* finish the operation immediately. */
-	if (b4cnt > 0)
-	{
-		b4cnt = 1;
-		afterdo();
-	}
-
-	/* in visual mode, the screen is probably screwed up */
-	if (mode == MODE_COLON)
-	{
-		mode = MODE_VI;
-	}
-	if (mode == MODE_VI)
-	{
-		redraw(MARK_UNSET, FALSE);
-	}
-}
-
-/* This function discards all changes made since the last call to beforedo() */
-int undo()
-{
-	BLK		oldhdr;
-
-	/* if beforedo() has never been run, fail */
-	if (!tstflag(file, UNDOABLE))
-	{
-		msg("You haven't modified this file yet.");
-		return FALSE;
-	}
-
-	/* read the old header form the tmp file */
-	lseek(tmpfd, 0L, 0);
-	if (read(tmpfd, oldhdr.c, (unsigned)BLKSIZE) != BLKSIZE)
-	{
-		msg("Trouble rereading the old header from tmp file");
-	}
-
-	/* "do" the changed version, so we can undo the "undo" */
-	cursor = undocurs;
-	beforedo(TRUE);
-	afterdo();
-
-	/* wipe out the block buffers - we can't assume they're correct */
-	blkinit();
-
-	/* use the old header -- and therefore the old text blocks */
-	hdr = oldhdr;
-
-	/* This is a change */
-	significant = TRUE;
-	changes++;
-
-	return TRUE;
-}
Index: trunk/minix/commands/elvis/build
===================================================================
--- trunk/minix/commands/elvis/build	(revision 9)
+++ 	(revision )
@@ -1,2 +1,0 @@
-#!/bin/sh
-make && make install
Index: trunk/minix/commands/elvis/cmd1.c
===================================================================
--- trunk/minix/commands/elvis/cmd1.c	(revision 9)
+++ 	(revision )
@@ -1,1774 +1,0 @@
-/* cmd1.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains some of the EX commands - mostly ones that deal with
- * files, options, etc. -- anything except text.
- */
-
-#include "config.h"
-#include "ctype.h"
-#include "vi.h"
-#include "regexp.h"
-
-#ifdef DEBUG
-/* print the selected lines with info on the blocks */
-/*ARGSUSED*/
-void cmd_debug(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	REG char	*scan;
-	REG long	l;
-	REG int		i;
-	int		len;
-
-	/* scan lnum[] to determine which block its in */
-	l = markline(frommark);
-	for (i = 1; l > lnum[i]; i++)
-	{
-	}
-
-	do
-	{
-		/* fetch text of the block containing that line */
-		scan = blkget(i)->c;
-
-		/* calculate its length */
-		if (scan[BLKSIZE - 1])
-		{
-			len = BLKSIZE;
-		}
-		else
-		{
-			len = strlen(scan);
-		}
-
-		/* print block stats */
-		msg("##### hdr[%d]=%d, lnum[%d-1]=%ld, lnum[%d]=%ld (%ld lines)",
-			i, hdr.n[i], i, lnum[i-1], i, lnum[i], lnum[i] - lnum[i - 1]);
-		msg("##### len=%d, buf=0x%lx, %sdirty",
-			len, scan, ((int *)scan)[MAXBLKS + 1] ? "" : "not ");
-		if (bang)
-		{
-			while (--len >= 0)
-			{
-				addch(*scan);
-				scan++;
-			}
-		}
-		exrefresh();
-
-		/* next block */
-		i++;
-	} while (i < MAXBLKS && lnum[i] && lnum[i - 1] < markline(tomark));
-}
-
-
-/* This function checks a lot of conditions to make sure they aren't screwy */
-/*ARGSUSED*/
-void cmd_validate(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	char	*scan;
-	int	i;
-	int	nlcnt;	/* used to count newlines */
-	int	len;	/* counts non-NUL characters */
-
-	/* check lnum[0] */
-	if (lnum[0] != 0L)
-	{
-		msg("lnum[0] = %ld", lnum[0]);
-	}
-
-	/* check each block */
-	for (i = 1; lnum[i] <= nlines; i++)
-	{
-		scan = blkget(i)->c;
-		if (scan[BLKSIZE - 1])
-		{
-			msg("block %d has no NUL at the end", i);
-		}
-		else
-		{
-			for (nlcnt = len = 0; *scan; scan++, len++)
-			{
-				if (*scan == '\n')
-				{
-					nlcnt++;
-				}
-			}
-			if (scan[-1] != '\n')
-			{
-				msg("block %d doesn't end with '\\n' (length %d)", i, len);
-			}
-			if (bang || nlcnt != lnum[i] - lnum[i - 1])
-			{
-				msg("block %d (line %ld?) has %d lines, but should have %ld",
-					i, lnum[i - 1] + 1L, nlcnt, lnum[i] - lnum[i - 1]);
-			}
-		}
-		exrefresh();
-	}
-
-	/* check lnum again */
-	if (lnum[i] != INFINITY)
-	{
-		msg("hdr.n[%d] = %d, but lnum[%d] = %ld",
-			i, hdr.n[i], i, lnum[i]);
-	}
-
-	msg("# = \"%s\", %% = \"%s\"", prevorig, origname);
-	msg("V_from=%ld.%d, cursor=%ld.%d", markline(V_from), markidx(V_from), markline(cursor), markidx(cursor));
-}
-#endif /* DEBUG */
-
-
-/*ARGSUSED*/
-void cmd_mark(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	/* validate the name of the mark */
-	if (*extra == '"')
-	{
-		extra++;
-	}
-	/* valid mark names are lowercase ascii characters */
-	if (!isascii(*extra) || !islower(*extra) || extra[1])
-	{
-		msg("Invalid mark name");
-		return;
-	}
-
-	mark[*extra - 'a'] = tomark;
-}
-
-/*ARGSUSED*/
-void cmd_write(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	int		fd;
-	int		append;	/* boolean: write in "append" mode? */
-	REG long	l;
-	REG char	*scan;
-	REG int		i;
-
-	/* if writing to a filter, then let filter() handle it */
-	if (*extra == '!')
-	{
-		filter(frommark, tomark, extra + 1, FALSE);
-		return;
-	}
-
-	/* if all lines are to be written, use tmpsave() */
-	if (frommark == MARK_FIRST && tomark == MARK_LAST && cmd == CMD_WRITE)
-	{
-		tmpsave(extra, bang);
-		return;
-	}
-
-	/* see if we're going to do this in append mode or not */
-	append = FALSE;
-	if (extra[0] == '>' && extra[1] == '>')
-	{
-		extra += 2;
-		append = TRUE;
-	}
-
-	/* either the file must not exist, or we must have a ! or be appending */
-	if (access(extra, 0) == 0 && !bang && !append)
-	{
-		msg("File already exists - Use :w! to overwrite");
-		return;
-	}
-
-	/* else do it line-by-line, like cmd_print() */
-	if (append)
-	{
-#ifdef O_APPEND
-		fd = open(extra, O_WRONLY|O_APPEND);
-#else
-		fd = open(extra, O_WRONLY);
-		if (fd >= 0)
-		{
-			lseek(fd, 0L, 2);
-		}
-#endif
-	}
-	else
-	{
-		fd = -1; /* so we know the file isn't open yet */
-	}
-
-	if (fd < 0)
-	{
-		fd = creat(extra, FILEPERMS);
-		if (fd < 0)
-		{
-			msg("Can't write to \"%s\"", extra);
-			return;
-		}
-	}
-	for (l = markline(frommark); l <= markline(tomark); l++)
-	{
-		/* get the next line */
-		scan = fetchline(l);
-		i = strlen(scan);
-		scan[i++] = '\n';
-
-		/* print the line */
-		if (twrite(fd, scan, i) < i)
-		{
-			msg("Write failed");
-			break;
-		}
-	}
-	rptlines = markline(tomark) - markline(frommark) + 1;
-	rptlabel = "written";
-	close(fd);
-}	
-
-
-/*ARGSUSED*/
-void cmd_shell(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	static char	prevextra[80];
-
-	/* special case: ":sh" means ":!sh" */
-	if (cmd == CMD_SHELL)
-	{
-		extra = o_shell;
-		frommark = tomark = 0L;
-	}
-
-	/* if extra is "!", substitute previous command */
-	if (*extra == '!')
-	{
-		if (!*prevextra)
-		{
-			msg("No previous shell command to substitute for '!'");
-			return;
-		}
-		extra = prevextra;
-	}
-	else if (cmd == CMD_BANG && strlen(extra) < sizeof(prevextra) - 1)
-	{
-		strcpy(prevextra, extra);
-	}
-
-	/* warn the user if the file hasn't been saved yet */
-	if (*o_warn && tstflag(file, MODIFIED))
-	{
-		if (mode == MODE_VI)
-		{
-			mode = MODE_COLON;
-		}
-		msg("Warning: \"%s\" has been modified but not yet saved", origname);
-	}
-
-	/* if no lines were specified, just run the command */
-	suspend_curses();
-	if (frommark == 0L)
-	{
-		system(extra);
-	}
-	else /* pipe lines from the file through the command */
-	{
-		filter(frommark, tomark, extra, TRUE);
-	}
-
-	/* resume curses quietly for MODE_EX, but noisily otherwise */
-	resume_curses(mode == MODE_EX);
-}
-
-
-/*ARGSUSED*/
-void cmd_global(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;	/* rest of the command line */
-{
-	char	*cmdptr;	/* the command from the command line */
-	char	cmdln[100];	/* copy of the command from the command line */
-	char	*line;		/* a line from the file */
-	long	l;		/* used as a counter to move through lines */
-	long	lqty;		/* quantity of lines to be scanned */
-	long	nchanged;	/* number of lines changed */
-	regexp	*re;		/* the compiled search expression */
-
-	/* can't nest global commands */
-	if (doingglobal)
-	{
-		msg("Can't nest global commands.");
-		rptlines = -1L;
-		return;
-	}
-
-	/* ":g! ..." is the same as ":v ..." */
-	if (bang)
-	{
-		cmd = CMD_VGLOBAL;
-	}
-
-	/* make sure we got a search pattern */
-	if (*extra != '/' && *extra != '?')
-	{
-		msg("Usage: %c /regular expression/ command", cmd == CMD_GLOBAL ? 'g' : 'v');
-		return;
-	}
-
-	/* parse & compile the search pattern */
-	cmdptr = parseptrn(extra);
-	if (!extra[1])
-	{
-		msg("Can't use empty regular expression with '%c' command", cmd == CMD_GLOBAL ? 'g' : 'v');
-		return;
-	}
-	re = regcomp(extra + 1);
-	if (!re)
-	{
-		/* regcomp found & described an error */
-		return;
-	}
-
-	/* for each line in the range */
-	doingglobal = TRUE;
-	ChangeText
-	{
-		/* NOTE: we have to go through the lines in a forward order,
-		 * otherwise "g/re/p" would look funny.  *BUT* for "g/re/d"
-		 * to work, simply adding 1 to the line# on each loop won't
-		 * work.  The solution: count lines relative to the end of
-		 * the file.  Think about it.
-		 */
-		for (l = nlines - markline(frommark),
-			lqty = markline(tomark) - markline(frommark) + 1L,
-			nchanged = 0L;
-		     lqty > 0 && nlines - l >= 0 && nchanged >= 0L;
-		     l--, lqty--)
-		{
-			/* fetch the line */
-			line = fetchline(nlines - l);
-
-			/* if it contains the search pattern... */
-			if ((!regexec(re, line, 1)) == (cmd != CMD_GLOBAL))
-			{
-				/* move the cursor to that line */
-				cursor = MARK_AT_LINE(nlines - l);
-
-				/* do the ex command (without mucking up
-				 * the original copy of the command line)
-				 */
-				strcpy(cmdln, cmdptr);
-				rptlines = 0L;
-				doexcmd(cmdln);
-				nchanged += rptlines;
-			}
-		}
-	}
-	doingglobal = FALSE;
-
-	/* free the regexp */
-	free(re);
-
-	/* Reporting...*/
-	rptlines = nchanged;
-}
-
-
-/*ARGSUSED*/
-void cmd_file(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-#ifndef CRUNCH
-	/* if we're given a new filename, use it as this file's name */
-	if (extra && *extra)
-	{
-		strcpy(origname, extra);
-		storename(origname);
-		setflag(file, NOTEDITED);
-	}
-#endif
-	if (cmd == CMD_FILE)
-	{
-#ifndef CRUNCH
-		msg("\"%s\" %s%s%s %ld lines,  line %ld [%ld%%]",
-#else
-		msg("\"%s\" %s%s %ld lines,  line %ld [%ld%%]",
-#endif
-			*origname ? origname : "[NO FILE]",
-			tstflag(file, MODIFIED) ? "[MODIFIED]" : "",
-#ifndef CRUNCH
-			tstflag(file, NOTEDITED) ?"[NOT EDITED]":"",
-#endif
-			tstflag(file, READONLY) ? "[READONLY]" : "",
-			nlines,
-			markline(frommark),
-			markline(frommark) * 100 / nlines);
-	}
-#ifndef CRUNCH
-	else if (markline(frommark) != markline(tomark))
-	{
-		msg("range \"%ld,%ld\" contains %ld lines",
-			markline(frommark),
-			markline(tomark),
-			markline(tomark) - markline(frommark) + 1L);
-	}
-#endif
-	else
-	{
-		msg("%ld", markline(frommark));
-	}
-}
-
-
-/*ARGSUSED*/
-void cmd_edit(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	long	line = 1L;	/* might be set to prevline */
-#ifndef CRUNCH
-	char	*init = (char *)0;
-#endif
-
-
-	/* if ":vi", then switch to visual mode, and if no file is named
-	 * then don't switch files.
-	 */
-	if (cmd == CMD_VISUAL)
-	{
-		mode = MODE_VI;
-		msg("");
-		if (!*extra)
-		{
-			return;
-		}
-	}
-
-	/* Editing previous file?  Then start at previous line */
-	if (!strcmp(extra, prevorig))
-	{
-		line = prevline;
-	}
-
-#ifndef CRUNCH
-	/* if we were given an explicit starting line, then start there */
-	if (*extra == '+')
-	{
-		for (init = ++extra; !isspace(*extra); extra++)
-		{
-		}
-		while (isspace(*extra))
-		{
-			*extra++ = '\0';
-		}
-		if (!*init)
-		{
-			init = "$";
-		}
-		if (!extra)
-		{
-			extra = origname;
-		}
-	}
-#endif /* not CRUNCH */
-
-	/* switch files */
-	if (tmpabort(bang))
-	{
-		tmpstart(extra);
-		if (line <= nlines && line >= 1L)
-		{
-			cursor = MARK_AT_LINE(line);
-		}
-#ifndef CRUNCH
-		if (init)
-		{
-			doexcmd(init);
-		}
-#endif
-	}
-	else
-	{
-		msg("Use edit! to abort changes, or w to save changes");
-
-		/* so we can say ":e!#" next time... */
-		strcpy(prevorig, extra);
-		prevline = 1L;
-	}
-}
-
-/* This code is also used for rewind -- GB */
-
-/*ARGSUSED*/
-void cmd_next(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	int	i, j;
-	char	*scan;
-
-	/* if extra stuff given, use ":args" to define a new args list */
-	if (cmd == CMD_NEXT && extra && *extra)
-	{
-		cmd_args(frommark, tomark, cmd, bang, extra);
-	}
-
-	/* move to the next arg */
-	if (cmd == CMD_NEXT)
-	{
-		i = argno + 1;
-	}
-	else if (cmd == CMD_PREVIOUS)
-	{
-		i = argno - 1;
-	}
-	else /* cmd == CMD_REWIND */
-	{
-		i = 0;
-	}	
-	if (i < 0 || i >= nargs)
-	{
-		msg("No %sfiles to edit", cmd == CMD_REWIND ? "" : "more ");
-		return;
-	}
-
-	/* find & isolate the name of the file to edit */
-	for (j = i, scan = args; j > 0; j--)
-	{
-		while(*scan++)
-		{
-		}
-	}
-
-	/* switch to the next file */
-	if (tmpabort(bang))
-	{
-		tmpstart(scan);
-		argno = i;
-	}
-	else
-	{
-		msg("Use :%s! to abort changes, or w to save changes",
-			cmd == CMD_NEXT ? "next" :
-			cmd == CMD_PREVIOUS ? "previous" :
-					"rewind");
-	}
-}
-
-/* also called from :wq -- always writes back in this case */
-
-/*ARGSUSED*/
-void cmd_xit(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	static long	whenwarned;	/* when the user was last warned of extra files */
-	int		oldflag;
-
-	/* if there are more files to edit, then warn user */
-	if (argno >= 0 && argno + 1 < nargs && whenwarned != changes && (!bang || cmd != CMD_QUIT))
-	{
-		msg("More files to edit -- Use \":n\" to go to next file");
-		whenwarned = changes;
-		return;
-	}
-
-	if (cmd == CMD_QUIT)
-	{
-		oldflag = *o_autowrite;
-		*o_autowrite = FALSE;
-		if (tmpabort(bang))
-		{
-			mode = MODE_QUIT;
-		}
-		else
-		{
-			msg("Use q! to abort changes, or wq to save changes");
-		}
-		*o_autowrite = oldflag;
-	}
-	else
-	{
-		/* else try to save this file */
-		oldflag = tstflag(file, MODIFIED);
-		if (cmd == CMD_WQUIT)
-			setflag(file, MODIFIED);
-		if (tmpend(bang))
-		{
-			mode = MODE_QUIT;
-		}
-		else
-		{
-			msg("Could not save file -- use quit! to abort changes, or w filename");
-		}
-		if (!oldflag)
-			clrflag(file, MODIFIED);
-	}
-}
-
-
-/*ARGSUSED*/
-void cmd_args(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	char	*scan;
-	int	col;
-	int	arg;
-	int	scrolled = FALSE;
-	int	width;
-
-	/* if no extra names given, or just current name, then report the args
-	 * we have now.
-	 */
-	if (!extra || !*extra)
-	{
-		/* empty args list? */
-		if (nargs == 1 && !*args)
-		{
-			return;
-		}
-
-		/* list the arguments */
-		for (scan = args, col = arg = 0;
-		     arg < nargs;
-		     scan += width + 1, col += width, arg++)
-		{
-			width = strlen(scan);
-			if (col + width >= COLS - 4)
-			{
-				addch('\n');
-				col = 0;
-				scrolled = TRUE;
-			}
-			else if (col > 0)
-			{
-				addch(' ');
-				col++;
-			}
-			if (arg == argno)
-			{
-				addch('[');
-				addstr(scan);
-				addch(']');
-				col += 2;
-			}
-			else
-			{
-				addstr(scan);
-			}
-		}
-
-		/* write a trailing newline */
-		if ((mode == MODE_EX || mode == MODE_COLON || scrolled) && col)
-		{
-			addch('\n');
-		}
-		exrefresh();	
-	}
-	else /* new args list given */
-	{
-		for (scan = args, nargs = 1; *extra; )
-		{
-			if (isspace(*extra))
-			{
-				*scan++ = '\0';
-				while (isspace(*extra))
-				{
-					extra++;
-				}
-				if (*extra)
-				{
-					nargs++;
-				}
-			}
-			else
-			{
-				*scan++ = *extra++;
-			}
-		}
-		*scan = '\0';
-
-		/* reset argno to before the first, so :next will go to first */
-		argno = -1;
-
-		if (nargs != 1)
-		{
-                        msg("%d files to edit", nargs);
-		}
-	}
-}
-
-
-/*ARGSUSED*/
-void cmd_cd(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	char	*getenv();
-
-#ifndef CRUNCH
-	/* if current file is modified, and no '!' was given, then error */
-	if (tstflag(file, MODIFIED) && !bang)
-	{
-		msg("File modified; use \"cd! %s\" to switch anyway", extra);
-	}
-#endif
-
-	/* default directory name is $HOME */
-	if (!*extra)
-	{
-		extra = getenv("HOME");
-		if (!extra)
-		{
-			msg("environment variable $HOME not set");
-			return;
-		}
-	}
-
-	/* go to the directory */
-	if (chdir(extra) < 0)
-	{
-		perror(extra);
-	}
-}
-
-
-/*ARGSUSED*/
-void cmd_map(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	char	*mapto;
-	char	*build, *scan;
-#ifndef NO_FKEY
-	static char *fnames[NFKEYS] =
-	{
-		"#10", "#1", "#2", "#3", "#4",
-		"#5", "#6", "#7", "#8", "#9",
-# ifndef NO_SHIFT_FKEY
-		"#10s", "#1s", "#2s", "#3s", "#4s",
-		"#5s", "#6s", "#7s", "#8s", "#9s",
-#  ifndef NO_CTRL_FKEY
-		"#10c", "#1c", "#2c", "#3c", "#4c",
-		"#5c", "#6c", "#7c", "#8c", "#9c",
-#   ifndef NO_ALT_FKEY
-		"#10a", "#1a", "#2a", "#3a", "#4a",
-		"#5a", "#6a", "#7a", "#8a", "#9a",
-#   endif
-#  endif
-# endif
-	};
-	int	key;
-#endif
-
-	/* "map" with no extra will dump the map table contents */
-	if (!*extra)
-	{
-#ifndef NO_ABBR
-		if (cmd == CMD_ABBR)
-		{
-			dumpkey(bang ? WHEN_EX|WHEN_VIINP|WHEN_VIREP : WHEN_VIINP|WHEN_VIREP, TRUE);
-		}
-		else
-#endif
-		{
-			dumpkey(bang ? WHEN_VIINP|WHEN_VIREP : WHEN_VICMD, FALSE);
-		}
-	}
-	else
-	{
-		/* "extra" is key to map, followed by what it maps to */
-
-		/* handle quoting inside the "raw" string */
-		for (build = mapto = extra;
-		     *mapto && (*mapto != ' ' && *mapto != '\t');
-		     *build++ = *mapto++)
-		{
-			if (*mapto == ctrl('V') && mapto[1])
-			{
-				mapto++;
-			}
-		}
-
-		/* skip whitespace, and mark the end of the "raw" string */
-		while ((*mapto == ' ' || *mapto == '\t'))
-		{
-			*mapto++ = '\0';
-		}
-		*build = '\0';
-
-		/* strip ^Vs from the "cooked" string */
-		for (scan = build = mapto; *scan; *build++ = *scan++)
-		{
-			if (*scan == ctrl('V') && scan[1])
-			{
-				scan++;
-			}
-		}
-		*build = '\0';
-
-#ifndef NO_FKEY
-		/* if the mapped string is '#' and a number, then assume
-		 * the user wanted that function key
-		 */
-		if (extra[0] == '#' && isdigit(extra[1]))
-		{
-			key = atoi(extra + 1) % 10;
-# ifndef NO_SHIFT_FKEY
-			build = extra + strlen(extra) - 1;
-			if (*build == 's')
-				key += 10;
-#  ifndef NO_CTRL_FKEY
-			else if (*build == 'c')
-				key += 20;
-#   ifndef NO_ALT_FKEY
-			else if (*build == 'a')
-				key += 30;
-#   endif
-#  endif
-# endif
-			if (FKEY[key])
-				mapkey(FKEY[key], mapto, bang ? WHEN_VIINP|WHEN_VIREP : WHEN_VICMD, fnames[key]);
-			else
-				msg("This terminal has no %s key", fnames[key]);
-		}
-		else
-#endif
-#ifndef NO_ABBR
-		if (cmd == CMD_ABBR || cmd == CMD_UNABBR)
-		{
-			mapkey(extra, mapto, bang ? WHEN_EX|WHEN_VIINP|WHEN_VIREP : WHEN_VIINP|WHEN_VIREP, "abbr");
-		}
-		else
-#endif
-		{
-			mapkey(extra, mapto, bang ? WHEN_VIINP|WHEN_VIREP : WHEN_VICMD, (char *)0);
-		}
-	}
-}
-
-
-/*ARGSUSED*/
-void cmd_set(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	if (!*extra)
-	{
-		dumpopts(FALSE);/* "FALSE" means "don't dump all" - only set */
-	}
-	else if (!strcmp(extra, "all"))
-	{
-		dumpopts(TRUE);	/* "TRUE" means "dump all" - even unset vars */
-	}
-	else
-	{
-		setopts(extra);
-
-		/* That option may have affected the appearence of text */
-		changes++;
-	}
-}
-
-/*ARGSUSED*/
-void cmd_tag(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	int	fd;	/* file descriptor used to read the file */
-	char	*scan;	/* used to scan through the tmpblk.c */
-#ifdef INTERNAL_TAGS
-	char	*cmp;	/* char of tag name we're comparing, or NULL */
-	char	*end;	/* marks the end of chars in tmpblk.c */
-#else
-	int	i;
-#endif
-#ifndef NO_MAGIC
-	char	wasmagic; /* preserves the original state of o_magic */
-#endif
-	static char prevtag[30];
-
-	/* if no tag is given, use the previous tag */
-	if (!extra || !*extra)
-	{
-		if (!*prevtag)
-		{
-			msg("No previous tag");
-			return;
-		}
-		extra = prevtag;
-	}
-	else
-	{
-		strncpy(prevtag, extra, sizeof prevtag);
-		prevtag[sizeof prevtag - 1] = '\0';
-	}
-
-#ifndef INTERNAL_TAGS
-	/* use "ref" to look up the tag info for this tag */
-	sprintf(tmpblk.c, "ref -t %s%s %s", (*origname ? "-f" : ""),origname, prevtag);
-	fd = rpipe(tmpblk.c, 0);
-	if (fd < 0)
-	{
-		msg("Can't run \"%s\"", tmpblk.c);
-		return;
-	}
-
-	/* try to read the tag info */
-	for (scan = tmpblk.c;
-	     (i = tread(fd, scan, scan - tmpblk.c + BLKSIZE)) > 0;
-	     scan += i)
-	{
-	}
-	*scan = '\0';
-
-	/* close the pipe.  abort if error */
-	if (rpclose(fd) != 0 || scan < tmpblk.c + 3)
-	{
-		msg("tag \"%s\" not found", extra);
-		return;
-	}
-
-#else /* use internal code to look up the tag */
-	/* open the tags file */
-	fd = open(TAGS, O_RDONLY);
-	if (fd < 0)
-	{
-		msg("No tags file");
-		return;
-	}
-
-	/* Hmmm... this would have been a lot easier with <stdio.h> */
-
-	/* find the line with our tag in it */
-	for(scan = end = tmpblk.c, cmp = extra; ; scan++)
-	{
-		/* read a block, if necessary */
-		if (scan >= end)
-		{
-			end = tmpblk.c + tread(fd, tmpblk.c, BLKSIZE);
-			scan = tmpblk.c;
-			if (scan >= end)
-			{
-				msg("tag \"%s\" not found", extra);
-				close(fd);
-				return;
-			}
-		}
-
-		/* if we're comparing, compare... */
-		if (cmp)
-		{
-			/* matched??? wow! */
-			if (!*cmp && *scan == '\t')
-			{
-				break;
-			}
-			if (*cmp++ != *scan)
-			{
-				/* failed! skip to newline */
-				cmp = (char *)0;
-			}
-		}
-
-		/* if we're skipping to newline, do it fast! */
-		if (!cmp)
-		{
-			while (scan < end && *scan != '\n')
-			{
-				scan++;
-			}
-			if (scan < end)
-			{
-				cmp = extra;
-			}
-		}
-	}
-
-	/* found it! get the rest of the line into memory */
-	for (cmp = tmpblk.c, scan++; scan < end && *scan != '\n'; )
-	{
-		*cmp++ = *scan++;
-	}
-	if (scan == end)
-	{
-		tread(fd, cmp, BLKSIZE - (int)(cmp - tmpblk.c));
-	}
-	else
-		*cmp = *scan;
-
-	/* we can close the tags file now */
-	close(fd);
-#endif /* INTERNAL_TAGS */
-
-	/* extract the filename from the line, and edit the file */
-	for (scan = tmpblk.c; *scan != '\t'; scan++)
-	{
-	}
-	*scan++ = '\0';
-	if (strcmp(origname, tmpblk.c) != 0)
-	{
-		if (!tmpabort(bang))
-		{
-			msg("Use :tag! to abort changes, or :w to save changes");
-			return;
-		}
-		tmpstart(tmpblk.c);
-	}
-
-	/* move to the desired line (or to line 1 if that fails) */
-#ifndef NO_MAGIC
-	wasmagic = *o_magic;
-	*o_magic = FALSE;
-#endif
-	cursor = MARK_FIRST;
-	linespec(scan, &cursor);
-	if (cursor == MARK_UNSET)
-	{
-		cursor = MARK_FIRST;
-		msg("Tag's address is out of date");
-	}
-#ifndef NO_MAGIC
-	*o_magic = wasmagic;
-#endif
-}
-
-
-
-
-
-/* describe this version of the program */
-/*ARGSUSED*/
-void cmd_version(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	msg("%s", VERSION);
-#ifdef CREDIT
-	msg("%s", CREDIT);
-#endif
-#ifdef CREDIT2
-	msg("%s", CREDIT2);
-#endif
-#ifdef COMPILED_BY
-	msg("Compiled by %s", COMPILED_BY);
-#endif
-#ifdef COPYING
-	msg("%s", COPYING);
-#endif
-}
-
-
-#ifndef NO_MKEXRC
-/* make a .exrc file which describes the current configuration */
-/*ARGSUSED*/
-void cmd_mkexrc(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	int	fd;
-
-	/* the default name for the .exrc file EXRC */
-	if (!*extra)
-	{
-		extra = EXRC;
-	}
-
-	/* create the .exrc file */
-	fd = creat(extra, FILEPERMS);
-	if (fd < 0)
-	{
-		msg("Couldn't create a new \"%s\" file", extra);
-		return;
-	}
-
-	/* save stuff */
-	saveopts(fd);
-	savemaps(fd, FALSE);
-#ifndef NO_ABBR
-	savemaps(fd, TRUE);
-#endif
-#ifndef NO_DIGRAPH
-	savedigs(fd);
-#endif
-#ifndef NO_COLOR
-	savecolor(fd);
-#endif
-
-	/* close the file */
-	close(fd);
-	msg("Configuration saved");
-}
-#endif
-
-#ifndef NO_DIGRAPH
-/*ARGSUSED*/
-void cmd_digraph(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	do_digraph(bang, extra);
-}
-#endif
-
-
-#ifndef NO_ERRLIST 
-static char	errfile[256];	/* the name of a file containing an error */
-static long	errline;	/* the line number for an error */
-static int	errfd = -2;	/* fd of the errlist file */
-
-/* This static function tries to parse an error message.
- *
- * For most compilers, the first word is taken to be the name of the erroneous
- * file, and the first number after that is taken to be the line number where
- * the error was detected.  The description of the error follows, possibly
- * preceded by an "error ... :" or "warning ... :" label which is skipped.
- *
- * For Coherent, error messages look like "line#: filename: message".
- *
- * For non-error lines, or unparsable error lines, this function returns NULL.
- * Normally, though, it alters errfile and errline, and returns a pointer to
- * the description.
- */
-static char *parse_errmsg(text)
-	REG char	*text;
-{
-	REG char	*cpy;
-	long		atol();
-# if COHERENT || TOS /* any Mark Williams compiler */
-	/* Get the line number.  If no line number, then ignore this line. */
-	errline = atol(text);
-	if (errline == 0L)
-		return (char *)0;
-
-	/* Skip to the start of the filename */
-	while (*text && *text++ != ':')
-	{
-	}
-	if (!*text++)
-		return (char *)0;
-
-	/* copy the filename to errfile */
-	for (cpy = errfile; *text && (*cpy++ = *text++) != ':'; )
-	{
-	}
-	if (!*text++)
-		return (char *)0;
-	cpy[-1] = '\0';
-
-	return text;
-# else /* not a Mark Williams compiler */
-	char		*errmsg;
-
-	/* the error message is the whole line, by default */
-	errmsg = text;
-
-	/* skip leading garbage */
-	while (*text && !isalnum(*text))
-	{
-		text++;
-	}
-
-	/* copy over the filename */
-	cpy = errfile;
-	while(isalnum(*text) || *text == '.')
-	{
-		*cpy++ = *text++;
-	}
-	*cpy = '\0';
-
-	/* ignore the name "Error" and filenames that contain a '/' */
-	if (*text == '/' || !*errfile || !strcmp(errfile + 1, "rror") || access(errfile, 0) < 0)
-	{
-		return (char *)0;
-	}
-
-	/* skip garbage between filename and line number */
-	while (*text && !isdigit(*text))
-	{
-		text++;
-	}
-
-	/* if the number is part of a larger word, then ignore this line */
-	if (*text && isalpha(text[-1]))
-	{
-		return (char *)0;
-	}
-
-	/* get the error line */
-	errline = 0L;
-	while (isdigit(*text))
-	{
-		errline *= 10;
-		errline += (*text - '0');
-		text++;
-	}
-
-	/* any line which lacks a filename or line number should be ignored */
-	if (!errfile[0] || !errline)
-	{
-		return (char *)0;
-	}
-
-	/* locate the beginning of the error description */
-	while (*text && !isspace(*text))
-	{
-		text++;
-	}
-	while (*text)
-	{
-#  ifndef CRUNCH
-		/* skip "error #:" and "warning #:" clauses */
-		if (!strncmp(text + 1, "rror ", 5)
-		 || !strncmp(text + 1, "arning ", 7)
-		 || !strncmp(text + 1, "atal error", 10))
-		{
-			do
-			{
-				text++;
-			} while (*text && *text != ':');
-			continue;
-		}
-#  endif
-
-		/* anything other than whitespace or a colon is important */
-		if (!isspace(*text) && *text != ':')
-		{
-			errmsg = text;
-			break;
-		}
-
-		/* else keep looking... */
-		text++;
-	}
-
-	return errmsg;
-# endif /* not COHERENT */
-}
-
-/*ARGSUSED*/
-void cmd_errlist(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	static long	endline;/* original number of lines in this file */
-	static long	offset;	/* offset of the next line in the errlist file */
-	int		i;
-	char		*errmsg;
-
-	/* if a new errlist file is named, open it */
-	if (extra && extra[0])
-	{
-		/* close the old one */
-		if (errfd >= 0)
-		{
-			close(errfd);
-		}
-
-		/* open the new one */
-		errfd = open(extra, O_RDONLY);
-		offset = 0L;
-		endline = nlines;
-	}
-	else if (errfd < 0)
-	{
-		/* open the default file */
-		errfd = open(ERRLIST, O_RDONLY);
-		offset = 0L;
-		endline = nlines;
-	}
-
-	/* do we have an errlist file now? */
-	if (errfd < 0)
-	{
-		msg("There is no errlist file");
-		beep();
-		return;
-	}
-
-	/* find the next error message in the file */
-	do
-	{
-		/* read the next line from the errlist */
-		lseek(errfd, offset, 0);
-		if (tread(errfd, tmpblk.c, (unsigned)BLKSIZE) <= 0)
-		{
-			msg("No more errors");
-			beep();
-			close(errfd);
-			errfd = -2;
-			return;
-		}
-		for (i = 0; tmpblk.c[i] != '\n'; i++)
-		{
-		}
-		tmpblk.c[i++] = 0;
-
-		/* look for an error message in the line */
-		errmsg = parse_errmsg(tmpblk.c);
-		if (!errmsg)
-		{
-			offset += i;
-		}
-
-	} while (!errmsg);
-
-	/* switch to the file containing the error, if this isn't it */
-	if (strcmp(origname, errfile))
-	{
-		if (!tmpabort(bang))
-		{
-			msg("Use :er! to abort changes, or :w to save changes");
-			beep();
-			return;
-		}
-		tmpstart(errfile);
-		endline = nlines;
-	}
-	else if (endline == 0L)
-	{
-		endline = nlines;
-	}
-
-	/* go to the line where the error was detected */
-	cursor = MARK_AT_LINE(errline + (nlines - endline));
-	if (cursor > MARK_LAST)
-	{
-		cursor = MARK_LAST;
-	}
-	if (mode == MODE_VI)
-	{
-		redraw(cursor, FALSE);
-	}
-
-	/* display the error message */
-#ifdef CRUNCH
-	msg("%.70s", errmsg);
-#else
-	if (nlines > endline)
-	{
-		msg("line %ld(+%ld): %.60s", errline, nlines - endline, errmsg);
-	}
-	else if (nlines < endline)
-	{
-		msg("line %ld(-%ld): %.60s", errline, endline - nlines, errmsg);
-	}
-	else
-	{
-		msg("line %ld: %.65s", errline, errmsg);
-	}
-#endif
-
-	/* remember where the NEXT error line will start */
-	offset += i;
-}
-
-
-/*ARGSUSED*/
-void cmd_make(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	BLK	buf;
-
-	/* if the file hasn't been saved, then complain unless ! */
-	if (tstflag(file, MODIFIED) && !bang)
-	{
-		msg("\"%s\" not saved yet", origname);
-		return;
-	}
-
-	/* build the command */
-	sprintf(buf.c, "%s %s %s%s", (cmd == CMD_CC ? o_cc : o_make), extra, REDIRECT, ERRLIST);
-	qaddstr(buf.c);
-	addch('\n');
-
-	/* close the old errlist file, if any */
-	if (errfd >= 0)
-	{
-		close(errfd);
-		errfd = -3;
-	}
-
-	/* run the command, with curses temporarily disabled */
-	suspend_curses();
-	system(buf.c);
-	resume_curses(mode == MODE_EX);
-	if (mode == MODE_COLON)
-		mode = MODE_VI;
-
-	/* run the "errlist" command */
-	cmd_errlist(MARK_UNSET, MARK_UNSET, cmd, bang, ERRLIST);
-}
-#endif
-
-
-
-#ifndef NO_COLOR
-
-/* figure out the number of text colors we use with this configuration */
-# ifndef NO_POPUP
-#  ifndef NO_VISIBLE
-#   define NCOLORS 7
-#  else
-#   define NCOLORS 6
-#  endif
-# else
-#  ifndef NO_VISIBLE
-#   define NCOLORS 6
-#  else
-#   define NCOLORS 5
-#  endif
-# endif
-
-/* the attribute bytes used in each of "when"s */
-static char bytes[NCOLORS];
-
-static struct
-{
-	char	*word;	/* a legal word */
-	int	type;	/* what type of word this is */
-	int	val;	/* some other value */
-}
-	words[] =
-{
-	{"normal",	1,	A_NORMAL},	/* all "when" names must come */
-	{"standout",	1,	A_STANDOUT},	/* at the top of the list.    */
-	{"bold",	1,	A_BOLD},	/* The first 3 must be normal,*/
-	{"underlined",	1,	A_UNDERLINE},	/* standout, and bold; the    */
-	{"italics",	1,	A_ALTCHARSET},	/* remaining names follow.    */
-#ifndef NO_POPUP
-	{"popup",	1,	A_POPUP},
-#endif
-#ifndef NO_VISIBLE
-	{"visible",	1,	A_VISIBLE},
-#endif
-
-	{"black",	3,	0x00},		/* The color names start right*/
-	{"blue",	3,	0x01},		/* after the "when" names.    */
-	{"green",	3,	0x02},
-	{"cyan",	3,	0x03},
-	{"red",		3,	0x04},
-	{"magenta",	3,	0x05},
-	{"brown",	3,	0x06},
-	{"white",	3,	0x07},
-	{"yellow",	3,	0x0E}, /* bright brown */
-	{"gray",	3,	0x08}, /* bright black?  of course! */
-	{"grey",	3,	0x08},
-
-	{"bright",	2,	0x08},
-	{"light",	2,	0x08},
-	{"blinking",	2,	0x80},
-	{"on",		0,	0},
-	{"n",		1,	A_NORMAL},
-	{"s",		1,	A_STANDOUT},
-	{"b",		1,	A_BOLD},
-	{"u",		1,	A_UNDERLINE},
-	{"i",		1,	A_ALTCHARSET},
-#ifndef NO_POPUP
-	{"p",		1,	A_POPUP},
-	{"menu",	1,	A_POPUP},
-#endif
-#ifndef NO_VISIBLE
-	{"v",		1,	A_VISIBLE},
-#endif
-	{(char *)0,	0,	0}
-};
-
-/*ARGSUSED*/
-void cmd_color(frommark, tomark, cmd, bang, extra)
-	MARK	frommark, tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	int	attrbyte;
-	int	cmode;
-	int	nowbg;	/* BOOLEAN: is the next color background? */
-
-	REG char *scan;
-	REG	i;
-
-
-#ifndef CRUNCH
-	/* if no args are given, then report the current colors */
-	if (!*extra)
-	{
-		/* if no colors are set, then say so */
-		if (!bytes[0])
-		{
-			msg("no colors have been set");
-			return;
-		}
-
-		/* report all five color combinations */
-		for (i = 0; i < NCOLORS; i++)
-		{
-			qaddstr("color ");
-			qaddstr(words[i].word);
-			qaddch(' ');
-			if (bytes[i] & 0x80)
-				qaddstr("blinking ");
-			switch (bytes[i] & 0xf)
-			{
-			  case 0x08:	qaddstr("gray");	break;
-			  case 0x0e:	qaddstr("yellow");	break;
-			  case 0x0f:	qaddstr("bright white");break;
-			  default:
-				if (bytes[i] & 0x08)
-					qaddstr("light ");
-				qaddstr(words[(bytes[i] & 0x07) + NCOLORS].word);
-			}
-			qaddstr(" on ");
-			qaddstr(words[((bytes[i] >> 4) & 0x07) + NCOLORS].word);
-			addch('\n');
-			exrefresh();
-		}
-		return;
-	}
-#endif
-
-	/* The default background color is the same as "normal" chars.
-	 * There is no default foreground color.
-	 */
-	cmode = A_NORMAL;
-	attrbyte = bytes[0] & 0x70;
-	nowbg = FALSE;
-
-	/* parse each word in the "extra" text */
-	for (scan = extra; *extra; extra = scan)
-	{
-		/* locate the end of the word */
-		while (*scan && *scan != ' ')
-		{
-			scan++;
-		}
-
-		/* skip whitespace at the end of the word */
-		while(*scan == ' ')
-		{
-			*scan++ = '\0';
-		}
-
-		/* lookup the word */
-		for (i = 0; words[i].word && strcmp(words[i].word, extra); i++)
-		{
-		}
-
-		/* if not a word, then complain */
-		if (!words[i].word)
-		{
-			msg("Invalid color name: %s", extra);
-			return;
-		}
-
-		/* process the word */
-		switch (words[i].type)
-		{
-		  case 1:
-			cmode = words[i].val;
-			break;
-
-		  case 2:
-			attrbyte |= words[i].val;
-			break;
-
-		  case 3:
-			if (nowbg)
-				attrbyte = ((attrbyte & ~0x70) | ((words[i].val & 0x07) << 4));
-			else
-				attrbyte |= words[i].val;
-			nowbg = TRUE;
-			break;
-		}
-	}
-
-	/* if nowbg isn't set now, then we were never given a foreground color */
-	if (!nowbg)
-	{
-		msg("usage: color [when] [\"bright\"] [\"blinking\"] foreground [background]");
-		return;
-	}
-
-	/* the first ":color" command MUST define the "normal" colors */
-	if (!bytes[0])
-		cmode = A_NORMAL;
-
-	/* we should now have a cmode and an attribute byte... */
-
-	/* set the color */
-	setcolor(cmode, attrbyte);
-
-	/* remember what we just did */
-	bytes[cmode] = attrbyte;
-
-	/* if the other colors haven't been set yet, then set them to defaults */
-	if (!bytes[1])
-	{
-		/* standout is the opposite of normal */
-		bytes[1] = ((attrbyte << 4) & 0x70 | (attrbyte >> 4) & 0x07);
-		setcolor(A_STANDOUT, bytes[1]);
-
-		/* if "normal" isn't bright, then bold defaults to normal+bright
-		 * else bold defaults to bright white.
-		 */
-		bytes[2] = attrbyte | ((attrbyte & 0x08) ? 0x0f : 0x08);
-		setcolor(A_BOLD, bytes[2]);
-
-		/* all others default to the "standout" colors, without blinking */
-		for (i = 3; i < NCOLORS; i++)
-		{
-			bytes[i] = (bytes[1] & 0x7f);
-			setcolor(words[i].val, bytes[i]);
-		}
-	}
-
-	/* force a redraw, so we see the new colors */
-	redraw(MARK_UNSET, FALSE);
-}
-
-
-
-void savecolor(fd)
-	int	fd;	/* file descriptor to write colors to */
-{
-	int	i;
-	char	buf[80];
-
-	/* if no colors are set, then return */
-	if (!bytes[0])
-	{
-		return;
-	}
-
-	/* save all five color combinations */
-	for (i = 0; i < NCOLORS; i++)
-	{
-		strcpy(buf, "color ");
-		strcat(buf, words[i].word);
-		strcat(buf, " ");
-		if (bytes[i] & 0x80)
-			strcat(buf, "blinking ");
-		switch (bytes[i] & 0xf)
-		{
-		  case 0x08:	strcat(buf, "gray");	break;
-		  case 0x0e:	strcat(buf, "yellow");	break;
-		  case 0x0f:	strcat(buf, "bright white");break;
-		  default:
-			if (bytes[i] & 0x08)
-				strcat(buf, "light ");
-			strcat(buf, words[(bytes[i] & 0x07) + NCOLORS].word);
-		}
-		strcat(buf, " on ");
-		strcat(buf, words[((bytes[i] >> 4) & 0x07) + NCOLORS].word);
-		strcat(buf, "\n");
-		twrite(fd, buf, (unsigned)strlen(buf));
-	}
-}
-#endif
-
-#ifdef SIGTSTP
-/* temporarily suspend elvis */
-/*ARGSUSED*/
-void cmd_suspend(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	void	(*func)();	/* stores the previous setting of SIGTSTP */
-
-#if ANY_UNIX
-	/* the Bourne shell can't handle ^Z */
-	if (!strcmp(o_shell, "/bin/sh"))
-	{
-		msg("The /bin/sh shell doesn't support ^Z");
-		return;
-	}
-#endif
-
-	move(LINES - 1, 0);
-	if (tstflag(file, MODIFIED))
-	{
-		addstr("Warning: \"");
-		addstr(origname);
-		addstr("\" modified but not yet saved");
-		clrtoeol();
-	}
-	refresh();
-	suspend_curses();
-	func = signal(SIGTSTP, SIG_DFL);
-	kill (0, SIGTSTP);
-
-	/* the process stops and resumes here */
-
-	signal(SIGTSTP, func);
-	resume_curses(TRUE);
-	if (mode == MODE_VI || mode == MODE_COLON)
-		redraw(MARK_UNSET, FALSE);
-	else
-		refresh ();
-}
-#endif
Index: trunk/minix/commands/elvis/cmd2.c
===================================================================
--- trunk/minix/commands/elvis/cmd2.c	(revision 9)
+++ 	(revision )
@@ -1,942 +1,0 @@
-/* cmd2.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains some of the commands - mostly ones that change text */
-
-#include "config.h"
-#include "ctype.h"
-#include "vi.h"
-#include "regexp.h"
-#if TOS
-# include <stat.h>
-#else
-# if OSK
-#  include "osk.h"
-# else
-#  if AMIGA
-#   include "amistat.h"
-#  else
-#   include <sys/stat.h>
-#  endif
-# endif
-#endif
-
-
-/*ARGSUSED*/
-void cmd_substitute(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;	/* rest of the command line */
-{
-	char	*line;	/* a line from the file */
-	regexp	*re;	/* the compiled search expression */
-	char	*subst;	/* the substitution string */
-	char	*opt;	/* substitution options */
-	long	l;	/* a line number */
-	char	*s, *d;	/* used during subtitutions */
-	char	*conf;	/* used during confirmation */
-	long	chline;	/* # of lines changed */
-	long	chsub;	/* # of substitutions made */
-	static	optp;	/* boolean option: print when done? */
-	static	optg;	/* boolean option: substitute globally in line? */
-	static	optc;	/* boolean option: confirm before subst? */
-#ifndef CRUNCH
-	long	oldnlines;
-#endif
-
-
-	/* for now, assume this will fail */
-	rptlines = -1L;
-
-	if (cmd == CMD_SUBAGAIN)
-	{
-#ifndef NO_MAGIC
-		if (*o_magic)
-			subst = "~";
-		else
-#endif
-		subst = "\\~";
-		re = regcomp("");
-
-		/* if visual "&", then turn off the "p" and "c" options */
-		if (bang)
-		{
-			optp = optc = FALSE;
-		}
-	}
-	else /* CMD_SUBSTITUTE */
-	{
-		/* make sure we got a search pattern */
-		if (*extra != '/' && *extra != '?')
-		{
-			msg("Usage: s/regular expression/new text/");
-			return;
-		}
-
-		/* parse & compile the search pattern */
-		subst = parseptrn(extra);
-		re = regcomp(extra + 1);
-	}
-
-	/* abort if RE error -- error message already given by regcomp() */
-	if (!re)
-	{
-		return;
-	}
-
-	if (cmd == CMD_SUBSTITUTE)
-	{
-		/* parse the substitution string & find the option string */
-		for (opt = subst; *opt && *opt != *extra; opt++)
-		{
-			if (*opt == '\\' && opt[1])
-			{
-				opt++;
-			}
-		}
-		if (*opt)
-		{
-			*opt++ = '\0';
-		}
-
-		/* analyse the option string */
-		if (!*o_edcompatible)
-		{
-			optp = optg = optc = FALSE;
-		}
-		while (*opt)
-		{
-			switch (*opt++)
-			{
-			  case 'p':	optp = !optp;	break;
-			  case 'g':	optg = !optg;	break;
-			  case 'c':	optc = !optc;	break;
-			  case ' ':
-			  case '\t':			break;
-			  default:
-				msg("Subst options are p, c, and g -- not %c", opt[-1]);
-				return;
-			}
-		}
-	}
-
-	/* if "c" or "p" flag was given, and we're in visual mode, then NEWLINE */
-	if ((optc || optp) && mode == MODE_VI)
-	{
-		addch('\n');
-		exrefresh();
-	}
-
-	ChangeText
-	{
-		/* reset the change counters */
-		chline = chsub = 0L;
-
-		/* for each selected line */
-		for (l = markline(frommark); l <= markline(tomark); l++)
-		{
-			/* fetch the line */
-			line = fetchline(l);
-
-			/* if it contains the search pattern... */
-			if (regexec(re, line, TRUE))
-			{
-				/* increment the line change counter */
-				chline++;
-
-				/* initialize the pointers */
-				s = line;
-				d = tmpblk.c;
-
-				/* do once or globally ... */
-				do
-				{
-#ifndef CRUNCH
-					/* confirm, if necessary */
-					if (optc)
-					{
-						for (conf = line; conf < re->startp[0]; conf++)
-							addch(*conf);
-						standout();
-						for ( ; conf < re->endp[0]; conf++)
-							addch(*conf);
-						standend();
-						for (; *conf; conf++)
-							addch(*conf);
-						addch('\n');
-						exrefresh();
-						if (getkey(0) != 'y')
-						{
-							/* copy accross the original chars */
-							while (s < re->endp[0])
-								*d++ = *s++;
-
-							/* skip to next match on this line, if any */
-							goto Continue;
-						}
-					}
-#endif /* not CRUNCH */
-
-					/* increment the substitution change counter */
-					chsub++;
-
-					/* copy stuff from before the match */
-					while (s < re->startp[0])
-					{
-						*d++ = *s++;
-					}
-
-					/* substitute for the matched part */
-					regsub(re, subst, d);
-					s = re->endp[0];
-					d += strlen(d);
-
-Continue:
-					/* if this regexp could conceivably match
-					 * a zero-length string, then require at
-					 * least 1 unmatched character between
-					 * matches.
-					 */
-					if (re->minlen == 0)
-					{
-						if (!*s)
-							break;
-						*d++ = *s++;
-					}
-
-				} while (optg && regexec(re, s, FALSE));
-
-				/* copy stuff from after the match */
-				while (*d++ = *s++)	/* yes, ASSIGNMENT! */
-				{
-				}
-
-#ifndef CRUNCH
-				/* NOTE: since the substitution text is allowed to have ^Ms which are
-				 * translated into newlines, it is possible that the number of lines
-				 * in the file will increase after each line has been substituted.
-				 * we need to adjust for this.
-				 */
-				oldnlines = nlines;
-#endif
-
-				/* replace the old version of the line with the new */
-				d[-1] = '\n';
-				d[0] = '\0';
-				change(MARK_AT_LINE(l), MARK_AT_LINE(l + 1), tmpblk.c);
-
-#ifndef CRUNCH
-				l += nlines - oldnlines;
-				tomark += MARK_AT_LINE(nlines - oldnlines);
-#endif
-
-				/* if supposed to print it, do so */
-				if (optp)
-				{
-					addstr(tmpblk.c);
-					exrefresh();
-				}
-
-				/* move the cursor to that line */
-				cursor = MARK_AT_LINE(l);
-			}
-		}
-	}
-
-	/* free the regexp */
-	free(re);
-
-	/* if done from within a ":g" command, then finish silently */
-	if (doingglobal)
-	{
-		rptlines = chline;
-		rptlabel = "changed";
-		return;
-	}
-
-	/* Reporting */
-	if (chsub == 0)
-	{
-		msg("Substitution failed");
-	}
-	else if (chline >= *o_report)
-	{
-		msg("%ld substitutions on %ld lines", chsub, chline);
-	}
-	rptlines = 0L;
-}
-
-
-
-
-/*ARGSUSED*/
-void cmd_delete(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	MARK	curs2;	/* an altered form of the cursor */
-
-	/* choose your cut buffer */
-	if (*extra == '"')
-	{
-		extra++;
-	}
-	if (*extra)
-	{
-		cutname(*extra);
-	}
-
-	/* make sure we're talking about whole lines here */
-	frommark = frommark & ~(BLKSIZE - 1);
-	tomark = (tomark & ~(BLKSIZE - 1)) + BLKSIZE;
-
-	/* yank the lines */
-	cut(frommark, tomark);
-
-	/* if CMD_DELETE then delete the lines */
-	if (cmd != CMD_YANK)
-	{
-		curs2 = cursor;
-		ChangeText
-		{
-			/* delete the lines */
-			delete(frommark, tomark);
-		}
-		if (curs2 > tomark)
-		{
-			cursor = curs2 - tomark + frommark;
-		}
-		else if (curs2 > frommark)
-		{
-			cursor = frommark;
-		}
-	}
-}
-
-
-/*ARGSUSED*/
-void cmd_append(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	long	l;	/* line counter */
-
-#ifndef CRUNCH
-	/* if '!' then toggle auto-indent */
-	if (bang)
-	{
-		*o_autoindent = !*o_autoindent;
-	}
-#endif
-
-	ChangeText
-	{
-		/* if we're doing a change, delete the old version */
-		if (cmd == CMD_CHANGE)
-		{
-			/* delete 'em */
-			cmd_delete(frommark, tomark, cmd, bang, extra);
-		}
-
-		/* new lines start at the frommark line, or after it */
-		l = markline(frommark);
-		if (cmd == CMD_APPEND)
-		{
- 			l++;
-		}
-
-		/* get lines until no more lines, or "." line, and insert them */
-		while (vgets('\0', tmpblk.c, BLKSIZE) >= 0)
-		{
-			addch('\n');
-			if (!strcmp(tmpblk.c, "."))
-			{
-				break;
-			}
-
-			strcat(tmpblk.c, "\n");
-			add(MARK_AT_LINE(l), tmpblk.c);
-			l++;
-		}
-	}
-
-	/* on the odd chance that we're calling this from vi mode ... */
-	redraw(MARK_UNSET, FALSE);
-}
-
-
-/*ARGSUSED*/
-void cmd_put(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	/* choose your cut buffer */
-	if (*extra == '"')
-	{
-		extra++;
-	}
-	if (*extra)
-	{
-		cutname(*extra);
-	}
-
-	/* paste it */
-	ChangeText
-	{
-		cursor = paste(frommark, TRUE, FALSE);
-	}
-}
-
-
-/*ARGSUSED*/
-void cmd_join(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	long	l;
-	char	*scan;
-	int	len;	/* length of the new line */
-
-	/* if only one line is specified, assume the following one joins too */
-	if (markline(frommark) == nlines)
-	{
-		msg("Nothing to join with this line");
-		return;
-	}
-	if (markline(frommark) == markline(tomark))
-	{
-		tomark += BLKSIZE;
-	}
-
-	/* get the first line */
-	l = markline(frommark);
-	strcpy(tmpblk.c, fetchline(l));
-	len = strlen(tmpblk.c);
-
-	/* build the longer line */
-	while (++l <= markline(tomark))
-	{
-		/* get the next line */
-		scan = fetchline(l);
-
-		/* remove any leading whitespace */
-		while (*scan == '\t' || *scan == ' ')
-		{
-			scan++;
-		}
-
-		/* see if the line will fit */
-		if (strlen(scan) + len + 3 > BLKSIZE)
-		{
-			msg("Can't join -- the resulting line would be too long");
-			return;
-		}
-
-		/* catenate it, with a space (or two) in between */
-		if (!bang)
-		{
-			if (len >= 1)
-			{
-				if (tmpblk.c[len - 1] == '.'
-				 || tmpblk.c[len - 1] == '?'
-				 || tmpblk.c[len - 1] == '!')
-				{
-					 tmpblk.c[len++] = ' ';
-				}
-				tmpblk.c[len++] = ' ';
-			}
-		}
-		strcpy(tmpblk.c + len, scan);
-		len += strlen(scan);
-	}
-	tmpblk.c[len++] = '\n';
-	tmpblk.c[len] = '\0';
-
-	/* make the change */
-	ChangeText
-	{
-		frommark &= ~(BLKSIZE - 1);
-		tomark &= ~(BLKSIZE - 1);
-		tomark += BLKSIZE;
-		change(frommark, tomark, tmpblk.c);
-	}
-
-	/* Reporting... */
-	rptlines = markline(tomark) - markline(frommark) - 1L;
-	rptlabel = "joined";
-}
-
-
-
-/*ARGSUSED*/
-void cmd_shift(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	long	l;	/* line number counter */
-	int	oldidx;	/* number of chars previously used for indent */
-	int	newidx;	/* number of chars in the new indent string */
-	int	oldcol;	/* previous indent amount */
-	int	newcol;	/* new indent amount */
-	char	*text;	/* pointer to the old line's text */
-
-	ChangeText
-	{
-		/* for each line to shift... */
-		for (l = markline(frommark); l <= markline(tomark); l++)
-		{
-			/* get the line - ignore empty lines unless ! mode */
-			text = fetchline(l);
-			if (!*text && !bang)
-				continue;
-
-			/* calc oldidx and oldcol */
-			for (oldidx = 0, oldcol = 0;
-			     text[oldidx] == ' ' || text[oldidx] == '\t';
-			     oldidx++)
-			{
-				if (text[oldidx] == ' ')
-				{
-					oldcol += 1;
-				}
-				else
-				{
-					oldcol += *o_tabstop - (oldcol % *o_tabstop);
-				}
-			}
-
-			/* calc newcol */
-			if (cmd == CMD_SHIFTR)
-			{
-				newcol = oldcol + (*o_shiftwidth & 0xff);
-			}
-			else
-			{
-				newcol = oldcol - (*o_shiftwidth & 0xff);
-				if (newcol < 0)
-					newcol = 0;
-			}
-
-			/* if no change, then skip to next line */
-			if (oldcol == newcol)
-				continue;
-
-			/* build a new indent string */
-			newidx = 0;
-			if (*o_autotab)
-			{
-				while (newcol >= *o_tabstop)
-				{
-					tmpblk.c[newidx++] = '\t';
-					newcol -= *o_tabstop;
-				}
-			}
-			while (newcol > 0)
-			{
-				tmpblk.c[newidx++] = ' ';
-				newcol--;
-			}
-			tmpblk.c[newidx] = '\0';
-
-			/* change the old indent string into the new */
-			change(MARK_AT_LINE(l), MARK_AT_LINE(l) + oldidx, tmpblk.c);
-		}
-	}
-
-	/* Reporting... */
-	rptlines = markline(tomark) - markline(frommark) + 1L;
-	if (cmd == CMD_SHIFTR)
-	{
-		rptlabel = ">ed";
-	}
-	else
-	{
-		rptlabel = "<ed";
-	}
-}
-
-
-/*ARGSUSED*/
-void cmd_read(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	int	fd, rc;	/* used while reading from the file */
-	char	*scan;	/* used for finding NUL characters */
-	int	hadnul;	/* boolean: any NULs found? */
-	int	addnl;	/* boolean: forced to add newlines? */
-	int	len;	/* number of chars in current line */
-	long	lines;	/* number of lines in current block */
-	struct stat statb;
-
-	/* special case: if ":r !cmd" then let the filter() function do it */
-	if (extra[0] == '!')
-	{
-		filter(frommark, MARK_UNSET, extra + 1, TRUE);
-		return;
-	}
-
-	/* open the file */
-	fd = open(extra, O_RDONLY);
-	if (fd < 0)
-	{
-		msg("Can't open \"%s\"", extra);
-		return;
-	}
-
-#ifndef CRUNCH
-	if (stat(extra, &statb) < 0)
-	{
-		msg("Can't stat \"%s\"", extra);
-	}
-# if TOS
-	if (statb.st_mode & S_IJDIR)
-# else
-#  if OSK
-	if (statb.st_mode & S_IFDIR)
-#  else
-	if ((statb.st_mode & S_IFMT) != S_IFREG)
-#  endif
-# endif
-	{
-		msg("\"%s\" is not a regular file", extra);
-		return;
-	}
-#endif /* not CRUNCH */
-
-	/* get blocks from the file, and add them */
-	ChangeText
-	{
-		/* insertion starts at the line following frommark */
-		tomark = frommark = (frommark | (BLKSIZE - 1L)) + 1L;
-		len = 0;
-		hadnul = addnl = FALSE;
-
-		/* add an extra newline, so partial lines at the end of
-		 * the file don't trip us up
-		 */
-		add(tomark, "\n");
-
-		/* for each chunk of text... */
-		while ((rc = tread(fd, tmpblk.c, BLKSIZE - 1)) > 0)
-		{
-			/* count newlines, convert NULs, etc. ... */
-			for (lines = 0, scan = tmpblk.c; rc > 0; rc--, scan++)
-			{
-				/* break up long lines */
-				if (*scan != '\n' && len + 2 > BLKSIZE)
-				{
-					*scan = '\n';
-					addnl = TRUE;
-				}
-
-				/* protect against NUL chars in file */
-				if (!*scan)
-				{
-					*scan = 0x80;
-					hadnul = TRUE;
-				}
-
-				/* starting a new line? */
-				if (*scan == '\n')
-				{
-					/* reset length at newline */
-					len = 0;
-					lines++;
-				}
-				else
-				{
-					len++;
-				}
-			}
-
-			/* add the text */
-			*scan = '\0';
-			add(tomark, tmpblk.c);
-			tomark += MARK_AT_LINE(lines) + len - markidx(tomark);
-		}
-
-		/* if partial last line, then retain that first newline */
-		if (len > 0)
-		{
-			msg("Last line had no newline");
-			tomark += BLKSIZE; /* <- for the rptlines calc */
-		}
-		else /* delete that first newline */
-		{
-			delete(tomark, (tomark | (BLKSIZE - 1L)) + 1L);
-		}
-	}
-
-	/* close the file */
-	close(fd);
-
-	/* Reporting... */
-	rptlines = markline(tomark) - markline(frommark);
-	rptlabel = "read";
-	if (mode == MODE_EX)
-	{
-		cursor = (tomark & ~BLKSIZE) - BLKSIZE;
-	}
-	else
-	{
-		cursor = frommark;
-	}
-
-	if (addnl)
-		msg("Newlines were added to break up long lines");
-	if (hadnul)
-		msg("NULs were converted to 0x80");
-}
-
-
-
-/*ARGSUSED*/
-void cmd_undo(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	undo();
-}
-
-
-/* print the selected lines */
-/*ARGSUSED*/
-void cmd_print(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	REG char	*scan;
-	REG long	l;
-	REG int		col;
-
-	for (l = markline(frommark); l <= markline(tomark); l++)
-	{
-		/* display a line number, if CMD_NUMBER */
-		if (cmd == CMD_NUMBER)
-		{
-			sprintf(tmpblk.c, "%6ld  ", l);
-			qaddstr(tmpblk.c);
-			col = 8;
-		}
-		else
-		{
-			col = 0;
-		}
-
-		/* get the next line & display it */
-		for (scan = fetchline(l); *scan; scan++)
-		{
-			/* expand tabs to the proper width */
-			if (*scan == '\t' && cmd != CMD_LIST)
-			{
-				do
-				{
-					qaddch(' ');
-					col++;
-				} while (col % *o_tabstop != 0);
-			}
-			else if (*scan > 0 && *scan < ' ' || *scan == '\177')
-			{
-				qaddch('^');
-				qaddch(*scan ^ 0x40);
-				col += 2;
-			}
-			else if ((*scan & 0x80) && cmd == CMD_LIST)
-			{
-				sprintf(tmpblk.c, "\\%03o", UCHAR(*scan));
-				qaddstr(tmpblk.c);
-				col += 4;
-			}
-			else
-			{
-				qaddch(*scan);
-				col++;
-			}
-
-			/* wrap at the edge of the screen */
-			if (!has_AM && col >= COLS)
-			{
-				addch('\n');
-				col -= COLS;
-			}
-		}
-		if (cmd == CMD_LIST)
-		{
-			qaddch('$');
-		}
-		addch('\n');
-		exrefresh();
-	}
-}
-
-
-/* move or copy selected lines */
-/*ARGSUSED*/
-void cmd_move(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	MARK	destmark;
-
-	/* parse the destination linespec.  No defaults.  Line 0 is okay */
-	destmark = cursor;
-	if (!strcmp(extra, "0"))
-	{
-		destmark = 0L;
-	}
-	else if (linespec(extra, &destmark) == extra || !destmark)
-	{
-		msg("invalid destination address");
-		return;
-	}
-
-	/* flesh the marks out to encompass whole lines */
-	frommark &= ~(BLKSIZE - 1);
-	tomark = (tomark & ~(BLKSIZE - 1)) + BLKSIZE;
-	destmark = (destmark & ~(BLKSIZE - 1)) + BLKSIZE;
-
-	/* make sure the destination is valid */
-	if (cmd == CMD_MOVE && destmark >= frommark && destmark < tomark)
-	{
-		msg("invalid destination address");
-	}
-
-	/* Do it */
-	ChangeText
-	{
-		/* save the text to a cut buffer */
-		cutname('\0');
-		cut(frommark, tomark);
-
-		/* if we're not copying, delete the old text & adjust destmark */
-		if (cmd != CMD_COPY)
-		{
-			delete(frommark, tomark);
-			if (destmark >= frommark)
-			{
-				destmark -= (tomark - frommark);
-			}
-		}
-
-		/* add the new text */
-		paste(destmark, FALSE, FALSE);
-	}
-
-	/* move the cursor to the last line of the moved text */
-	cursor = destmark + (tomark - frommark) - BLKSIZE;
-	if (cursor < MARK_FIRST || cursor >= MARK_LAST + BLKSIZE)
-	{
-		cursor = MARK_LAST;
-	}
-
-	/* Reporting... */
-	rptlabel = ( (cmd == CMD_COPY) ? "copied" : "moved" );
-}
-
-
-
-/* execute EX commands from a file */
-/*ARGSUSED*/
-void cmd_source(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	/* must have a filename */
-	if (!*extra)
-	{
-		msg("\"source\" requires a filename");
-		return;
-	}
-
-	doexrc(extra);
-}
-
-
-#ifndef NO_AT
-/*ARGSUSED*/
-void cmd_at(frommark, tomark, cmd, bang, extra)
-	MARK	frommark;
-	MARK	tomark;
-	CMD	cmd;
-	int	bang;
-	char	*extra;
-{
-	static	nest = FALSE;
-	int	result;
-	char	buf[MAXRCLEN];
-
-	/* don't allow nested macros */
-	if (nest)
-	{
-		msg("@ macros can't be nested");
-		return;
-	}
-	nest = TRUE;
-
-	/* require a buffer name */
-	if (*extra == '"')
-		extra++;
-	if (!*extra || !isascii(*extra) ||!islower(*extra))
-	{
-		msg("@ requires a cut buffer name (a-z)");
-	}
-
-	/* get the contents of the buffer */
-	result = cb2str(*extra, buf, (unsigned)(sizeof buf));
-	if (result <= 0)
-	{
-		msg("buffer \"%c is empty", *extra);
-	}
-	else if (result >= sizeof buf)
-	{
-		msg("buffer \"%c is too large to execute", *extra);
-	}
-	else
-	{
-		/* execute the contents of the buffer as ex commands */
-		exstring(buf, result, '\\');
-	}
-
-	nest = FALSE;
-}
-#endif
Index: trunk/minix/commands/elvis/config.h
===================================================================
--- trunk/minix/commands/elvis/config.h	(revision 9)
+++ 	(revision )
@@ -1,525 +1,0 @@
-/*
- * vi configuration file
- * We try to automatically configure to various compilers and operating
- * systems. Extend the autoconf section as needed.
- */
-
-#ifndef _CONFIG_H
-# define _CONFIG_H
-
-/*************************** autoconf section ************************/
-
-/* Commodore-Amiga */
-#ifdef	amiga
-# define AMIGA		1
-# define COMPILED_BY	"Manx Aztec C 5.2b"
-#endif
-
-/* standard unix V (?) */
-#ifdef	M_SYSV
-# define UNIXV		1
-#endif
-
-/* xelos system, University of Ulm */
-#ifdef	xelos
-# define UNIXV		1
-#endif
-
-/* BSD UNIX? */
-#ifdef bsd
-# define BSD		1
-#else
-# ifdef sun
-#  define BSD		1
-# endif
-#endif
-
-/* Microsoft C: sorry, Watcom does the same thing */
-#ifdef	M_I86
-# ifndef M_SYSV
-#  define MSDOS		1
-#  ifdef IBMC2
-#   define COMPILED_BY	"IBM C/2 1.00"
-#  else
-#   define MICROSOFT	1
-#   define COMPILED_BY	"Microsoft C 5.10"
-#  endif
-# endif
-#endif
-
-/* Borland's Turbo C */
-#ifdef	__TURBOC__
-# define MSDOS		1
-# define TURBOC		1
-# ifdef __BORLANDC__
-# define COMPILED_BY	"Borland C 2.00"
-# else
-# define COMPILED_BY	(__TURBOC__ >= 661 ? "Turbo C++ 1.00" : "Turbo C 2.00")
-# endif
-#endif
-
-/* Tos Mark-Williams */
-#ifdef	M68000
-# define TOS 1
-# define COMPILED_BY	"Mark Williams C"
-#endif
-
-/* Tos GNU-C */
-#if defined(__atarist__) && defined(__gem__)
-# define TOS 1
-# define COMPILED_BY	"GNU-C " __VERSION__
-#endif
-
-/* OS9/68000 */
-#ifdef	OSK
-# define COMPILED_BY	"Microware C V2.3 Edition 40"
-#endif
-
-/* DEC Rainbow, running MS-DOS (handled by earlier MS-DOS tests) */
-/* (would need -DRAINBOW in CFLAGS to compile a Rainbow-compatible .EXE) */
-
-#ifdef VMS
-# define COMPILED_BY    "VAX/VMS VAXC compiler"
-# undef VMS
-# define VMS 1
-#endif
-
-/*************************** end of autoconf section ************************/
-
-/* All undefined symbols are defined to zero here, to allow for older    */
-/* compilers which dont understand #if defined() or #if UNDEFINED_SYMBOL */
-
-/*************************** operating systems *****************************/
- 
-#ifndef	BSD
-# define BSD	0		/* UNIX - Berkeley 4.x */
-#endif
-
-#ifndef	UNIXV
-# define UNIXV	0		/* UNIX - AT&T SYSV */
-#endif
-
-#ifndef	UNIX7
-# define UNIX7	0		/* UNIX - version 7 */
-#endif
-
-#ifndef	MSDOS
-# define MSDOS	0		/* PC		*/
-#endif
-
-#ifndef	TOS
-# define TOS	0		/* Atari ST	*/
-#endif
-
-#ifndef	AMIGA
-# define AMIGA	0		/* Commodore Amiga */
-#endif
-
-#ifndef OSK
-# define OSK	0		/* OS-9 / 68k */
-#endif
-
-#ifndef COHERENT
-# define COHERENT 0		/* Coherent */
-#endif
-
-#ifndef RAINBOW			/* DEC Rainbow support, under MS-DOS */
-# define RAINBOW 0
-#endif
-
-#ifndef VMS
-# define VMS 0                  /* VAX/VMS */
-#endif
-				/* Minix has no predefines */
-#if !BSD && !UNIXV && !UNIX7 && !MSDOS && !TOS && !AMIGA && !OSK && !COHERENT && !VMS
-# define MINIX	1
-#else
-# define MINIX	0
-#endif
-
-				/* generic combination of Unices */
-#if UNIXV || UNIX7 || BSD || MINIX || COHERENT
-# define ANY_UNIX 1
-#else
-# define ANY_UNIX 0
-#endif
-
-/*************************** compilers **************************************/
- 
-#ifndef	AZTEC_C
-# define AZTEC_C	0
-#endif
-
-#ifndef	MICROSOFT
-# define MICROSOFT	0
-#endif
-
-#ifndef	TURBOC
-# define TURBOC		0
-#endif
-
-/******************************* Credit ************************************/
-
-#if MSDOS
-# define CREDIT "Ported to MS-DOS by Guntram Blohm & Martin Patzel"
-# if RAINBOW
-#  define CREDIT2 "Rainbow support added by Willett Kempton"
-# endif
-#endif
-
-#if AMIGA
-# define CREDIT "Ported to AmigaDOS 2.04 by Mike Rieser & Dale Rahn"
-#endif
-
-#if TOS
-# define CREDIT "Ported to Atari/TOS by Guntram Blohm & Martin Patzel"
-#endif
-
-#if OSK
-# define CREDIT	"Ported to Microware OS9/68k by Peter Reinig"
-#endif
-
-#if COHERENT
-# define CREDIT	"Ported to Coherent by Esa Ahola"
-#endif
-
-#if VMS
-# define CREDIT "Ported to VAX/VMS by John Campbell"
-#endif
-/*************************** functions depending on OS *********************/
-
-/* There are two terminal-related functions that we need: ttyread() and
- * ttywrite().  The ttyread() function implements read-with-timeout and is
- * a true function on all systems.  The ttywrite() function is almost always
- * just a macro...
- */
-#if !TOS && !AMIGA
-# define ttywrite(buf, len)	write(1, buf, (unsigned)(len))	/* raw write */
-#endif
-
-/* The strchr() function is an official standard now, so everybody has it
- * except Unix version 7 (which is old) and BSD Unix (which is academic).
- * Those guys use something called index() to do the same thing.
- */
-#if BSD || UNIX7 || OSK
-# define strchr	index
-#endif
-extern char *strchr();
-
-/* BSD uses bcopy() instead of memcpy() */
-#if BSD
-# define memcpy(dest, src, siz)	bcopy(src, dest, siz)
-#endif
-
-/* BSD uses getwd() instead of getcwd().  The arguments are a little different,
- * but we'll ignore that and hope for the best; adding arguments to the macro
- * would mess up an "extern" declaration of the function.
- */
-#if BSD || COHERENT
-# define getcwd	getwd
-#endif
-extern char *getcwd();
-
-/* text versa binary mode for read/write */
-#if !TOS
-#define	tread(fd,buf,n)		read(fd,buf,(unsigned)(n))
-#define twrite(fd,buf,n)	write(fd,buf,(unsigned)(n))
-#endif
-
-/**************************** Compiler quirks *********************************/
-
-/* the UNIX version 7 and (some) TOS compilers, don't allow "void" */
-#if UNIX7 || TOS
-# define void int
-#endif
-
-/* as far as I know, all compilers except version 7 support unsigned char */
-/* NEWFLASH: the Minix-ST compiler has subtle problems with unsigned char */
-#if UNIX7 || MINIX
-# define UCHAR(c)	((c) & 0xff)
-# define uchar		char
-#else
-# define UCHAR(c)	((unsigned char)(c))
-# define uchar		unsigned char
-#endif
-
-/* Some compilers prefer to have malloc declared as returning a (void *) */
-#if BSD || AMIGA
-extern void *malloc();
-#else
-extern char *malloc();
-#endif
-
-/* everybody but Amiga wants lseek declared here */
-#if !AMIGA
-extern long lseek();
-#endif
-
-/******************* Names of files and environment vars **********************/
-
-#if ANY_UNIX
-# ifndef TMPDIR
-#  if MINIX
-#   define TMPDIR	"/tmp"
-#  endif
-# endif
-# ifndef PRSVDIR
-#  define PRSVDIR	"/usr/preserve"	/* directory where preserved file live */
-# endif
-# ifndef PRSVINDEX
-#  define PRSVINDEX	"/usr/preserve/Index" /* index of files in PRSVDIR */
-# endif
-# ifndef EXRC
-#  define EXRC		".exrc"		/* init file in current directory */
-# endif
-# define SCRATCHOUT	"%s/soXXXXXX"	/* temp file used as input to filter */
-# ifndef SHELL
-#  define SHELL		"/bin/sh"	/* default shell */
-# endif
-# if COHERENT
-#  ifndef REDIRECT
-#   define REDIRECT	">"		/* Coherent CC writes errors to stdout */
-#  endif
-# endif
-#endif
-
-#if AMIGA		/* Specify AMIGA environment */
-# ifndef CC_COMMAND
-#  define CC_COMMAND	"cc"		/* generic C compiler */
-# endif
-# ifndef COLON
-#  define COLON		':'		/* Amiga files can also end in `:' */
-# endif
-# ifndef SYSEXRC
-#  define SYSEXRC	"S:" EXRC	/* name of ".exrc" file in system dir */
-# endif
-# ifndef MAXRCLEN
-#  define MAXRCLEN	2048		/* max size of a .exrc file */
-# endif
-# ifndef NBUFS
-#  define NBUFS		10		/* must be at least 3 -- more is better */
-# endif
-# ifndef NEEDSYNC
-#  define NEEDSYNC	TRUE		/* assume ":se sync" by default */
-# endif
-# ifndef PRSVDIR
-#  define PRSVDIR	"Elvis:"	/* directory where preserved file live */
-# endif
-# ifndef PRSVINDEX
-#  define PRSVINDEX	"Elvis:Index"	/* index of files in PRSVDIR */
-# endif
-# ifndef REDIRECT
-#  define REDIRECT	">"		/* Amiga writes errors to stdout */
-# endif
-# ifndef SCRATCHIN
-#  define SCRATCHIN	"%sSIXXXXXX"
-# endif
-# ifndef SCRATCHOUT
-#  define SCRATCHOUT	"%sSOXXXXXX"
-# endif
-# ifndef SHELL
-#  define SHELL		"newshell"	/* default shell */
-# endif
-# ifndef TERMTYPE
-#  define TERMTYPE	"amiga"		/* default termtype */
-# endif
-# ifndef TMPDIR				/* for AMIGA should end in `:' or `/' */
-#  define TMPDIR	"T:"		/* directory where temp files live */
-# endif
-# ifndef TMPNAME
-#  define TMPNAME	"%selv_%x.%x"	/* format of names for temp files */
-# endif
-#endif
-
-#if MSDOS || TOS
-/* do not change TMPNAME and SCRATCH*: they MUST begin with '%s\\'! */
-# ifndef TMPDIR
-#  define TMPDIR	"C:\\tmp"	/* directory where temp files live */
-# endif
-# ifndef PRSVDIR
-#  define PRSVDIR	"C:\\preserve"	/* directory where preserved file live */
-# endif
-# ifndef PRSVINDEX
-#  define PRSVINDEX	"C:\\preserve\\Index" /* index of files in PRSVDIR */
-# endif
-# define TMPNAME	"%s\\elv_%x.%x" /* temp file */
-# if MSDOS
-#  if MICROSOFT
-#   define CC_COMMAND	"cl -c"		/* C compiler */
-#  else
-#   if __BORLANDC__  /* Borland C */
-#    define CC_COMMAND	"bcc"		/* C compiler */
-#   else
-#   if TURBOC        /* Turbo C */
-#    define CC_COMMAND	"tcc"		/* C compiler */
-#   endif	/* TURBOC */
-#   endif	/* BORLANDC */
-#  endif		/* MICROSOFT */
-# endif		/* MSDOS */
-# define SCRATCHIN	"%s\\siXXXXXX"	/* DOS ONLY - output of filter program */
-# define SCRATCHOUT	"%s\\soXXXXXX"	/* temp file used as input to filter */
-# define SLASH		'\\'
-# ifndef SHELL
-#  if TOS
-#   define SHELL	"shell.ttp"	/* default shell */
-#  else
-#   define SHELL	"command.com"	/* default shell */
-#  endif
-# endif
-# define NEEDSYNC	TRUE		/* assume ":se sync" by default */
-# if TOS && __GNUC__			/* probably on other systems, too */
-#  define REDIRECT	"2>"		/* GNUC reports on 2, others on 1 */
-#  define CC_COMMAND	"gcc -c"
-# else
-#  define REDIRECT	">"		/* shell's redirection of stderr */
-# endif
-#endif
-
-#if VMS
-/* do not change TMPNAME, and SCRATCH*: they MUST begin with '%s\\'! */
-# ifndef TMPDIR
-#  define TMPDIR        "sys$scratch:"  /* directory where temp files live */
-# endif
-# define TMPNAME        "%selv_%x.%x;1" /* temp file */
-# define SCRATCHIN      "%ssiXXXXXX"    /* DOS ONLY - output of filter program */
-# define SCRATCHOUT     "%ssoXXXXXX"    /* temp file used as input to filter */
-# define SLASH          '\:'  /* Worry point... jdc */
-# ifndef SHELL
-#   define SHELL        ""      /* default shell */
-# endif
-# define REDIRECT       ">"             /* shell's redirection of stderr */
-# define tread(fd,buf,n)  vms_read(fd,buf,(unsigned)(n))
-# define close vms_close
-# define lseek vms_lseek
-# define unlink vms_delete
-# define delete __delete   /* local routine conflicts w/VMS rtl routine. */
-# define rpipe vms_rpipe
-# define rpclose vms_rpclose
-# define ttyread vms_ttyread
-/* There is no sync() on vms */
-# define sync()
-/* jdc -- seems VMS external symbols are case insensitive */
-# define m_fWord m_fw_ord
-# define m_bWord m_bw_ord
-# define m_eWord m_ew_ord
-# define m_Nsrch m_n_srch
-# define m_Fch   m_f_ch
-# define m_Tch   m_t_ch
-# define v_Xchar v_x_char
-/* jdc -- also, braindead vms curses always found by linker. */
-# define LINES elvis_LINES
-# define COLS  elvis_COLS
-# define curscr elvis_curscr
-# define stdscr elvis_stdscr
-# define initscr elvis_initscr
-# define endwin  elvis_endwin
-# define wrefresh elvis_wrefresh
-#endif
-
-#if OSK
-# ifndef TMPDIR
-#  define TMPDIR	"/dd/tmp"	   /* directory where temp files live */
-# endif
-# ifndef PRSVDIR
-#  define PRSVDIR	"/dd/usr/preserve" /* directory where preserved file live */
-# endif
-# ifndef PRSVINDEX
-#  define PRSVINDEX	"/dd/usr/preserve/Index" /* index of files in PRSVDIR */
-# endif
-# ifndef CC_COMMAND
-#  define CC_COMMAND	"cc -r"		   /* name of the compiler */
-# endif
-# ifndef EXRC
-#  define EXRC		".exrc"		   /* init file in current directory */
-# endif
-# define SCRATCHOUT	"%s/soXXXXXX"	   /* temp file used as input to filter */
-# ifndef SHELL
-#  define SHELL		"shell"		   /* default shell */
-# endif
-# define FILEPERMS	(S_IREAD|S_IWRITE) /* file permissions used for creat() */
-# define REDIRECT	">>-"		   /* shell's redirection of stderr */
-# define sync()				   /* OS9 doesn't need a sync() */
-#endif
-
-#ifndef	TAGS
-# define TAGS		"tags"		/* name of the tags file */
-#endif
-
-#ifndef TMPNAME
-# define TMPNAME	"%s/elv_%x.%x"	/* format of names for temp files */
-#endif
-
-#ifndef EXINIT
-# define EXINIT		"EXINIT"	/* name of EXINIT environment variable */
-#endif
-
-#ifndef	EXRC
-# define EXRC		"elvis.rc"	/* name of ".exrc" file in current dir */
-#endif
-
-#ifndef HMEXRC
-# define HMEXRC		EXRC		/* name of ".exrc" file in home dir */
-#endif
-
-#ifndef	KEYWORDPRG
-# define KEYWORDPRG	"ref"
-#endif
-
-#ifndef	SCRATCHOUT
-# define SCRATCHIN	"%s/SIXXXXXX"
-# define SCRATCHOUT	"%s/SOXXXXXX"
-#endif
-
-#ifndef ERRLIST
-# define ERRLIST	"errlist"
-#endif
-
-#ifndef	SLASH
-# define SLASH		'/'
-#endif
-
-#ifndef SHELL
-# define SHELL		"shell"
-#endif
-
-#ifndef REG
-# define REG		register
-#endif
-
-#ifndef NEEDSYNC
-# define NEEDSYNC	FALSE
-#endif
-
-#ifndef FILEPERMS
-# define FILEPERMS	0666
-#endif
-
-#ifndef PRESERVE
-# define PRESERVE	"elvprsv"	/* name of the "preserve" program */
-#endif
-
-#ifndef CC_COMMAND
-# define CC_COMMAND	"cc -c"
-#endif
-
-#ifndef MAKE_COMMAND
-# define MAKE_COMMAND	"make"
-#endif
-
-#ifndef REDIRECT
-# define REDIRECT	"2>"
-#endif
-
-#ifndef BLKSIZE
-# ifdef CRUNCH
-#  define BLKSIZE	1024
-# else
-#  define BLKSIZE	2048
-# endif
-#endif
-
-#ifndef KEYBUFSIZE
-# define KEYBUFSIZE	1000
-#endif
-
-#endif  /* ndef _CONFIG_H */
Index: trunk/minix/commands/elvis/ctags.c
===================================================================
--- trunk/minix/commands/elvis/ctags.c	(revision 9)
+++ 	(revision )
@@ -1,819 +1,0 @@
-/* ctags.c */
-
-/* This is a reimplementation of the ctags(1) program.  It supports ANSI C,
- * and has heaps o' flags.  It is meant to be distributed with elvis.
- */
-
-#include <stdio.h>
-#include "config.h"
-#ifndef FALSE
-# define FALSE	0
-# define TRUE	1
-#endif
-#ifndef TAGS
-# define TAGS	"tags"
-#endif
-#ifndef REFS
-# define REFS	"refs"
-#endif
-#ifndef BLKSIZE
-# define BLKSIZE 1024
-#endif
-
-#include "ctype.c" /* yes, that really is the .c file, not the .h one. */
-
-/* -------------------------------------------------------------------------- */
-/* Some global variables */
-
-/* The following boolean variables are set according to command line flags */
-int	incl_static;	/* -s  include static tags */
-int	incl_types;	/* -t  include typedefs and structs */
-int	incl_vars;	/* -v  include variables */
-int	make_refs;	/* -r  generate a "refs" file */
-int	append_files;	/* -a  append to "tags" [and "refs"] files */
-
-/* The following are used for outputting to the "tags" and "refs" files */
-FILE	*tags;		/* used for writing to the "tags" file */
-FILE	*refs;		/* used for writing to the "refs" file */
-
-/* -------------------------------------------------------------------------- */
-/* These are used for reading a source file.  It keeps track of line numbers */
-char	*file_name;	/* name of the current file */
-FILE	*file_fp;	/* stream used for reading the file */
-long	file_lnum;	/* line number in the current file */
-long	file_seek;	/* fseek() offset to the start of current line */
-int	file_afternl;	/* boolean: was previous character a newline? */
-int	file_prevch;	/* a single character that was ungotten */
-int	file_header;	/* boolean: is the current file a header file? */
-
-/* This function opens a file, and resets the line counter.  If it fails, it
- * it will display an error message and leave the file_fp set to NULL.
- */
-void file_open(name)
-	char	*name;	/* name of file to be opened */
-{
-	/* if another file was already open, then close it */
-	if (file_fp)
-	{
-		fclose(file_fp);
-	}
-
-	/* try to open the file for reading.  The file must be opened in
-	 * "binary" mode because otherwise fseek() would misbehave under DOS.
-	 */
-#if MSDOS || TOS
-	file_fp = fopen(name, "rb");
-#else
-	file_fp = fopen(name, "r");
-#endif
-	if (!file_fp)
-	{
-		perror(name);
-	}
-
-	/* reset the name & line number */
-	file_name = name;
-	file_lnum = 0L;
-	file_seek = 0L;
-	file_afternl = TRUE;
-
-	/* determine whether this is a header file */
-	file_header = FALSE;
-	name += strlen(name) - 2;
-	if (name >= file_name && name[0] == '.' && (name[1] == 'h' || name[1] == 'H'))
-	{
-		file_header = TRUE;
-	}
-}
-
-/* This function reads a single character from the stream.  If the *previous*
- * character was a newline, then it also increments file_lnum and sets
- * file_offset.
- */
-int file_getc()
-{
-	int	ch;
-
-	/* if there is an ungotten character, then return it.  Don't do any
-	 * other processing on it, though, because we already did that the
-	 * first time it was read.
-	 */
-	if (file_prevch)
-	{
-		ch = file_prevch;
-		file_prevch = 0;
-		return ch;
-	}
-
-	/* if previous character was a newline, then we're starting a line */
-	if (file_afternl)
-	{
-		file_afternl = FALSE;
-		file_seek = ftell(file_fp);
-		file_lnum++;
-	}
-
-	/* Get a character.  If no file is open, then return EOF */
-	ch = (file_fp ? getc(file_fp) : EOF);
-
-	/* if it is a newline, then remember that fact */
-	if (ch == '\n')
-	{
-		file_afternl = TRUE;
-	}
-
-	/* return the character */
-	return ch;
-}
-
-/* This function ungets a character from the current source file */
-void file_ungetc(ch)
-	int	ch;	/* character to be ungotten */
-{
-	file_prevch = ch;
-}
-
-/* This function copies the current line out some other fp.  It has no effect
- * on the file_getc() function.  During copying, any '\' characters are doubled
- * and a leading '^' or trailing '$' is also quoted.  The newline character is
- * not copied.
- *
- * This is meant to be used when generating a tag line.
- */
-void file_copyline(seek, fp)
-	long	seek;	/* where the lines starts in the source file */
-	FILE	*fp;	/* the output stream to copy it to */
-{
-	long	oldseek;/* where the file's pointer was before we messed it up */
-	char	ch;	/* a single character from the file */
-	char	next;	/* the next character from this file */
-
-	/* go to the start of the line */
-	oldseek = ftell(file_fp);
-	fseek(file_fp, seek, 0);
-
-	/* if first character is '^', then emit \^ */
-	ch = getc(file_fp);
-	if (ch == '^')
-	{
-		putc('\\', fp);
-		putc('^', fp);
-		ch = getc(file_fp);
-	}
-
-	/* write everything up to, but not including, the newline */
-	while (ch != '\n')
-	{
-		/* preread the next character from this file */
-		next = getc(file_fp);
-
-		/* if character is '\', or a terminal '$', then quote it */
-		if (ch == '\\' || (ch == '$' && next == '\n'))
-		{
-			putc('\\', fp);
-		}
-		putc(ch, fp);
-
-		/* next character... */
-		ch = next;
-	}
-
-	/* seek back to the old position */
-	fseek(file_fp, oldseek, 0);
-}
-
-/* -------------------------------------------------------------------------- */
-/* This section handles preprocessor directives.  It strips out all of the
- * directives, and may emit a tag for #define directives.
- */
-
-int	cpp_afternl;	/* boolean: look for '#' character? */
-int	cpp_prevch;	/* an ungotten character, if any */
-int	cpp_refsok;	/* boolean: can we echo characters out to "refs"? */
-
-/* This function opens the file & resets variables */
-void cpp_open(name)
-	char	*name;	/* name of source file to be opened */
-{
-	/* use the lower-level file_open function to open the file */
-	file_open(name);
-
-	/* reset variables */
-	cpp_afternl = TRUE;
-	cpp_refsok = TRUE;
-}
-
-/* This function copies a character from the source file to the "refs" file */
-void cpp_echo(ch)
-	int	ch; /* the character to copy */
-{
-	static	wasnl;
-
-	/* echo non-EOF chars, unless not making "ref", or echo turned off */
-	if (ch != EOF && make_refs && cpp_refsok && !file_header)
-	{
-		/* try to avoid blank lines */
-		if (ch == '\n')
-		{
-			if (wasnl)
-			{
-				return;
-			}
-			wasnl = TRUE;
-		}
-		else
-		{
-			wasnl = FALSE;
-		}
-
-		/* add the character */
-		putc(ch, refs);
-	}
-}
-
-/* This function returns the next character which isn't part of a directive */
-int cpp_getc()
-{
-	static
-	int	ch;	/* the next input character */
-	char	*scan;
-
-	/* if we have an ungotten character, then return it */
-	if (cpp_prevch)
-	{
-		ch = cpp_prevch;
-		cpp_prevch = 0;
-		return ch;
-	}
-
-	/* Get a character from the file.  Return it if not special '#' */
-	ch = file_getc();
-	if (ch == '\n')
-	{
-		cpp_afternl = TRUE;
-		cpp_echo(ch);
-		return ch;
-	}
-	else if (ch != '#' || !cpp_afternl)
-	{
-		/* normal character.  Any non-whitespace should turn off afternl */
-		if (ch != ' ' && ch != '\t')
-		{
-			cpp_afternl = FALSE;
-		}
-		cpp_echo(ch);
-		return ch;
-	}
-
-	/* Yikes!  We found a directive */
-
-	/* see whether this is a #define line */
-	scan = " define ";
-	while (*scan)
-	{
-		if (*scan == ' ')
-		{
-			/* space character matches any whitespace */
-			do
-			{
-				ch = file_getc();
-			} while (ch == ' ' || ch == '\t');
-			file_ungetc(ch);
-		}
-		else
-		{
-			/* other characters should match exactly */
-			ch = file_getc();
-			if (ch != *scan)
-			{
-				file_ungetc(ch);
-				break;
-			}
-		}
-		scan++;
-	}
-
-	/* is this a #define line?  and should we generate a tag for it? */
-	if (!*scan && (file_header || incl_static))
-	{
-		/* if not a header, then this will be a static tag */
-		if (!file_header)
-		{
-			fputs(file_name, tags);
-			putc(':', tags);
-		}
-
-		/* output the tag name */
-		for (ch = file_getc(); isalnum(ch) || ch == '_'; ch = file_getc())
-		{
-			putc(ch, tags);
-		}
-
-		/* output a tab, the filename, another tab, and the line number */
-		fprintf(tags, "\t%s\t%ld\n", file_name, file_lnum);
-	}
-
-	/* skip to the end of the directive -- a newline that isn't preceded
-	 * by a '\' character.
-	 */
-	while (ch != EOF && ch != '\n')
-	{
-		if (ch == '\\')
-		{
-			ch = file_getc();
-		}
-		ch = file_getc();
-	}
-
-	/* return the newline that we found at the end of the directive */
-	cpp_echo(ch);
-	return ch;
-}
-
-/* This puts a character back into the input queue for the source file */
-cpp_ungetc(ch)
-	int	ch;	/* a character to be ungotten */
-{
-	cpp_prevch = ch;
-}
-
-
-/* -------------------------------------------------------------------------- */
-/* This is the lexical analyser.  It gets characters from the preprocessor,
- * and gives tokens to the parser.  Some special codes are...
- *   (deleted)  /*...* /	(comments)
- *   (deleted)	//...\n	(comments)
- *   (deleted)	(*	(parens used in complex declaration)
- *   (deleted)	[...]	(array subscript, when ... contains no ])
- *   (deleted)	struct	(intro to structure declaration)
- *   BODY	{...}	('{' can occur anywhere, '}' only at BOW if ... has '{')
- *   ARGS	(...{	(args of function, not extern or forward)
- *   ARGS	(...);	(args of an extern/forward function declaration)
- *   COMMA	,	(separate declarations that have same scope)
- *   SEMICOLON	;	(separate declarations that have different scope)
- *   SEMICOLON  =...;	(initializer)
- *   TYPEDEF	typedef	(the "typedef" keyword)
- *   STATIC	static	(the "static" keyword)
- *   STATIC	private	(the "static" keyword)
- *   STATIC	PRIVATE	(the "static" keyword)
- *   NAME	[a-z]+	(really any valid name that isn't reserved word)
- */
-
-/* #define EOF -1 */
-#define DELETED	  0
-#define BODY	  1
-#define ARGS	  2
-#define COMMA	  3
-#define SEMICOLON 4
-#define TYPEDEF   5
-#define STATIC	  6
-#define EXTERN	  7
-#define NAME	  8
-
-char	lex_name[BLKSIZE];	/* the name of a "NAME" token */
-long	lex_seek;		/* start of line that contains lex_name */
-
-lex_gettoken()
-{
-	int	ch;		/* a character from the preprocessor */
-	int	next;		/* the next character */
-	int	token;		/* the token that we'll return */
-	int	i;
-
-	/* loop until we get a token that isn't "DELETED" */
-	do
-	{
-		/* get the next character */
-		ch = cpp_getc();
-
-		/* process the character */
-		switch (ch)
-		{
-		  case ',':
-			token = COMMA;
-			break;
-
-		  case ';':
-			token = SEMICOLON;
-			break;
-
-		  case '/':
-			/* get the next character */
-			ch = cpp_getc();
-			switch (ch)
-			{
-			  case '*':	/* start of C comment */
-				ch = cpp_getc();
-				next = cpp_getc();
-				while (next != EOF && (ch != '*' || next != '/'))
-				{
-					ch = next;
-					next = cpp_getc();
-				}
-				break;
-
-			  case '/':	/* start of a C++ comment */
-				do
-				{
-					ch = cpp_getc();
-				} while (ch != '\n' && ch != EOF);
-				break;
-
-			  default:	/* some other slash */
-				cpp_ungetc(ch);
-			}
-			token = DELETED;
-			break;
-
-		  case '(':
-			ch = cpp_getc();
-			if (ch == '*')
-			{
-				token = DELETED;
-			}
-			else
-			{
-				next = cpp_getc();
-				while (ch != '{' && ch != EOF && (ch != ')' || next != ';'))/*}*/
-				{
-					ch = next;
-					next = cpp_getc();
-				}
-				if (ch == '{')/*}*/
-				{
-					cpp_ungetc(ch);
-				}
-				else if (next == ';')
-				{
-					cpp_ungetc(next);
-				}
-				token = ARGS;
-			}
-			break;
-
-		  case '{':/*}*/
-			/* don't send the next characters to "refs" */
-			cpp_refsok = FALSE;
-
-			/* skip ahead to closing '}', or to embedded '{' */
-			do
-			{
-				ch = cpp_getc();
-			} while (ch != '{' && ch != '}' && ch != EOF);
-
-			/* if has embedded '{', then skip to '}' in column 1 */
-			if (ch == '{') /*}*/
-			{
-				ch = cpp_getc();
-				next = cpp_getc();
-				while (ch != EOF && (ch != '\n' || next != '}'))/*{*/
-				{
-					ch = next;
-					next = cpp_getc();
-				}
-			}
-
-			/* resume "refs" processing */
-			cpp_refsok = TRUE;
-			cpp_echo('}');
-
-			token = BODY;
-			break;
-
-		  case '[':
-			/* skip to matching ']' */
-			do
-			{
-				ch = cpp_getc();
-			} while (ch != ']' && ch != EOF);
-			token = DELETED;
-			break;
-
-		  case '=':
-		  	/* skip to next ';' */
-			do
-			{
-				ch = cpp_getc();
-
-				/* leave array initializers out of "refs" */
-				if (ch == '{')
-				{
-					cpp_refsok = FALSE;
-				}
-			} while (ch != ';' && ch != EOF);
-
-			/* resume echoing to "refs" */
-			if (!cpp_refsok)
-			{
-				cpp_refsok = TRUE;
-				cpp_echo('}');
-				cpp_echo(';');
-			}
-			token = SEMICOLON;
-			break;
-
-		  case EOF:
-			token = EOF;
-			break;
-
-		  default:
-			/* is this the start of a name/keyword? */
-			if (isalpha(ch) || ch == '_')
-			{
-				/* collect the whole word */
-				lex_name[0] = ch;
-				for (i = 1, ch = cpp_getc();
-				     i < BLKSIZE - 1 && (isalnum(ch) || ch == '_');
-				     i++, ch = cpp_getc())
-				{
-					lex_name[i] = ch;
-				}
-				lex_name[i] = '\0';
-				cpp_ungetc(ch);
-
-				/* is it a reserved word? */
-				if (!strcmp(lex_name, "typedef"))
-				{
-					token = TYPEDEF;
-					lex_seek = -1L;
-				}
-				else if (!strcmp(lex_name, "static")
-				      || !strcmp(lex_name, "private")
-				      || !strcmp(lex_name, "PRIVATE"))
-				{
-					token = STATIC;
-					lex_seek = -1L;
-				}
-				else if (!strcmp(lex_name, "extern")
-				      || !strcmp(lex_name, "EXTERN")
-				      || !strcmp(lex_name, "FORWARD"))
-				{
-					token = EXTERN;
-					lex_seek = -1L;
-				}
-				else
-				{
-					token = NAME;
-					lex_seek = file_seek;
-				}
-			}
-			else /* not part of a name/keyword */
-			{
-				token = DELETED;
-			}
-
-		} /* end switch(ch) */
-
-	} while (token == DELETED);
-
-	return token;
-}
-
-/* -------------------------------------------------------------------------- */
-/* This is the parser.  It locates tag candidates, and then decides whether to
- * generate a tag for them.
- */
-
-/* This function generates a tag for the object in lex_name, whose tag line is
- * located at a given seek offset.
- */
-void maketag(scope, seek)
-	int	scope;	/* 0 if global, or STATIC if static */
-	long	seek;	/* the seek offset of the line */
-{
-	/* output the tagname and filename fields */
-	if (scope == EXTERN)
-	{
-		/* whoa!  we should *never* output a tag for "extern" decl */
-		return;
-	}
-	else if (scope == STATIC)
-	{
-		fprintf(tags, "%s:%s\t%s\t", file_name, lex_name, file_name);
-	}
-	else
-	{
-		fprintf(tags, "%s\t%s\t", lex_name, file_name);
-	}
-
-	/* output the target line */
-	putc('/', tags);
-	putc('^', tags);
-	file_copyline(seek, tags);
-	putc('$', tags);
-	putc('/', tags);
-	putc('\n', tags);
-}
-
-
-/* This function parses a source file, adding any tags that it finds */
-void ctags(name)
-	char	*name;	/* the name of a source file to be checked */
-{
-	int	prev;	/* the previous token from the source file */
-	int	token;	/* the current token from the source file */
-	int	scope;	/* normally 0, but could be a TYPEDEF or STATIC token */
-	int	gotname;/* boolean: does lex_name contain a tag candidate? */
-	long	tagseek;/* start of line that contains lex_name */
-
-	/* open the file */
-	cpp_open(name);
-
-	/* reset */
-	scope = 0;
-	gotname = FALSE;
-	token = SEMICOLON;
-
-	/* parse until the end of the file */
-	while (prev = token, (token = lex_gettoken()) != EOF)
-	{
-		/* scope keyword? */
-		if (token == TYPEDEF || token == STATIC || token == EXTERN)
-		{
-			scope = token;
-			gotname = FALSE;
-			continue;
-		}
-
-		/* name of a possible tag candidate? */
-		if (token == NAME)
-		{
-			tagseek = file_seek;
-			gotname = TRUE;
-			continue;
-		}
-
-		/* if NAME BODY, without ARGS, then NAME is a struct tag */
-		if (gotname && token == BODY && prev != ARGS)
-		{
-			gotname = FALSE;
-			
-			/* ignore if in typedef -- better name is coming soon */
-			if (scope == TYPEDEF)
-			{
-				continue;
-			}
-
-			/* generate a tag, if -t and maybe -s */
-			if (incl_types && (file_header || incl_static))
-			{
-				maketag(file_header ? 0 : STATIC, tagseek);
-			}
-		}
-
-		/* If NAME ARGS BODY, then NAME is a function */
-		if (gotname && prev == ARGS && token == BODY)
-		{
-			gotname = FALSE;
-			
-			/* generate a tag, maybe checking -s */
-			if (scope != STATIC || incl_static)
-			{
-				maketag(scope, tagseek);
-			}
-		}
-
-		/* If NAME SEMICOLON or NAME COMMA, then NAME is var/typedef */
-		if (gotname && (token == SEMICOLON || token == COMMA))
-		{
-			gotname = FALSE;
-
-			/* generate a tag, if -v/-t and maybe -s */
-			if (scope == TYPEDEF && incl_types && (file_header || incl_static)
-			 || scope == STATIC && incl_vars && incl_static
-			 || incl_vars)
-			{
-				/* a TYPEDEF outside of a header is STATIC */
-				if (scope == TYPEDEF && !file_header)
-				{
-					maketag(STATIC, tagseek);
-				}
-				else /* use whatever scope was declared */
-				{
-					maketag(scope, tagseek);
-				}
-			}
-		}
-
-		/* reset after a semicolon or ARGS BODY pair */
-		if (token == SEMICOLON || (prev == ARGS && token == BODY))
-		{
-			scope = 0;
-			gotname = FALSE;
-		}
-	}
-
-	/* The source file will be automatically closed */
-}
-
-/* -------------------------------------------------------------------------- */
-
-void usage()
-{
-	fprintf(stderr, "usage: ctags [flags] filenames...\n");
-	fprintf(stderr, "\t-s  include static functions\n");
-	fprintf(stderr, "\t-t  include typedefs\n");
-	fprintf(stderr, "\t-v  include variable declarations\n");
-	fprintf(stderr, "\t-r  generate a \"refs\" file, too\n");
-	fprintf(stderr, "\t-a  append to \"tags\", instead of overwriting\n");
-	exit(2);
-}
-
-
-
-#if AMIGA
-# include "amiwild.c"
-#endif
-
-#if VMS
-# include "vmswild.c"
-#endif
-
-main(argc, argv)
-	int	argc;
-	char	**argv;
-{
-	int	i, j;
-
-#if MSDOS || TOS
-	char	**wildexpand();
-	argv = wildexpand(&argc, argv);
-#endif
-
-	/* build the tables used by the ctype macros */
-	_ct_init("");
-
-	/* parse the option flags */
-	for (i = 1; i < argc && argv[i][0] == '-'; i++)
-	{
-		for (j = 1; argv[i][j]; j++)
-		{
-			switch (argv[i][j])
-			{
-			  case 's':	incl_static = TRUE;	break;
-			  case 't':	incl_types = TRUE;	break;
-			  case 'v':	incl_vars = TRUE;	break;
-			  case 'r':	make_refs = TRUE;	break;
-			  case 'a':	append_files = TRUE;	break;
-			  default:	usage();
-			}
-		}
-	}
-
-	/* There should always be at least one source file named in args */
-	if (i == argc)
-	{
-		usage();
-	}
-
-	/* open the "tags" and maybe "refs" files */
-	tags = fopen(TAGS, append_files ? "a" : "w");
-	if (!tags)
-	{
-		perror(TAGS);
-		exit(3);
-	}
-	if (make_refs)
-	{
-		refs = fopen(REFS, append_files ? "a" : "w");
-		if (!refs)
-		{
-			perror(REFS);
-			exit(4);
-		}
-	}
-
-	/* parse each source file */
-	for (; i < argc; i++)
-	{
-		ctags(argv[i]);
-	}
-
-	/* close "tags" and maybe "refs" */
-	fclose(tags);
-	if (make_refs)
-	{
-		fclose(refs);
-	}
-
-#ifdef SORT
-		/* This is a hack which will sort the tags list.   It should
-		 * on UNIX and OS-9.  You may have trouble with csh.   Note
-		 * that the tags list only has to be sorted if you intend to
-		 * use it with the real vi;  elvis permits unsorted tags.
-		 */
-# if OSK
-		system("qsort tags >-_tags; -nx; del tags; rename _tags tags");
-# else	
-		system("sort tags >_tags$$; mv _tags$$ tags");
-# endif
-#endif
-
-	exit(0);
-	/*NOTREACHED*/
-}
-
-#if MSDOS || TOS
-# define WILDCARD_NO_MAIN
-# include "wildcard.c"
-#endif
Index: trunk/minix/commands/elvis/ctype.c
===================================================================
--- trunk/minix/commands/elvis/ctype.c	(revision 9)
+++ 	(revision )
@@ -1,74 +1,0 @@
-/* ctype.c */
-
-/* This file contains the tables and initialization function for elvis'
- * version of <ctype.h>.  It should be portable.
- */
-
-#include "config.h"
-#include "ctype.h"
-
-uchar	_ct_toupper[256];
-uchar	_ct_tolower[256];
-uchar	_ct_ctypes[256];
-
-/* This function initializes the tables used by the ctype macros.  It should
- * be called at the start of the program.  It can be called again anytime you
- * wish to change the non-standard "flipcase" list.  The "flipcase" list is
- * a string of characters which are taken to be lowercase/uppercase pairs.
- * If you don't want to use any special flipcase characters, then pass an
- * empty string.
- */
-void _ct_init(flipcase)
-	uchar	*flipcase;	/* list of non-standard lower/upper letter pairs */
-{
-	int	i;
-	uchar	*scan;
-
-	/* reset all of the tables */
-	for (i = 0; i < 256; i++)
-	{
-		_ct_toupper[i] = _ct_tolower[i] = i;
-		_ct_ctypes[i] = 0;
-	}
-
-	/* add the digits */
-	for (scan = (uchar *)"0123456789"; *scan; scan++)
-	{
-		_ct_ctypes[*scan] |= _CT_DIGIT | _CT_ALNUM;
-	}
-
-	/* add the whitespace */
-	for (scan = (uchar *)" \t\n\r\f"; *scan; scan++)
-	{
-		_ct_ctypes[*scan] |= _CT_SPACE;
-	}
-
-	/* add the standard ASCII letters */
-	for (scan = (uchar *)"aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ"; *scan; scan += 2)
-	{
-		_ct_ctypes[scan[0]] |= _CT_LOWER | _CT_ALNUM;
-		_ct_ctypes[scan[1]] |= _CT_UPPER | _CT_ALNUM;
-		_ct_toupper[scan[0]] = scan[1];
-		_ct_tolower[scan[1]] = scan[0];
-	}
-
-	/* add the flipcase letters */
-	for (scan = flipcase; scan[0] && scan[1]; scan += 2)
-	{
-		_ct_ctypes[scan[0]] |= _CT_LOWER | _CT_ALNUM;
-		_ct_ctypes[scan[1]] |= _CT_UPPER | _CT_ALNUM;
-		_ct_toupper[scan[0]] = scan[1];
-		_ct_tolower[scan[1]] = scan[0];
-	}
-
-	/* include '_' in the isalnum() list */
-	_ct_ctypes[UCHAR('_')] |= _CT_ALNUM;
-
-	/* !!! find the control characters in an ASCII-dependent way */
-	for (i = 0; i < ' '; i++)
-	{
-		_ct_ctypes[i] |= _CT_CNTRL;
-	}
-	_ct_ctypes[127] |= _CT_CNTRL;
-	_ct_ctypes[255] |= _CT_CNTRL;
-}
Index: trunk/minix/commands/elvis/ctype.h
===================================================================
--- trunk/minix/commands/elvis/ctype.h	(revision 9)
+++ 	(revision )
@@ -1,40 +1,0 @@
-/* ctype.h */
-
-/* This file contains macros definitions and extern declarations for a
- * version of <ctype.h> which is aware of the o_flipcase letters used in
- * elvis.
- *
- * This file uses the "uchar" data type and "UCHAR" conversion macro which
- * are defined in "config.h".  Consequently, any file that includes this
- * header must include config.h first.
- */
-
-#ifndef _CT_UPPER
-
-#define _CT_UPPER	0x01
-#define _CT_LOWER	0x02
-#define _CT_SPACE	0x04
-#define _CT_DIGIT	0x08
-#define _CT_ALNUM	0x10
-#define _CT_CNTRL	0x20
-
-#define isalnum(c)	(_ct_ctypes[UCHAR(c)] & _CT_ALNUM)
-#define isalpha(c)	(_ct_ctypes[UCHAR(c)] & (_CT_LOWER|_CT_UPPER))
-#define isdigit(c)	(_ct_ctypes[UCHAR(c)] & _CT_DIGIT)
-#define islower(c)	(_ct_ctypes[UCHAR(c)] & _CT_LOWER)
-#define isspace(c)	(_ct_ctypes[UCHAR(c)] & _CT_SPACE)
-#define isupper(c)	(_ct_ctypes[UCHAR(c)] & _CT_UPPER)
-#define iscntrl(c)	(_ct_ctypes[UCHAR(c)] & _CT_CNTRL)
-#define ispunct(c)	(!_ct_ctypes[UCHAR(c)]) /* punct = "none of the above" */
-
-#define isascii(c)	(!((c) & 0x80))
-
-#define toupper(c)	_ct_toupper[UCHAR(c)]
-#define tolower(c)	_ct_tolower[UCHAR(c)]
-
-extern uchar	_ct_toupper[];
-extern uchar	_ct_tolower[];
-extern uchar	_ct_ctypes[];
-extern void	_ct_init(/* char *flipcase */);
-
-#endif /* ndef _CT_UPPER */
Index: trunk/minix/commands/elvis/curses.c
===================================================================
--- trunk/minix/commands/elvis/curses.c	(revision 9)
+++ 	(revision )
@@ -1,930 +1,0 @@
-/* curses.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the functions & variables needed for a tiny subset of
- * curses.  The principle advantage of this version of curses is its
- * extreme speed.  Disadvantages are potentially larger code, few supported
- * functions, limited compatibility with full curses, and only stdscr.
- */
-
-#include "config.h"
-#include "vi.h"
-
-#if ANY_UNIX
-/* The termios/termio/sgtty #ifdefs were a mess, so I removed all but termios.
- * (KJB)
- */
-# include	<termios.h>
-# if MINIX
-#  include	<sys/ioctl.h>
-# endif
-#endif
-
-#if TOS
-# include	<osbind.h>
-#endif
-
-#if OSK
-# include	<sgstat.h>
-#endif
-
-#if VMS
-extern int VMS_read_raw;  /* Set in initscr() */
-#endif
-
-
-extern char	*getenv();
-static void	 starttcap();
-
-/* variables, publicly available & used in the macros */
-char	*termtype;	/* name of terminal entry */
-short	ospeed;		/* speed of the tty, eg B2400 */
-#if OSK
-char	PC_;	/* Pad char */
-char	*BC;	/* backspace character string */
-#else
-char	PC;		/* Pad char */
-#endif
-WINDOW	*stdscr;	/* pointer into kbuf[] */
-WINDOW	kbuf[KBSIZ];	/* a very large output buffer */
-int	LINES;		/* :li#: number of rows */
-int	COLS;		/* :co#: number of columns */
-int	AM;		/* :am:  boolean: auto margins? */
-int	PT;		/* :pt:  boolean: physical tabs? */
-char	*VB;		/* :vb=: visible bell */
-char	*UP;		/* :up=: move cursor up */
-char	*SO = "";	/* :so=: standout start */
-char	*SE = "";	/* :se=: standout end */
-char	*US = "";	/* :us=: underline start */
-char	*UE = "";	/* :ue=: underline end */
-char	*MD = "";	/* :md=: bold start */
-char	*ME = "";	/* :me=: bold end */
-char	*AS = "";	/* :as=: alternate (italic) start */
-char	*AE = "";	/* :ae=: alternate (italic) end */
-#ifndef NO_VISIBLE
-char	*MV;		/* :mv=: "visible" selection start */
-#endif
-char	*CM;		/* :cm=: cursor movement */
-char	*CE;		/* :ce=: clear to end of line */
-char	*CD;		/* :cd=: clear to end of screen */
-char	*AL;		/* :al=: add a line */
-char	*DL;		/* :dl=: delete a line */
-#if OSK
-char	*SR_;		/* :sr=: scroll reverse */
-#else
-char	*SR;		/* :sr=: scroll reverse */
-#endif
-char	*KS = "";	/* :ks=: init string for cursor */
-char	*KE = "";	/* :ke=: restore string for cursor */
-char	*KU;		/* :ku=: key sequence sent by up arrow */
-char	*KD;		/* :kd=: key sequence sent by down arrow */
-char	*KL;		/* :kl=: key sequence sent by left arrow */
-char	*KR;		/* :kr=: key sequence sent by right arrow */
-char	*HM;		/* :HM=: key sequence sent by the <Home> key */
-char	*EN;		/* :EN=: key sequence sent by the <End> key */
-char	*PU;		/* :PU=: key sequence sent by the <PgUp> key */
-char	*PD;		/* :PD=: key sequence sent by the <PgDn> key */
-char	*KI;		/* :kI=: key sequence sent by the <Insert> key */
-#ifndef NO_FKEY
-char	*FKEY[NFKEYS];	/* :k0=: ... :k9=: sequences sent by function keys */
-#endif
-char	*IM = "";	/* :im=: insert mode start */
-char	*IC = "";	/* :ic=: insert the following character */
-char	*EI = "";	/* :ei=: insert mode end */
-char	*DC;		/* :dc=: delete a character */
-char	*TI = "";	/* :ti=: terminal init */	/* GB */
-char	*TE = "";	/* :te=: terminal exit */	/* GB */
-#ifndef NO_CURSORSHAPE
-#if 1
-char	*CQ = (char *)0;/* :cQ=: normal cursor */
-char	*CX = (char *)1;/* :cX=: cursor used for EX command/entry */
-char	*CV = (char *)2;/* :cV=: cursor used for VI command mode */
-char	*CI = (char *)3;/* :cI=: cursor used for VI input mode */
-char	*CR = (char *)4;/* :cR=: cursor used for VI replace mode */
-#else
-char	*CQ = "";	/* :cQ=: normal cursor */
-char	*CX = "";	/* :cX=: cursor used for EX command/entry */
-char	*CV = "";	/* :cV=: cursor used for VI command mode */
-char	*CI = "";	/* :cI=: cursor used for VI input mode */
-char	*CR = "";	/* :cR=: cursor used for VI replace mode */
-#endif
-#endif
-char	*aend = "";	/* end an attribute -- either UE or ME */
-char	ERASEKEY;	/* backspace key taken from ioctl structure */
-#ifndef NO_COLOR
-char	normalcolor[16];
-char	SOcolor[16];
-char	SEcolor[16];
-char	UScolor[16];
-char	UEcolor[16];
-char	MDcolor[16];
-char	MEcolor[16];
-char	AScolor[16];
-char	AEcolor[16];
-# ifndef NO_POPUP
-char	POPUPcolor[16];
-# endif
-# ifndef NO_VISIBLE
-char	VISIBLEcolor[16];
-# endif
-#endif
-
-#if ANY_UNIX
-static struct termios	oldtermio;	/* original tty mode */
-static struct termios	newtermio;	/* cbreak/noecho tty mode */
-#endif
-
-#if OSK
-static struct sgbuf	oldsgttyb;	/* orginal tty mode */
-static struct sgbuf	newsgttyb;	/* noecho tty mode */
-#endif
-
-static char	*capbuf;	/* capability string buffer */
-
-
-/* Initialize the Curses package. */
-void initscr()
-{
-	/* make sure TERM variable is set */
-	termtype = getenv("TERM");
-
-#if VMS
-	/* VMS getenv() handles TERM as a environment setting.  Foreign 
-	 * terminal support can be implemented by setting the ELVIS_TERM
-	 * logical or symbol to match a tinytcap entry.
-	 */
-	if (!strcmp(termtype,"unknown"))
-		termtype = getenv("ELVIS_TERM");
-#endif
-#if MSDOS
-	/* For MS-DOS, if TERM is unset we can default to "pcbios", or
-	 * maybe "rainbow".
-	 */
-	if (!termtype)
-	{
-#ifdef RAINBOW
-		if (*(unsigned char far*)(0xffff000eL) == 6   /* Rainbow 100a */
-		 || *(unsigned char far*)(0xffff000eL) == 148)/* Rainbow 100b */
-		{
-			termtype = "rainbow";
-		}
-		else
-#endif
-			termtype = "pcbios";
-	}
-	if (!strcmp(termtype, "pcbios"))
-#else
-	if (!termtype)
-#endif
-	{
-#if ANY_UNIX
-		write(2, "Environment variable TERM must be set\n", (unsigned)38);
-		exit(1);
-#endif
-#if OSK
-		writeln(2, "Environment variable TERM must be set\n", (unsigned)38);
-		exit(1);
-#endif
-#if AMIGA
-		termtype = TERMTYPE;
-		starttcap(termtype);
-#endif
-#if MSDOS
-		starttcap("pcbios");
-#endif
-#if TOS
-		termtype = "vt52";
-		starttcap(termtype);
-#endif
-#if VMS
-		write(2, "UNKNOWN terminal: define ELVIS_TERM\n", (unsigned)36);
-		exit(1);
-#endif
-	}
-	else
-	{
-#if MSDOS
-		*o_pcbios = 0;
-#endif
-		/* start termcap stuff */
-		starttcap(termtype);
-	}
-
-	/* create stdscr and curscr */
-	stdscr = kbuf;
-
-	/* change the terminal mode to cbreak/noecho */
-#if ANY_UNIX
-	tcgetattr(2, &oldtermio);
-#endif
-
-#if OSK
-	_gs_opt(0, &oldsgttyb);
-#endif
-
-#if VMS
-	VMS_read_raw = 1;   /* cbreak/noecho */
-	vms_open_tty();
-#endif
-	resume_curses(TRUE);
-}
-
-/* Shut down the Curses package. */
-void endwin()
-{
-	/* change the terminal mode back the way it was */
-	suspend_curses();
-#if AMIGA
-	amiclosewin();
-#endif
-}
-
-
-static int curses_active = FALSE;
-
-/* Send any required termination strings.  Turn off "raw" mode. */
-void suspend_curses()
-{
-#ifndef NO_CURSORSHAPE
-	if (has_CQ)
-	{
-		do_CQ();
-	}
-#endif
-	if (has_TE)					/* GB */
-	{
-		do_TE();
-	}
-	if (has_KE)
-	{
-		do_KE();
-	}
-#ifndef NO_COLOR
-	quitcolor();
-#endif
-	refresh();
-
-	/* change the terminal mode back the way it was */
-#if ANY_UNIX
-	tcsetattr(2, TCSADRAIN, &oldtermio);
-#endif
-#if OSK
-	_ss_opt(0, &oldsgttyb);
-#endif
-#if AMIGA
-	ttyshutdown();
-#endif
-#if MSDOS
-	raw_set_stdio(FALSE);
-#endif
-
-#if VMS
-	VMS_read_raw = 0;
-#endif
-	curses_active = FALSE;
-}
-
-
-/* put the terminal in RAW mode.  If "quietly" is FALSE, then ask the user
- * to hit a key, and wait for keystroke before returning.
- */
-void resume_curses(quietly)
-	int	quietly;
-{
-	if (!curses_active)
-	{
-		/* change the terminal mode to cbreak/noecho */
-#if ANY_UNIX
-		ospeed = cfgetospeed(&oldtermio);
-		ERASEKEY = oldtermio.c_cc[VERASE];
-		newtermio = oldtermio;
-		newtermio.c_iflag &= (IXON|IXOFF|IXANY|ISTRIP|IGNBRK);
-		newtermio.c_oflag &= ~OPOST;
-		newtermio.c_lflag &= ISIG;
-		newtermio.c_cc[VINTR] = ctrl('C'); /* always use ^C for interrupts */
-		newtermio.c_cc[VMIN] = 1;
-		newtermio.c_cc[VTIME] = 0;
-		newtermio.c_cc[VSUSP] = 0;
-		tcsetattr(2, TCSADRAIN, &newtermio);
-#endif
-#if OSK
-		newsgttyb = oldsgttyb;
-		newsgttyb.sg_echo = 0;
-		newsgttyb.sg_eofch = 0;
-		newsgttyb.sg_kbach = 0;
-		newsgttyb.sg_kbich = ctrl('C');
-		_ss_opt(0, &newsgttyb);
-		ospeed = oldsgttyb.sg_baud;
-		ERASEKEY = oldsgttyb.sg_bspch;
-#endif
-#if AMIGA
-		/* turn on window resize and RAW */
-		ttysetup();
-#endif
-#if MSDOS
-		raw_set_stdio(TRUE);
-#endif
-
-#if VMS
-		VMS_read_raw = 1;
-		{ int c;
-			read(0,&c,0);   /* Flush the tty buffer. */
-		}
-		ERASEKEY = '\177';  /* Accept <DEL> as <^H> for VMS */
-#endif
-
-		if (has_TI)					/* GB */
-		{
-			do_TI();
-		}
-		if (has_KS)
-		{
-			do_KS();
-		}
-
-		curses_active = TRUE;
-	}
-
-	/* If we're supposed to quit quietly, then we're done */
-	if (quietly)
-	{
-		return;
-	}
-
-	signal(SIGINT, SIG_IGN);
-
-	move(LINES - 1, 0);
-	do_SO();
-#if VMS
-	qaddstr("\n[Press <RETURN> to continue]");
-#else
-	qaddstr("[Press <RETURN> to continue]");
-#endif
-	do_SE();
-	refresh();
-	ttyread(kbuf, 20, 0); /* in RAW mode, so <20 is very likely */
-	if (kbuf[0] == ':')
-	{
-		mode = MODE_COLON;
-		addch('\n');
-		refresh();
-	}
-	else
-	{
-		mode = MODE_VI;
-		redraw(MARK_UNSET, FALSE);
-	}	
-	exwrote = FALSE;
-
-#if TURBOC || __GNUC__ || _ANSI
-	signal(SIGINT, (void(*)()) trapint);
-#else
-	signal(SIGINT, trapint);
-#endif
-}
-
-/* This function fetches an optional string from termcap */
-static void mayhave(T, s)
-	char	**T;	/* where to store the returned pointer */
-	char	*s;	/* name of the capability */
-{
-	char	*val;
-
-	val = tgetstr(s, &capbuf);
-	if (val)
-	{
-		*T = val;
-	}
-}
-
-
-/* This function fetches a required string from termcap */
-static void musthave(T, s)
-	char	**T;	/* where to store the returned pointer */
-	char	*s;	/* name of the capability */
-{
-	mayhave(T, s);
-	if (!*T)
-	{
-		write(2, "This termcap entry lacks the :", (unsigned)30);
-		write(2, s, (unsigned)2);
-		write(2, "=: capability\n", (unsigned)14);
-#if OSK
-		write(2, "\l", 1);
-#endif
-		exit(1);
-	}
-}
-
-
-/* This function fetches a pair of strings from termcap.  If one of them is
- * missing, then the other one is ignored.
- */
-static void pair(T, U, sT, sU)
-	char	**T;	/* where to store the first pointer */
-	char	**U;	/* where to store the second pointer */
-	char	*sT;	/* name of the first capability */
-	char	*sU;	/* name of the second capability */
-{
-	mayhave(T, sT);
-	mayhave(U, sU);
-	if (!**T || !**U)
-	{
-		*T = *U = "";
-	}
-}
-
-
-
-/* Read everything from termcap */
-static void starttcap(term)
-	char	*term;
-{
-	static char	cbmem[800];
-
-	/* allocate memory for capbuf */
-	capbuf = cbmem;
-
-	/* get the termcap entry */
-	switch (tgetent(kbuf, term))
-	{
-	  case -1:
-		write(2, "Can't read /etc/termcap\n", (unsigned)24);
-#if OSK
-		write(2, "\l", 1);
-#endif
-		exit(2);
-
-	  case 0:
-		write(2, "Unrecognized TERM type\n", (unsigned)23);
-#if OSK
-		write(2, "\l", 1);
-#endif
-		exit(3);
-	}
-
-	/* get strings */
-	musthave(&UP, "up");
-	mayhave(&VB, "vb");
-	musthave(&CM, "cm");
-	pair(&SO, &SE, "so", "se");
-	mayhave(&TI, "ti");
-	mayhave(&TE, "te");
-	if (tgetnum("ug") <= 0)
-	{
-		pair(&US, &UE, "us", "ue");
-		pair(&MD, &ME, "md", "me");
-
-		/* get italics, or have it default to underline */
-		pair(&AS, &AE, "as", "ae");
-		if (!*AS)
-		{
-			AS = US;
-			AE = UE;
-		}
-	}
-#ifndef NO_VISIBLE
-	MV = SO; /* by default */
-	mayhave(&MV, "mv");
-#endif
-	mayhave(&AL, "al");
-	mayhave(&DL, "dl");
-	musthave(&CE, "ce");
-	mayhave(&CD, "cd");
-#if OSK
-	mayhave(&SR_, "sr");
-#else	
-	mayhave(&SR, "sr");
-#endif
-	pair(&IM, &EI, "im", "ei");
-	mayhave(&IC, "ic");
-	mayhave(&DC, "dc");
-
-	/* other termcap stuff */
-	AM = (tgetflag("am") && !tgetflag("xn"));
-	PT = tgetflag("pt");
-#if AMIGA
-	amiopenwin(termtype);	/* Must run this before ttysetup(); */
-	ttysetup();	/* Must run this before getsize(0); */
-#endif
-	getsize(0);
-
-	/* Key sequences */
-	pair(&KS, &KE, "ks", "ke");
-	mayhave(&KU, "ku");		/* up */
-	mayhave(&KD, "kd");		/* down */
-	mayhave(&KL, "kl");		/* left */
-	mayhave(&KR, "kr");		/* right */
-	mayhave(&PU, "kP");		/* PgUp */
-	mayhave(&PD, "kN");		/* PgDn */
-	mayhave(&HM, "kh");		/* Home */
-	mayhave(&EN, "kH");		/* End */
-	mayhave(&KI, "kI");		/* Insert */
-#ifndef CRUNCH
-	if (!PU) mayhave(&PU, "K2");	/* "3x3 pad" names for PgUp, etc. */
-	if (!PD) mayhave(&PD, "K5");
-	if (!HM) mayhave(&HM, "K1");
-	if (!EN) mayhave(&EN, "K4");
-
-	mayhave(&PU, "PU");		/* old XENIX names for PgUp, etc. */
-	mayhave(&PD, "PD");		/* (overrides others, if used.) */
-	mayhave(&HM, "HM");
-	mayhave(&EN, "EN");
-#endif
-#ifndef NO_FKEY
-	mayhave(&FKEY[0], "k0");		/* function key codes */
-	mayhave(&FKEY[1], "k1");
-	mayhave(&FKEY[2], "k2");
-	mayhave(&FKEY[3], "k3");
-	mayhave(&FKEY[4], "k4");
-	mayhave(&FKEY[5], "k5");
-	mayhave(&FKEY[6], "k6");
-	mayhave(&FKEY[7], "k7");
-	mayhave(&FKEY[8], "k8");
-	mayhave(&FKEY[9], "k9");
-# ifndef NO_SHIFT_FKEY
-	mayhave(&FKEY[10], "s0");		/* shift function key codes */
-	mayhave(&FKEY[11], "s1");
-	mayhave(&FKEY[12], "s2");
-	mayhave(&FKEY[13], "s3");
-	mayhave(&FKEY[14], "s4");
-	mayhave(&FKEY[15], "s5");
-	mayhave(&FKEY[16], "s6");
-	mayhave(&FKEY[17], "s7");
-	mayhave(&FKEY[18], "s8");
-	mayhave(&FKEY[19], "s9");
-#  ifndef NO_CTRL_FKEY
-	mayhave(&FKEY[20], "c0");		/* control function key codes */
-	mayhave(&FKEY[21], "c1");
-	mayhave(&FKEY[22], "c2");
-	mayhave(&FKEY[23], "c3");
-	mayhave(&FKEY[24], "c4");
-	mayhave(&FKEY[25], "c5");
-	mayhave(&FKEY[26], "c6");
-	mayhave(&FKEY[27], "c7");
-	mayhave(&FKEY[28], "c8");
-	mayhave(&FKEY[29], "c9");
-#   ifndef NO_ALT_FKEY
-	mayhave(&FKEY[30], "a0");		/* alt function key codes */
-	mayhave(&FKEY[31], "a1");
-	mayhave(&FKEY[32], "a2");
-	mayhave(&FKEY[33], "a3");
-	mayhave(&FKEY[34], "a4");
-	mayhave(&FKEY[35], "a5");
-	mayhave(&FKEY[36], "a6");
-	mayhave(&FKEY[37], "a7");
-	mayhave(&FKEY[38], "a8");
-	mayhave(&FKEY[39], "a9");
-#   endif
-#  endif
-# endif
-#endif
-
-#ifndef NO_CURSORSHAPE
-	/* cursor shapes */
-	CQ = tgetstr("cQ", &capbuf);
-	if (has_CQ)
-	{
-		CX = tgetstr("cX", &capbuf);
-		if (!CX) CX = CQ;
-		CV = tgetstr("cV", &capbuf);
-		if (!CV) CV = CQ;
-		CI = tgetstr("cI", &capbuf);
-		if (!CI) CI = CQ;
-		CR = tgetstr("cR", &capbuf);
-		if (!CR) CR = CQ;
-	}
-# ifndef CRUNCH
-	else
-	{
-		CQ = CV = "";
-		pair(&CQ, &CV, "ve", "vs");
-		CX = CI = CR = CQ;
-	}
-# endif /* !CRUNCH */
-#endif /* !NO_CURSORSHAPE */
-
-#ifndef NO_COLOR
-	strcpy(SOcolor, SO);
-	strcpy(SEcolor, SE);
-	strcpy(AScolor, AS);
-	strcpy(AEcolor, AE);
-	strcpy(MDcolor, MD);
-	strcpy(MEcolor, ME);
-	strcpy(UScolor, US);
-	strcpy(UEcolor, UE);
-# ifndef NO_POPUP
-	strcpy(POPUPcolor, SO);
-# endif
-# ifndef NO_VISIBLE
-	strcpy(VISIBLEcolor, MV);
-# endif
-#endif
-
-}
-
-
-/* This function gets the window size.  It uses the TIOCGWINSZ ioctl call if
- * your system has it, or tgetnum("li") and tgetnum("co") if it doesn't.
- * This function is called once during initialization, and thereafter it is
- * called whenever the SIGWINCH signal is sent to this process.
- */
-int getsize(signo)
-	int	signo;
-{
-	int	lines;
-	int	cols;
-#ifdef TIOCGWINSZ
-	struct winsize size;
-#endif
-
-#ifdef SIGWINCH
-	/* reset the signal vector */
-	signal(SIGWINCH, getsize);
-#endif
-
-	/* get the window size, one way or another. */
-	lines = cols = 0;
-#ifdef TIOCGWINSZ
-	if (ioctl(2, TIOCGWINSZ, &size) >= 0)
-	{
-		lines = size.ws_row;
-		cols = size.ws_col;
-	}
-#endif
-#if AMIGA
-	/* Amiga gets window size by asking the console.device */
-	if (!strcmp(TERMTYPE, termtype))
-	{
-	    auto long len;
-	    auto char buf[30];
-	    
-	    Write(Output(), "\2330 q", 4); /* Ask the console.device */
-	    len = Read(Input(), buf, 29);
-	    buf[len] = '\000';
-	    sscanf(&buf[5], "%d;%d", &lines, &cols);
-	}
-#endif
-	if ((lines == 0 || cols == 0) && signo == 0)
-	{
-		LINES = tgetnum("li");
-		COLS = tgetnum("co");
-	}
-#if MSDOS
-# ifdef RAINBOW
-	if (!strcmp(termtype, "rainbow"))
-	{
-		/* Determine whether Rainbow is in 80-column or 132-column mode */
-		cols = *(unsigned char far *)0xee000f57L;
-	}
-	else
-# endif
-	{
-		lines = v_rows();
-		cols = v_cols();
-	}
-#endif
-	if (lines >= 2)
-	{
-		LINES = lines;
-	}
-
-	if (cols >= 30)
-	{
-		COLS = cols;
-	}
-
-	/* Make sure we got values that we can live with */
-	if (LINES < 2 || COLS < 30)
-	{
-		write(2, "Screen too small\n", (unsigned)17);
-#if OSK
-		write(2, "\l", 1);
-#endif
-		endwin();
-		exit(2);
-	}
-
-#if AMIGA
-	if (*o_lines != LINES || *o_columns != COLS)
-	{
-		*o_lines = LINES;
-		*o_columns = COLS;
-	}
-#endif
-
-	return 0;
-}
-
-
-/* This is a function version of addch() -- it is used by tputs() */
-int faddch(ch)
-	int	ch;
-{
-	addch(ch);
-
-	return 0;
-}
-
-/* This function quickly adds a string to the output queue.  It does *NOT*
- * convert \n into <CR><LF>.
- */
-void qaddstr(str)
-	char	*str;
-{
-	REG char *s_, *d_;
-
-#if MSDOS
-	if (o_pcbios[0])
-	{
-		while (*str)
-			qaddch(*str++);
-		return;
-	}
-#endif
-	for (s_=(str), d_=stdscr; *d_++ = *s_++; )
-	{
-	}
-	stdscr = d_ - 1;
-}
-
-/* Output the ESC sequence needed to go into any video mode, if supported */
-void attrset(a)
-	int	a;
-{
-	do_aend();
-	if (a == A_BOLD)
-	{
-		do_MD();
-		aend = ME;
-	}
-	else if (a == A_UNDERLINE)
-	{
-		do_US();
-		aend = UE;
-	}
-	else if (a == A_ALTCHARSET)
-	{
-		do_AS();
-		aend = AE;
-	}
-	else
-	{
-		aend = "";
-	}
-}
-
-
-/* Insert a single character into the display */
-void insch(ch)
-	int	ch;
-{
-	if (has_IM)
-		do_IM();
-	do_IC();
-	qaddch(ch);
-	if (has_EI)
-		do_EI();
-}
-
-void wrefresh()
-{
-	if (stdscr != kbuf)
-	{
-		VOIDBIOS(;,ttywrite(kbuf, (unsigned)(stdscr - kbuf)));
-		stdscr = kbuf;
-	}
-}
-
-void wqrefresh()
-{
-	if (stdscr - kbuf > 2000)
-	{
-		VOIDBIOS(stdscr = kbuf,
-		{
-			ttywrite(kbuf, (unsigned)(stdscr - kbuf)); 
-			stdscr = kbuf;
-		});
-	}
-}
-
-#ifndef NO_COLOR
-/* This function is called during termination.  It resets color modes */
-int ansiquit()
-{
-	/* if ANSI color terminal, then reset the colors */
-	if (!strcmp(UP, "\033[A"))
-	{
-		tputs("\033[37;40m\033[m", 1, faddch);
-		clrtoeol();
-		return 1;
-	}
-	return 0;
-}
-
-/* This sets the color strings that work for ANSI terminals.  If the TERMCAP
- * doesn't look like an ANSI terminal, then it returns FALSE.  If the colors
- * aren't understood, it also returns FALSE.  If all goes well, it returns TRUE
- */
-int ansicolor(cmode, attrbyte)
-	int	cmode;		/* mode to set, e.g. A_NORMAL */
-	int	attrbyte;	/* IBM PC attribute byte */
-{
-	char	temp[16];	/* hold the new mode string */
-
-	/* if not ANSI-ish, then fail */
-	if (strcmp(UP, "\033[A") && strcmp(UP, "\033OA"))
-	{
-		msg("Don't know how to set colors for this terminal");
-		return 0;
-	}
-
-	/* construct the color string */
-	sprintf(temp, "\033[m\033[3%c;4%c%s%sm",
-		"04261537"[attrbyte & 0x07],
-		"04261537"[(attrbyte >> 4) & 0x07],
-		(attrbyte & 0x08) ? ";1" : "",
-		(attrbyte & 0x80) ? ";5" : "");
-
-	/* stick it in the right place */
-	switch (cmode)
-	{
-	  case A_NORMAL:
-		if (!strcmp(MEcolor, normalcolor))
-			strcpy(MEcolor, temp);
-		if (!strcmp(UEcolor, normalcolor))
-			strcpy(UEcolor, temp);
-		if (!strcmp(AEcolor, normalcolor))
-			strcpy(AEcolor, temp);
-		if (!strcmp(SEcolor, normalcolor))
-			strcpy(SEcolor, temp);
-
-		strcpy(normalcolor, temp);
-		tputs(normalcolor, 1, faddch);
-		break;
-
-	  case A_BOLD:
-		strcpy(MDcolor, temp);
-		strcpy(MEcolor, normalcolor);
-		break;
-
-	  case A_UNDERLINE:
-		strcpy(UScolor, temp);
-		strcpy(UEcolor, normalcolor);
-		break;
-
-	  case A_ALTCHARSET:
-		strcpy(AScolor, temp);
-		strcpy(AEcolor, normalcolor);
-		break;
-
-	  case A_STANDOUT:
-		strcpy(SOcolor, temp);
-		strcpy(SEcolor, normalcolor);
-		break;
-
-#ifndef NO_POPUP
-	  case A_POPUP:
-		strcpy(POPUPcolor, temp);
-		break;
-#endif
-
-#ifndef NO_VISIBLE
-	  case A_VISIBLE:
-		strcpy(VISIBLEcolor, temp);
-		break;
-#endif
-	}
-
-	return 1;
-}
-
-
-/* This function outputs the ESC sequence needed to switch the screen back
- * to "normal" mode.  On color terminals which haven't had their color set
- * yet, this is one of the termcap strings; for color terminals that really
- * have had colors defined, we just the "normal color" escape sequence.
- */
-endcolor()
-{
-	if (aend == ME)
-		tputs(MEcolor, 1, faddch);
-	else if (aend == UE)
-		tputs(UEcolor, 1, faddch);
-	else if (aend == AE)
-		tputs(AEcolor, 1, faddch);
-	else if (aend == SE)
-		tputs(SEcolor, 1, faddch);
-	aend = "";
-	return 0;
-}
-
-
-#endif /* !NO_COLOR */
Index: trunk/minix/commands/elvis/curses.h
===================================================================
--- trunk/minix/commands/elvis/curses.h	(revision 9)
+++ 	(revision )
@@ -1,319 +1,0 @@
-/* curses.h */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This is the header file for a small, fast, fake curses package */
-
-/* termcap stuff */
-extern char	*tgoto();
-extern char	*tgetstr();
-extern void	tputs();
-
-#if MSDOS
-/* BIOS interface used instead of termcap for MS-DOS */
-extern int	vmode;
-extern void	v_up();
-extern void	v_cb();
-extern void	v_cs();
-extern void	v_ce();
-extern void	v_cl();
-extern void	v_cd();
-extern void	v_al();
-extern void	v_dl();
-extern void	v_sr();
-extern void	v_move();
-#endif
-
-/* faddch() is a function.  a pointer to it is passed to tputs() */
-extern int	faddch();
-
-/* data types */
-#define WINDOW	char
-
-/* CONSTANTS & SYMBOLS */
-#define TRUE		1
-#define FALSE		0
-#define A_NORMAL	0
-#define A_STANDOUT	1
-#define A_BOLD		2
-#define A_UNDERLINE	3
-#define A_ALTCHARSET	4
-#define A_POPUP		5
-#define A_VISIBLE	6
-#define KBSIZ		4096
-
-/* figure out how many function keys we need to allow. */
-#ifndef NO_FKEY
-# ifdef NO_SHIFT_FKEY
-#  define	NFKEYS	10
-# else
-#  ifdef NO_CTRL_FKEY
-#   define	NFKEYS	20
-#  else
-#   ifdef NO_ALT_FKEY
-#    define	NFKEYS	30
-#   else
-#    define	NFKEYS	40
-#   endif
-#  endif
-# endif
-extern char	*FKEY[NFKEYS];	/* :k0=:...:k9=: codes sent by function keys */
-#endif
-
-/* extern variables, defined in curses.c */
-extern char	*termtype;	/* name of terminal entry */
-extern short	ospeed;		/* tty speed, eg B2400 */
-#if OSK
-extern char PC_;	/* Pad char */
-extern char	*BC;	/* Backspace char string */
-#else
-extern char	PC;		/* Pad char */
-#endif
-extern WINDOW	*stdscr;	/* pointer into kbuf[] */
-extern WINDOW	kbuf[KBSIZ];	/* a very large output buffer */
-extern int	LINES;		/* :li#: number of rows */
-extern int	COLS;		/* :co#: number of columns */
-extern int	AM;		/* :am:  boolean: auto margins? */
-extern int	PT;		/* :pt:  boolean: physical tabs? */
-extern char	*VB;		/* :vb=: visible bell */
-extern char	*UP;		/* :up=: move cursor up */
-extern char	*SO;		/* :so=: standout start */
-extern char	*SE;		/* :se=: standout end */
-extern char	*US;		/* :us=: underline start */
-extern char	*UE;		/* :ue=: underline end */
-extern char	*MD;		/* :md=: bold start */
-extern char	*ME;		/* :me=: bold end */
-extern char	*AS;		/* :as=: alternate (italic) start */
-extern char	*AE;		/* :ae=: alternate (italic) end */
-#ifndef NO_VISIBLE
-extern char	*MV;		/* :mv=: "visible" selection start */
-#endif
-extern char	*CM;		/* :cm=: cursor movement */
-extern char	*CE;		/* :ce=: clear to end of line */
-extern char	*CD;		/* :cd=: clear to end of screen */
-extern char	*AL;		/* :al=: add a line */
-extern char	*DL;		/* :dl=: delete a line */
-#if OSK
-extern char	*SR_;		/* :sr=: scroll reverse */
-#else
-extern char	*SR;		/* :sr=: scroll reverse */
-#endif
-extern char	*KS;		/* :ks=: init string for cursor */
-extern char	*KE;		/* :ke=: restore string for cursor */
-extern char	*KU;		/* :ku=: sequence sent by up key */
-extern char	*KD;		/* :kd=: sequence sent by down key */
-extern char	*KL;		/* :kl=: sequence sent by left key */
-extern char	*KR;		/* :kr=: sequence sent by right key */
-extern char	*PU;		/* :PU=: key sequence sent by PgUp key */
-extern char	*PD;		/* :PD=: key sequence sent by PgDn key */
-extern char	*HM;		/* :HM=: key sequence sent by Home key */
-extern char	*EN;		/* :EN=: key sequence sent by End key */
-extern char	*KI;		/* :kI=: key sequence sent by Insert key */
-extern char	*IM;		/* :im=: insert mode start */
-extern char	*IC;		/* :ic=: insert following char */
-extern char	*EI;		/* :ei=: insert mode end */
-extern char	*DC;		/* :dc=: delete a character */
-extern char	*TI;		/* :ti=: terminal init */	/* GB */
-extern char	*TE;		/* :te=: terminal exit */	/* GB */
-#ifndef NO_CURSORSHAPE
-extern char	*CQ;		/* :cQ=: normal cursor */
-extern char	*CX;		/* :cX=: cursor used for EX command/entry */
-extern char	*CV;		/* :cV=: cursor used for VI command mode */
-extern char	*CI;		/* :cI=: cursor used for VI input mode */
-extern char	*CR;		/* :cR=: cursor used for VI replace mode */
-#endif
-extern char	*aend;		/* end an attribute -- either UE or ME */
-extern char	ERASEKEY;	/* taken from the ioctl structure */
-#ifndef NO_COLOR
-extern char	SOcolor[];
-extern char	SEcolor[];
-extern char	UScolor[];
-extern char	UEcolor[];
-extern char	MDcolor[];
-extern char	MEcolor[];
-extern char	AScolor[];
-extern char	AEcolor[];
-# ifndef NO_POPUP
-extern char	POPUPcolor[];
-# endif
-# ifndef NO_VISIBLE
-extern char	VISIBLEcolor[];
-# endif
-extern char	normalcolor[];
-#endif /* undef NO_COLOR */
-
-/* Msdos-versions may use bios; others always termcap.
- * Will emit some 'code has no effect' warnings in unix.
- */
- 
-#if MSDOS
-extern char o_pcbios[1];		/* BAH! */
-#define	CHECKBIOS(x,y)	(*o_pcbios ? (x) : (y))
-#define VOIDBIOS(x,y)	{if (*o_pcbios) {x;} else {y;}}
-#else
-#define	CHECKBIOS(x,y)	(y)
-#define VOIDBIOS(x,y)	{y;}
-#endif
-
-#ifndef NO_COLOR
-# define setcolor(m,a)	CHECKBIOS(bioscolor(m,a), ansicolor(m,a))
-# define fixcolor()	VOIDBIOS(;, tputs(normalcolor, 1, faddch))
-# define quitcolor()	CHECKBIOS(biosquit(), ansiquit())
-# define do_SO()	VOIDBIOS((vmode=A_STANDOUT), tputs(SOcolor, 1, faddch))
-# define do_SE()	VOIDBIOS((vmode=A_NORMAL), tputs(SEcolor, 1, faddch))
-# define do_US()	VOIDBIOS((vmode=A_UNDERLINE), tputs(UScolor, 1, faddch))
-# define do_UE()	VOIDBIOS((vmode=A_NORMAL), tputs(UEcolor, 1, faddch))
-# define do_MD()	VOIDBIOS((vmode=A_BOLD), tputs(MDcolor, 1, faddch))
-# define do_ME()	VOIDBIOS((vmode=A_NORMAL), tputs(MEcolor, 1, faddch))
-# define do_AS()	VOIDBIOS((vmode=A_ALTCHARSET), tputs(AScolor, 1, faddch))
-# define do_AE()	VOIDBIOS((vmode=A_NORMAL), tputs(AEcolor, 1, faddch))
-# define do_POPUP()	VOIDBIOS((vmode=A_POPUP), tputs(POPUPcolor, 1, faddch))
-# define do_VISIBLE()	VOIDBIOS((vmode=A_VISIBLE), tputs(VISIBLEcolor, 1, faddch))
-#else
-# define do_SO()	VOIDBIOS((vmode=A_STANDOUT), tputs(SO, 1, faddch))
-# define do_SE()	VOIDBIOS((vmode=A_NORMAL), tputs(SE, 1, faddch))
-# define do_US()	VOIDBIOS((vmode=A_UNDERLINE), tputs(US, 1, faddch))
-# define do_UE()	VOIDBIOS((vmode=A_NORMAL), tputs(UE, 1, faddch))
-# define do_MD()	VOIDBIOS((vmode=A_BOLD), tputs(MD, 1, faddch))
-# define do_ME()	VOIDBIOS((vmode=A_NORMAL), tputs(ME, 1, faddch))
-# define do_AS()	VOIDBIOS((vmode=A_ALTCHARSET), tputs(AS, 1, faddch))
-# define do_AE()	VOIDBIOS((vmode=A_NORMAL), tputs(AE, 1, faddch))
-# define do_POPUP()	VOIDBIOS((vmode=A_POPUP), tputs(SO, 1, faddch))
-# define do_VISIBLE()	VOIDBIOS((vmode=A_VISIBLE), tputs(MV, 1, faddch))
-#endif
-
-#define	do_VB()		VOIDBIOS(;, tputs(VB, 1, faddch))
-#define	do_UP()		VOIDBIOS(v_up(), tputs(UP, 1, faddch))
-#undef	do_CM		/* move */
-#define	do_CE()		VOIDBIOS(v_ce(), tputs(CE, 1, faddch))
-#define	do_CD()		VOIDBIOS(v_cd(), tputs(CD, 1, faddch))
-#define	do_AL()		VOIDBIOS(v_al(), tputs(AL, LINES, faddch))
-#define	do_DL()		VOIDBIOS(v_dl(), tputs(DL, LINES, faddch))
-#if OSK
-#define	do_SR()		VOIDBIOS(v_sr(), tputs(SR_, 1, faddch))
-#else
-#define	do_SR()		VOIDBIOS(v_sr(), tputs(SR, 1, faddch))
-#endif
-#define do_KS()		VOIDBIOS(1, tputs(KS, 1, faddch))
-#define do_KE()		VOIDBIOS(1, tputs(KE, 1, faddch))
-#define	do_IM()		VOIDBIOS(;, tputs(IM, 1, faddch))
-#define	do_IC()		VOIDBIOS(;, tputs(IC, 1, faddch))
-#define	do_EI()		VOIDBIOS(;, tputs(EI, 1, faddch))
-#define	do_DC()		VOIDBIOS(;, tputs(DC, COLS, faddch))
-#define	do_TI()		VOIDBIOS(;, (void)ttywrite(TI, (unsigned)strlen(TI)))
-#define	do_TE()		VOIDBIOS(;, (void)ttywrite(TE, (unsigned)strlen(TE)))
-#ifndef NO_CURSORSHAPE
-# define do_CQ()	VOIDBIOS(v_cs(), tputs(CQ, 1, faddch))
-# define do_CX()	VOIDBIOS(v_cs(), tputs(CX, 1, faddch))
-# define do_CV()	VOIDBIOS(v_cs(), tputs(CV, 1, faddch))
-# define do_CI()	VOIDBIOS(v_cb(), tputs(CI, 1, faddch))
-# define do_CR()	VOIDBIOS(v_cb(), tputs(CR, 1, faddch))
-#endif
-#ifndef NO_COLOR
-# define do_aend()	VOIDBIOS((vmode=A_NORMAL), endcolor())
-#else
-# define do_aend()	VOIDBIOS((vmode=A_NORMAL), tputs(aend, 1, faddch))
-#endif
-
-#define	has_AM		CHECKBIOS(1, AM)
-#define	has_PT		CHECKBIOS(0, PT)
-#define	has_VB		CHECKBIOS((char *)0, VB)
-#define	has_UP		CHECKBIOS((char *)1, UP)
-#define	has_SO		CHECKBIOS((char)1, (*SO))
-#define	has_SE		CHECKBIOS((char)1, (*SE))
-#define	has_US		CHECKBIOS((char)1, (*US))
-#define	has_UE		CHECKBIOS((char)1, (*UE))
-#define	has_MD		CHECKBIOS((char)1, (*MD))
-#define	has_ME		CHECKBIOS((char)1, (*ME))
-#define	has_AS		CHECKBIOS((char)1, (*AS))
-#define	has_AE		CHECKBIOS((char)1, (*AE))
-#undef	has_CM		/* cursor move: don't need */
-#define	has_CB		CHECKBIOS(1, 0)
-#define	has_CS		CHECKBIOS(1, 0)
-#define	has_CE		CHECKBIOS((char *)1, CE)
-#define	has_CD		CHECKBIOS((char *)1, CD)
-#define	has_AL		CHECKBIOS((char *)1, AL)
-#define	has_DL		CHECKBIOS((char *)1, DL)
-#if OSK
-#define	has_SR		CHECKBIOS((char *)1, SR_)
-#else
-#define	has_SR		CHECKBIOS((char *)1, SR)
-#endif
-#define has_KS		CHECKBIOS((char)1, (*KS))
-#define has_KE		CHECKBIOS((char)1, (*KE))
-#define	has_KU		KU
-#define	has_KD		KD
-#define	has_KL		KL
-#define	has_KR		KR
-#define has_HM		HM
-#define has_EN		EN
-#define has_PU		PU
-#define has_PD		PD
-#define has_KI		KI
-#define	has_IM		CHECKBIOS((char)0, (*IM))
-#define	has_IC		CHECKBIOS((char)0, (*IC))
-#define	has_EI		CHECKBIOS((char)0, (*EI))
-#define	has_DC		CHECKBIOS((char *)0, DC)
-#define	has_TI		CHECKBIOS((char)0, (*TI))
-#define	has_TE		CHECKBIOS((char)0, (*TE))
-#ifndef NO_CURSORSHAPE
-#define has_CQ		CHECKBIOS((char *)1, CQ)
-#endif
-
-/* (pseudo)-Curses-functions */
-
-#ifdef lint
-# define _addCR		VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : (stdscr[-1] = '\n')))
-#else
-# if OSK
-#  define _addCR	VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\l') : (stdscr[-1] = stdscr[-1])))
-# else
-#  define _addCR	VOIDBIOS(;, (stdscr[-1] == '\n' ? qaddch('\r') : 0))
-# endif
-#endif
-
-#ifdef AZTEC_C
-# define qaddch(ch)	CHECKBIOS(v_put(ch), (*stdscr = (ch), *stdscr++))
-#else
-#define qaddch(ch)	CHECKBIOS(v_put(ch), (*stdscr++ = (ch)))
-#endif
-
-#if OSK
-#define addch(ch)	if (qaddch(ch) == '\n') qaddch('\l'); else
-#else
-#define addch(ch)	if (qaddch(ch) == '\n') qaddch('\r'); else
-#endif
-
-extern void initscr();
-extern void endwin();
-extern void suspend_curses();
-extern void resume_curses();
-extern void attrset();
-extern void insch();
-extern void qaddstr();
-extern void wrefresh();
-extern void wqrefresh();
-#define addstr(str)	{qaddstr(str); _addCR;}
-#define move(y,x)	VOIDBIOS(v_move(x,y), tputs(tgoto(CM, x, y), 1, faddch))
-#define mvaddch(y,x,ch)	{move(y,x); addch(ch);}
-#define refresh()	VOIDBIOS(;, wrefresh())
-#define standout()	do_SO()
-#define standend()	do_SE()
-#define clrtoeol()	do_CE()
-#define clrtobot()	do_CD()
-#define insertln()	do_AL()
-#define deleteln()	do_DL()
-#define delch()		do_DC()
-#define scrollok(w,b)
-#define raw()
-#define echo()
-#define cbreak()
-#define noraw()
-#define noecho()
-#define nocbreak()
Index: trunk/minix/commands/elvis/cut.c
===================================================================
--- trunk/minix/commands/elvis/cut.c	(revision 9)
+++ 	(revision )
@@ -1,700 +1,0 @@
-/* cut.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains function which manipulate the cut buffers. */
-
-#include "config.h"
-#include "vi.h"
-#if TURBOC
-#include <process.h>		/* needed for getpid */
-#endif
-#if TOS
-#include <osbind.h>
-#define	rename(a,b)	Frename(0,a,b)
-#endif
-
-# define NANONS	9	/* number of anonymous buffers */
-
-static struct cutbuf
-{
-	short	*phys;	/* pointer to an array of #s of BLKs containing text */
-	int	nblks;	/* number of blocks in phys[] array */
-	int	start;	/* offset into first block of start of cut */
-	int	end;	/* offset into last block of end of cut */
-	int	tmpnum;	/* ID number of the temp file */
-	char	lnmode;	/* boolean: line-mode cut? (as opposed to char-mode) */
-}
-	named[27],	/* cut buffers "a through "z and ". */
-	anon[NANONS];	/* anonymous cut buffers */
-
-static char	cbname;	/* name chosen for next cut/paste operation */
-static char	dotcb;	/* cut buffer to use if "doingdot" is set */
-
-
-#ifndef NO_RECYCLE
-/* This function builds a list of all blocks needed in the current tmp file
- * for the contents of cut buffers.
- * !!! WARNING: if you have more than ~450000 bytes of text in all of the
- * cut buffers, then this will fail disastrously, because buffer overflow
- * is *not* allowed for.
- */
-int cutneeds(need)
-	BLK		*need;	/* this is where we deposit the list */
-{
-	struct cutbuf	*cb;	/* used to count through cut buffers */
-	int		i;	/* used to count through blocks of a cut buffer */
-	int		n;	/* total number of blocks in list */
-
-	n = 0;
-
-	/* first the named buffers... */
-	for (cb = named; cb < &named[27]; cb++)
-	{
-		if (cb->tmpnum != tmpnum)
-			continue;
-
-		for (i = cb->nblks; i-- > 0; )
-		{
-			need->n[n++] = cb->phys[i];
-		}
-	}
-
-	/* then the anonymous buffers */
-	for (cb = anon; cb < &anon[NANONS]; cb++)
-	{
-		if (cb->tmpnum != tmpnum)
-			continue;
-
-		for (i = cb->nblks; i-- > 0; )
-		{
-			need->n[n++] = cb->phys[i];
-		}
-	}
-
-	/* return the length of the list */
-	return n;
-}
-#endif
-
-static void maybezap(num)
-	int	num;	/* the tmpnum of the temporary file to [maybe] delete */
-{
-	char	cutfname[80];
-	int	i;
-
-	/* if this is the current tmp file, then we'd better keep it! */
-	if (tmpfd >= 0 && num == tmpnum)
-	{
-		return;
-	}
-
-	/* see if anybody else needs this tmp file */
-	for (i = 27; --i >= 0; )
-	{
-		if (named[i].nblks > 0 && named[i].tmpnum == num)
-		{
-			break;
-		}
-	}
-	if (i < 0)
-	{
-		for (i = NANONS; --i >= 0 ; )
-		{
-			if (anon[i].nblks > 0 && anon[i].tmpnum == num)
-			{
-				break;
-			}
-		}
-	}
-
-	/* if nobody else needs it, then discard the tmp file */
-	if (i < 0)
-	{
-#if MSDOS || TOS
-		strcpy(cutfname, o_directory);
-		if ((i = strlen(cutfname)) && !strchr(":/\\", cutfname[i - 1]))
-			cutfname[i++] = SLASH;
-		sprintf(cutfname + i, TMPNAME + 3, getpid(), num);
-#else
-		sprintf(cutfname, TMPNAME, o_directory, getpid(), num);
-#endif
-		unlink(cutfname);
-	}
-}
-
-/* This function frees a cut buffer.  If it was the last cut buffer that
- * refered to an old temp file, then it will delete the temp file. */
-static void cutfree(buf)
-	struct cutbuf	*buf;
-{
-	int	num;
-
-	/* return immediately if the buffer is already empty */
-	if (buf->nblks <= 0)
-	{
-		return;
-	}
-
-	/* else free up stuff */
-	num = buf->tmpnum;
-	buf->nblks = 0;
-#ifdef DEBUG
-	if (!buf->phys)
-		msg("cutfree() tried to free a NULL buf->phys pointer.");
-	else
-#endif
-	free((char *)buf->phys);
-
-	/* maybe delete the temp file */
-	maybezap(num);
-}
-
-/* This function is called when we are about to abort a tmp file.
- *
- * To minimize the number of extra files lying around, only named cut buffers
- * are preserved in a file switch; the anonymous buffers just go away.
- */
-void cutswitch()
-{
-	int	i;
-
-	/* mark the current temp file as being "obsolete", and close it.  */
-	storename((char *)0);
-	close(tmpfd);
-	tmpfd = -1;
-
-	/* discard all anonymous cut buffers */
-	for (i = 0; i < NANONS; i++)
-	{
-		cutfree(&anon[i]);
-	}
-
-	/* delete the temp file, if we don't really need it */
-	maybezap(tmpnum);
-}
-
-/* This function should be called just before termination of vi */
-void cutend()
-{
-	int	i;
-
-	/* free the anonymous buffers, if they aren't already free */
-	cutswitch();
-
-	/* free all named cut buffers, since they might be forcing an older
-	 * tmp file to be retained.
-	 */
-	for (i = 0; i < 27; i++)
-	{
-		cutfree(&named[i]);
-	}
-
-	/* delete the temp file */
-	maybezap(tmpnum);
-}
-
-
-/* This function is used to select the cut buffer to be used next */
-void cutname(name)
-	int	name;	/* a single character */
-{
-	cbname = name;
-}
-
-
-
-
-/* This function copies a selected segment of text to a cut buffer */
-void cut(from, to)
-	MARK	from;		/* start of text to cut */
-	MARK	to;		/* end of text to cut */
-{
-	int		first;	/* logical number of first block in cut */
-	int		last;	/* logical number of last block used in cut */
-	long		line;	/* a line number */
-	int		lnmode;	/* boolean: will this be a line-mode cut? */
-	MARK		delthru;/* end of text temporarily inserted for apnd */
-	REG struct cutbuf *cb;
-	REG long	l;
-	REG int		i;
-	REG char	*scan;
-	char		*blkc;
-
-	/* detect whether this must be a line-mode cut or char-mode cut */
-	if (markidx(from) == 0 && markidx(to) == 0)
-		lnmode = TRUE;
-	else
-		lnmode = FALSE;
-
-	/* by default, we don't "delthru" anything */
-	delthru = MARK_UNSET;
-
-	/* handle the "doingdot" quirks */
-	if (doingdot)
-	{
-		if (!cbname)
-		{
-			cbname = dotcb;
-		}
-	}
-	else if (cbname != '.')
-	{
-		dotcb = cbname;
-	}
-
-	/* decide which cut buffer to use */
-	if (!cbname)
-	{
-		/* free up the last anonymous cut buffer */
-		cutfree(&anon[NANONS - 1]);
-
-		/* shift the anonymous cut buffers */
-		for (i = NANONS - 1; i > 0; i--)
-		{
-			anon[i] = anon[i - 1];
-		}
-
-		/* use the first anonymous cut buffer */
-		cb = anon;
-		cb->nblks = 0;
-	}
-	else if (cbname >= 'a' && cbname <= 'z')
-	{
-		cb = &named[cbname - 'a'];
-		cutfree(cb);
-	}
-#ifndef CRUNCH
-	else if (cbname >= 'A' && cbname <= 'Z')
-	{
-		cb = &named[cbname - 'A'];
-		if (cb->nblks > 0)
-		{
-			/* resolve linemode/charmode differences */
-			if (!lnmode && cb->lnmode)
-			{
-				from &= ~(BLKSIZE - 1);
-				if (markidx(to) != 0 || to == from)
-				{
-					to = to + BLKSIZE - markidx(to);
-				}
-				lnmode = TRUE;
-			}
-
-			/* insert the old cut-buffer before the new text */
-			mark[28] = to;
-			delthru = paste(from, FALSE, TRUE);
-			if (delthru == MARK_UNSET)
-			{
-				return;
-			}
-			delthru++;
-			to = mark[28];
-		}
-		cutfree(cb);
-	}
-#endif /* not CRUNCH */
-	else if (cbname == '.')
-	{
-		cb = &named[26];
-		cutfree(cb);
-	}
-	else
-	{
-		msg("Invalid cut buffer name: \"%c", cbname);
-		dotcb = cbname = '\0';
-		return;
-	}
-	cbname = '\0';
-	cb->tmpnum = tmpnum;
-
-	/* detect whether we're doing a line mode cut */
-	cb->lnmode = lnmode;
-
-	/* ---------- */
-
-	/* Reporting... */	
-	if (markidx(from) == 0 && markidx(to) == 0)
-	{
-		rptlines = markline(to) - markline(from);
-		rptlabel = "yanked";
-	}
-
-	/* ---------- */
-
-	/* make sure each block has a physical disk address */
-	blksync();
-
-	/* find the first block in the cut */
-	line = markline(from);
-	for (first = 1; line > lnum[first]; first++)
-	{
-	}
-
-	/* fetch text of the block containing that line */
-	blkc = scan = blkget(first)->c;
-
-	/* find the mark in the block */
-	for (l = lnum[first - 1]; ++l < line; )
-	{
-		while (*scan++ != '\n')
-		{
-		}
-	}
-	scan += markidx(from);
-
-	/* remember the offset of the start */
-	cb->start = scan - blkc;
-
-	/* ---------- */
-
-	/* find the last block in the cut */
-	line = markline(to);
-	for (last = first; line > lnum[last]; last++)
-	{
-	}
-
-	/* fetch text of the block containing that line */
-	if (last != first)
-	{
-		blkc = scan = blkget(last)->c;
-	}
-	else
-	{
-		scan = blkc;
-	}
-
-	/* find the mark in the block */
-	for (l = lnum[last - 1]; ++l < line; )
-	{
-		while (*scan++ != '\n')
-		{
-		}
-	}
-	if (markline(to) <= nlines)
-	{
-		scan += markidx(to);
-	}
-
-	/* remember the offset of the end */
-	cb->end = scan - blkc;
-
-	/* ------- */
-
-	/* remember the physical block numbers of all included blocks */
-	cb->nblks = last - first;
-	if (cb->end > 0)
-	{
-		cb->nblks++;
-	}
-#ifdef lint
-	cb->phys = (short *)0;
-#else
-	cb->phys = (short *)malloc((unsigned)(cb->nblks * sizeof(short)));
-#endif
-	for (i = 0; i < cb->nblks; i++)
-	{
-		cb->phys[i] = hdr.n[first++];
-	}
-
-#ifndef CRUNCH
-	/* if we temporarily inserted text for appending, then delete that
-	 * text now -- before the user sees it.
-	 */
-	if (delthru)
-	{
-		line = rptlines;
-		delete(from, delthru);
-		rptlines = line;
-		rptlabel = "yanked";
-	}
-#endif /* not CRUNCH */
-}
-
-
-static void readcutblk(cb, blkno)
-	struct cutbuf	*cb;
-	int		blkno;
-{
-	char		cutfname[50];/* name of an old temp file */
-	int		fd;	/* either tmpfd or the result of open() */
-#if MSDOS || TOS
-	int		i;
-#endif
-
-	/* decide which fd to use */
-	if (cb->tmpnum == tmpnum)
-	{
-		fd = tmpfd;
-	}
-	else
-	{
-#if MSDOS || TOS
-		strcpy(cutfname, o_directory);
-		if ((i = strlen(cutfname)) && !strchr(":/\\", cutfname[i-1]))
-			cutfname[i++]=SLASH;
-		sprintf(cutfname+i, TMPNAME+3, getpid(), cb->tmpnum);
-#else
-		sprintf(cutfname, TMPNAME, o_directory, getpid(), cb->tmpnum);
-#endif
-		fd = open(cutfname, O_RDONLY);
-	}
-
-	/* get the block */
-	lseek(fd, (long)cb->phys[blkno] * (long)BLKSIZE, 0);
-	if (read(fd, tmpblk.c, (unsigned)BLKSIZE) != BLKSIZE)
-	{
-		msg("Error reading back from tmp file for pasting!");
-	}
-
-	/* close the fd, if it isn't tmpfd */
-	if (fd != tmpfd)
-	{
-		close(fd);
-	}
-}
-
-
-/* This function inserts text from a cut buffer, and returns the MARK where
- * insertion ended.  Return MARK_UNSET on errors.
- */
-MARK paste(at, after, retend)
-	MARK	at;	/* where to insert the text */
-	int	after;	/* boolean: insert after mark? (rather than before) */
-	int	retend;	/* boolean: return end of text? (rather than start) */
-{
-	REG struct cutbuf	*cb;
-	REG int			i;
-
-	/* handle the "doingdot" quirks */
-	if (doingdot)
-	{
-		if (!cbname)
-		{
-			if (dotcb >= '1' && dotcb < '1' + NANONS - 1)
-			{
-				dotcb++;
-			}
-			cbname = dotcb;
-		}
-	}
-	else if (cbname != '.')
-	{
-		dotcb = cbname;
-	}
-
-	/* decide which cut buffer to use */
-	if (cbname >= 'A' && cbname <= 'Z')
-	{
-		cb = &named[cbname - 'A'];
-	}
-	else if (cbname >= 'a' && cbname <= 'z')
-	{
-		cb = &named[cbname - 'a'];
-	}
-	else if (cbname >= '1' && cbname <= '9')
-	{
-		cb = &anon[cbname - '1'];
-	}
-	else if (cbname == '.')
-	{
-		cb = &named[26];
-	}
-	else if (!cbname)
-	{
-		cb = anon;
-	}
-	else
-	{
-		msg("Invalid cut buffer name: \"%c", cbname);
-		cbname = '\0';
-		return MARK_UNSET;
-	}
-
-	/* make sure it isn't empty */
-	if (cb->nblks == 0)
-	{
-		if (cbname)
-			msg("Cut buffer \"%c is empty", cbname);
-		else
-			msg("Cut buffer is empty");
-		cbname = '\0';
-		return MARK_UNSET;
-	}
-	cbname = '\0';
-
-	/* adjust the insertion MARK for "after" and line-mode cuts */
-	if (cb->lnmode)
-	{
-		at &= ~(BLKSIZE - 1);
-		if (after)
-		{
-			at += BLKSIZE;
-		}
-	}
-	else if (after)
-	{
-		/* careful! if markidx(at) == 0 we might be pasting into an
-		 * empty line -- so we can't blindly increment "at".
-		 */
-		if (markidx(at) == 0)
-		{
-			pfetch(markline(at));
-			if (plen != 0)
-			{
-				at++;
-			}
-		}
-		else
-		{
-			at++;
-		}
-	}
-
-	/* put a copy of the "at" mark in the mark[] array, so it stays in
-	 * sync with changes made via add().
-	 */
-	mark[27] = at;
-
-	/* simple one-block paste? */
-	if (cb->nblks == 1)
-	{
-		/* get the block */
-		readcutblk(cb, 0);
-
-		/* isolate the text we need within it */
-		if (cb->end)
-		{
-			tmpblk.c[cb->end] = '\0';
-		}
-
-		/* insert it */
-		ChangeText
-		{
-			add(at, &tmpblk.c[cb->start]);
-		}
-	}
-	else
-	{
-		/* multi-block paste */
-
-		ChangeText
-		{
-			i = cb->nblks - 1;
-
-			/* add text from the last block first */
-			if (cb->end > 0)
-			{
-				readcutblk(cb, i);
-				tmpblk.c[cb->end] = '\0';
-				add(at, tmpblk.c);
-				i--;
-			}
-
-			/* add intervening blocks */
-			while (i > 0)
-			{
-				readcutblk(cb, i);
-				add(at, tmpblk.c);
-				i--;
-			}
-
-			/* add text from the first cut block */
-			readcutblk(cb, 0);
-			add(at, &tmpblk.c[cb->start]);
-		}
-	}
-
-	/* Reporting... */
-	rptlines = markline(mark[27]) - markline(at);
-	rptlabel = "pasted";
-
-	/* return the mark at the beginning/end of inserted text */
-	if (retend)
-	{
-		return mark[27] - 1L;
-	}
-	return at;
-}
-
-
-
-
-#ifndef NO_AT
-
-/* This function copies characters from a cut buffer into a string.
- * It returns the number of characters in the cut buffer.  If the cut
- * buffer is too large to fit in the string (i.e. if cb2str() returns
- * a number >= size) then the characters will not have been copied.
- * It returns 0 if the cut buffer is empty, and -1 for invalid cut buffers.
- */
-int cb2str(name, buf, size)
-	int	name;	/* the name of a cut-buffer to get: a-z only! */
-	char	*buf;	/* where to put the string */
-	unsigned size;	/* size of buf */
-{
-	REG struct cutbuf	*cb;
-	REG char		*src;
-	REG char		*dest;
-
-	/* decide which cut buffer to use */
-	if (name >= 'a' && name <= 'z')
-	{
-		cb = &named[name - 'a'];
-	}
-	else
-	{
-		return -1;
-	}
-
-	/* if the buffer is empty, return 0 */
-	if (cb->nblks == 0)
-	{
-		return 0;
-	}
-
-	/* !!! if not a single-block cut, then fail */
-	if (cb->nblks != 1)
-	{
-		return size;
-	}
-
-	/* if too big, return the size now, without doing anything */
-	if (cb->end - cb->start >= size)
-	{
-		return cb->end - cb->start;
-	}
-
-	/* get the block */
-	readcutblk(cb, 0);
-
-	/* isolate the string within that blk */
-	if (cb->start == 0)
-	{
-		tmpblk.c[cb->end] = '\0';
-	}
-	else
-	{
-		for (dest = tmpblk.c, src = dest + cb->start; src < tmpblk.c + cb->end; )
-		{
-			*dest++ = *src++;
-		}
-		*dest = '\0';
-	}
-
-	/* copy the string into the buffer */
-	if (buf != tmpblk.c)
-	{
-		strcpy(buf, tmpblk.c);
-	}
-
-	/* return the length */
-	return cb->end - cb->start;
-}
-#endif
Index: trunk/minix/commands/elvis/elvprsv.c
===================================================================
--- trunk/minix/commands/elvis/elvprsv.c	(revision 9)
+++ 	(revision )
@@ -1,287 +1,0 @@
-/* elvprsv.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the portable sources for the "elvprsv" program.
- * "Elvprsv" is run by Elvis when Elvis is about to die.  It is also
- * run when the computer boots up.  It is not intended to be run directly
- * by the user, ever.
- *
- * Basically, this program does the following four things:
- *    - It extracts the text from the temporary file, and places the text in
- *	a file in the /usr/preserve directory.
- *    - It adds a line to the /usr/preserve/Index file, describing the file
- *	that it just preserved.
- *    - It removes the temporary file.
- *    -	It sends mail to the owner of the file, saying that the file was
- *	preserved, and how it can be recovered.
- *
- * The /usr/preserve/Index file is a log file that contains one line for each
- * file that has ever been preserved.  Each line of this file describes one
- * preserved file.  The first word on the line is the name of the file that
- * contains the preserved text.  The second word is the full pathname of the
- * file that was being edited; for anonymous buffers, this is the directory
- * name plus "/foo".
- *
- * If elvprsv's first argument (after the command name) starts with a hyphen,
- * then the characters after the hyphen are used as a description of when
- * the editor went away.  This is optional.
- *
- * The remaining arguments are all the names of temporary files that are
- * to be preserved.  For example, on a UNIX system, the /etc/rc file might
- * invoke it this way:
- *
- *	elvprsv "-the system went down" /tmp/elv_*.*
- *
- * This file contains only the portable parts of the preserve program.
- * It must #include a system-specific file.  The system-specific file is
- * expected to define the following functions:
- *
- *	char *ownername(char *filename)	- returns name of person who owns file
- *
- *	void mail(char *user, char *name, char *when)
- *					- tell user that file was preserved
- */
-
-#include <stdio.h>
-#include "config.h"
-#include "vi.h"
-
-#if AMIGA
-BLK tmpblk;
-#error AMIGA here DEBUG
-# include "amiwild.c"
-# include "amiprsv.c"
-#endif
-
-#if OSK
-# undef sprintf
-#endif
-
-#if ANY_UNIX || OSK
-# include "prsvunix.c"
-#endif
-
-#if MSDOS || TOS
-# include "prsvdos.c"
-# define WILDCARD_NO_MAIN
-# include "wildcard.c"
-#endif
-
-
-BLK	buf;
-BLK	hdr;
-BLK	name;
-int	rewrite_now;	/* boolean: should we send text directly to orig file? */
-
-
-
-/* This function preserves a single file, and announces its success/failure
- * via an e-mail message.
- */
-void preserve(tname, when)
-	char	*tname;		/* name of a temp file to be preserved */
-	char	*when;		/* description of when the editor died */
-{
-	int	infd;		/* fd used for reading from the temp file */
-	FILE	*outfp;		/* fp used for writing to the recovery file */
-	FILE	*index;		/* fp used for appending to index file */
-	char	outname[100];	/* the name of the recovery file */
-	char	*user;		/* name of the owner of the temp file */
-#if AMIGA
-	char	*prsvdir;
-#endif
-	int	i;
-
-	/* open the temp file */
-	infd = open(tname, O_RDONLY|O_BINARY);
-	if (infd < 0)
-	{
-		/* if we can't open the file, then we should assume that
-		 * the filename contains wildcard characters that weren't
-		 * expanded... and also assume that they weren't expanded
-		 * because there are no files that need to be preserved.
-		 * THEREFORE... we should silently ignore it.
-		 * (Or loudly ignore it if the user was using -R)
-		 */
-		if (rewrite_now)
-		{
-			perror(tname);
-		}
-		return;
-	}
-
-	/* read the header and name from the file */
-	if (read(infd, hdr.c, BLKSIZE) != BLKSIZE
-	 || read(infd, name.c, BLKSIZE) != BLKSIZE)
-	{
-		/* something wrong with the file - sorry */
-		fprintf(stderr, "%s: trucated header blocks\n", tname);
-		close(infd);
-		return;
-	}
-
-	/* If the filename block contains an empty string, then Elvis was
-	 * only keeping the temp file around because it contained some text
-	 * that was needed for a named cut buffer.  The user doesn't care
-	 * about that kind of temp file, so we should silently delete it.
-	 */
-	if (name.c[0] == '\0' && name.c[1] == '\177')
-	{
-		close(infd);
-		unlink(tname);
-		return;
-	}
-
-	if (rewrite_now)
-	{
-		/* we don't need to open the index file */
-		index = (FILE *)0;
-
-		/* make sure we can read every block! */
-		for (i = 1; i < MAXBLKS && hdr.n[i]; i++)
-		{
-			lseek(infd, (long)hdr.n[i] * (long)BLKSIZE, 0);
-			if (read(infd, buf.c, BLKSIZE) != BLKSIZE)
-			{
-				/* messed up header */
-				fprintf(stderr, "%s: unrecoverable -- header trashed\n", name.c);
-				close(infd);
-				return;
-			}
-		}
-
-		/* open the user's file for writing */
-		outfp = fopen(name.c, "w");
-		if (!outfp)
-		{
-			perror(name.c);
-			close(infd);
-			return;
-		}
-	}
-	else
-	{
-		/* open/create the index file */
-		index = fopen(PRSVINDEX, "a");
-		if (!index)
-		{
-			perror(PRSVINDEX);
-			exit(1);
-		}
-
-		/* create the recovery file in the PRESVDIR directory */
-#if AMIGA
-		prsvdir = &PRSVDIR[strlen(PRSVDIR) - 1];
-		if (*prsvdir == '/' || *prsvdir == ':')
-		{
-			sprintf(outname, "%sp%ld", PRSVDIR, ftell(index));
-		}
-		else
-#endif
-		sprintf(outname, "%s%cp%ld", PRSVDIR, SLASH, ftell(index));
-		outfp = fopen(outname, "w");
-		if (!outfp)
-		{
-			perror(outname);
-			close(infd);
-			fclose(index);
-			return;
-		}
-	}
-
-	/* write the text of the file out to the recovery file */
-	for (i = 1; i < MAXBLKS && hdr.n[i]; i++)
-	{
-		lseek(infd, (long)hdr.n[i] * (long)BLKSIZE, 0);
-		if (read(infd, buf.c, BLKSIZE) != BLKSIZE)
-		{
-			/* messed up header */
-			fprintf(stderr, "%s: unrecoverable -- header trashed\n", name.c);
-			fclose(outfp);
-			close(infd);
-			if (index)
-			{
-				fclose(index);
-			}
-			unlink(outname);
-			return;
-		}
-		fputs(buf.c, outfp);
-	}
-
-	/* add a line to the index file */
-	if (index)
-	{
-		fprintf(index, "%s %s\n", outname, name.c);
-	}
-
-	/* close everything */
-	close(infd);
-	fclose(outfp);
-	if (index)
-	{
-		fclose(index);
-	}
-
-	/* Are we doing this due to something more frightening than just
-	 * a ":preserve" command?
-	 */
-	if (*when)
-	{
-		/* send a mail message */
-		mail(ownername(tname), name.c, when);
-
-		/* remove the temp file -- the editor has died already */
-		unlink(tname);
-	}
-}
-
-main(argc, argv)
-	int	argc;
-	char	**argv;
-{
-	int	i;
-	char	*when = "the editor went away";
-
-#if MSDOS || TOS
-	/* expand any wildcards in the command line */
-	argv = wildexpand(&argc, argv);
-#endif
-
-	/* do we have a "when" argument? */
-	i = 1;
-	if (argc >= i + 1 && !strcmp(argv[i], "-R"))
-	{
-		rewrite_now = 1;
-		when = "";
-		i++;
-#if ANY_UNIX
-		setuid(geteuid());
-#endif
-	}
-#if OSK
-	else
-	{
-		setuid(0);
-	}
-#endif
-	if (argc >= i + 1 && argv[i][0] == '-')
-	{
-		when = argv[i] + 1;
-		i++;
-	}
-
-	/* preserve everything we're supposed to */
-	while (i < argc)
-	{
-		preserve(argv[i], when);
-		i++;
-	}
-}
Index: trunk/minix/commands/elvis/elvrec.c
===================================================================
--- trunk/minix/commands/elvis/elvrec.c	(revision 9)
+++ 	(revision )
@@ -1,199 +1,0 @@
-/* elvrec.c */
-
-/* This file contains the file recovery program */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-#include <stdio.h>
-#include "config.h"
-#include "vi.h"
-#include <sys/stat.h>
-
-void recover(basename, outname)
-	char	*basename;	/* the name of the file to recover */
-	char	*outname;	/* the name of the file to write to */
-{
-	char	pathname[500];	/* full pathname of the file to recover */
-	char	line[600];	/* a line from the /usr/preserve/Index file */
-	int	ch;		/* a character from the text being recovered */
-	FILE	*from;		/* the /usr/preserve file, or /usr/preserve/Index */
-	FILE	*to;		/* the user's text file */
-	char	*ptr;
-	struct stat st;
-#if OSK
-	int		uid;
-#endif
-
-	/* convert basename to a full pathname */
-	if (basename)
-	{
-#ifndef CRUNCH
-# if MSDOS || TOS
-		if (!basename[0] || basename[1] != ':')
-# else
-		if (basename[0] != SLASH)
-# endif
-		{
-			ptr = getcwd(pathname, sizeof pathname);
-			if (ptr != pathname)
-			{
-				strcpy(pathname, ptr);
-			}
-			ptr = pathname + strlen(pathname);
-			*ptr++ = SLASH;
-			strcpy(ptr, basename);
-		}
-		else
-#endif
-		{
-			strcpy(pathname, basename);
-		}
-	}
-
-#if OSK
-	uid = getuid();
-	if(setuid(0))
-		exit(_errmsg(errno, "Can't set uid\n"));
-#endif
-	/* scan the /usr/preserve/Index file, for the *oldest* unrecovered
-	 * version of this file.
-	 */
-	from = fopen(PRSVINDEX, "r");
-	while (from && fgets(line, sizeof line, from))
-	{
-		/* strip off the newline from the end of the string */
-		line[strlen(line) - 1] = '\0';
-
-		/* parse the line into a "preserve" name and a "text" name */
-		for (ptr = line; *ptr != ' '; ptr++)
-		{
-		}
-		*ptr++ = '\0';
-
-		/* If the "preserve" file is missing, then ignore this line
-		 * because it describes a file that has already been recovered.
-		 */
-		if (stat(line, &st) < 0)
-		{
-			continue;
-		}
-
-		/* are we looking for a specific file? */
-		if (basename)
-		{
-			/* quit if we found it */
-			if (!strcmp(ptr, pathname))
-			{
-				break;
-			}
-		}
-		else
-		{
-			/* list this file as "available for recovery" */
-			puts(ptr);
-		}
-	}
-
-	/* file not found? */
-	if (!basename || !from || feof(from))
-	{
-		if (from != NULL) fclose(from);
-		if (basename)
-		{
-			fprintf(stderr, "%s: no recovered file has that exact name\n", pathname);
-		}
-		return;
-	}
-	if (from != NULL) fclose(from);
-
-	/* copy the recovered text back into the user's file... */
-
-	/* open the /usr/preserve file for reading */
-	from = fopen(line, "r");
-	if (!from)
-	{
-		perror(line);
-		exit(2);
-	}
-
-#if ANY_UNIX
-	/* Be careful about user-id.  We want to be running under the user's
-	 * real id when we open/create the user's text file... but we want
-	 * to be superuser when we delete the /usr/preserve file.  For UNIX,
-	 * we accomplish this by deleting the /usr/preserve file *now*,
-	 * when it is open but before we've read it.  Then we revert to the
-	 * user's real id.
-	 */
-	unlink(line);
-	setuid(getuid());
-#endif
-#if OSK
-	setuid(uid);
-#endif
-
-	if (outname == NULL) return;
-
-	/* open the user's file for writing */
-	to = fopen(outname, "w");
-	if (!to)
-	{
-		perror(ptr);
-		exit(2);
-	}
-
-	/* copy the text */
-	while ((ch = getc(from)) != EOF)
-	{
-		putc(ch, to);
-	}
-
-#if !ANY_UNIX
-#if OSK
-	fclose(from);
-	setuid(0);
-#endif
-	/* delete the /usr/preserve file */
-	unlink(line);
-#if OSK
-	setuid(uid);
-#endif
-#endif
-}
-
-main(argc, argv)
-	int	argc;
-	char	**argv;
-{
-	/* check arguments */
-	if (argc > 3)
-	{
-		fprintf(stderr, "usage: %s [preserved_file [recovery_file]]\n", argv[0]);
-		exit(1);
-	}
-
-	/* recover the requested file, or list recoverable files */
-	if (argc == 3)
-	{
-		/* recover the file, but write it to a different filename */
-		recover (argv[1], argv[2]);
-	}
-	else if (argc == 2)
-	{
-		/* recover the file */
-		recover(argv[1], argv[1]);
-	}
-	else
-	{
-		/* list the recoverable files */
-		recover((char *)0, (char *)0);
-	}
-
-	/* success! */
-	exit(0);
-}
Index: trunk/minix/commands/elvis/ex.c
===================================================================
--- trunk/minix/commands/elvis/ex.c	(revision 9)
+++ 	(revision )
@@ -1,722 +1,0 @@
-/* ex.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the code for reading ex commands. */
-
-#include "config.h"
-#include "ctype.h"
-#include "vi.h"
-
-/* This data type is used to describe the possible argument combinations */
-typedef short ARGT;
-#define FROM	1		/* allow a linespec */
-#define	TO	2		/* allow a second linespec */
-#define BANG	4		/* allow a ! after the command name */
-#define EXTRA	8		/* allow extra args after command name */
-#define XFILE	16		/* expand wildcards in extra part */
-#define NOSPC	32		/* no spaces allowed in the extra part */
-#define	DFLALL	64		/* default file range is 1,$ */
-#define DFLNONE	128		/* no default file range */
-#define NODFL	256		/* do not default to the current file name */
-#define EXRCOK	512		/* can be in a .exrc file */
-#define NL	1024		/* if mode!=MODE_EX, then write a newline first */
-#define PLUS	2048		/* allow a line number, as in ":e +32 foo" */
-#define ZERO	4096		/* allow 0 to be given as a line number */
-#define NOBAR	8192		/* treat following '|' chars as normal */
-#define FILES	(XFILE + EXTRA)	/* multiple extra files allowed */
-#define WORD1	(EXTRA + NOSPC)	/* one extra word allowed */
-#define FILE1	(FILES + NOSPC)	/* 1 file allowed, defaults to current file */
-#define NAMEDF	(FILE1 + NODFL)	/* 1 file allowed, defaults to "" */
-#define NAMEDFS	(FILES + NODFL)	/* multiple files allowed, default is "" */
-#define RANGE	(FROM + TO)	/* range of linespecs allowed */
-#define NONE	0		/* no args allowed at all */
-
-/* This array maps ex command names to command codes. The order in which
- * command names are listed below is significant -- ambiguous abbreviations
- * are always resolved to be the first possible match.  (e.g. "r" is taken
- * to mean "read", not "rewind", because "read" comes before "rewind")
- */
-static struct
-{
-	char	*name;	/* name of the command */
-	CMD	code;	/* enum code of the command */
-	void	(*fn)();/* function which executes the command */
-	ARGT	argt;	/* command line arguments permitted/needed/used */
-}
-	cmdnames[] =
-{   /*	cmd name	cmd code	function	arguments */
-	{"append",	CMD_APPEND,	cmd_append,	FROM+ZERO+BANG	},
-#ifdef DEBUG
-	{"bug",		CMD_DEBUG,	cmd_debug,	RANGE+BANG+EXTRA+NL},
-#endif
-	{"change",	CMD_CHANGE,	cmd_append,	RANGE+BANG	},
-	{"delete",	CMD_DELETE,	cmd_delete,	RANGE+WORD1	},
-	{"edit",	CMD_EDIT,	cmd_edit,	BANG+FILE1+PLUS	},
-	{"file",	CMD_FILE,	cmd_file,	NAMEDF		},
-	{"global",	CMD_GLOBAL,	cmd_global,	RANGE+BANG+EXTRA+DFLALL+NOBAR},
-	{"insert",	CMD_INSERT,	cmd_append,	FROM+BANG	},
-	{"join",	CMD_INSERT,	cmd_join,	RANGE+BANG	},
-	{"k",		CMD_MARK,	cmd_mark,	FROM+WORD1	},
-	{"list",	CMD_LIST,	cmd_print,	RANGE+NL	},
-	{"move",	CMD_MOVE,	cmd_move,	RANGE+EXTRA	},
-	{"next",	CMD_NEXT,	cmd_next,	BANG+NAMEDFS	},
-	{"Next",	CMD_PREVIOUS,	cmd_next,	BANG		},
-	{"print",	CMD_PRINT,	cmd_print,	RANGE+NL	},
-	{"quit",	CMD_QUIT,	cmd_xit,	BANG		},
-	{"read",	CMD_READ,	cmd_read,	FROM+ZERO+NAMEDF},
-	{"substitute",	CMD_SUBSTITUTE,	cmd_substitute,	RANGE+EXTRA	},
-	{"to",		CMD_COPY,	cmd_move,	RANGE+EXTRA	},
-	{"undo",	CMD_UNDO,	cmd_undo,	NONE		},
-	{"vglobal",	CMD_VGLOBAL,	cmd_global,	RANGE+EXTRA+DFLALL+NOBAR},
-	{"write",	CMD_WRITE,	cmd_write,	RANGE+BANG+FILE1+DFLALL},
-	{"xit",		CMD_XIT,	cmd_xit,	BANG+NL		},
-	{"yank",	CMD_YANK,	cmd_delete,	RANGE+WORD1	},
-
-	{"!",		CMD_BANG,	cmd_shell,	EXRCOK+RANGE+NAMEDFS+DFLNONE+NL+NOBAR},
-	{"#",		CMD_NUMBER,	cmd_print,	RANGE+NL	},
-	{"<",		CMD_SHIFTL,	cmd_shift,	RANGE		},
-	{">",		CMD_SHIFTR,	cmd_shift,	RANGE		},
-	{"=",		CMD_EQUAL,	cmd_file,	RANGE		},
-	{"&",		CMD_SUBAGAIN,	cmd_substitute,	RANGE		},
-#ifndef NO_AT
-	{"@",		CMD_AT,		cmd_at,		EXTRA		},
-#endif
-
-#ifndef NO_ABBR
-	{"abbreviate",	CMD_ABBR,	cmd_map,	EXRCOK+BANG+EXTRA},
-#endif
-	{"args",	CMD_ARGS,	cmd_args,	EXRCOK+NAMEDFS	},
-#ifndef NO_ERRLIST
-	{"cc",		CMD_CC,		cmd_make,	BANG+FILES	},
-#endif
-	{"cd",		CMD_CD,		cmd_cd,		EXRCOK+BANG+NAMEDF},
-	{"copy",	CMD_COPY,	cmd_move,	RANGE+EXTRA	},
-#ifndef NO_DIGRAPH
-	{"digraph",	CMD_DIGRAPH,	cmd_digraph,	EXRCOK+BANG+EXTRA},
-#endif
-#ifndef NO_ERRLIST
-	{"errlist",	CMD_ERRLIST,	cmd_errlist,	BANG+NAMEDF	},
-#endif
-	{"ex",		CMD_EDIT,	cmd_edit,	BANG+FILE1	},
-	{"mark",	CMD_MARK,	cmd_mark,	FROM+WORD1	},
-#ifndef NO_MKEXRC
-	{"mkexrc",	CMD_MKEXRC,	cmd_mkexrc,	NAMEDF		},
-#endif
-	{"number",	CMD_NUMBER,	cmd_print,	RANGE+NL	},
-	{"put",		CMD_PUT,	cmd_put,	FROM+ZERO+WORD1	},
-	{"set",		CMD_SET,	cmd_set,	EXRCOK+EXTRA	},
-	{"shell",	CMD_SHELL,	cmd_shell,	NL		},
-	{"source",	CMD_SOURCE,	cmd_source,	EXRCOK+NAMEDF	},
-#ifdef SIGTSTP
-	{"stop",	CMD_STOP,	cmd_suspend,	NONE		},
-#endif
-	{"tag",		CMD_TAG,	cmd_tag,	BANG+WORD1	},
-	{"version",	CMD_VERSION,	cmd_version,	EXRCOK+NONE	},
-	{"visual",	CMD_VISUAL,	cmd_edit,	BANG+NAMEDF	},
-	{"wq",		CMD_WQUIT,	cmd_xit,	NL		},
-
-#ifdef DEBUG
-	{"debug",	CMD_DEBUG,	cmd_debug,	RANGE+BANG+EXTRA+NL},
-	{"validate",	CMD_VALIDATE,	cmd_validate,	BANG+NL		},
-#endif
-	{"chdir",	CMD_CD,		cmd_cd,		EXRCOK+BANG+NAMEDF},
-#ifndef NO_COLOR
-	{"color",	CMD_COLOR,	cmd_color,	EXRCOK+EXTRA	},
-#endif
-#ifndef NO_ERRLIST
-	{"make",	CMD_MAKE,	cmd_make,	BANG+NAMEDFS	},
-#endif
-	{"map",		CMD_MAP,	cmd_map,	EXRCOK+BANG+EXTRA},
-	{"previous",	CMD_PREVIOUS,	cmd_next,	BANG		},
-	{"rewind",	CMD_REWIND,	cmd_next,	BANG		},
-#ifdef SIGTSTP
-	{"suspend",	CMD_SUSPEND,	cmd_suspend,	NONE		},
-#endif
-	{"unmap",	CMD_UNMAP,	cmd_map,	EXRCOK+BANG+EXTRA},
-#ifndef NO_ABBR
-	{"unabbreviate",CMD_UNABBR,	cmd_map,	EXRCOK+WORD1	},
-#endif
-
-	{(char *)0}
-};
-
-
-/* This function parses a search pattern - given a pointer to a / or ?,
- * it replaces the ending / or ? with a \0, and returns a pointer to the
- * stuff that came after the pattern.
- */
-char	*parseptrn(ptrn)
-	REG char	*ptrn;
-{
-	REG char 	*scan;
-
-	for (scan = ptrn + 1;
-	     *scan && *scan != *ptrn;
-	     scan++)
-	{
-		/* allow backslashed versions of / and ? in the pattern */
-		if (*scan == '\\' && scan[1] != '\0')
-		{
-			scan++;
-		}
-	}
-	if (*scan)
-	{
-		*scan++ = '\0';
-	}
-
-	return scan;
-}
-
-
-/* This function parses a line specifier for ex commands */
-char *linespec(s, markptr)
-	REG char	*s;		/* start of the line specifier */
-	MARK		*markptr;	/* where to store the mark's value */
-{
-	long		num;
-	REG char	*t;
-
-	/* parse each ;-delimited clause of this linespec */
-	do
-	{
-		/* skip an initial ';', if any */
-		if (*s == ';')
-		{
-			s++;
-		}
-
-		/* skip leading spaces */
-		while (isspace(*s))
-		{
-			s++;
-		}
-
-		/* dot means current position */
-		if (*s == '.')
-		{
-			s++;
-			*markptr = cursor;
-		}
-		/* '$' means the last line */
-		else if (*s == '$')
-		{
-			s++;
-			*markptr = MARK_LAST;
-		}
-		/* digit means an absolute line number */
-		else if (isdigit(*s))
-		{
-			for (num = 0; isdigit(*s); s++)
-			{
-				num = num * 10 + *s - '0';
-			}
-			*markptr = MARK_AT_LINE(num);
-		}
-		/* appostrophe means go to a set mark */
-		else if (*s == '\'')
-		{
-			s++;
-			*markptr = m_tomark(cursor, 1L, (int)*s);
-			s++;
-		}
-		/* slash means do a search */
-		else if (*s == '/' || *s == '?')
-		{
-			/* put a '\0' at the end of the search pattern */
-			t = parseptrn(s);
-
-			/* search for the pattern */
-			*markptr &= ~(BLKSIZE - 1);
-			if (*s == '/')
-			{
-				pfetch(markline(*markptr));
-				if (plen > 0)
-					*markptr += plen - 1;
-				*markptr = m_fsrch(*markptr, s);
-			}
-			else
-			{
-				*markptr = m_bsrch(*markptr, s);
-			}
-
-			/* adjust command string pointer */
-			s = t;
-		}
-
-		/* if linespec was faulty, quit now */
-		if (!*markptr)
-		{
-			return s;
-		}
-
-		/* maybe add an offset */
-		t = s;
-		if (*t == '-' || *t == '+')
-		{
-			s++;
-			for (num = 0; isdigit(*s); s++)
-			{
-				num = num * 10 + *s - '0';
-			}
-			if (num == 0)
-			{
-				num = 1;
-			}
-			*markptr = m_updnto(*markptr, num, *t);
-		}
-	} while (*s == ';' || *s == '+' || *s == '-');
-
-	/* protect against invalid line numbers */
-	num = markline(*markptr);
-	if (num < 1L || num > nlines)
-	{
-		msg("Invalid line number -- must be from 1 to %ld", nlines);
-		*markptr = MARK_UNSET;
-	}
-
-	return s;
-}
-
-
-
-/* This function reads an ex command and executes it. */
-void ex()
-{
-	char		cmdbuf[150];
-	REG int		cmdlen;
-	static long	oldline;
-
-	significant = FALSE;
-	oldline = markline(cursor);
-
-	while (mode == MODE_EX)
-	{
-		/* read a line */
-#ifdef CRUNCH
-		cmdlen = vgets(':', cmdbuf, sizeof(cmdbuf));
-#else
-		cmdlen = vgets(*o_prompt ? ':' : '\0', cmdbuf, sizeof(cmdbuf));
-#endif
-		if (cmdlen < 0)
-		{
-			return;
-		}
-
-		/* if empty line, assume ".+1" */
-		if (cmdlen == 0)
-		{
-			strcpy(cmdbuf, ".+1");
-			qaddch('\r');
-			clrtoeol();
-		}
-		else
-		{
-			addch('\n');
-		}
-		refresh();
-
-		/* parse & execute the command */
-		doexcmd(cmdbuf);
-
-		/* handle autoprint */
-		if (significant || markline(cursor) != oldline)
-		{
-			significant = FALSE;
-			oldline = markline(cursor);
-			if (*o_autoprint && mode == MODE_EX)
-			{
-				cmd_print(cursor, cursor, CMD_PRINT, FALSE, "");
-			}
-		}
-	}
-}
-
-void doexcmd(cmdbuf)
-	char		*cmdbuf;	/* string containing an ex command */
-{
-	REG char	*scan;		/* used to scan thru cmdbuf */
-	MARK		frommark;	/* first linespec */
-	MARK		tomark;		/* second linespec */
-	REG int		cmdlen;		/* length of the command name given */
-	CMD		cmd;		/* what command is this? */
-	ARGT		argt;		/* argument types for this command */
-	short		forceit;	/* bang version of a command? */
-	REG int		cmdidx;		/* index of command */
-	REG char	*build;		/* used while copying filenames */
-	int		iswild;		/* boolean: filenames use wildcards? */
-	int		isdfl;		/* using default line ranges? */
-	int		didsub;		/* did we substitute file names for % or # */
-
-	/* ex commands can't be undone via the shift-U command */
-	U_line = 0L;
-
-	/* permit extra colons at the start of the line */
-	for (; *cmdbuf == ':'; cmdbuf++)
-	{
-	}
-
-	/* ignore command lines that start with a double-quote */
-	if (*cmdbuf == '"')
-	{
-		return;
-	}
-	scan = cmdbuf;
-
-	/* parse the line specifier */
-	if (nlines < 1)
-	{
-		/* no file, so don't allow addresses */
-	}
-	else if (*scan == '%')
-	{
-		/* '%' means all lines */
-		frommark = MARK_FIRST;
-		tomark = MARK_LAST;
-		scan++;
-	}
-	else if (*scan == '0')
-	{
-		frommark = tomark = MARK_UNSET;
-		scan++;
-	}
-	else
-	{
-		frommark = cursor;
-		scan = linespec(scan, &frommark);
-		tomark = frommark;
-		if (frommark && *scan == ',')
-		{
-			scan++;
-			scan = linespec(scan, &tomark);
-		}
-		if (!tomark)
-		{
-			/* faulty line spec -- fault already described */
-			return;
-		}
-		if (frommark > tomark)
-		{
-			msg("first address exceeds the second");
-			return;
-		}
-	}
-	isdfl = (scan == cmdbuf);
-
-	/* skip whitespace */
-	while (isspace(*scan))
-	{
-		scan++;
-	}
-
-	/* if no command, then just move the cursor to the mark */
-	if (!*scan)
-	{
-		if (tomark != MARK_UNSET)
-			cursor = tomark;
-		return;
-	}
-
-	/* figure out how long the command name is */
-	if (!isalpha(*scan))
-	{
-		cmdlen = 1;
-	}
-	else
-	{
-		for (cmdlen = 1;
-		     isalpha(scan[cmdlen]);
-		     cmdlen++)
-		{
-		}
-	}
-
-	/* lookup the command code */
-	for (cmdidx = 0;
-	     cmdnames[cmdidx].name && strncmp(scan, cmdnames[cmdidx].name, cmdlen);
-	     cmdidx++)
-	{
-	}
-	argt = cmdnames[cmdidx].argt;
-	cmd = cmdnames[cmdidx].code;
-	if (cmd == CMD_NULL)
-	{
-		msg("Unknown command \"%.*s\"", cmdlen, scan);
-		return;
-	}
-
-	/* !!! if the command doesn't have NOBAR set, then replace | with \0 */
-
-	/* if the command ended with a bang, set the forceit flag */
-	scan += cmdlen;
-	if ((argt & BANG) && *scan == '!')
-	{
-		scan++;
-		forceit = 1;
-	}
-	else
-	{
-		forceit = 0;
-	}
-
-	/* skip any more whitespace, to leave scan pointing to arguments */
-	while (isspace(*scan))
-	{
-		scan++;
-	}
-
-	/* a couple of special cases for filenames */
-	if (argt & XFILE)
-	{
-		/* if names were given, process them */
-		if (*scan)
-		{
-			for (build = tmpblk.c, iswild = didsub = FALSE; *scan; scan++)
-			{
-				switch (*scan)
-				{
-				  case '\\':
-					if (scan[1] == '\\' || scan[1] == '%' || scan[1] == '#')
-					{
-						*build++ = *++scan;
-					}
-					else
-					{
-						*build++ = '\\';
-					}
-					break;
-
-				  case '%':
-					if (!*origname)
-					{
-						msg("No filename to substitute for %%");
-						return;
-					}
-					strcpy(build, origname);
-					while (*build)
-					{
-						build++;
-					}
-					didsub = TRUE;
-					break;
-
-				  case '#':
-					if (!*prevorig)
-					{
-						msg("No filename to substitute for #");
-						return;
-					}
-					strcpy(build, prevorig);
-					while (*build)
-					{
-						build++;
-					}
-					didsub = TRUE;
-					break;
-
-				  case '*':
-				  case '?':
-#if !(MSDOS || TOS)
-				  case '[':
-				  case '`':
-				  case '{': /* } */
-				  case '$':
-				  case '~':
-#endif
-					*build++ = *scan;
-					iswild = TRUE;
-					break;
-
-				  default:
-					*build++ = *scan;
-				}
-			}
-			*build = '\0';
-
-			if (cmd == CMD_BANG
-			 || cmd == CMD_READ && tmpblk.c[0] == '!'
-			 || cmd == CMD_WRITE && tmpblk.c[0] == '!')
-			{
-				if (didsub)
-				{
-					if (mode != MODE_EX)
-					{
-						addch('\n');
-					}
-					addstr(tmpblk.c);
-					addch('\n');
-					exrefresh();
-				}
-			}
-			else
-			{
-				if (iswild && tmpblk.c[0] != '>')
-				{
-					scan = wildcard(tmpblk.c);
-				}
-			}
-		}
-		else /* no names given, maybe assume origname */
-		{
-			if (!(argt & NODFL))
-			{
-				strcpy(tmpblk.c, origname);
-			}
-			else
-			{
-				*tmpblk.c = '\0';
-			}
-		}
-
-		scan = tmpblk.c;
-	}
-
-	/* bad arguments? */
-	if (!(argt & EXRCOK) && nlines < 1L)
-	{
-		msg("Can't use the \"%s\" command in a %s file", cmdnames[cmdidx].name, EXRC);
-		return;
-	}
-	if (!(argt & (ZERO | EXRCOK)) && frommark == MARK_UNSET)
-	{
-		msg("Can't use address 0 with \"%s\" command.", cmdnames[cmdidx].name);
-		return;
-	}
-	if (!(argt & FROM) && frommark != cursor && nlines >= 1L)
-	{
-		msg("Can't use address with \"%s\" command.", cmdnames[cmdidx].name);
-		return;
-	}
-	if (!(argt & TO) && tomark != frommark && nlines >= 1L)
-	{
-		msg("Can't use a range with \"%s\" command.", cmdnames[cmdidx].name);
-		return;
-	}
-	if (!(argt & EXTRA) && *scan)
-	{
-		msg("Extra characters after \"%s\" command.", cmdnames[cmdidx].name);
-		return;
-	}
-	if ((argt & NOSPC) && !(cmd == CMD_READ && (forceit || *scan == '!')))
-	{
-		build = scan;
-#ifndef CRUNCH
-		if ((argt & PLUS) && *build == '+')
-		{
-			while (*build && !isspace(*build))
-			{
-				build++;
-			}
-			while (*build && isspace(*build))
-			{
-				build++;
-			}
-		}
-#endif /* not CRUNCH */
-		for (; *build; build++)
-		{
-			if (isspace(*build))
-			{
-				msg("Too many %s to \"%s\" command.",
-					(argt & XFILE) ? "filenames" : "arguments",
-					cmdnames[cmdidx].name);
-				return;
-			}
-		}
-	}
-
-	/* some commands have special default ranges */
-	if (isdfl && (argt & DFLALL))
-	{
-		frommark = MARK_FIRST;
-		tomark = MARK_LAST;
-	}
-	else if (isdfl && (argt & DFLNONE))
-	{
-		frommark = tomark = 0L;
-	}
-
-	/* write a newline if called from visual mode */
-	if ((argt & NL) && mode != MODE_EX && !exwrote)
-	{
-		addch('\n');
-		exrefresh();
-	}
-
-	/* act on the command */
-	(*cmdnames[cmdidx].fn)(frommark, tomark, cmd, forceit, scan);
-}
-
-
-/* This function executes EX commands from a file.  It returns 1 normally, or
- * 0 if the file could not be opened for reading.
- */
-int doexrc(filename)
-	char	*filename;	/* name of a ".exrc" file */
-{
-	int	fd;		/* file descriptor */
-	int	len;		/* length of the ".exrc" file */
-
-	/* !!! kludge: we use U_text as the buffer.  This has the side-effect
-	 * of interfering with the shift-U visual command.  Disable shift-U.
-	 */
-	U_line = 0L;
-
-	/* open the file, read it, and close */
-	fd = open(filename, O_RDONLY);
-	if (fd < 0)
-	{
-		return 0;
-	}
-	len = tread(fd, U_text, BLKSIZE);
-	close(fd);
-
-	/* execute the string */
-	exstring(U_text, len, ctrl('V'));
-
-	return 1;
-}
-
-/* This function executes EX commands from a string.  The commands may be
- * separated by newlines or by | characters.  It also handles quoting.
- * Each individual command is limited to 132 bytes, but the total string
- * may be longer.
- */
-void exstring(buf, len, qchar)
-	char	*buf;	/* the commands to execute */
-	int	len;	/* the length of the string */
-	int	qchar;	/* the quote character -- ^V for file, or \ for kbd */
-{
-	char	single[133];	/* a single command */
-	char	*src, *dest;
-	int	i;
-
-	/* find & do each command */
-	for (src = buf; src < &buf[len]; src++)
-	{
-		/* Copy a single command into single[].  Convert any quoted |
-		 * into a normal |, and stop at a newline or unquoted |.
-		 */
-		for (dest = single, i = 0;
-		     i < 132 && src < &buf[len] && *src != '\n' && *src != '|';
-		     src++, i++)
-		{
-			if (src[0] == qchar && src[1] == '|')
-			{
-				src++;
-			}
-			*dest++ = *src;
-		}
-		*dest = '\0';
-
-		/* do it */
-		doexcmd(single);
-	}
-}
Index: trunk/minix/commands/elvis/fmt.c
===================================================================
--- trunk/minix/commands/elvis/fmt.c	(revision 9)
+++ 	(revision )
@@ -1,266 +1,0 @@
-/* fmt.c */
-
-/* usage: fmt [-width] [files]...
- *
- * Fmt rearrages text in order to make each line have roughly the
- * same width.  Indentation and word spacing is preserved.
- *
- * The default width is 72 characters, but you can override that via -width.
- * If no files are given on the command line, then it reads stdin.
- */
-
-#include <stdio.h>
-
-#ifndef TRUE
-# define TRUE	1
-# define FALSE	0
-#endif
-
-
-
-int	width = 72;	/* the desired line width */
-int	isblank;	/* is the current output line blank? */
-int	indent;		/* width of the indentation */
-char	ind[512];	/* indentation text */
-char	word[1024];	/* word buffer */
-
-/* This function displays a usage message and quits */
-void usage()
-{
-	fprintf(stderr, "usage: fmt [-width] [files]...\n");
-	exit(2);
-}
-
-
-
-/* This function outputs a single word.  It takes care of spacing and the
- * newlines within a paragraph.
- */
-void putword()
-{
-	int		i;		/* index into word[], or whatever */
-	int		ww;		/* width of the word */
-	int		sw;		/* width of spacing after word */
-	static int	psw;		/* space width of previous word */
-	static int	tab;		/* the width of text already written */
-
-
-	/* separate the word and its spacing */
-	for (ww = 0; word[ww] && word[ww] != ' '; ww++)
-	{
-	}
-	sw = strlen(word) - ww;
-	word[ww] = '\0';
-
-	/* if no spacing (that is, the word was at the end of the line) then
-	 * assume 1 space unless the last char of the word was punctuation
-	 */
-	if (sw == 0)
-	{
-		sw = 1;
-		if (word[ww - 1] == '.' || word[ww - 1] == '?' || word[ww - 1] == '!')
-			sw = 2;
-	}
-
-	/* if this is the first word on the line... */
-	if (isblank)
-	{
-		/* output the indentation first */
-		fputs(ind, stdout);
-		tab = indent;
-	}
-	else /* text has already been written to this output line */
-	{
-		/* will the word fit on this line? */
-		if (psw + ww + tab <= width)
-		{
-			/* yes - so write the previous word's spacing */
-			for (i = 0; i < psw; i++)
-			{
-				putchar(' ');
-			}
-			tab += psw;
-		}
-		else
-		{
-			/* no, so write a newline and the indentation */
-			putchar('\n');
-			fputs(ind, stdout);
-			tab = indent;
-		}
-	}
-
-	/* write the word itself */
-	fputs(word, stdout);
-	tab += ww;
-
-	/* remember this word's spacing */
-	psw = sw;
-
-	/* this output line isn't blank anymore. */
-	isblank = FALSE;
-}
-
-
-
-/* This function reformats text. */
-void fmt(in)
-	FILE	*in;		/* the name of the input stream */
-{
-	int	ch;		/* character from input stream */
-	int	prevch;		/* the previous character in the loop */
-	int	i;		/* index into ind[] or word[] */
-	int	inword;		/* boolean: are we between indent & newline? */
-
-
-	/* for each character in the stream... */
-	for (indent = -1, isblank = TRUE, inword = FALSE, i = 0, prevch = '\n';
-	     (ch = getc(in)) != EOF;
-	     prevch = ch)
-	{
-		/* is this the end of a line? */
-		if (ch == '\n')
-		{
-			/* if end of last word in the input line */
-			if (inword)
-			{
-				/* if it really is a word */
-				if (i > 0)
-				{
-					/* output it */
-					word[i] = '\0';
-					putword();
-				}
-			}
-			else /* blank line in input */
-			{
-				/* finish the previous paragraph */
-				if (!isblank)
-				{
-					putchar('\n');
-					isblank = TRUE;
-				}
-
-				/* output a blank line */
-				putchar('\n');
-			}
-
-			/* continue with next input line... */
-			indent = -1;
-			i = 0;
-			inword = FALSE;
-			continue;
-		}
-
-		/* if we're expecting indentation now... */
-		if (indent < 0)
-		{
-			/* if this is part of the indentation... */
-			if (ch == ' ' || ch == '\t')
-			{
-				/* remember it */
-				ind[i++] = ch;
-			}
-			else /* end of indentation */
-			{
-				/* mark the end of the indentation string */
-				ind[i] = '\0';
-
-				/* calculate the width of the indentation */
-				for (i = indent = 0; ind[i]; i++)
-				{
-					if (ind[i] == '\t')
-						indent = (indent | 7) + 1;
-					else
-						indent++;
-				}
-
-				/* reset the word index */
-				i = 0;
-
-				/* reprocess that last character */
-				ungetc(ch, in);
-			}
-
-			/* continue in the for-loop */
-			continue;
-		}
-
-		/* if we get here, we're either in a word or in the space
-		 * after a word.
-		 */
-		inword = TRUE;
-
-		/* is this the start of a new word? */
-		if (ch != ' ' && prevch == ' ')
-		{
-			/* yes!  output the previous word */
-			word[i] = '\0';
-			putword();
-
-			/* reset `i' to the start of the word[] buffer */
-			i = 0;
-		}
-		word[i++] = ch;
-	}
-
-	/* if necessary, write a final newline */
-	if (!isblank)
-	{
-		putchar('\n');
-		isblank = TRUE;
-	}
-}
-
-
-
-
-
-int main(argc, argv)
-	int	argc;
-	char	**argv;
-{
-	FILE	*in;	/* an input stream */
-	int	error;	/* if non-zero, then an error occurred */
-	int	i;
-
-
-	/* handle the -width flag, if given */
-	if (argc > 1 && argv[1][0] == '-')
-	{
-		width = atoi(argv[1] + 1);
-		if (width <= 0)
-		{
-			usage();
-		}
-		argc--;
-		argv++;
-	}
-
-	/* if no filenames given, then process stdin */
-	if (argc == 1)
-	{
-		fmt(stdin);
-	}
-	else /* one or more filenames given */
-	{
-		for (error = 0, i = 1; i < argc; i++)
-		{
-			in = fopen(argv[i], "r");
-			if (!in)
-			{
-				perror(argv[i]);
-				error = 3;
-			}
-			else
-			{
-				fmt(in);
-				fclose(in);
-			}
-		}
-	}
-
-	/* exit, possibly indicating an error */
-	exit(error);
-	/*NOTREACHED*/
-}
Index: trunk/minix/commands/elvis/input.c
===================================================================
--- trunk/minix/commands/elvis/input.c	(revision 9)
+++ 	(revision )
@@ -1,852 +1,0 @@
-/* input.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the input() function, which implements vi's INPUT mode.
- * It also contains the code that supports digraphs.
- */
-
-#include "config.h"
-#include "ctype.h"
-#include "vi.h"
-
-
-#ifndef NO_DIGRAPH
-static struct _DIG
-{
-	struct _DIG	*next;
-	char		key1;
-	char		key2;
-	char		dig;
-	char		save;
-} *digs;
-
-char digraph(key1, key2)
-	char	key1;	/* the underlying character */
-	char	key2;	/* the second character */
-{
-	int		newkey;
-	REG struct _DIG	*dp;
-
-	/* if digraphs are disabled, then just return the new char */
-	if (!*o_digraph)
-	{
-		return key2;
-	}
-
-	/* remember the new key, so we can return it if this isn't a digraph */
-	newkey = key2;
-
-	/* sort key1 and key2, so that their original order won't matter */
-	if (key1 > key2)
-	{
-		key2 = key1;
-		key1 = newkey;
-	}
-
-	/* scan through the digraph chart */
-	for (dp = digs;
-	     dp && (dp->key1 != key1 || dp->key2 != key2);
-	     dp = dp->next)
-	{
-	}
-
-	/* if this combination isn't in there, just use the new key */
-	if (!dp)
-	{
-		return newkey;
-	}
-
-	/* else use the digraph key */
-	return dp->dig;
-}
-
-/* this function lists or defines digraphs */
-void do_digraph(bang, extra)
-	int	bang;
-	char	extra[];
-{
-	int		dig;
-	REG struct _DIG	*dp;
-	struct _DIG	*prev;
-	static int	user_defined = FALSE; /* boolean: are all later digraphs user-defined? */
-	char		listbuf[8];
-
-	/* if "extra" is NULL, then we've reached the end of the built-ins */
-	if (!extra)
-	{
-		user_defined = TRUE;
-		return;
-	}
-
-	/* if no args, then display the existing digraphs */
-	if (*extra < ' ')
-	{
-		listbuf[0] = listbuf[1] = listbuf[2] = listbuf[5] = ' ';
-		listbuf[7] = '\0';
-		for (dig = 0, dp = digs; dp; dp = dp->next)
-		{
-			if (dp->save || bang)
-			{
-				dig += 7;
-				if (dig >= COLS)
-				{
-					addch('\n');
-					exrefresh();
-					dig = 7;
-				}
-				listbuf[3] = dp->key1;
-				listbuf[4] = dp->key2;
-				listbuf[6] = dp->dig;
-				qaddstr(listbuf);
-			}
-		}
-		addch('\n');
-		exrefresh();
-		return;
-	}
-
-	/* make sure we have at least two characters */
-	if (!extra[1])
-	{
-		msg("Digraphs must be composed of two characters");
-		return;
-	}
-
-	/* sort key1 and key2, so that their original order won't matter */
-	if (extra[0] > extra[1])
-	{
-		dig = extra[0];
-		extra[0] = extra[1];
-		extra[1] = dig;
-	}
-
-	/* locate the new digraph character */
-	for (dig = 2; extra[dig] == ' ' || extra[dig] == '\t'; dig++)
-	{
-	}
-	dig = extra[dig];
-	if (!bang && dig)
-	{
-		dig |= 0x80;
-	}
-
-	/* search for the digraph */
-	for (prev = (struct _DIG *)0, dp = digs;
-	     dp && (dp->key1 != extra[0] || dp->key2 != extra[1]);
-	     prev = dp, dp = dp->next)
-	{
-	}
-
-	/* deleting the digraph? */
-	if (!dig)
-	{
-		if (!dp)
-		{
-#ifndef CRUNCH
-			msg("%c%c not a digraph", extra[0], extra[1]);
-#endif
-			return;
-		}
-		if (prev)
-			prev->next = dp->next;
-		else
-			digs = dp->next;
-		free(dp);
-		return;
-	}
-
-	/* if necessary, create a new digraph struct for the new digraph */
-	if (dig && !dp)
-	{
-		dp = (struct _DIG *)malloc(sizeof *dp);
-		if (!dp)
-		{
-			msg("Out of space in the digraph table");
-			return;
-		}
-		if (prev)
-			prev->next = dp;
-		else
-			digs = dp;
-		dp->next = (struct _DIG *)0;
-	}
-
-	/* assign it the new digraph value */
-	dp->key1 = extra[0];
-	dp->key2 = extra[1];
-	dp->dig = dig;
-	dp->save = user_defined;
-}
-
-# ifndef NO_MKEXRC
-void savedigs(fd)
-	int		fd;
-{
-	static char	buf[] = "digraph! XX Y\n";
-	REG struct _DIG	*dp;
-
-	for (dp = digs; dp; dp = dp->next)
-	{
-		if (dp->save)
-		{
-			buf[9] = dp->key1;
-			buf[10] = dp->key2;
-			buf[12] = dp->dig;
-			write(fd, buf, (unsigned)14);
-		}
-	}
-}
-# endif
-#endif
-
-
-/* This function allows the user to replace an existing (possibly zero-length)
- * chunk of text with typed-in text.  It returns the MARK of the last character
- * that the user typed in.
- */
-MARK input(from, to, when, above)
-	MARK	from;	/* where to start inserting text */
-	MARK	to;	/* extent of text to delete */
-	int	when;	/* either WHEN_VIINP or WHEN_VIREP */
-	int	above;	/* boolean: take indentation from lower line? */
-{
-	char	key[2];	/* key char followed by '\0' char */
-	char	*build;	/* used in building a newline+indent string */
-	char	*scan;	/* used while looking at the indent chars of a line */
-	MARK	m;	/* some place in the text */
-#ifndef NO_EXTENSIONS
-	int	quit = FALSE;	/* boolean: are we exiting after this? */
-	int	inchg;	/* boolean: have we done a "beforedo()" yet? */
-#endif
-
-#ifdef DEBUG
-	/* if "from" and "to" are reversed, complain */
-	if (from > to)
-	{
-		msg("ERROR: input(%ld:%d, %ld:%d)",
-			markline(from), markidx(from),
-			markline(to), markidx(to));
-		return MARK_UNSET;
-	}
-#endif
-
-	key[1] = 0;
-
-	/* if we're replacing text with new text, save the old stuff */
-	/* (Alas, there is no easy way to save text for replace mode) */
-	if (from != to)
-	{
-		cut(from, to);
-	}
-
-	/* if doing a dot command, then reuse the previous text */
-	if (doingdot)
-	{
-		ChangeText
-		{
-			/* delete the text that's there now */
-			if (from != to)
-			{
-				delete(from, to);
-			}
-
-			/* insert the previous text */
-			cutname('.');
-			cursor = paste(from, FALSE, TRUE) + 1L;
-		}
-	}
-	else /* interactive version */
-	{
-		/* assume that whoever called this already did a beforedo() */
-#ifndef NO_EXTENSIONS
-		inchg = TRUE;
-#endif
-
-		/* if doing a change within the line... */
-		if (from != to && markline(from) == markline(to))
-		{
-			/* mark the end of the text with a "$" */
-			change(to - 1, to, "$");
-		}
-		else
-		{
-			/* delete the old text right off */
-			if (from != to)
-			{
-				delete(from, to);
-			}
-			to = from;
-		}
-
-		/* handle autoindent of the first line, maybe */
-		cursor = from;
-		m = (above ? (cursor + BLKSIZE) : (cursor - BLKSIZE));
-		if (*o_autoindent && markidx(m) == 0
-		 && markline(m) >= 1L && markline(m) <= nlines)
-		{
-			/* Only autoindent blank lines. */
-			pfetch(markline(cursor));
-			if (plen == 0)
-			{
-				/* Okay, we really want to autoindent */
-				pfetch(markline(m));
-				for (scan = ptext, build = tmpblk.c;
-				     *scan == ' ' || *scan == '\t';
-				     )
-				{
-					*build++ = *scan++;
-				}
-				if (build > tmpblk.c)
-				{
-					*build = '\0';
-					add(cursor, tmpblk.c);
-					cursor += (build - tmpblk.c);
-					if (cursor > to)
-						to = cursor;
-				}
-			}
-		}
-
-		/* repeatedly add characters from the user */
-		for (;;)
-		{
-			/* Get a character */
-			redraw(cursor, TRUE);
-#ifdef DEBUG2
-			msg("cursor=%ld.%d, to=%ld.%d",
-				markline(cursor), markidx(cursor),
-				markline(to), markidx(to));
-#endif
-#ifndef NO_ABBR
-			pfetch(markline(cursor));
-			build = ptext;
-			if (pline == markline(from))
-				build += markidx(from);
-			for (scan = ptext + markidx(cursor); --scan >= build && isalnum(*scan); )
-			{
-			}
-			scan++;
-			key[0] = getabkey(when, scan, (int)(ptext + markidx(cursor) - scan));
-#else
-			key[0] = getkey(when);
-#endif
-#ifndef NO_VISIBLE
-			if (key[0] != '\0' && V_from != MARK_UNSET)
-			{
-				msg("Can't modify text during a selection");
-				beep();
-				continue;
-			}
-#endif
-
-#ifndef NO_EXTENSIONS
-			if (key[0] == ctrl('O'))
-			{
-				if (inchg)
-				{
-					if (cursor < to)
-					{
-						delete(cursor, to);
-						redraw(cursor, TRUE);
-					}
-					afterdo();
-					inchg = FALSE;
-				}
-			}
-			else if (key[0] != ctrl('['))
-			{
-				if (!inchg)
-				{
-					beforedo(FALSE);
-					inchg = TRUE;
-				}
-			}
-#endif
-
-#ifndef CRUNCH
-			/* if wrapmargin is set & we're past the
-			 * warpmargin, then change the last whitespace
-			 * characters on line into a newline
-			 */
-			if (*o_wrapmargin != 0)
-			{
-				pfetch(markline(cursor));
-				if (idx2col(cursor, ptext, TRUE) > COLS - (*o_wrapmargin & 0xff))
-				{
-					build = tmpblk.c;
-					*build++ = '\n';
-					if (*o_autoindent)
-					{
-						/* figure out indent for next line */
-						for (scan = ptext; *scan == ' ' || *scan == '\t'; )
-						{
-							*build++ = *scan++;
-						}
-					}
-					*build = '\0';
-
-					scan = ptext + plen;
-					m = cursor & ~(BLKSIZE - 1);
-					while (ptext < scan)
-					{
-						scan--;
-						if (*scan != ' ' && *scan != '\t')
-							continue;
-
-						/*break up line, and we do autoindent if needed*/
-						change(m + (scan - ptext), m + (scan - ptext) + 1, tmpblk.c);
-						cursor = (cursor & ~(BLKSIZE - 1))
-							+ BLKSIZE
-							+ strlen(tmpblk.c) - 1
-							+ plen - (scan - ptext) - 1;
-
-						/*remove trailing spaces on previous line*/
-						pfetch(markline(m));
-						scan = ptext + plen;
-						while (ptext < scan)
-						{
-							scan--;
-							if (*scan != ' ' && *scan != '\t')
-								break;
-						}
-						delete(m + (scan-ptext) + 1, m + plen);
-
-						break;
-					}
-				}
-			}
-#endif /* !CRUNCH */
-
-			/* process it */
-			switch (*key)
-			{
-#ifndef NO_EXTENSIONS
-			  case ctrl('O'): /* special movement mapped keys */
-				*key = getkey(0);
-				switch (*key)
-				{
-				  case 'h':	m = m_left(cursor, 0L);		break;
-				  case 'j':
-				  case 'k':	m = m_updnto(cursor, 0L, *key);	break;
-				  case 'l':	m = cursor + 1;			break;
-				  case 'B':
-				  case 'b':	m = m_bword(cursor, 0L, *key);	break;
-				  case 'W':
-				  case 'w':	m = m_fword(cursor, 0L, *key, '\0');	break;
-				  case '^':	m = m_front(cursor, 0L);	break;
-				  case '$':	m = m_rear(cursor, 0L);		break;
-				  case ctrl('B'):
-				  case ctrl('F'):
-						m = m_scroll(cursor, 0L, *key); break;
-				  case 'x':
-#ifndef NO_VISIBLE
-						if (V_from)
-							beep();
-						else
-#endif
-						ChangeText
-						{
-							m = v_xchar(cursor, 0L, 'x');
-						}
-						break;
-				  case 'i':	m = to = from = cursor;
-						when = WHEN_VIINP + WHEN_VIREP - when;
-										break;
-				  case 'K':
-					pfetch(markline(cursor));
-					changes++; /* <- after this, we can alter ptext */
-					ptext[markidx(cursor)] = 0;
-					for (scan = ptext + markidx(cursor) - 1;
-					     scan >= ptext && isalnum(*scan);
-					     scan--)
-					{
-					}
-					scan++;
-					m = (*scan ? v_keyword(scan, cursor, 0L) : cursor);
-					break;
-
-# ifndef NO_VISIBLE
-				  case 'v':
-				  case 'V':
-					if (V_from)
-						V_from = MARK_UNSET;
-					else
-						V_from = cursor;
-					m = from = to = cursor;
-					V_linemd = (*key == 'V');
-					break;
-
-				  case 'd':
-				  case 'y':
-				  case '\\':
-					/* do nothing if unmarked */
-					if (!V_from)
-					{
-						msg("You must mark the text first");
-						beep();
-						break;
-					}
-
-					/* "from" must come before "to" */
-					if (V_from < cursor)
-					{
-						from = V_from;
-						to = cursor;
-					}
-					else
-					{
-						from = cursor;
-						to = V_from;
-					}
-
-					/* we don't need V_from anymore */
-					V_from = MARK_UNSET;
-
-					if (V_linemd)
-					{
-						/* adjust for line mode */
-						from &= ~(BLKSIZE - 1);
-						to |= (BLKSIZE - 1);
-					}
-					else
-					{
-						/* in character mode, we must
-						 * worry about deleting the newline
-						 * at the end of the last line
-						 */
-						pfetch(markline(to));
-						if (markidx(to) == plen)
-							to |= (BLKSIZE - 1);
-					}
-					to++;
-
-					switch (*key)
-					{
-					  case 'y':
-						cut(from, to);
-						break;
-
-					  case 'd':
-						ChangeText
-						{
-							cut(from, to);
-							delete(from, to);
-						}
-						cursor = from;
-						break;
-
-#ifndef NO_POPUP
-					  case '\\':
-						ChangeText
-						{
-							cursor = v_popup(from, to);
-						}
-						break;
-#endif
-					}
-					m = from = to = cursor;
-					break;
-
-				  case 'p':
-				  case 'P':
-					V_from = MARK_UNSET;
-					ChangeText
-					{
-						m = from = to = cursor = paste(cursor, (*key == 'p'), FALSE);
-					}
-					break;
-# endif /* !NO_VISIBLE */
-				  default:	m = MARK_UNSET;
-				}
-
-				/* adjust the moved cursor */
-				if (m != cursor)
-				{
-					m = adjmove(cursor, m, (*key == 'j' || *key == 'k' ? 0x20 : 0));
-					if (*key == '$' || (*key == 'l' && m <= cursor))
-					{
-						m++;
-					}
-				}
-
-				/* if the cursor is reasonable, use it */
-				if (m == MARK_UNSET)
-				{
-					beep();
-				}
-				else
-				{
-					from = to = cursor = m;
-				}
-				break;
-
-			  case ctrl('Z'):
-				if (getkey(0) == ctrl('Z'))
-				{
-					quit = TRUE;
-					goto BreakBreak;
-				}
-				break;
-#endif
-
-			  case ctrl('['):
-				/* if last line contains only whitespace, then remove whitespace */
-				if (*o_autoindent)
-				{
-					pfetch(markline(cursor));
-					for (scan = ptext; isspace(*scan); scan++)
-					{
-					}
-					if (scan > ptext && !*scan)
-					{
-						cursor &= ~(BLKSIZE - 1L);
-						if (to < cursor + plen)
-						{
-							to = cursor + plen;
-						}
-					}
-				}
-				goto BreakBreak;
-
-			  case ctrl('U'):
-				if (markline(cursor) == markline(from))
-				{
-					cursor = from;
-				}
-				else
-				{
-					cursor &= ~(BLKSIZE - 1);
-				}
-				break;
-
-			  case ctrl('D'):
-			  case ctrl('T'):
-				if (to > cursor)
-				{
-					delete(cursor, to);
-				}
-				mark[27] = cursor;
-				cmd_shift(cursor, cursor, *key == ctrl('D') ? CMD_SHIFTL : CMD_SHIFTR, TRUE, "");
-				if (mark[27])
-				{
-					cursor = mark[27];
-				}
-				else
-				{
-					cursor = m_front(cursor, 0L);
-				}
-				to = cursor;
-				break;
-
-			  case '\b':
-				if (cursor <= from)
-				{
-					beep();
-				}
-				else if (markidx(cursor) == 0)
-				{
-					cursor -= BLKSIZE;
-					pfetch(markline(cursor));
-					cursor += plen;
-				}
-				else
-				{
-					cursor--;
-				}
-				break;
-
-			  case ctrl('W'):
-				m = m_bword(cursor, 1L, 'b');
-				if (markline(m) == markline(cursor) && m >= from)
-				{
-					cursor = m;
-					if (from > cursor)
-					{
-						from = cursor;
-					}
-				}
-				else
-				{
-					beep();
-				}
-				break;
-
-			  case '\n':
-#if OSK
-			  case '\l':
-#else				  
-			  case '\r':
-#endif
-				build = tmpblk.c;
-				*build++ = '\n';
-				if (*o_autoindent)
-				{
-					/* figure out indent for next line */
-					pfetch(markline(cursor));
-					for (scan = ptext; *scan == ' ' || *scan == '\t'; )
-					{
-						*build++ = *scan++;
-					}
-
-					/* remove indent from this line, if blank */
-					if ((scan - ptext) >= markidx(cursor) && plen > 0)
-					{
-						to = cursor &= ~(BLKSIZE - 1);
-						delete(cursor, cursor + plen);
-					}
-				}
-				*build = 0;
-				if (cursor >= to && when != WHEN_VIREP)
-				{
-					add(cursor, tmpblk.c);
-				}
-				else
-				{
-					change(cursor, to, tmpblk.c);
-				}
-				redraw(cursor, TRUE);
-				to = cursor = (cursor & ~(BLKSIZE - 1))
-						+ BLKSIZE
-						+ (int)(build - tmpblk.c) - 1;
-				break;
-
-			  case ctrl('A'):
-			  case ctrl('P'):
-				if (cursor < to)
-				{
-					delete(cursor, to);
-				}
-				if (*key == ctrl('A'))
-				{
-					cutname('.');
-				}
-				to = cursor = paste(cursor, FALSE, TRUE) + 1L;
-				break;
-
-			  case ctrl('V'):
-				if (cursor >= to && when != WHEN_VIREP)
-				{
-					add(cursor, "^");
-				}
-				else
-				{
-					change(cursor, to, "^");
-					to = cursor + 1;
-				}
-				redraw(cursor, TRUE);
-				*key = getkey(0);
-				if (*key == '\n')
-				{
-					/* '\n' too hard to handle */
-#if OSK
-					*key = '\l';
-#else
-					*key = '\r';
-#endif
-				}
-				change(cursor, cursor + 1, key);
-				cursor++;
-				if (cursor > to)
-				{
-					to = cursor;
-				}
-				break;
-
-			  case ctrl('L'):
-			  case ctrl('R'):
-				redraw(MARK_UNSET, FALSE);
-				break;
-
-			  default:
-				if (cursor >= to && when != WHEN_VIREP)
-				{
-					add(cursor, key);
-					cursor++;
-					to = cursor;
-				}
-				else
-				{
-					pfetch(markline(cursor));
-					if (markidx(cursor) == plen)
-					{
-						add(cursor, key);
-					}
-					else
-					{
-#ifndef NO_DIGRAPH
-						*key = digraph(ptext[markidx(cursor)], *key);
-#endif
-						change(cursor, cursor + 1, key);
-					}
-					cursor++;
-				}
-#ifndef NO_SHOWMATCH
-				/* show matching "({[" if necessary */
-				if (*o_showmatch && strchr(")}]", *key))
-				{
-					redraw(cursor, TRUE);
-					m = m_match(cursor - 1, 0L);
-					if (markline(m) >= topline
-					 && markline(m) <= botline)
-					{
-						redraw(m, TRUE);
-						refresh();
-						sleep(1);
-					}
-				}
-#endif
-			} /* end switch(*key) */
-		} /* end for(;;) */
-BreakBreak:;
-		/* delete any excess characters */
-		if (cursor < to)
-		{
-#ifndef NO_EXTENSIONS
-			/* if we aren't in the middle of a change, start one! */
-			if (!inchg)
-			{
-				beforedo(FALSE);
-				inchg = TRUE;
-			}
-#endif
-			delete(cursor, to);
-		}
-
-	} /* end if doingdot else */
-
-	/* put the new text into a cut buffer for possible reuse */
-	if (!doingdot)
-	{
-		blksync();
-		cutname('.');
-		cut(from, cursor);
-	}
-
-	/* move to last char that we inputted, unless it was newline */
-	if (markidx(cursor) != 0)
-	{
-		cursor--;
-	}
-	redraw(cursor, FALSE);
-
-#ifndef NO_EXTENSIONS
-	if (quit)
-	{
-		/* if this is a nested "do", then cut it short */
-		abortdo();
-
-		/* exit, unless we can't write out the file */
-		cursor = v_xit(cursor, 0L, 'Z');
-	}
-#endif
-
-	rptlines = 0L;
-	return cursor;
-}
Index: trunk/minix/commands/elvis/main.c
===================================================================
--- trunk/minix/commands/elvis/main.c	(revision 9)
+++ 	(revision )
@@ -1,516 +1,0 @@
-/* main.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the main() function of vi */
-
-/* HACK! bcc needs to disable use of precompiled headers for this file,
-   or else command line args will not be passed to elvis */
-#if __BORLANDC__
-#include "borland.h"
-#endif
-
-#include "config.h"
-#include <setjmp.h>
-#include "vi.h"
-
-extern		trapint(); /* defined below */
-extern char	*getenv();
-jmp_buf		jmpenv;
-
-#ifndef NO_DIGRAPH
-static init_digraphs();
-#endif
-
-/*---------------------------------------------------------------------*/
-
-#if AMIGA
-# include "amiwild.c"
-main (argc, argv)
-#else
-# if VMS
-#  include "vmswild.c"
-main (argc, argv)
-# else
-void main(argc, argv)
-# endif
-#endif
-	int	argc;
-	char	*argv[];
-{
-	int	i;
-	char	*cmd = (char *)0;
-	char	*err = (char *)0;
-	char	*str;
-	char	*tag = (char *)0;
-
-	/* set mode to MODE_VI or MODE_EX depending on program name */
-	switch (argv[0][strlen(argv[0]) - 1])
-	{
-	  case 'x':			/* "ex" */
-		mode = MODE_EX;
-		break;
-
-	  case 'w':			/* "view" */
-		mode = MODE_VI;
-		*o_readonly = TRUE;
-		break;
-#ifndef NO_EXTENSIONS
-	  case 't':			/* "edit" or "input" */
-		mode = MODE_VI;
-		*o_inputmode = TRUE;
-		break;
-#endif
-	  default:			/* "vi" or "elvis" */
-		mode = MODE_VI;
-	}
-
-#ifndef DEBUG
-# ifdef	SIGQUIT
-	/* normally, we ignore SIGQUIT.  SIGINT is trapped later */
-	signal(SIGQUIT, SIG_IGN);
-# endif
-#endif
-
-	/* temporarily ignore SIGINT */
-	signal(SIGINT, SIG_IGN);
-
-	/* start curses */
-	initscr();
-	cbreak();
-	noecho();
-	scrollok(stdscr, TRUE);
-
-	/* arrange for deadly signals to be caught */
-# ifdef SIGHUP
-	signal(SIGHUP, (void(*)()) deathtrap);
-# endif
-# ifndef DEBUG
-#  ifdef SIGILL
-	signal(SIGILL, (void(*)()) deathtrap);
-#  endif
-#  ifdef SIGBUS
-	signal(SIGBUS, (void(*)()) deathtrap);
-#  endif
-#  ifdef SIGSEGV
-	signal(SIGSEGV, (void(*)()) deathtrap);
-#  endif
-#  ifdef SIGSYS
-	signal(SIGSYS, (void(*)()) deathtrap);
-#  endif
-# endif /* !DEBUG */
-# ifdef SIGPIPE
-	signal(SIGPIPE, (void(*)()) deathtrap);
-# endif
-# ifdef SIGTERM
-	signal(SIGTERM, (void(*)()) deathtrap);
-# endif
-# ifdef SIGUSR1
-	signal(SIGUSR1, (void(*)()) deathtrap);
-# endif
-# ifdef SIGUSR2
-	signal(SIGUSR2, (void(*)()) deathtrap);
-# endif
-
-	/* initialize the options - must be done after initscr(), so that
-	 * we can alter LINES and COLS if necessary.
-	 */
-	initopts();
-
-	/* map the arrow keys.  The KU,KD,KL,and KR variables correspond to
-	 * the :ku=: (etc.) termcap capabilities.  The variables are defined
-	 * as part of the curses package.
-	 */
-	if (has_KU) mapkey(has_KU, "k",    WHEN_VICMD|WHEN_INMV, "<Up>");
-	if (has_KD) mapkey(has_KD, "j",    WHEN_VICMD|WHEN_INMV, "<Down>");
-	if (has_KL) mapkey(has_KL, "h",    WHEN_VICMD|WHEN_INMV, "<Left>");
-	if (has_KR) mapkey(has_KR, "l",    WHEN_VICMD|WHEN_INMV, "<Right>");
-	if (has_HM) mapkey(has_HM, "^",    WHEN_VICMD|WHEN_INMV, "<Home>");
-	if (has_EN) mapkey(has_EN, "$",    WHEN_VICMD|WHEN_INMV, "<End>");
-	if (has_PU) mapkey(has_PU, "\002", WHEN_VICMD|WHEN_INMV, "<PageUp>");
-	if (has_PD) mapkey(has_PD, "\006", WHEN_VICMD|WHEN_INMV, "<PageDn>");
-	if (has_KI) mapkey(has_KI, "i",    WHEN_VICMD|WHEN_INMV, "<Insert>");
-#if MSDOS
-# if RAINBOW
-	if (!strcmp("rainbow", o_term))
-	{
-		mapkey("\033[1~",  "/",		WHEN_VICMD,		"<Find>");
-		mapkey("\033[3~",  "x",		WHEN_VICMD|WHEN_INMV,	"<Remove>");
-		mapkey("\033[4~",  "v",		WHEN_VICMD|WHEN_INMV,	"<Select>");
-		mapkey("\033[17~", ":sh\n",	WHEN_VICMD,		"<Intrpt>");
-		mapkey("\033[19~", ":q\n",	WHEN_VICMD,		"<Cancel>");
-		mapkey("\033[21~", "ZZ",	WHEN_VICMD,		"<Exit>");
-		mapkey("\033[26~", "V",		WHEN_VICMD|WHEN_INMV,	"<AddlOp>");
-		mapkey("\033[28~", "\\",	WHEN_VICMD|WHEN_INMV,	"<Help>");
-		mapkey("\033[29~", "K",		WHEN_VICMD|WHEN_INMV,	"<Do>");
-	}
-	else
-# endif /* RAINBOW */
-	{
-		mapkey("#S", "x", WHEN_VICMD|WHEN_INMV,	"<Delete>");
-		mapkey("#s", "B", WHEN_VICMD|WHEN_INMV,	"^<Left>");
-		mapkey("#t", "W", WHEN_VICMD|WHEN_INMV,	"^<Right>");
-	}
-#else /* not MSDOS */
-# if COHERENT
-	mapkey("\033[P", "x", WHEN_VICMD|WHEN_INMV, "<Del>");
-# else
-#if AMIGA
-	mapkey("\233?~", "\\",	WHEN_VICMD|WHEN_INMV,	"<Help>");
-#endif
-
-	if (ERASEKEY != '\177')
-	{
-		mapkey("\177", "x", WHEN_VICMD|WHEN_INMV, "<Del>");
-	}
-# endif
-#endif
-
-#ifndef NO_DIGRAPH
-	init_digraphs();
-#endif /* NO_DIGRAPH */
-
-	/* process any flags */
-	for (i = 1; i < argc && *argv[i] == '-'; i++)
-	{
-		switch (argv[i][1])
-		{
-		  case 'R':	/* readonly */
-			*o_readonly = TRUE;
-			break;
-
-		  case 'L':
-		  case 'r':	/* recover */
-			msg("Use the `elvrec` program to recover lost files");
-			endmsgs();
-			refresh();
-			endwin();
-			exit(0);
-			break;
-
-		  case 't':	/* tag */
-			if (argv[i][2])
-			{
-				tag = argv[i] + 2;
-			}
-			else
-			{
-				tag = argv[++i];
-			}
-			break;
-
-		  case 'v':	/* vi mode */
-			mode = MODE_VI;
-			break;
-
-		  case 'e':	/* ex mode */
-			mode = MODE_EX;
-			break;
-#ifndef NO_EXTENSIONS
-		  case 'i':	/* input mode */
-			*o_inputmode = TRUE;
-			break;
-#endif
-#ifndef NO_ERRLIST
-		  case 'm':	/* use "errlist" as the errlist */
-			if (argv[i][2])
-			{
-				err = argv[i] + 2;
-			}
-			else if (i + 1 < argc)
-			{
-				err = argv[++i];
-			}
-			else
-			{
-				err = "";
-			}
-			break;
-#endif
-#ifndef CRUNCH
-		 case 'c':	/* run the following command, later */
-			if (argv[i][2])
-			{
-				cmd = argv[i] + 2;
-			}
-			else
-			{
-				cmd = argv[++i];
-			}
-			break;
-
-		  case 'w':	/* set the window size */
-			if (argv[i][2])
-			{
-				*o_window = atoi(argv[i] + 2);
-				wset = TRUE;
-			}
-			else
-			{
-				*o_window = atoi(argv[++i]);
-				wset = TRUE;
-			}
-			break;
-#endif
-		  default:
-			msg("Ignoring unknown flag \"%s\"", argv[i]);
-		}
-	}
-
-	/* if we were given an initial ex command, save it... */
-	if (i < argc && *argv[i] == '+')
-	{
-		if (argv[i][1])
-		{
-			cmd = argv[i++] + 1;
-		}
-		else
-		{
-			cmd = "$"; /* "vi + file" means start at EOF */
-			i++;
-		}
-	}
-
-	/* the remaining args are file names. */
-	if (i < argc)
-	{
-		strcpy(args, argv[i]);
-		while (++i < argc && strlen(args) + 1 + strlen(argv[i]) < sizeof args)
-		{
-			strcat(args, " ");
-			strcat(args, argv[i]);
-		}
-#if MSDOS || TOS
-		/* expand wildcard characters, if necessary */
-		if (strchr(args, '*') || strchr(args, '?'))
-		{
-			strcpy(args, wildcard(args));
-		}
-#endif
-		strcpy(tmpblk.c, args);
-		cmd_args(MARK_UNSET, MARK_UNSET, CMD_ARGS, TRUE, tmpblk.c);
-	}
-	else
-	{
-		/* empty args list */
-		args[0] = '\0';
-		nargs = 1;
-		argno = -1;
-	}
-
-	/* perform the .exrc files and EXINIT environment variable */
-#ifdef SYSEXRC
-	doexrc(SYSEXRC);
-#endif
-#ifdef HMEXRC
-	str = getenv("HOME");
-	if (str && *str)
-	{
-		strcpy(tmpblk.c, str);
-		str = tmpblk.c + strlen(tmpblk.c);
-#if !VMS
-# if AMIGA	/* Don't SLASH a device. "Elvis:.exrc" */
-		if (str[-1] != COLON && str[-1] != SLASH)
-# else
-		if (str[-1] != SLASH)
-# endif
-		{
-			*str++ = SLASH;
-		}
-#endif
-		strcpy(str, HMEXRC);
-		doexrc(tmpblk.c);
-	}
-#endif
-#ifndef CRUNCH
-	if (*o_exrc)
-#endif
-	{
-		doexrc(EXRC);
-	}
-#ifdef EXINIT
-	str = getenv(EXINIT);
-	if (str)
-	{
-		exstring(str, strlen(str), ctrl('V'));
-	}
-#endif
-
-	/* search for a tag (or an error) now, if desired */
-	blkinit();
-	if (tag)
-	{
-		cmd_tag(MARK_FIRST, MARK_FIRST, CMD_TAG, 0, tag);
-	}
-#ifndef NO_ERRLIST
-	else if (err)
-	{
-		cmd_errlist(MARK_FIRST, MARK_FIRST, CMD_ERRLIST, 0, err);
-	}
-#endif
-
-	/* if no tag/err, or tag failed, then start with first arg */
-	if (tmpfd < 0)
-	{
-		/* start with first arg */
-		cmd_next(MARK_UNSET, MARK_UNSET, CMD_NEXT, FALSE, "");
-
-		/* pretend to do something, just to force a recoverable
-		 * version of the file out to disk
-		 */
-		ChangeText
-		{
-		}
-		clrflag(file, MODIFIED);
-	}
-
-	/* now we do the immediate ex command that we noticed before */
-	if (cmd)
-	{
-		doexcmd(cmd);
-	}
-
-	/* repeatedly call ex() or vi() (depending on the mode) until the
-	 * mode is set to MODE_QUIT
-	 */
-	while (mode != MODE_QUIT)
-	{
-		if (setjmp(jmpenv))
-		{
-			/* Maybe we just aborted a change? */
-			abortdo();
-		}
-		signal(SIGINT, (void(*)()) trapint);
-
-		switch (mode)
-		{
-		  case MODE_VI:
-			vi();
-			break;
-
-		  case MODE_EX:
-			ex();
-			break;
-#ifdef DEBUG
-		  default:
-			msg("mode = %d?", mode);
-			mode = MODE_QUIT;
-#endif
-		}
-	}
-
-	/* free up the cut buffers */
-	cutend();
-
-	/* end curses */
-#ifndef	NO_CURSORSHAPE
-	if (has_CQ)
-		do_CQ();
-#endif
-	endmsgs();
-	move(LINES - 1, 0);
-	clrtoeol();
-	refresh();
-	endwin();
-
-	exit(0);
-	/*NOTREACHED*/
-}
-
-
-/*ARGSUSED*/
-int trapint(signo)
-	int	signo;
-{
-	beep();
-	resume_curses(FALSE);
-	abortdo();
-#if OSK
-	sigmask(-1);
-#endif
-#if TURBOC || __GNUC__ || _ANSI
-	signal(signo, (void (*)())trapint);
-#else
-	signal(signo, trapint);
-#endif
-	doingglobal = FALSE;
-
-	longjmp(jmpenv, 1);
-
-	return 0;
-}
-
-
-
-#ifndef NO_DIGRAPH
-
-/* This stuff us used to build the default digraphs table. */
-static char	digtable[][4] =
-{
-# ifdef CS_IBMPC
-	"C,\200",	"u\"\1",	"e'\2",		"a^\3",
-	"a\"\4",	"a`\5",		"a@\6",		"c,\7",
-	"e^\10",	"e\"\211",	"e`\12",	"i\"\13",
-	"i^\14",	"i`\15",	"A\"\16",	"A@\17",
-	"E'\20",	"ae\21",	"AE\22",	"o^\23",
-	"o\"\24",	"o`\25",	"u^\26",	"u`\27",
-	"y\"\30",	"O\"\31",	"U\"\32",	"a'\240",
-	"i'!",		"o'\"",		"u'#",		"n~$",
-	"N~%",		"a-&",		"o-'",		"~?(",
-	"~!-",		"\"<.",		"\">/",
-#  ifdef CS_SPECIAL
-	"2/+",		"4/,",		"^+;",		"^q<",
-	"^c=",		"^r>",		"^t?",		"pp]",
-	"^^^",		"oo_",		"*a`",		"*ba",
-	"*pc",		"*Sd",		"*se",		"*uf",
-	"*tg",		"*Ph",		"*Ti",		"*Oj",
-	"*dk",		"*Hl",		"*hm",		"*En",
-	"*No",		"eqp",		"pmq",		"ger",
-	"les",		"*It",		"*iu",		"*/v",
-	"*=w",		"sq{",		"^n|",		"^2}",
-	"^3~",		"^_\377",
-#  endif /* CS_SPECIAL */
-# endif /* CS_IBMPC */
-# ifdef CS_LATIN1
-	"~!!",		"a-*",		"\">+",		"o-:",
-	"\"<>",		"~??",
-
-	"A`@",		"A'A",		"A^B",		"A~C",
-	"A\"D",		"A@E",		"AEF",		"C,G",
-	"E`H",		"E'I",		"E^J",		"E\"K",
-	"I`L",		"I'M",		"I^N",		"I\"O",
-	"-DP",		"N~Q",		"O`R",		"O'S",
-	"O^T",		"O~U",		"O\"V",		"O/X",
-	"U`Y",		"U'Z",		"U^[",		"U\"\\",
-	"Y'_",
-
-	"a``",		"a'a",		"a^b",		"a~c",
-	"a\"d",		"a@e",		"aef",		"c,g",
-	"e`h",		"e'i",		"e^j",		"e\"k",
-	"i`l",		"i'm",		"i^n",		"i\"o",
-	"-dp",		"n~q",		"o`r",		"o's",
-	"o^t",		"o~u",		"o\"v",		"o/x",
-	"u`y",		"u'z",		"u^{",		"u\"|",
-	"y'~",
-# endif /* CS_LATIN1 */
-	""
-};
-
-static init_digraphs()
-{
-	int	i;
-
-	for (i = 0; *digtable[i]; i++)
-	{
-		do_digraph(FALSE, digtable[i]);
-	}
-	do_digraph(FALSE, (char *)0);
-	return 0;
-}
-#endif /* NO_DIGRAPH */
Index: trunk/minix/commands/elvis/misc.c
===================================================================
--- trunk/minix/commands/elvis/misc.c	(revision 9)
+++ 	(revision )
@@ -1,103 +1,0 @@
-/* misc.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains functions which didn't seem happy anywhere else */
-
-#include "config.h"
-#include "vi.h"
-
-
-/* find a particular line & return a pointer to a copy of its text */
-char *fetchline(line)
-	long	line;	/* line number of the line to fetch */
-{
-	int		i;
-	REG char	*scan;	/* used to search for the line in a BLK */
-	long		l;	/* line number counter */
-	static BLK	buf;	/* holds ONLY the selected line (as string) */
-	REG char	*cpy;	/* used while copying the line */
-	static long	nextline;	/* }  These four variables are used */
-	static long	chglevel;	/*  } to implement a shortcut when  */
-	static char	*nextscan;	/*  } consecutive lines are fetched */
-	static long	nextlnum;	/* }                                */
-
-	/* can we do a shortcut? */
-	if (changes == chglevel && line == nextline)
-	{
-		scan = nextscan;
-	}
-	else
-	{
-		/* scan lnum[] to determine which block its in */
-		for (i = 1; line > lnum[i]; i++)
-		{
-		}
-		nextlnum = lnum[i];
-
-		/* fetch text of the block containing that line */
-		scan = blkget(i)->c;
-
-		/* find the line in the block */
-		for (l = lnum[i - 1]; ++l < line; )
-		{
-			while (*scan++ != '\n')
-			{
-			}
-		}
-	}
-
-	/* copy it into a block by itself, with no newline */
-	for (cpy = buf.c; *scan != '\n'; )
-	{
-		*cpy++ = *scan++;
-	}
-	*cpy = '\0';
-
-	/* maybe speed up the next call to fetchline() ? */
-	if (line < nextlnum)
-	{
-		nextline = line + 1;
-		chglevel = changes;
-		nextscan = scan + 1;
-	}
-	else
-	{
-		nextline = 0;
-	}
-
-	/* Calls to fetchline() interfere with calls to pfetch().  Make sure
-	 * that pfetch() resets itself on its next invocation.
-	 */
-	pchgs = 0L;
-
-	/* Return a pointer to the line's text */
-	return buf.c;
-}
-
-
-/* error message from the regexp code */
-void regerror(txt)
-	char	*txt;	/* an error message */
-{
-	msg("RE error: %s", txt);
-}
-
-/* This function is equivelent to the pfetch() macro */
-void	pfetch(l)
-	long	l;	/* line number of line to fetch */
-{
-	if(l != pline || changes != pchgs)
-	{
-		pline = (l);
-		ptext = fetchline(pline);
-		plen = strlen(ptext);
-		pchgs = changes;
-	}
-}
Index: trunk/minix/commands/elvis/modify.c
===================================================================
--- trunk/minix/commands/elvis/modify.c	(revision 9)
+++ 	(revision )
@@ -1,474 +1,0 @@
-/* modify.c */
-
-/* This file contains the low-level file modification functions:
- *	delete(frommark, tomark)	- removes line or portions of lines
- *	add(frommark, text)		- inserts new text
- *	change(frommark, tomark, text)	- delete, then add
- */
-
-#include "config.h"
-#include "vi.h"
-
-#ifdef DEBUG2
-# include <stdio.h>
-static FILE *dbg;
-
-/*VARARGS1*/
-debout(msg, arg1, arg2, arg3, arg4, arg5)
-	char	*msg, *arg1, *arg2, *arg3, *arg4, *arg5;
-{
-	if (!dbg)
-	{
-		dbg = fopen("debug.out", "w");
-		if (!dbg)
-			return;
-		setbuf(dbg, (FILE *)0);
-	}
-	fprintf(dbg, msg, arg1, arg2, arg3, arg4, arg5);
-}
-#endif /* DEBUG2 */
-
-/* delete a range of text from the file */
-void delete(frommark, tomark)
-	MARK		frommark;	/* first char to be deleted */
-	MARK		tomark;		/* AFTER last char to be deleted */
-{
-	int		i;		/* used to move thru logical blocks */
-	REG char	*scan;		/* used to scan thru text of the blk */
-	REG char	*cpy;		/* used when copying chars */
-	BLK		*blk;		/* a text block */
-	long		l;		/* a line number */
-	MARK		m;		/* a traveling version of frommark */
-
-#ifdef DEBUG2
-	debout("delete(%ld.%d, %ld.%d)\n", markline(frommark), markidx(frommark), markline(tomark), markidx(tomark));
-#endif
-
-	/* if not deleting anything, quit now */
-	if (frommark == tomark)
-	{
-		return;
-	}
-
-	/* This is a change */
-	changes++;
-	significant = TRUE;
-
-	/* supply clues to the redraw module */
-	redrawrange(markline(frommark), markline(tomark), markline(frommark));
-
-	/* adjust marks 'a through 'z and '' as needed */
-	l = markline(tomark);
-	for (i = 0; i < NMARKS; i++)
-	{
-		if (mark[i] < frommark)
-		{
-			continue;
-		}
-		else if (mark[i] < tomark)
-		{
-			mark[i] = MARK_UNSET;
-		}
-		else if (markline(mark[i]) == l)
-		{
-			if (markline(frommark) == l)
-			{
-				mark[i] -= markidx(tomark) - markidx(frommark);
-			}
-			else
-			{
-				mark[i] -= markidx(tomark);
-			}
-		}
-		else
-		{
-			mark[i] -= MARK_AT_LINE(l - markline(frommark));
-		}
-	}
-
-	/* Reporting... */
-	if (markidx(frommark) == 0 && markidx(tomark) == 0)
-	{
-		rptlines = markline(tomark) - markline(frommark);
-		rptlabel = "deleted";
-	}
-
-	/* find the block containing frommark */
-	l = markline(frommark);
-	for (i = 1; lnum[i] < l; i++)
-	{
-	}
-
-	/* process each affected block... */
-	for (m = frommark;
-	     m < tomark && lnum[i] < INFINITY;
-	     m = MARK_AT_LINE(lnum[i - 1] + 1))
-	{
-		/* fetch the block */
-		blk = blkget(i);
-
-		/* find the mark in the block */
-		scan = blk->c;
-		for (l = markline(m) - lnum[i - 1] - 1; l > 0; l--)
-		{
-			while (*scan++ != '\n')
-			{
-			}
-		}
-		scan += markidx(m);
-
-		/* figure out where the changes to this block end */
-		if (markline(tomark) > lnum[i])
-		{
-			cpy = blk->c + BLKSIZE;
-		}
-		else if (markline(tomark) == markline(m))
-		{
-			cpy = scan - markidx(m) + markidx(tomark);
-		}
-		else
-		{
-			cpy = scan;
-			for (l = markline(tomark) - markline(m);
-			     l > 0;
-			     l--)
-			{
-				while (*cpy++ != '\n')
-				{
-				}
-			}
-			cpy += markidx(tomark);
-		}
-
-		/* delete the stuff by moving chars within this block */
-		while (cpy < blk->c + BLKSIZE)
-		{
-			*scan++ = *cpy++;
-		}
-		while (scan < blk->c + BLKSIZE)
-		{
-			*scan++ = '\0';
-		}
-
-		/* adjust tomark to allow for lines deleted from this block */
-		tomark -= MARK_AT_LINE(lnum[i] + 1 - markline(m));
-
-		/* if this block isn't empty now, then advance i */
-		if (*blk->c)
-		{
-			i++;
-		}
-
-		/* the buffer has changed.  Update hdr and lnum. */
-		blkdirty(blk);
-	}
-
-	/* must have at least 1 line */
-	if (nlines == 0)
-	{
-		blk = blkadd(1);
-		blk->c[0] = '\n';
-		blkdirty(blk);
-		cursor = MARK_FIRST;
-	}
-}
-
-
-/* add some text at a specific place in the file */
-void add(atmark, newtext)
-	MARK		atmark;		/* where to insert the new text */
-	char		*newtext;	/* NUL-terminated string to insert */
-{
-	REG char	*scan;		/* used to move through string */
-	REG char	*build;		/* used while copying chars */
-	int		addlines;	/* number of lines we're adding */
-	int		lastpart;	/* size of last partial line */
-	BLK		*blk;		/* the block to be modified */
-	int		blkno;		/* the logical block# of (*blk) */
-	REG char	*newptr;	/* where new text starts in blk */
-	BLK		buf;		/* holds chars from orig blk */
-	BLK		linebuf;	/* holds part of line that didn't fit */
-	BLK		*following;	/* the BLK following the last BLK */
-	int		i;
-	long		l;
-
-#ifdef DEBUG2
-	debout("add(%ld.%d, \"%s\")\n", markline(atmark), markidx(atmark), newtext);
-#endif
-#ifdef lint
-	buf.c[0] = 0;
-#endif
-	/* if not adding anything, return now */
-	if (!*newtext)
-	{
-		return;
-	}
-
-	/* This is a change */
-	changes++;
-	significant = TRUE;
-
-	/* count the number of lines in the new text */
-	for (scan = newtext, lastpart = addlines = 0; *scan; )
-	{
-		if (*scan++ == '\n')
-		{
-			addlines++;
-			lastpart = 0;
-		}
-		else
-		{
-			lastpart++;
-		}
-	}
-
-	/* Reporting... */
-	if (lastpart == 0 && markidx(atmark) == 0)
-	{
-		rptlines = addlines;
-		rptlabel = "added";
-	}
-
-	/* extract the line# from atmark */
-	l = markline(atmark);
-
-	/* supply clues to the redraw module */
-	if ((markidx(atmark) == 0 && lastpart == 0) || addlines == 0)
-	{
-		redrawrange(l, l, l + addlines);
-	}
-	else
-	{
-		/* make sure the last line gets redrawn -- it was
-		 * split, so its appearance has changed
-		 */
-		redrawrange(l, l + 1L, l + addlines + 1L);
-	}
-
-	/* adjust marks 'a through 'z and '' as needed */
-	for (i = 0; i < NMARKS; i++)
-	{
-		if (mark[i] < atmark)
-		{
-			/* earlier line, or earlier in same line: no change */
-			continue;
-		}
-		else if (markline(mark[i]) > l)
-		{
-			/* later line: move down a whole number of lines */
-			mark[i] += MARK_AT_LINE(addlines);
-		}
-		else
-		{
-			/* later in same line */
-			if (addlines > 0)
-			{
-				/* multi-line add, which split this line:
-				 * move down, and possibly left or right,
-				 * depending on where the split was and how
-				 * much text was inserted after the last \n
-				 */
-				mark[i] += MARK_AT_LINE(addlines) + lastpart - markidx(atmark);
-			}
-			else
-			{
-				/* totally within this line: move right */
-				mark[i] += lastpart;
-			}
-		}
-	}
-
-	/* get the block to be modified */
-	for (blkno = 1; lnum[blkno] < l && lnum[blkno + 1] < INFINITY; blkno++)
-	{
-	}
-	blk = blkget(blkno);
-	buf = *blk;
-
-	/* figure out where the new text starts */
-	for (newptr = buf.c, l = markline(atmark) - lnum[blkno - 1] - 1;
-	     l > 0;
-	     l--)
-	{
-		while (*newptr++ != '\n')
-		{
-		}
-	}
-	newptr += markidx(atmark);
-
-	/* keep start of old block */
-	build = blk->c + (int)(newptr - buf.c);
-
-	/* fill this block (or blocks) from the newtext string */
-	while (*newtext)
-	{
-		while (*newtext && build < blk->c + BLKSIZE - 1)
-		{
-			*build++ = *newtext++;
-		}
-		if (*newtext)
-		{
-			/* save the excess */
-			for (scan = linebuf.c + BLKSIZE;
-			     build > blk->c && build[-1] != '\n';
-			     )
-			{
-				*--scan = *--build;
-			}
-
-			/* write the block */
-			while (build < blk->c + BLKSIZE)
-			{
-				*build++ = '\0';
-			}
-			blkdirty(blk);
-
-			/* add another block */
-			blkno++;
-			blk = blkadd(blkno);
-
-			/* copy in the excess from last time */
-			for (build = blk->c; scan < linebuf.c + BLKSIZE; )
-			{
-				*build++ = *scan++;
-			}
-		}
-	}
-
-	/* fill this block(s) from remainder of orig block */
-	while (newptr < buf.c + BLKSIZE && *newptr)
-	{
-		while (newptr < buf.c + BLKSIZE
-		    && *newptr
-		    && build < blk->c + BLKSIZE - 1)
-		{
-			*build++ = *newptr++;
-		}
-		if (newptr < buf.c + BLKSIZE && *newptr)
-		{
-			/* save the excess */
-			for (scan = linebuf.c + BLKSIZE;
-			     build > blk->c && build[-1] != '\n';
-			     )
-			{
-				*--scan = *--build;
-			}
-
-			/* write the block */
-			while (build < blk->c + BLKSIZE)
-			{
-				*build++ = '\0';
-			}
-			blkdirty(blk);
-
-			/* add another block */
-			blkno++;
-			blk = blkadd(blkno);
-
-			/* copy in the excess from last time */
-			for (build = blk->c; scan < linebuf.c + BLKSIZE; )
-			{
-				*build++ = *scan++;
-			}
-		}
-	}
-
-	/* see if we can combine our last block with the following block */
-	if (lnum[blkno] < nlines && lnum[blkno + 1] - lnum[blkno] < (BLKSIZE >> 6))
-	{
-		/* hey, we probably can!  Get the following block & see... */
-		following = blkget(blkno + 1);
-		if (strlen(following->c) + (build - blk->c) < BLKSIZE - 1)
-		{
-			/* we can!  Copy text from following to blk */
-			for (scan = following->c; *scan; )
-			{
-				*build++ = *scan++;
-			}
-			while (build < blk->c + BLKSIZE)
-			{
-				*build++ = '\0';
-			}
-			blkdirty(blk);
-
-			/* pretend the following was the last blk */
-			blk = following;
-			build = blk->c;
-		}
-	}
-
-	/* that last block is dirty by now */
-	while (build < blk->c + BLKSIZE)
-	{
-		*build++ = '\0';
-	}
-	blkdirty(blk);
-}
-
-
-/* change the text of a file */
-void change(frommark, tomark, newtext)
-	MARK	frommark, tomark;
-	char	*newtext;
-{
-	int	i;
-	long	l;
-	char	*text;
-	BLK	*blk;
-
-#ifdef DEBUG2
-	debout("change(%ld.%d, %ld.%d, \"%s\")\n", markline(frommark), markidx(frommark), markline(tomark), markidx(tomark), newtext);
-#endif
-
-	/* optimize for single-character replacement */
-	if (frommark + 1 == tomark && newtext[0] && !newtext[1] && newtext[0] != '\n')
-	{
-		/* find the block containing frommark */
-		l = markline(frommark);
-		for (i = 1; lnum[i] < l; i++)
-		{
-		}
-
-		/* get the block */
-		blk = blkget(i);
-
-		/* find the line within the block */
-		for (text = blk->c, i = l - lnum[i - 1] - 1; i > 0; text++)
-		{
-			if (*text == '\n')
-			{
-				i--;
-			}
-		}
-
-		/* replace the char */
-		text += markidx(frommark);
-		if (*text == newtext[0])
-		{
-			/* no change was needed - same char */
-			return;
-		}
-		else if (*text != '\n')
-		{
-			/* This is a change */
-			changes++;
-			significant = TRUE;
-			ChangeText
-			{
-				*text = newtext[0];
-				blkdirty(blk);
-			}
-			redrawrange(markline(frommark), markline(tomark), markline(frommark));
-			return;
-		}
-		/* else it is a complex change involving newline... */
-	}
-
-	/* couldn't optimize, so do delete & add */
-	ChangeText
-	{
-		delete(frommark, tomark);
-		add(frommark, newtext);
-		rptlabel = "changed";
-	}
-}
Index: trunk/minix/commands/elvis/move1.c
===================================================================
--- trunk/minix/commands/elvis/move1.c	(revision 9)
+++ 	(revision )
@@ -1,585 +1,0 @@
-/* move1.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains most movement functions */
-
-#include "config.h"
-#include "vi.h"
-#include "ctype.h"
-
-MARK	m_updnto(m, cnt, cmd)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument */
-	char	cmd;	/* the command character */
-{
-	DEFAULT(cmd == 'G' ? nlines : 1L);
-
-	/* move up or down 'cnt' lines */
-	switch (cmd)
-	{
-	  case ctrl('P'):
-	  case '-':
-	  case 'k':
-		m -= MARK_AT_LINE(cnt);
-		break;
-
-	  case 'G':
-		if (cnt < 1L || cnt > nlines)
-		{
-			msg("Only %ld lines", nlines);
-			return MARK_UNSET;
-		}
-		m = MARK_AT_LINE(cnt);
-		break;
-
-	  case '_':
-		cnt--;
-		/* fall through... */
-
-	  default:
-		m += MARK_AT_LINE(cnt);
-	}
-
-	/* if that left us screwed up, then fail */
-	if (m < MARK_FIRST || markline(m) > nlines)
-	{
-		return MARK_UNSET;
-	}
-
-	return m;
-}
-
-/*ARGSUSED*/
-MARK	m_right(m, cnt, key, prevkey)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument */
-	int	key;	/* movement keystroke */
-	int	prevkey;/* operator keystroke, or 0 if none */
-{
-	int		idx;	/* index of the new cursor position */
-
-	DEFAULT(1);
-
-	/* If used with an operator, then move 1 less character, since the 'l'
-	 * command includes the character that it moves onto.
-	 */
-	if (prevkey != '\0')
-	{
-		cnt--;
-	}
-
-	/* move to right, if that's OK */
-	pfetch(markline(m));
-	idx = markidx(m) + cnt;
-	if (idx < plen)
-	{
-		m += cnt;
-	}
-	else
-	{
-		return MARK_UNSET;
-	}
-
-	return m;
-}
-
-/*ARGSUSED*/
-MARK	m_left(m, cnt)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument */
-{
-	DEFAULT(1);
-
-	/* move to the left, if that's OK */
-	if (markidx(m) >= cnt)
-	{
-		m -= cnt;
-	}
-	else
-	{
-		return MARK_UNSET;
-	}
-
-	return m;
-}
-
-/*ARGSUSED*/
-MARK	m_tocol(m, cnt, cmd)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument */
-	int	cmd;	/* either ctrl('X') or '|' */
-{
-	char	*text;	/* text of the line */
-	int	col;	/* column number */
-	int	idx;	/* index into the line */
-
-
-	/* if doing ^X, then adjust for sideways scrolling */
-	if (cmd == ctrl('X'))
-	{
-		DEFAULT(*o_columns & 0xff);
-		cnt += leftcol;
-	}
-	else
-	{
-		DEFAULT(1);
-	}
-
-	/* internally, columns are numbered 0..COLS-1, not 1..COLS */
-	cnt--;
-
-	/* if 0, that's easy */
-	if (cnt == 0)
-	{
-		m &= ~(BLKSIZE - 1);
-		return m;
-	}
-
-	/* find that column within the line */
-	pfetch(markline(m));
-	text = ptext;
-	for (col = idx = 0; col < cnt && *text; text++, idx++)
-	{
-		if (*text == '\t' && !*o_list)
-		{
-			col += *o_tabstop;
-			col -= col % *o_tabstop;
-		}
-		else if (UCHAR(*text) < ' ' || *text == '\177')
-		{
-			col += 2;
-		}
-#ifndef NO_CHARATTR
-		else if (text[0] == '\\' && text[1] == 'f' && text[2] && *o_charattr)
-		{
-			text += 2; /* plus one more as part of for loop */
-		}
-#endif
-		else
-		{
-			col++;
-		}
-	}
-	if (!*text)
-	{
-		/* the desired column was past the end of the line, so
-		 * act like the user pressed "$" instead.
-		 */
-		return m | (BLKSIZE - 1);
-	}
-	else
-	{
-		m = (m & ~(BLKSIZE - 1)) + idx;
-	}
-	return m;
-}
-
-/*ARGSUSED*/
-MARK	m_front(m, cnt)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument (ignored) */
-{
-	char	*scan;
-
-	/* move to the first non-whitespace character */
-	pfetch(markline(m));
-	scan = ptext;
-	m &= ~(BLKSIZE - 1);
-	while (*scan == ' ' || *scan == '\t')
-	{
-		scan++;
-		m++;
-	}
-
-	return m;
-}
-
-/*ARGSUSED*/
-MARK	m_rear(m, cnt)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument (ignored) */
-{
-	/* Try to move *EXTREMELY* far to the right.  It is fervently hoped
-	 * that other code will convert this to a more reasonable MARK before
-	 * anything tries to actually use it.  (See adjmove() in vi.c)
-	 */
-	return m | (BLKSIZE - 1);
-}
-
-#ifndef NO_SENTENCE
-static int isperiod(ptr)
-	char	*ptr;	/* pointer to possible sentence-ender */
-{
-	/* if not '.', '?', or '!', then it isn't a sentence ender */
-	if (*ptr != '.' && *ptr != '?' && *ptr != '!')
-	{
-		return FALSE;
-	}
-
-	/* skip any intervening ')', ']', or '"' characters */
-	do
-	{
-		ptr++;
-	} while (*ptr == ')' || *ptr == ']' || *ptr == '"');
-
-	/* do we have two spaces or EOL? */
-	if (!*ptr || ptr[0] == ' ' && ptr[1] == ' ')
-	{
-		return TRUE;
-	}
-	return FALSE;
-}
-
-/*ARGSUSED*/
-MARK	m_sentence(m, cnt, cmd)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument */
-	int	cmd;	/* either '(' or ')' */
-{
-	REG char	*text;
-	REG long	l;
-
-	DEFAULT(1);
-
-	/* If '(' command, then move back one word, so that if we hit '(' at
-	 * the start of a sentence we don't simply stop at the end of the
-	 * previous sentence and bounce back to the start of this one again.
-	 */
-	if (cmd == '(')
-	{
-		m = m_bword(m, 1L, 'b');
-		if (!m)
-		{
-			return m;
-		}
-	}
-
-	/* get the current line */
-	l = markline(m);
-	pfetch(l);
-	text = ptext + markidx(m);
-
-	/* for each requested sentence... */
-	while (cnt-- > 0)
-	{
-		/* search forward for one of [.?!] followed by spaces or EOL */
-		do
-		{
-			if (cmd == ')')
-			{
-				/* move forward, wrap at end of line */
-				if (!text[0])
-				{
-					if (l >= nlines)
-					{
-						return MARK_UNSET;
-					}
-					l++;
-					pfetch(l);
-					text = ptext;
-				}
-				else
-				{
-					text++;
-				}
-			}
-			else
-			{
-				/* move backward, wrap at beginning of line */
-				if (text == ptext)
-				{
-					do
-					{
-						if (l <= 1)
-						{
-							return MARK_FIRST;
-						}
-						l--;
-						pfetch(l);
-					} while (!*ptext);
-					text = ptext + plen - 1;
-				}
-				else
-				{
-					text--;
-				}
-			}
-		} while (!isperiod(text));
-	}
-
-	/* construct a mark for this location */
-	m = buildmark(text);
-
-	/* move forward to the first word of the next sentence */
-	m = m_fword(m, 1L, 'w', '\0');
-
-	return m;
-}
-#endif
-
-MARK	m_paragraph(m, cnt, cmd)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument */
-	int	cmd;	/* either '{' or '}' */
-{
-	char	*text;	/* text of the current line */
-	char	*pscn;	/* used to scan thru value of "paragraphs" option */
-	long	l, ol;	/* current line number, original line number */
-	int	dir;	/* -1 if we're moving up, or 1 if down */
-	char	col0;	/* character to expect in column 0 */
-#ifndef NO_SENTENCE
-# define SENTENCE(x)	(x)
-	char	*list;	/* either o_sections or o_paragraph */
-#else
-# define SENTENCE(x)
-#endif
-
-	DEFAULT(1);
-
-	/* set the direction, based on the command */
-	switch (cmd)
-	{
-	  case '{':
-		dir = -1;
-		col0 = '\0';
-		SENTENCE(list = o_paragraphs); 
-		break;
-
-	  case '}':
-		dir = 1;
-		col0 = '\0';
-		SENTENCE(list = o_paragraphs); 
-		break;
-
-	  case '[':
-		if (getkey(0) != '[')
-		{
-			return MARK_UNSET;
-		}
-		dir = -1;
-		col0 = '{';
-		SENTENCE(list = o_sections); 
-		break;
-
-	  case ']':
-		if (getkey(0) != ']')
-		{
-			return MARK_UNSET;
-		}
-		dir = 1;
-		col0 = '{';
-		SENTENCE(list = o_sections); 
-		break;
-	}
-	ol = l = markline(m);
-
-	/* for each paragraph that we want to travel through... */
-	while (l > 0 && l <= nlines && cnt-- > 0)
-	{
-		/* skip blank lines between paragraphs */
-		while (l > 0 && l <= nlines && col0 == *(text = fetchline(l)))
-		{
-			l += dir;
-		}
-
-		/* skip non-blank lines that aren't paragraph separators
-		 */
-		do
-		{
-#ifndef NO_SENTENCE
-			if (*text == '.' && l != ol)
-			{
-				for (pscn = list; pscn[0] && pscn[1]; pscn += 2)
-				{
-					if (pscn[0] == text[1] && pscn[1] == text[2])
-					{
-						pscn = (char *)0;
-						goto BreakBreak;
-					}
-				}
-			}
-#endif
-			l += dir;
-		} while (l > 0 && l <= nlines && col0 != *(text = fetchline(l)));
-BreakBreak:	;
-	}
-
-	if (l > nlines)
-	{
-		m = MARK_LAST;
-	}
-	else if (l <= 0)
-	{
-		m = MARK_FIRST;
-	}
-	else
-	{
-		m = MARK_AT_LINE(l);
-	}
-	return m;
-}
-
-
-/*ARGSUSED*/
-MARK	m_match(m, cnt)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument (normally 0) */
-{
-	long	l;
-	REG char	*text;
-	REG char	match;
-	REG char	nest;
-	REG int		count;
-
-#ifndef NO_EXTENSIONS
-	/* if we're given a number, then treat it as a percentage of the file */
-	if (cnt > 0)
-	{
-		/* make sure it is a reasonable number */
-		if (cnt > 100)
-		{
-			msg("can only be from 1%% to 100%%");
-			return MARK_UNSET;
-		}
-
-		/* return the appropriate line number */
-		l = (nlines - 1L) * cnt / 100L + 1L;
-		return MARK_AT_LINE(l);
-	}
-#endif /* undef NO_EXTENSIONS */
-
-	/* get the current line */
-	l = markline(m);
-	pfetch(l);
-	text = ptext + markidx(m);
-
-	/* search forward within line for one of "[](){}" */
-	for (match = '\0'; !match && *text; text++)
-	{
-		/* tricky way to recognize 'em in ASCII */
-		nest = *text;
-		if ((nest & 0xdf) == ']' || (nest & 0xdf) == '[')
-		{
-			match = nest ^ ('[' ^ ']');
-		}
-		else if ((nest & 0xfe) == '(')
-		{
-			match = nest ^ ('(' ^ ')');
-		}
-		else
-		{
-			match = 0;
-		}
-	}
-	if (!match)
-	{
-		return MARK_UNSET;
-	}
-	text--;
-
-	/* search forward or backward for match */
-	if (match == '(' || match == '[' || match == '{')
-	{
-		/* search backward */
-		for (count = 1; count > 0; )
-		{
-			/* wrap at beginning of line */
-			if (text == ptext)
-			{
-				do
-				{
-					if (l <= 1L)
-					{
-						return MARK_UNSET;
-					}
-					l--;
-					pfetch(l);
-				} while (!*ptext);
-				text = ptext + plen - 1;
-			}
-			else
-			{
-				text--;
-			}
-
-			/* check the char */
-			if (*text == match)
-				count--;
-			else if (*text == nest)
-				count++;
-		}
-	}
-	else
-	{
-		/* search forward */
-		for (count = 1; count > 0; )
-		{
-			/* wrap at end of line */
-			if (!*text)
-			{
-				if (l >= nlines)
-				{
-					return MARK_UNSET;
-				}
-				l++;
-				pfetch(l);
-				text = ptext;
-			}
-			else
-			{
-				text++;
-			}
-
-			/* check the char */
-			if (*text == match)
-				count--;
-			else if (*text == nest)
-				count++;
-		}
-	}
-
-	/* construct a mark for this place */
-	m = buildmark(text);
-	return m;
-}
-
-/*ARGSUSED*/
-MARK	m_tomark(m, cnt, key)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* (ignored) */
-	int	key;	/* keystroke - the mark to move to */
-{
-	/* mark '' is a special case */
-	if (key == '\'' || key == '`')
-	{
-		if (mark[26] == MARK_UNSET)
-		{
-			return MARK_FIRST;
-		}
-		else
-		{
-			return mark[26];
-		}
-	}
-
-	/* if not a valid mark number, don't move */
-	if (key < 'a' || key > 'z')
-	{
-		return MARK_UNSET;
-	}
-
-	/* return the selected mark -- may be MARK_UNSET */
-	if (!mark[key - 'a'])
-	{
-		msg("mark '%c is unset", key);
-	}
-	return mark[key - 'a'];
-}
-
Index: trunk/minix/commands/elvis/move2.c
===================================================================
--- trunk/minix/commands/elvis/move2.c	(revision 9)
+++ 	(revision )
@@ -1,291 +1,0 @@
-/* move2.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This function contains the movement functions that perform RE searching */
-
-#include "config.h"
-#include "vi.h"
-#include "regexp.h"
-
-extern long	atol();
-
-static regexp	*re;	/* compiled version of the pattern to search for */
-static		prevsf;	/* boolean: previous search direction was forward? */
-
-#ifndef NO_EXTENSIONS
-/*ARGSUSED*/
-MARK m_wsrch(word, m, cnt)
-	char	*word;	/* the word to search for */
-	MARK	m;	/* the starting point */
-	int	cnt;	/* ignored */
-{
-	char	buffer[30];
-
-	/* wrap \< and \> around the word */
-	strcpy(buffer, "/\\<");
-	strcat(buffer, word);
-	strcat(buffer, "\\>");
-
-	/* show the searched-for word on the bottom line */
-	move(LINES - 1, 0);
-	qaddstr(buffer);
-	clrtoeol();
-	refresh();
-
-	/* search for the word */
-	return m_fsrch(m, buffer);
-}
-#endif
-
-MARK	m_nsrch(m)
-	MARK	m;	/* where to start searching */
-{
-	if (prevsf)
-	{
-		m = m_fsrch(m, (char *)0);
-		prevsf = TRUE;
-	}
-	else
-	{
-		m = m_bsrch(m, (char *)0);
-		prevsf = FALSE;
-	}
-	return m;
-}
-
-MARK	m_Nsrch(m)
-	MARK	m;	/* where to start searching */
-{
-	if (prevsf)
-	{
-		m = m_bsrch(m, (char *)0);
-		prevsf = TRUE;
-	}
-	else
-	{
-		m = m_fsrch(m, (char *)0);
-		prevsf = FALSE;
-	}
-	return m;
-}
-
-MARK	m_fsrch(m, ptrn)
-	MARK	m;	/* where to start searching */
-	char	*ptrn;	/* pattern to search for */
-{
-	long	l;	/* line# of line to be searched */
-	char	*line;	/* text of line to be searched */
-	int	wrapped;/* boolean: has our search wrapped yet? */
-	int	pos;	/* where we are in the line */
-#ifndef CRUNCH
-	long	delta = INFINITY;/* line offset, for things like "/foo/+1" */
-#endif
-
-	/* remember: "previous search was forward" */
-	prevsf = TRUE;
-
-	if (ptrn && *ptrn)
-	{
-		/* locate the closing '/', if any */
-		line = parseptrn(ptrn);
-#ifndef CRUNCH
-		if (*line)
-		{
-			delta = atol(line);
-		}
-#endif
-		ptrn++;
-
-		/* free the previous pattern */
-		if (re) free(re);
-
-		/* compile the pattern */
-		re = regcomp(ptrn);
-		if (!re)
-		{
-			return MARK_UNSET;
-		}
-	}
-	else if (!re)
-	{
-		msg("No previous expression");
-		return MARK_UNSET;
-	}
-
-	/* search forward for the pattern */
-	pos = markidx(m) + 1;
-	pfetch(markline(m));
-	if (pos >= plen)
-	{
-		pos = 0;
-		m = (m | (BLKSIZE - 1)) + 1;
-	}
-	wrapped = FALSE;
-	for (l = markline(m); l != markline(m) + 1 || !wrapped; l++)
-	{
-		/* wrap search */
-		if (l > nlines)
-		{
-			/* if we wrapped once already, then the search failed */
-			if (wrapped)
-			{
-				break;
-			}
-
-			/* else maybe we should wrap now? */
-			if (*o_wrapscan)
-			{
-				l = 0;
-				wrapped = TRUE;
-				continue;
-			}
-			else
-			{
-				break;
-			}
-		}
-
-		/* get this line */
-		line = fetchline(l);
-
-		/* check this line */
-		if (regexec(re, &line[pos], (pos == 0)))
-		{
-			/* match! */
-			if (wrapped && *o_warn)
-				msg("(wrapped)");
-#ifndef CRUNCH
-			if (delta != INFINITY)
-			{
-				l += delta;
-				if (l < 1 || l > nlines)
-				{
-					msg("search offset too big");
-					return MARK_UNSET;
-				}
-				force_flags = LNMD|INCL;
-				return MARK_AT_LINE(l);
-			}
-#endif
-			return MARK_AT_LINE(l) + (int)(re->startp[0] - line);
-		}
-		pos = 0;
-	}
-
-	/* not found */
-	msg(*o_wrapscan ? "Not found" : "Hit bottom without finding RE");
-	return MARK_UNSET;
-}
-
-MARK	m_bsrch(m, ptrn)
-	MARK	m;	/* where to start searching */
-	char	*ptrn;	/* pattern to search for */
-{
-	long	l;	/* line# of line to be searched */
-	char	*line;	/* text of line to be searched */
-	int	wrapped;/* boolean: has our search wrapped yet? */
-	int	pos;	/* last acceptable idx for a match on this line */
-	int	last;	/* remembered idx of the last acceptable match on this line */
-	int	try;	/* an idx at which we strat searching for another match */
-#ifndef CRUNCH
-	long	delta = INFINITY;/* line offset, for things like "/foo/+1" */
-#endif
-
-	/* remember: "previous search was not forward" */
-	prevsf = FALSE;
-
-	if (ptrn && *ptrn)
-	{
-		/* locate the closing '?', if any */
-		line = parseptrn(ptrn);
-#ifndef CRUNCH
-		if (*line)
-		{
-			delta = atol(line);
-		}
-#endif
-		ptrn++;
-
-		/* free the previous pattern, if any */
-		if (re) free(re);
-
-		/* compile the pattern */
-		re = regcomp(ptrn);
-		if (!re)
-		{
-			return MARK_UNSET;
-		}
-	}
-	else if (!re)
-	{
-		msg("No previous expression");
-		return MARK_UNSET;
-	}
-
-	/* search backward for the pattern */
-	pos = markidx(m);
-	wrapped = FALSE;
-	for (l = markline(m); l != markline(m) - 1 || !wrapped; l--)
-	{
-		/* wrap search */
-		if (l < 1)
-		{
-			if (*o_wrapscan)
-			{
-				l = nlines + 1;
-				wrapped = TRUE;
-				continue;
-			}
-			else
-			{
-				break;
-			}
-		}
-
-		/* get this line */
-		line = fetchline(l);
-
-		/* check this line */
-		if (regexec(re, line, 1) && (int)(re->startp[0] - line) < pos)
-		{
-			/* match!  now find the last acceptable one in this line */
-			do
-			{
-				last = (int)(re->startp[0] - line);
-				try = (int)(re->endp[0] - line);
-			} while (try > 0
-				 && regexec(re, &line[try], FALSE)
-				 && (int)(re->startp[0] - line) < pos);
-
-			if (wrapped && *o_warn)
-				msg("(wrapped)");
-#ifndef CRUNCH
-			if (delta != INFINITY)
-			{
-				l += delta;
-				if (l < 1 || l > nlines)
-				{
-					msg("search offset too big");
-					return MARK_UNSET;
-				}
-				force_flags = LNMD|INCL;
-				return MARK_AT_LINE(l);
-			}
-#endif
-			return MARK_AT_LINE(l) + last;
-		}
-		pos = BLKSIZE;
-	}
-
-	/* not found */
-	msg(*o_wrapscan ? "Not found" : "Hit top without finding RE");
-	return MARK_UNSET;
-}
-
Index: trunk/minix/commands/elvis/move3.c
===================================================================
--- trunk/minix/commands/elvis/move3.c	(revision 9)
+++ 	(revision )
@@ -1,163 +1,0 @@
-/* move3.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains movement functions that perform character searches */
-
-#include "config.h"
-#include "vi.h"
-
-#ifndef NO_CHARSEARCH
-static MARK	(*prevfwdfn)();	/* function to search in same direction */
-static MARK	(*prevrevfn)();	/* function to search in opposite direction */
-static char	prev_key;	/* sought cvhar from previous [fFtT] */
-
-MARK	m__ch(m, cnt, cmd)
-	MARK	m;	/* current position */
-	long	cnt;
-	char	cmd;	/* command: either ',' or ';' */
-{
-	MARK	(*tmp)();
-
-	if (!prevfwdfn)
-	{
-		msg("No previous f, F, t, or T command");
-		return MARK_UNSET;
-	}
-
-	if (cmd == ',')
-	{
-		m =  (*prevrevfn)(m, cnt, prev_key);
-
-		/* Oops! we didn't want to change the prev*fn vars! */
-		tmp = prevfwdfn;
-		prevfwdfn = prevrevfn;
-		prevrevfn = tmp;
-
-		return m;
-	}
-	else
-	{
-		return (*prevfwdfn)(m, cnt, prev_key);
-	}
-}
-
-/* move forward within this line to next occurrence of key */
-MARK	m_fch(m, cnt, key)
-	MARK	m;	/* where to search from */
-	long	cnt;
-	char	key;	/* what to search for */
-{
-	REG char	*text;
-
-	DEFAULT(1);
-
-	prevfwdfn = m_fch;
-	prevrevfn = m_Fch;
-	prev_key = key;
-
-	pfetch(markline(m));
-	text = ptext + markidx(m);
-	while (cnt-- > 0)
-	{
-		do
-		{
-			m++;
-			text++;
-		} while (*text && *text != key);
-	}
-	if (!*text)
-	{
-		return MARK_UNSET;
-	}
-	return m;
-}
-
-/* move backward within this line to previous occurrence of key */
-MARK	m_Fch(m, cnt, key)
-	MARK	m;	/* where to search from */
-	long	cnt;
-	char	key;	/* what to search for */
-{
-	REG char	*text;
-
-	DEFAULT(1);
-
-	prevfwdfn = m_Fch;
-	prevrevfn = m_fch;
-	prev_key = key;
-
-	pfetch(markline(m));
-	text = ptext + markidx(m);
-	while (cnt-- > 0)
-	{
-		do
-		{
-			m--;
-			text--;
-		} while (text >= ptext && *text != key);
-	}
-	if (text < ptext)
-	{
-		return MARK_UNSET;
-	}
-	return m;
-}
-
-/* move forward within this line almost to next occurrence of key */
-MARK	m_tch(m, cnt, key)
-	MARK	m;	/* where to search from */
-	long	cnt;
-	char	key;	/* what to search for */
-{
-	/* skip the adjacent char */
-	pfetch(markline(m));
-	if (plen <= markidx(m))
-	{
-		return MARK_UNSET;
-	}
-	m++;
-
-	m = m_fch(m, cnt, key);
-	if (m == MARK_UNSET)
-	{
-		return MARK_UNSET;
-	}
-
-	prevfwdfn = m_tch;
-	prevrevfn = m_Tch;
-
-	return m - 1;
-}
-
-/* move backward within this line almost to previous occurrence of key */
-MARK	m_Tch(m, cnt, key)
-	MARK	m;	/* where to search from */
-	long	cnt;
-	char	key;	/* what to search for */
-{
-	/* skip the adjacent char */
-	if (markidx(m) == 0)
-	{
-		return MARK_UNSET;
-	}
-	m--;
-
-	m = m_Fch(m, cnt, key);
-	if (m == MARK_UNSET)
-	{
-		return MARK_UNSET;
-	}
-
-	prevfwdfn = m_Tch;
-	prevrevfn = m_tch;
-
-	return m + 1;
-}
-#endif
Index: trunk/minix/commands/elvis/move4.c
===================================================================
--- trunk/minix/commands/elvis/move4.c	(revision 9)
+++ 	(revision )
@@ -1,211 +1,0 @@
-/* move4.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains movement functions which are screen-relative */
-
-#include "config.h"
-#include "vi.h"
-
-/* This moves the cursor to a particular row on the screen */
-/*ARGSUSED*/
-MARK m_row(m, cnt, key)
-	MARK	m;	/* the cursor position */
-	long	cnt;	/* the row we'll move to */
-	int	key;	/* the keystroke of this move - H/L/M */
-{
-	DEFAULT(1);
-
-	/* calculate destination line based on key */
-	cnt--;
-	switch (key)
-	{
-	  case 'H':
-		cnt = topline + cnt;
-		break;
-
-	  case 'M':
-		cnt = topline + (LINES - 1) / 2;
-		break;
-
-	  case 'L':
-		cnt = botline - cnt;
-		break;
-	}
-
-	/* return the mark of the destination line */
-	return MARK_AT_LINE(cnt);
-}
-
-
-/* This function repositions the current line to show on a given row */
-MARK m_z(m, cnt, key)
-	MARK	m;	/* the cursor */
-	long	cnt;	/* the line number we're repositioning */
-	int	key;	/* key struck after the z */
-{
-	long	newtop;
-	int	i;
-
-	/* Which line are we talking about? */
-	if (cnt < 0 || cnt > nlines)
-	{
-		return MARK_UNSET;
-	}
-	if (cnt)
-	{
-		m = MARK_AT_LINE(cnt);
-		newtop = cnt;
-	}
-	else
-	{
-		newtop = markline(m);
-	}
-
-	/* allow a "window size" number to be entered */
-	for (i = 0; key >= '0' && key <= '9'; key = getkey(0))
-	{
-		i = i * 10 + key - '0';
-	}
-#ifndef CRUNCH
-	if (i > 0 && i <= LINES - 1)
-	{
-		*o_window = i;
-		wset = TRUE;
-	}
-#else
-	/* the number is ignored if -DCRUNCH */
-#endif
-
-	/* figure out which line will have to be at the top of the screen */
-	switch (key)
-	{
-	  case '\n':
-#if OSK
-	  case '\l':
-#else
-	  case '\r':
-#endif
-	  case '+':
-		break;
-
-	  case '.':
-	  case 'z':
-		newtop -= LINES / 2;
-		break;
-
-	  case '-':
-		newtop -= LINES - 1;
-		break;
-
-	  default:
-		return MARK_UNSET;
-	}
-
-	/* make the new topline take effect */
-	redraw(MARK_UNSET, FALSE);
-	if (newtop >= 1)
-	{
-		topline = newtop;
-	}
-	else
-	{
-		topline = 1L;
-	}
-	redrawrange(0L, INFINITY, INFINITY);
-
-	/* The cursor doesn't move */
-	return m;
-}
-
-
-/* This function scrolls the screen.  It does this by calling redraw() with
- * an off-screen line as the argument.  It will move the cursor if necessary
- * so that the cursor is on the new screen.
- */
-/*ARGSUSED*/
-MARK m_scroll(m, cnt, key)
-	MARK	m;	/* the cursor position */
-	long	cnt;	/* for some keys: the number of lines to scroll */
-	int	key;	/* keystroke that causes this movement */
-{
-	MARK	tmp;	/* a temporary mark, used as arg to redraw() */
-
-	/* adjust cnt, and maybe *o_scroll, depending of key */
-	switch (key)
-	{
-	  case ctrl('F'):
-	  case ctrl('B'):
-		DEFAULT(1);
-		redrawrange(0L, INFINITY, INFINITY); /* force complete redraw */
-		cnt = cnt * (LINES - 1) - 2; /* keeps two old lines on screen */
-		break;
-
-	  case ctrl('E'):
-	  case ctrl('Y'):
-		DEFAULT(1);
-		break;
-
-	  case ctrl('U'):
-	  case ctrl('D'):
-		if (cnt == 0) /* default */
-		{
-			cnt = *o_scroll;
-		}
-		else
-		{
-			if (cnt > LINES - 1)
-			{
-				cnt = LINES - 1;
-			}
-			*o_scroll = cnt;
-		}
-		break;
-	}
-
-	/* scroll up or down, depending on key */
-	switch (key)
-	{
-	  case ctrl('B'):
-	  case ctrl('Y'):
-	  case ctrl('U'):
-		cnt = topline - cnt;
-		if (cnt < 1L)
-		{
-			cnt = 1L;
-			m = MARK_FIRST;
-		}
-		tmp = MARK_AT_LINE(cnt) + markidx(m);
-		redraw(tmp, FALSE);
-		if (markline(m) > botline)
-		{
-			m = MARK_AT_LINE(botline);
-		}
-		break;
-
-	  case ctrl('F'):
-	  case ctrl('E'):
-	  case ctrl('D'):
-		cnt = botline + cnt;
-		if (cnt > nlines)
-		{
-			cnt = nlines;
-			m = MARK_LAST;
-		}
-		tmp = MARK_AT_LINE(cnt) + markidx(m);
-		redraw(tmp, FALSE);
-		if (markline(m) < topline)
-		{
-			m = MARK_AT_LINE(topline);
-		}
-		break;
-	}
-
-	return m;
-}
Index: trunk/minix/commands/elvis/move5.c
===================================================================
--- trunk/minix/commands/elvis/move5.c	(revision 9)
+++ 	(revision )
@@ -1,256 +1,0 @@
-/* move5.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the word-oriented movement functions */
-
-#include "config.h"
-#include "ctype.h"
-#include "vi.h"
-
-MARK	m_fword(m, cnt, cmd, prevkey)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument */
-	int	cmd;	/* either 'w' or 'W' */
-	int	prevkey;/* previous command... if 'c' then exclude whitespace */
-{
-	REG long	l;
-	REG char	*text;
-	REG int		i;
-
-	DEFAULT(1);
-
-	l = markline(m);
-	pfetch(l);
-	text = ptext + markidx(m);
-
-#ifndef CRUNCH
-	/* As a special case, "cw" or "cW" on whitespace without a count
-	 * treats the single whitespace character under the cursor as a word.
-	 */
-	if (cnt == 1L && prevkey == 'c' && isspace(*text))
-	{
-		return m + 1L;
-	}
-#endif
-
-	while (cnt-- > 0) /* yes, ASSIGNMENT! */
-	{
-		i = *text++;
-
-		if (cmd == 'W')
-		{
-			/* include any non-whitespace */
-			while (i && !isspace(i))
-			{
-				i = *text++;
-			}
-		}
-		else if (isalnum(i) || i == '_')
-		{
-			/* include an alphanumeric word */
-			while (i && isalnum(i))
-			{
-				i = *text++;
-			}
-		}
-		else
-		{
-			/* include contiguous punctuation */
-			while (i && !isalnum(i) && !isspace(i))
-			{
-				i = *text++;
-			}
-		}
-
-		/* if not part of "cw" or "cW" command... */
-		if (prevkey != 'c' || cnt > 0)
-		{
-			/* include trailing whitespace */
-			while (!i || isspace(i))
-			{
-				/* did we hit the end of this line? */
-				if (!i)
-				{
-					/* "dw" shouldn't delete newline after word */
-					if (prevkey && cnt == 0)
-					{
-						break;
-					}
-
-					/* move to next line, if there is one */
-					l++;
-					if (l > nlines)
-					{
-						return MARK_UNSET;
-					}
-					pfetch(l);
-					text = ptext;
-				}
-
-				i = *text++;
-			}
-		}
-		text--;
-	}
-
-	/* if argument to operator, then back off 1 char since "w" and "W"
-	 * include the last char in the affected text.
-	 */
-	if (prevkey)
-	{
-		text--;
-	}
-
-	/* construct a MARK for this place */
-	m = buildmark(text);
-	return m;
-}
-
-
-MARK	m_bword(m, cnt, cmd)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument */
-	int	cmd;	/* either 'b' or 'B' */
-{
-	REG long	l;
-	REG char	*text;
-
-	DEFAULT(1);
-
-	l = markline(m);
-	pfetch(l);
-	text = ptext + markidx(m);
-	while (cnt-- > 0) /* yes, ASSIGNMENT! */
-	{
-		text--;
-
-		/* include preceding whitespace */
-		while (text < ptext || isspace(*text))
-		{
-			/* did we hit the end of this line? */
-			if (text < ptext)
-			{
-				/* move to preceding line, if there is one */
-				l--;
-				if (l <= 0)
-				{
-					return MARK_UNSET;
-				}
-				pfetch(l);
-				text = ptext + plen - 1;
-			}
-			else
-			{
-				text--;
-			}
-		}
-
-		if (cmd == 'B')
-		{
-			/* include any non-whitespace */
-			while (text >= ptext && !isspace(*text))
-			{
-				text--;
-			}
-		}
-		else if (isalnum(*text) || *text == '_')
-		{
-			/* include an alphanumeric word */
-			while (text >= ptext && isalnum(*text))
-			{
-				text--;
-			}
-		}
-		else
-		{
-			/* include contiguous punctuation */
-			while (text >= ptext && !isalnum(*text) && !isspace(*text))
-			{
-				text--;
-			}
-		}
-		text++;
-	}
-
-	/* construct a MARK for this place */
-	m = buildmark(text);
-	return m;
-}
-
-MARK	m_eword(m, cnt, cmd)
-	MARK	m;	/* movement is relative to this mark */
-	long	cnt;	/* a numeric argument */
-	int	cmd;	/* either 'e' or 'E' */
-{
-	REG long	l;
-	REG char	*text;
-	REG int		i;
-
-	DEFAULT(1);
-
-	l = markline(m);
-	pfetch(l);
-	text = ptext + markidx(m);
-	while (cnt-- > 0) /* yes, ASSIGNMENT! */
-	{
-		if (*text)
-			text++;
-		i = *text++;
-
-		/* include preceding whitespace */
-		while (!i || isspace(i))
-		{
-			/* did we hit the end of this line? */
-			if (!i)
-			{
-				/* move to next line, if there is one */
-				l++;
-				if (l > nlines)
-				{
-					return MARK_UNSET;
-				}
-				pfetch(l);
-				text = ptext;
-			}
-
-			i = *text++;
-		}
-
-		if (cmd == 'E')
-		{
-			/* include any non-whitespace */
-			while (i && !isspace(i))
-			{
-				i = *text++;
-			}
-		}
-		else if (isalnum(i) || i == '_')
-		{
-			/* include an alphanumeric word */
-			while (i && isalnum(i))
-			{
-				i = *text++;
-			}
-		}
-		else
-		{
-			/* include contiguous punctuation */
-			while (i && !isalnum(i) && !isspace(i))
-			{
-				i = *text++;
-			}
-		}
-		text -= 2;
-	}
-
-	/* construct a MARK for this place */
-	m = buildmark(text);
-	return m;
-}
Index: trunk/minix/commands/elvis/opts.c
===================================================================
--- trunk/minix/commands/elvis/opts.c	(revision 9)
+++ 	(revision )
@@ -1,797 +1,0 @@
-/* opts.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the code that manages the run-time options -- The 
- * values that can be modified via the "set" command.
- */
-
-#include "config.h"
-#include "vi.h"
-#include "ctype.h"
-#ifndef NULL
-#define NULL (char *)0
-#endif
-extern char	*getenv();
-
-/* maximum width to permit for strings, including ="" */
-#define MAXWIDTH 20
-
-/* These are the default values of all options */
-char	o_autoindent[1] =	{FALSE};
-char	o_autoprint[1] =	{TRUE};
-char	o_autotab[1] =		{TRUE};
-char	o_autowrite[1] = 	{FALSE};
-char	o_columns[3] =		{80, 32, 255};
-char	o_directory[30] =	TMPDIR;
-char	o_edcompatible[1] =	{FALSE};
-char	o_equalprg[80] =	{"fmt"};
-char	o_errorbells[1] =	{TRUE};
-char	o_exrefresh[1] =	{TRUE};
-char	o_ignorecase[1] =	{FALSE};
-char	o_keytime[3] =		{1, 0, 50};
-char	o_keywordprg[80] =	{KEYWORDPRG};
-char	o_lines[3] =		{25, 2, 96};
-char	o_list[1] =		{FALSE};
-char	o_number[1] =		{FALSE};
-char	o_readonly[1] =		{FALSE};
-char	o_remap[1] =		{TRUE};
-char	o_report[3] =		{5, 1, 127};
-char	o_scroll[3] =		{12, 1, 127};
-char	o_shell[60] =		SHELL;
-char	o_shiftwidth[3] =	{8, 1, 255};
-char	o_sidescroll[3] =	{8, 1, 40};
-char	o_sync[1] =		{NEEDSYNC};
-char	o_tabstop[3] =		{8, 1, 40};
-char	o_term[30] =		"?";
-char	o_flash[1] =		{TRUE};
-char	o_warn[1] =		{TRUE};
-char	o_wrapscan[1] =		{TRUE};
-
-#ifndef CRUNCH
-char	o_beautify[1] =		{FALSE};
-char	o_exrc[1] =		{FALSE};
-char	o_mesg[1] =		{TRUE};
-char	o_more[1] =		{TRUE};
-char	o_novice[1] =		{FALSE};
-char	o_prompt[1] =		{TRUE};
-char	o_taglength[3] =	{0, 0, 30};
-char	o_terse[1] =		{FALSE};
-char	o_window[3] =		{0, 1, 24};
-char	o_wrapmargin[3] =	{0, 0, 255};
-char	o_writeany[1] =		{FALSE};
-#endif
-
-#ifndef NO_ERRLIST
-char	o_cc[30] =		{CC_COMMAND};
-char	o_make[30] =		{MAKE_COMMAND};
-#endif
-
-#ifndef NO_CHARATTR
-char	o_charattr[1] =		{FALSE};
-#endif
-
-#ifndef NO_DIGRAPH
-char	o_digraph[1] =		{FALSE};
-char	o_flipcase[80]
-# ifdef CS_IBMPC
-	= {"\207\200\201\232\202\220\204\216\206\217\221\222\224\231\244\245"}
-# endif
-# ifdef CS_LATIN1
-	/* initialized by initopts() */
-# endif
-	;
-#endif
-
-#ifndef NO_SENTENCE
-char	o_hideformat[1] =	{FALSE};
-#endif
-
-#ifndef NO_EXTENSIONS
-char	o_inputmode[1] =	{FALSE};
-char	o_ruler[1] =		{FALSE};
-#endif
-
-#ifndef NO_MAGIC
-char	o_magic[1] =		{TRUE};
-#endif
-
-#ifndef NO_MODELINES
-char	o_modelines[1] =	{FALSE};
-#endif
-
-#ifndef NO_SENTENCE
-char	o_paragraphs[30] =	"PPppIPLPQP";
-char	o_sections[30] =	"NHSHSSSEse";
-#endif
-
-#if MSDOS
-char	o_pcbios[1] =		{TRUE};
-#endif
-
-#ifndef NO_SHOWMATCH
-char	o_showmatch[1] =	{FALSE};
-#endif
-
-#ifndef	NO_SHOWMODE
-char	o_smd[1] =		{FALSE};
-#endif
-
-
-/* The following describes the names & types of all options */
-#define BOOL	0
-#define	NUM	1
-#define	STR	2
-#define SET	0x01	/* this option has had its value altered */
-#define CANSET	0x02	/* this option can be set at any time */
-#define RCSET	0x06	/* this option can be set in a .exrc file only */
-#define NOSAVE	0x0a	/* this option should never be saved by mkexrc */
-#define WSET	0x20	/* is this the "window" size option? */
-#define MR	0x40	/* does this option affect the way text is displayed? */
-struct
-{
-	char	*name;	/* name of an option */
-	char	*nm;	/* short name of an option */
-	char	type;	/* type of an option */
-	char	flags;	/* boolean: has this option been set? */
-	char	*value;	/* value */
-}
-	opts[] =
-{
-	/* name			type	flags		value */
-	{ "autoindent",	"ai",	BOOL,	CANSET,		o_autoindent	},
-	{ "autoprint",	"ap",	BOOL,	CANSET,		o_autoprint	},
-	{ "autotab",	"at",	BOOL,	CANSET,		o_autotab	},
-	{ "autowrite",	"aw",	BOOL,	CANSET,		o_autowrite	},
-#ifndef CRUNCH
-	{ "beautify",	"bf",	BOOL,	CANSET,		o_beautify	},
-#endif
-#ifndef NO_ERRLIST
-	{ "cc",		"cc",	STR,	CANSET,		o_cc		},
-#endif
-#ifndef NO_CHARATTR
-	{ "charattr",	"ca",	BOOL,	CANSET|MR,	o_charattr	},
-#endif
-	{ "columns",	"co",	NUM,	SET|NOSAVE|MR,	o_columns	},
-#ifndef NO_DIGRAPH
-	{ "digraph",	"dig",	BOOL,	CANSET,		o_digraph	},
-#endif
-	{ "directory",	"dir",	STR,	RCSET,		o_directory	},
-	{ "edcompatible","ed",	BOOL,	CANSET,		o_edcompatible	},
-	{ "equalprg",	"ep",	STR,	CANSET,		o_equalprg	},
-	{ "errorbells",	"eb",	BOOL,	CANSET,		o_errorbells	},
-#ifndef CRUNCH
-	{ "exrc",	"exrc",	BOOL,	CANSET,		o_exrc		},
-#endif
-	{ "exrefresh",	"er",	BOOL,	CANSET,		o_exrefresh	},
-	{ "flash",	"vbell",BOOL,	CANSET,		o_flash		},
-#ifndef NO_DIGRAPH
-	{ "flipcase",	"fc",	STR,	CANSET,		o_flipcase	},
-#endif
-#ifndef NO_SENTENCE
-	{ "hideformat",	"hf",	BOOL,	CANSET|MR,	o_hideformat	},
-#endif
-	{ "ignorecase",	"ic",	BOOL,	CANSET,		o_ignorecase	},
-#ifndef NO_EXTENSIONS
-	{ "inputmode",	"im",	BOOL,	CANSET,		o_inputmode	},
-#endif
-	{ "keytime",	"kt",	NUM,	CANSET,		o_keytime	},
-	{ "keywordprg",	"kp",	STR,	CANSET,		o_keywordprg	},
-	{ "lines",	"ls",	NUM,	SET|NOSAVE|MR,	o_lines		},
-	{ "list",	"li",	BOOL,	CANSET|MR,	o_list		},
-#ifndef NO_MAGIC
-	{ "magic",	"ma",	BOOL,	CANSET,		o_magic		},
-#endif
-#ifndef NO_ERRLIST
-	{ "make",	"mk",	STR,	CANSET,		o_make		},
-#endif
-#ifndef CRUNCH
-	{ "mesg",	"me",	BOOL,	CANSET,		o_mesg		},
-#endif
-#ifndef NO_MODELINES
-	{ "modelines",	"ml",	BOOL,	CANSET,		o_modelines	},
-#endif
-#ifndef CRUNCH
-	{ "more",	"mo",	BOOL,	CANSET,		o_more		},
-	{ "novice",	"nov",	BOOL,	CANSET,		o_novice	},
-#endif
-	{ "number",	"nu",	BOOL,	CANSET|MR,	o_number	},
-#ifndef NO_SENTENCE
-	{ "paragraphs",	"para",	STR,	CANSET,		o_paragraphs	},
-#endif
-#if MSDOS
-	{ "pcbios",	"pc",	BOOL,	SET|NOSAVE,	o_pcbios	},
-#endif
-#ifndef CRUNCH
-	{ "prompt",	"pr",	BOOL,	CANSET,		o_prompt	},
-#endif
-	{ "readonly",	"ro",	BOOL,	CANSET,		o_readonly	},
-	{ "remap",	"remap",BOOL,	CANSET,		o_remap		},
-	{ "report",	"re",	NUM,	CANSET,		o_report	},
-#ifndef NO_EXTENSIONS
-	{ "ruler",	"ru",	BOOL,	CANSET,		o_ruler		},
-#endif
-	{ "scroll",	"sc",	NUM,	CANSET,		o_scroll	},
-#ifndef NO_SENTENCE
-	{ "sections",	"sect",	STR,	CANSET,		o_sections	},
-#endif
-	{ "shell",	"sh",	STR,	CANSET,		o_shell		},
-#ifndef NO_SHOWMATCH
-	{ "showmatch",	"sm",	BOOL,	CANSET,		o_showmatch	},
-#endif
-#ifndef	NO_SHOWMODE
-	{ "showmode",	"smd",	BOOL,	CANSET,		o_smd		},
-#endif
-	{ "shiftwidth",	"sw",	NUM,	CANSET,		o_shiftwidth	},
-	{ "sidescroll",	"ss",	NUM,	CANSET,		o_sidescroll	},
-	{ "sync",	"sy",	BOOL,	CANSET,		o_sync		},
-	{ "tabstop",	"ts",	NUM,	CANSET|MR,	o_tabstop	},
-#ifndef CRUNCH
-	{ "taglength",	"tl",	NUM,	CANSET,		o_taglength	},
-#endif
-	{ "term",	"te",	STR,	SET,		o_term		},
-#ifndef CRUNCH
-	{ "terse",	"tr",	BOOL,	CANSET,		o_terse		},
-	{ "timeout",	"to",	BOOL,	CANSET,		o_keytime	},
-#endif
-#ifndef CRUNCH
-	{ "window",	"wi",	NUM,	CANSET|MR|WSET,	o_window	},
-	{ "wrapmargin",	"wm",	NUM,	CANSET,		o_wrapmargin	},
-#endif
-	{ "wrapscan",	"ws",	BOOL,	CANSET,		o_wrapscan	},
-#ifndef CRUNCH
-	{ "writeany",	"wr",	BOOL,	CANSET,		o_writeany	},
-#endif
-	{ NULL, NULL, 0, CANSET, NULL }
-};
-
-
-/* This function initializes certain options from environment variables, etc. */
-void initopts()
-{
-	char	*val;
-	int	i;
-
-	/* set some stuff from environment variables */
-#if MSDOS
-	if (val = getenv("COMSPEC")) /* yes, ASSIGNMENT! */
-#else
-	if (val = getenv("SHELL")) /* yes, ASSIGNMENT! */
-#endif
-	{
-		strcpy(o_shell, val);
-	}
-
-	strcpy(o_term, termtype);
-#if MSDOS
-	if (strcmp(termtype, "pcbios"))
-	{
-		o_pcbios[0] = FALSE;
-	}
-	else
-	{
-		o_pcbios[0] = TRUE;
-	}
-#endif
-
-#if AMIGA || MSDOS || TOS
-	if ((val = getenv("TMP")) /* yes, ASSIGNMENT! */
-	||  (val = getenv("TEMP")))
-		strcpy(o_directory, val);
-#endif
-
-#ifndef CRUNCH
-	if ((val = getenv("LINES")) && atoi(val) > 4) /* yes, ASSIGNMENT! */
-	{
-		LINES = atoi(val);
-	}
-	if ((val = getenv("COLUMNS")) && atoi(val) > 30) /* yes, ASSIGNMENT! */
-	{
-		COLS = atoi(val);
-	}
-#endif
-	*o_lines = LINES;
-	*o_columns = COLS;
-	*o_scroll = LINES / 2 - 1;
-#ifndef CRUNCH
-	if (o_window[0] == 0)
-	{
-		o_window[0] = o_window[2] = *o_lines;
-	}
-#endif
-
-	/* disable the flash option if we don't know how to do a flash */
-	if (!has_VB)
-	{
-		for (i = 0; opts[i].value != o_flash; i++)
-		{
-		}
-		opts[i].flags &= ~CANSET;
-		*o_flash = FALSE;
-	}
-
-#ifndef NO_DIGRAPH
-# ifdef CS_LATIN1
-	for (i = 0, val = o_flipcase; i < 32; i++)
-	{
-		/* leave out the multiply/divide symbols */
-		if (i == 23)
-			continue;
-
-		/* add lower/uppercase pair */
-		*val++ = i + 0xe0;
-		*val++ = i + 0xc0;
-	}
-	*val = '\0';
-# endif /* CS_LATIN1 */
-
-	/* initialize the ctype package */
-	_ct_init(o_flipcase);
-#else
-	_ct_init("");
-#endif /* not NO_DIGRAPH */
-}
-
-/* This function lists the current values of all options */
-void dumpopts(all)
-	int	all;	/* boolean: dump all options, or just set ones? */
-{
-#ifndef NO_OPTCOLS
-	int	i, j, k;
-	char	nbuf[4];	/* used for converting numbers to ASCII */
-	int	widths[5];	/* width of each column, including gap */
-	int	ncols;		/* number of columns */
-	int	nrows;		/* number of options per column */
-	int	nset;		/* number of options to be output */
-	int	width;		/* width of a particular option */
-	int	todump[60];	/* indicies of options to be dumped */
-
-	/* step 1: count the number of set options */
-	for (nset = i = 0; opts[i].name; i++)
-	{
-		if (all || (opts[i].flags & SET))
-		{
-			todump[nset++] = i;
-		}
-	}
-
-	/* step two: try to use as many columns as possible */
-	for (ncols = (nset > 5 ? 5 : nset); ncols > 1; ncols--)
-	{
-		/* how many would go in this column? */
-		nrows = (nset + ncols - 1) / ncols;
-
-		/* figure out the width of each column */
-		for (i = 0; i < ncols; i++)
-		{
-			widths[i] = 0;
-			for (j = 0, k = nrows * i; j < nrows && k < nset; j++, k++)
-			{
-				/* figure out the width of a particular option */
-				switch (opts[todump[k]].type)
-				{
-				  case BOOL:
-					if (!*opts[todump[k]].value)
-						width = 2;
-					else
-						width = 0;
-					break;
-
-				  case STR:
-					width = 3 + strlen(opts[todump[k]].value);
-					if (width > MAXWIDTH)
-						width = MAXWIDTH;
-					break;
-
-				  case NUM:
-					width = 4;
-					break;
-				}
-				width += strlen(opts[todump[k]].name);
-
-				/* if this is the widest so far, widen col */
-				if (width > widths[i])
-				{
-					widths[i] = width;
-				}
-			}
-
-		}
-
-		/* if the total width is narrow enough, then use it */
-		for (width = -2, i = 0; i < ncols; i++)
-		{
-			width += widths[i] + 2;
-		}
-		if (width < COLS - 1)
-		{
-			break;
-		}
-	}
-
-	/* step 3: output the columns */
-	nrows = (nset + ncols - 1) / ncols;
-	for (i = 0; i < nrows; i++)
-	{
-		for (j = 0; j < ncols; j++)
-		{
-			/* if we hit the end of the options, quit */
-			k = i + j * nrows;
-			if (k >= nset)
-			{
-				break;
-			}
-
-			/* output this option's value */
-			width = 0;
-			switch (opts[todump[k]].type)
-			{
-			  case BOOL:
-				if (!*opts[todump[k]].value)
-				{
-					qaddch('n');
-					qaddch('o');
-					width = 2;
-				}
-				qaddstr(opts[todump[k]].name);
-				width += strlen(opts[todump[k]].name);
-				break;
-
-			  case NUM:
-				sprintf(nbuf, "%-3d", UCHAR(*opts[todump[k]].value));
-				qaddstr(opts[todump[k]].name);
-				qaddch('=');
-				qaddstr(nbuf);
-				width = 4 + strlen(opts[todump[k]].name);
-				break;
-
-			  case STR:
-				qaddstr(opts[todump[k]].name);
-				qaddch('=');
-				qaddch('"');
-				strcpy(tmpblk.c, opts[todump[k]].value);
-				width = 3 + strlen(tmpblk.c);
-				if (width > MAXWIDTH)
-				{
-					width = MAXWIDTH;
-					strcpy(tmpblk.c + MAXWIDTH - 6, "...");
-				}
-				qaddstr(tmpblk.c);
-				qaddch('"');
-				width += strlen(opts[todump[k]].name);
-				break;
-			}
-
-			/* pad the field to the correct size */
-			if (k + nrows <= nset)
-			{
-				while (width < widths[j] + 2)
-				{
-					qaddch(' ');
-					width++;
-				}
-			}
-		}
-		addch('\n');
-		exrefresh();
-	}
-#else
-	int	i;
-	int	col;
-	char	nbuf[4];
-
-	for (i = col = 0; opts[i].name; i++)
-	{
-		/* if not set and not all, ignore this option */
-		if (!all && !(opts[i].flags & SET))
-		{
-			continue;
-		}
-
-		/* align this option in one of the columns */
-		if (col > 52)
-		{
-			addch('\n');
-			col = 0;
-		}
-		else if (col > 26)
-		{
-			while (col < 52)
-			{
-				qaddch(' ');
-				col++;
-			}
-		}
-		else if (col > 0)
-		{
-			while (col < 26)
-			{
-				qaddch(' ');
-				col++;
-			}
-		}
-
-		switch (opts[i].type)
-		{
-		  case BOOL:
-			if (!*opts[i].value)
-			{
-				qaddch('n');
-				qaddch('o');
-				col += 2;
-			}
-			qaddstr(opts[i].name);
-			col += strlen(opts[i].name);
-			break;
-
-		  case NUM:
-			sprintf(nbuf, "%-3d", UCHAR(*opts[i].value));
-			qaddstr(opts[i].name);
-			qaddch('=');
-			qaddstr(nbuf);
-			col += 4 + strlen(opts[i].name);
-			break;
-
-		  case STR:
-			qaddstr(opts[i].name);
-			qaddch('=');
-			qaddch('"');
-			qaddstr(opts[i].value);
-			qaddch('"');
-			col += 3 + strlen(opts[i].name) + strlen(opts[i].value);
-			break;
-		}
-		exrefresh();
-	}
-	if (col > 0)
-	{
-		addch('\n');
-		exrefresh();
-	}
-#endif
-}
-
-#ifndef NO_MKEXRC
-/* This function saves the current configuration of options to a file */
-void saveopts(fd)
-	int	fd;	/* file descriptor to write to */
-{
-	int	i;
-	char	buf[256], *pos;
-
-	/* write each set options */
-	for (i = 0; opts[i].name; i++)
-	{
-		/* if unset or unsettable, ignore this option */
-		if ((opts[i].flags & (SET|CANSET|NOSAVE)) != (SET|CANSET))
-		{
-			continue;
-		}
-
-		strcpy(buf, "set ");
-		pos = &buf[4];
-		switch (opts[i].type)
-		{
-		  case BOOL:
-			if (!*opts[i].value)
-			{
-				*pos++='n';
-				*pos++='o';
-			}
-			strcpy(pos, opts[i].name);
-			strcat(pos, "\n");
-			break;
-
-		  case NUM:
-			sprintf(pos, "%s=%-3d\n", opts[i].name, *opts[i].value & 0xff);
-			break;
-
-		  case STR:
-			sprintf(pos, "%s=\"%s\"\n", opts[i].name, opts[i].value);
-			break;
-		}
-		twrite(fd, buf, (unsigned)strlen(buf));
-	}
-}
-#endif
-
-
-/* This function changes the values of one or more options. */
-void setopts(assignments)
-	char	*assignments;	/* a string containing option assignments */
-{
-	char	*name;		/* name of variable in assignments */
-	char	*value;		/* value of the variable */
-	char	*scan;		/* used for moving through strings */
-	char	*build;		/* used for copying chars from "scan" */
-	char	*prefix;	/* pointer to "neg" or "no" at front of a boolean */
-	int	quote;		/* boolean: inside '"' quotes? */
-	int	i, j;
-
-#ifndef CRUNCH
-	/* reset the upper limit of "window" option to lines-1 */
-	*o_window = *o_lines - 1;
-#endif
-
-	/* for each assignment... */
-	for (name = assignments; *name; )
-	{
-		/* skip whitespace */
-		if (*name == ' ' || *name == '\t')
-		{
-			name++;
-			continue;
-		}
-
-		/* after the name, find the value (if any) */
-		for (scan = name; isalnum(*scan); scan++)
-		{
-		}
-		if (*scan == '=')
-		{
-			*scan++ = '\0';
-			value = build = scan;
-			for (quote = FALSE; *scan && (quote || !isspace(*scan)); scan++)
-			{
-				if (*scan == '"')
-				{
-					quote = !quote;
-				}
-				else if (*scan == '\\' && scan[1])
-				{
-					*build++ = *++scan;
-				}
-				else
-				{
-					*build++ = *scan;
-				}
-			}
-			if (*scan)
-				scan++;
-			*build = '\0';
-		}
-		else /* no "=" so it is probably boolean... */
-		{
-			if (*scan)
-			{
-				*scan++ = '\0';
-			}
-			value = NULL;
-			prefix = name;
-#ifndef CRUNCH
-			if (!strcmp(name, "novice"))
-				/* don't check for a "no" prefix */;
-			else
-#endif
-			if (prefix[0] == 'n' && prefix[1] == 'o')
-				name += 2;
-			else if (prefix[0] == 'n' && prefix[1] == 'e' && prefix[2] == 'g')
-				name += 3;
-		}
-
-		/* find the variable */
-		for (i = 0;
-		     opts[i].name && strcmp(opts[i].name, name) && strcmp(opts[i].nm, name);
-		     i++)
-		{
-		}
-
-		/* change the variable */
-		if (!opts[i].name)
-		{
-			msg("invalid option name \"%s\"", name);
-		}
-		else if ((opts[i].flags & CANSET) != CANSET)
-		{
-			msg("option \"%s\" can't be altered", name);
-		}
-		else if ((opts[i].flags & RCSET) != CANSET && nlines >= 1L)
-		{
-			msg("option \"%s\" can only be set in a %s file", name, EXRC);
-		}
-		else if (value)
-		{
-			switch (opts[i].type)
-			{
-			  case BOOL:
-				msg("option \"[no]%s\" is boolean", name);
-				break;
-
-			  case NUM:
-				j = atoi(value);
-				if (j == 0 && *value != '0')
-				{
-					msg("option \"%s\" must have a numeric value", name);
-				}
-				else if (j < opts[i].value[1] || j > (opts[i].value[2] & 0xff))
-				{
-					msg("option \"%s\" must have a value between %d and %d",
-						name, opts[i].value[1], opts[i].value[2] & 0xff);
-				}
-				else
-				{
-					*opts[i].value = atoi(value);
-					opts[i].flags |= SET;
-				}
-				break;
-
-			  case STR:
-				strcpy(opts[i].value, value);
-				opts[i].flags |= SET;
-				break;
-			}
-			if (opts[i].flags & MR)
-			{
-				redraw(MARK_UNSET, FALSE);
-			}
-#ifndef CRUNCH
-			if (opts[i].flags & WSET)
-			{
-				wset = TRUE;
-			}
-#endif
-		}
-		else /* valid option, no value */
-		{
-			if (opts[i].type == BOOL)
-			{
-				if (prefix == name)
-					*opts[i].value = TRUE;
-				else if (prefix[1] == 'o')
-					*opts[i].value = FALSE;
-				else
-					*opts[i].value = !*opts[i].value;
-
-				opts[i].flags |= SET;
-				if (opts[i].flags & MR)
-				{
-					redraw(MARK_UNSET, FALSE);
-				}
-			}
-			else
-			{
-				msg("option \"%s\" must be given a value", name);
-			}
-		}
-
-		/* move on to the next option */
-		name = scan;
-	}
-
-	/* special processing ... */
-
-#ifndef CRUNCH
-	/* if "novice" is set, then ":set report=1 showmode nomagic" */
-	if (*o_novice)
-	{
-		*o_report = 1;
-# ifndef NO_SHOWMODE
-		*o_smd = TRUE;
-# endif
-# ifndef NO_MAGIC
-		*o_magic = FALSE;
-# endif
-	}
-#endif
-
-	/* if "readonly" then set the READONLY flag for this file */
-	if (*o_readonly)
-	{
-		setflag(file, READONLY);
-	}
-
-#ifndef NO_DIGRAPH
-	/* re-initialize the ctype package */
-	_ct_init(o_flipcase);
-#endif /* not NO_DIGRAPH */
-
-	/* copy o_lines and o_columns into LINES and COLS */
-	LINES = (*o_lines & 255);
-	COLS = (*o_columns & 255);
-}
Index: trunk/minix/commands/elvis/prsvunix.c
===================================================================
--- trunk/minix/commands/elvis/prsvunix.c	(revision 9)
+++ 	(revision )
@@ -1,106 +1,0 @@
-/* prsvunix.c */
-
-/* This file contains the UNIX-specific parts of the "elvprsv" program. */
-
-#if OSK
-#define ELVPRSV
-#include "osk.c"
-#else
-#include <sys/stat.h>
-#include <pwd.h>
-#endif
-extern struct passwd *getpwuid();
-
-/* This variable is used to add extra error messages for mail sent to root */
-char *ps;
-
-/* This function returns the login name of the owner of a file */
-char *ownername(filename)
-	char	*filename;	/* name of a file */
-{
-	struct stat	st;
-	struct passwd	*pw;
-
-	/* stat the file, to get its uid */
-	if (stat(filename, &st) < 0)
-	{
-		ps = "stat() failed";
-		return "root";
-	}
-
-	/* get the /etc/passwd entry for that user */
-	pw = getpwuid(st.st_uid);
-	if (!pw)
-	{
-		ps = "uid not found in password file";
-		return "root";
-	}
-
-	/* return the user's name */
-	return pw->pw_name;
-}
-
-
-/* This function sends a mail message to a given user, saying that a file
- * has been preserved.
- */
-void mail(user, file, when)
-	char	*user;	/* name of user who should receive the mail */
-	char	*file;	/* name of original text file that was preserved */
-	char	*when;	/* description of why the file was preserved */
-{
-	char	cmd[80];/* buffer used for constructing a "mail" command */
-	FILE	*m, *popen();	/* stream used for giving text to the "mail" program */
-	char	*base;	/* basename of the file */
-
-	/* separate the directory name from the basename. */
-	for (base = file + strlen(file); --base > file && *base != SLASH; )
-	{
-	}
-	if (*base == SLASH)
-	{
-		*base++ = '\0';
-	}
-
-	/* for anonymous buffers, pretend the name was "foo" */
-	if (!strcmp(base, "*"))
-	{
-		base = "foo";
-	}
-
-	/* open a pipe to the "mail" program */
-#if OSK
-	sprintf(cmd, "mail \"-s=%s preserved!\" %s", base, user);
-#else /* ANY_UNIX */
-	sprintf(cmd, "mail %s >/dev/null 2>/dev/null", user);
-#endif
-	m = popen(cmd, "w");
-	if (!m)
-	{
-		/* Can't send mail!  Hope the user figures it out. */
-		return;
-	}
-
-	/* Tell the user that the file was preserved */
-	fprintf(m, "A version of your file \"%s%c%s\"\n", file, SLASH, base);
-	fprintf(m, "was preserved when %s.\n", when);
-	fprintf(m, "To recover this file, do the following:\n");
-	fprintf(m, "\n");
-#if OSK
-	fprintf(m, "     chd %s\n", file);
-#else /* ANY_UNIX */
-	fprintf(m, "     cd %s\n", file);
-#endif
-	fprintf(m, "     elvrec %s\n", base);
-	fprintf(m, "\n");
-	fprintf(m, "With fond wishes for a speedy recovery,\n");
-	fprintf(m, "                                    Elvis\n");
-	if (ps)
-	{
-		fprintf(m, "\nP.S. %s\n", ps);
-		ps = (char *)0;
-	}
-
-	/* close the stream */
-	pclose(m);
-}
Index: trunk/minix/commands/elvis/recycle.c
===================================================================
--- trunk/minix/commands/elvis/recycle.c	(revision 9)
+++ 	(revision )
@@ -1,183 +1,0 @@
-/* recycle.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the functions perform garbage collection and allocate
- * reusable blocks.
- */
-
-#include "config.h"
-#include "vi.h"
-
-#ifndef NO_RECYCLE
-/* this whole file would have be skipped if NO_RECYCLE is defined */
-
-
-#define BTST(bitno, byte)	((byte) & (1 << (bitno)))
-#define BSET(bitno, byte)	((byte) |= (1 << (bitno)))
-#define BCLR(bitno, byte)	((byte) &= ~(1 << (bitno)))
-
-#define TST(blkno)		((blkno) < MAXBIT ? BTST((blkno) & 7, bitmap[(blkno) >> 3]) : 1)
-#define SET(blkno)		if ((blkno) < MAXBIT) BSET((blkno) & 7, bitmap[(blkno) >> 3])
-#define CLR(blkno)		if ((blkno) < MAXBIT) BCLR((blkno) & 7, bitmap[(blkno) >> 3])
-
-/* bitmap of free blocks in first 4096k of tmp file */
-static unsigned char bitmap[512];
-#define MAXBIT	(sizeof bitmap << 3)
-
-/* this function locates all free blocks in the current tmp file */
-void garbage()
-{
-	int	i;
-	BLK	oldhdr;
-
-	/* start by assuming every block is free */
-	for (i = 0; i < sizeof bitmap; i++)
-	{
-		bitmap[i] = 255;
-	}
-
-	/* header blocks aren't free */
-#ifndef lint
-	CLR(0);
-	CLR(1);
-#endif
-
-	/* blocks needed for current hdr aren't free */
-	for (i = 1; i < MAXBLKS; i++)
-	{
-		CLR(hdr.n[i]);
-	}
-
-	/* blocks needed for undo version aren't free */
-	lseek(tmpfd, 0L, 0);
-	if (read(tmpfd, &oldhdr, (unsigned)sizeof oldhdr) != sizeof oldhdr)
-	{
-		msg("garbage() failed to read oldhdr??");
-		for (i = 0; i < sizeof bitmap; i++)
-		{
-			bitmap[i] = 0;
-		}
-		return;
-	}
-	for (i = 1; i < MAXBLKS; i++)
-	{
-		CLR(oldhdr.n[i]);
-	}
-
-	/* blocks needed for cut buffers aren't free */
-	for (i = cutneeds(&oldhdr) - 1; i >= 0; i--)
-	{
-		CLR(oldhdr.n[i]);
-	}
-}
-
-/* This function allocates the first available block in the tmp file */
-long allocate()
-{
-	int	i;
-	long	offset;
-
-	/* search for the first byte with a free bit set */
-	for (i = 0; i < sizeof bitmap && bitmap[i] == 0; i++)
-	{
-	}
-
-	/* if we hit the end of the bitmap, return the end of the file */
-	if (i == sizeof bitmap)
-	{
-		offset = lseek(tmpfd, 0L, 2);
-	}
-	else /* compute the offset for the free block */
-	{
-		for (i <<= 3; TST(i) == 0; i++)
-		{
-		}
-		offset = (long)i * (long)BLKSIZE;
-
-		/* mark the block as "allocated" */
-		CLR(i);
-	}
-
-	return offset;
-}
-
-#endif
-
-#ifdef DEBUG
-# include <stdio.h>
-# undef malloc
-# undef free
-# define MEMMAGIC 0x19f72cc0L
-# define MAXALLOC 800
-static char *allocated[MAXALLOC];
-static char *fromfile[MAXALLOC];
-static int  fromline[MAXALLOC]; 
-static int  sizes[MAXALLOC];
-
-char *dbmalloc(size, file, line)
-	int	size;
-	char	*file;
-	int	line;
-{
-	char	*ret;
-	int	i;
-
-	size = size + sizeof(long) - (size % sizeof(long));
-	ret = (char *)malloc(size + 2 * sizeof(long)) + sizeof(long);
-	for (i = 0; i < MAXALLOC && allocated[i]; i++)
-	{
-	}
-	if (i == MAXALLOC)
-	{
-		endwin();
-		fprintf(stderr, "\r\n%s(%d): Too many malloc calls!\n", file, line);
-		abort();
-	}
-	sizes[i] = size/sizeof(long);
-	allocated[i] = ret;
-	fromfile[i] = file;
-	fromline[i] = line;
-	((long *)ret)[-1] = MEMMAGIC;
-	((long *)ret)[sizes[i]] = MEMMAGIC;
-	return ret;
-}
-
-dbfree(ptr, file, line)
-	char	*ptr;
-	char	*file;
-	int	line;
-{
-	int	i;
-
-	for (i = 0; i < MAXALLOC && allocated[i] != ptr; i++)
-	{
-	}
-	if (i == MAXALLOC)
-	{
-		endwin();
-		fprintf(stderr, "\r\n%s(%d): attempt to free mem that wasn't allocated\n", file, line);
-		abort();
-	}
-	allocated[i] = (char *)0;
-	if (((long *)ptr)[-1] != MEMMAGIC)
-	{
-		endwin();
-		fprintf(stderr, "\r\n%s(%d): underflowed malloc space, allocated at %s(%d)\n", file, line, fromfile[i], fromline[i]);
-		abort();
-	}
-	if (((long *)ptr)[sizes[i]] != MEMMAGIC)
-	{
-		endwin();
-		fprintf(stderr, "\r\n%s(%d): overflowed malloc space, allocated at %s(%d)\n", file, line, fromfile[i], fromline[i]);
-		abort();
-	}
-	free(ptr - sizeof(long));
-}
-#endif
Index: trunk/minix/commands/elvis/redraw.c
===================================================================
--- trunk/minix/commands/elvis/redraw.c	(revision 9)
+++ 	(revision )
@@ -1,1295 +1,0 @@
-/* redraw.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains functions that draw text on the screen.  The major entry
- * points are:
- *	redrawrange()	- called from modify.c to give hints about what parts
- *			  of the screen need to be redrawn.
- *	redraw()	- redraws the screen (or part of it) and positions
- *			  the cursor where it belongs.
- *	idx2col()	- converts a markidx() value to a logical column number.
- */
-
-#include "config.h"
-#include "vi.h"
-
-/* This variable contains the line number that smartdrawtext() knows best */
-static long smartlno;
-
-/* This function remembers where changes were made, so that the screen can be
- * redraw in a more efficient manner.
- */
-static long	redrawafter;	/* line# of first line that must be redrawn */
-static long	preredraw;	/* line# of last line changed, before change */
-static long	postredraw;	/* line# of last line changed, after change */
-static int	mustredraw;	/* boolean: anything forcing a screen update? */
-void redrawrange(after, pre, post)
-	long	after;	/* lower bound of redrawafter */
-	long	pre;	/* upper bound of preredraw */
-	long	post;	/* upper bound of postredraw */
-{
-	if (after == redrawafter)
-	{
-		/* multiple insertions/deletions at the same place -- combine
-		 * them
-		 */
-		preredraw -= (post - pre);
-		if (postredraw < post)
-		{
-			preredraw += (post - postredraw);
-			postredraw = post;
-		}
-		if (redrawafter > preredraw)
-		{
-			redrawafter = preredraw;
-		}
-		if (redrawafter < 1L)
-		{
-			redrawafter = 0L;
-			preredraw = postredraw = INFINITY;
-		}
-	}
-	else if (postredraw > 0L)
-	{
-		/* multiple changes in different places -- redraw everything
-		 * after "after".
-		 */
-		postredraw = preredraw = INFINITY;
-		if (after < redrawafter)
-			redrawafter = after;
-	}
-	else
-	{
-		/* first change */
-		redrawafter = after;
-		preredraw = pre;
-		postredraw = post;
-	}
-	mustredraw = TRUE;
-}
-
-
-#ifndef NO_CHARATTR
-/* see if a given line uses character attribute strings */
-static int hasattr(lno, text)
-	long		lno;	/* the line# of the cursor */
-	REG char	*text;	/* the text of the line, from fetchline */
-{
-	static long	plno;	/* previous line number */
-	static long	chgs;	/* previous value of changes counter */
-	static int	panswer;/* previous answer */
-	char		*scan;
-
-	/* if charattr is off, then the answer is "no, it doesn't" */
-	if (!*o_charattr)
-	{
-		chgs = 0; /* <- forces us to check if charattr is later set */
-		return FALSE;
-	}
-
-	/* if we already know the answer, return it... */
-	if (lno == plno && chgs == changes)
-	{
-		return panswer;
-	}
-
-	/* get the line & look for "\fX" */
-	if (!text[0] || !text[1] || !text[2])
-	{
-		panswer = FALSE;
-	}
-	else
-	{
-		for (scan = text; scan[2] && !(scan[0] == '\\' && scan[1] == 'f'); scan++)
-		{
-		}
-		panswer = (scan[2] != '\0');
-	}
-
-	/* save the results */
-	plno = lno;
-	chgs = changes;
-
-	/* return the results */
-	return panswer;
-}
-#endif
-
-
-#ifndef NO_VISIBLE
-/* This function checks to make sure that the correct lines are shown in
- * reverse-video.  This is used to handle the "v" and "V" commands.
- */
-static long	vizlow, vizhigh;	/* the starting and ending lines */
-static int	vizleft, vizright;	/* starting & ending indicies */
-static int	vizchange;		/* boolean: must use stupid drawtext? */
-static void setviz(curs)
-	MARK		curs;
-{
-	long		newlow, newhigh;
-	long		extra = 0L;
-
-	/* for now, assume the worst... */
-	vizchange = TRUE;
-
-	/* set newlow & newhigh according to V_from and cursor */
-	if (!V_from)
-	{
-		/* no lines should have reverse-video */
-		if (vizlow)
-		{
-			redrawrange(vizlow, vizhigh + 1L, vizhigh + 1L);
-			vizlow = vizhigh = 0L;
-		}
-		else
-		{
-			vizchange = FALSE;
-		}
-		return;
-	}
-
-	/* figure out which lines *SHOULD* have hilites */
-	if (V_from < curs)
-	{
-		newlow = markline(V_from);
-		newhigh = markline(curs);
-		vizleft = markidx(V_from);
-		vizright = markidx(curs) + 1;
-	}
-	else
-	{
-		newlow = markline(curs);
-		newhigh = markline(V_from);
-		vizleft = markidx(curs);
-		vizright = markidx(V_from) + 1;
-	}
-
-	/* adjust for line-mode hiliting */
-	if (V_linemd)
-	{
-		vizleft = 0;
-		vizright = BLKSIZE - 1;
-	}
-	else
-	{
-		extra = 1L;
-	}
-
-	/* arrange for the necessary lines to be redrawn */
-	if (vizlow == 0L)
-	{
-		/* just starting to redraw */
-		redrawrange(newlow, newhigh, newhigh);
-	}
-	else
-	{
-		/* Were new lines added/removed at the front? */
-		if (newlow != vizlow)
-		{
-			if (newlow < vizlow)
-				redrawrange(newlow, vizlow + extra, vizlow + extra);
-			else
-				redrawrange(vizlow, newlow + extra, newlow + extra);
-		}
-
-		/* Were new lines added/removed at the back? */
-		if (newhigh != vizhigh)
-		{
-			if (newhigh < vizhigh)
-				redrawrange(newhigh + 1L - extra, vizhigh + 1L, vizhigh + 1L);
-			else
-				redrawrange(vizhigh + 1L - extra, newhigh, newhigh);
-		}
-	}
-
-	/* remember which lines will contain hilighted text now */
-	vizlow = newlow;
-	vizhigh = newhigh;
-}
-#endif /* !NO_VISIBLE */
-
-
-/* This function converts a MARK to a column number.  It doesn't automatically
- * adjust for leftcol; that must be done by the calling function
- */
-int idx2col(curs, text, inputting)
-	MARK		curs;	/* the line# & index# of the cursor */
-	REG char	*text;	/* the text of the line, from fetchline */
-	int		inputting;	/* boolean: called from input() ? */
-{
-	static MARK	pcursor;/* previous cursor, for possible shortcut */
-	static MARK	pcol;	/* column number for pcol */
-	static long	chgs;	/* previous value of changes counter */
-	REG int		col;	/* used to count column numbers */
-	REG int		idx;	/* used to count down the index */
-	REG int		i;
-
-	/* for now, assume we have to start counting at the left edge */
-	col = 0;
-	idx = markidx(curs);
-
-	/* if the file hasn't changed & line number is the same & it has no
-	 * embedded character attribute strings, can we do shortcuts?
-	 */
-	if (chgs == changes
-	 && !((curs ^ pcursor) & ~(BLKSIZE - 1))
-#ifndef NO_CHARATTR
-	 && !hasattr(markline(curs), text)
-#endif
-	)
-	{
-		/* no movement? */
-		if (curs == pcursor)
-		{
-			/* return the column of the char; for tabs, return its last column */
-			if (text[idx] == '\t' && !inputting && !*o_list)
-			{
-				return pcol + *o_tabstop - (pcol % *o_tabstop) - 1;
-			}
-			else
-			{
-				return pcol;
-			}
-		}
-
-		/* movement to right? */
-		if (curs > pcursor)
-		{
-			/* start counting from previous place */
-			col = pcol;
-			idx = markidx(curs) - markidx(pcursor);
-			text += markidx(pcursor);
-		}
-	}
-
-	/* count over to the char after the idx position */
-	while (idx > 0 && (i = *text)) /* yes, ASSIGNMENT! */
-	{
-		if (i == '\t' && !*o_list)
-		{
-			col += *o_tabstop;
-			col -= col % *o_tabstop;
-		}
-		else if (i >= '\0' && i < ' ' || i == '\177')
-		{
-			col += 2;
-		}
-#ifndef NO_CHARATTR
-		else if (i == '\\' && text[1] == 'f' && text[2] && *o_charattr)
-		{
-			text += 2; /* plus one more at bottom of loop */
-			idx -= 2;
-		}			
-#endif
-		else
-		{
-			col++;
-		}
-		text++;
-		idx--;
-	}
-
-	/* save stuff to speed next call */
-	pcursor = curs;
-	pcol = col;
-	chgs = changes;
-
-	/* return the column of the char; for tabs, return its last column */
-	if (*text == '\t' && !inputting && !*o_list)
-	{
-		return col + *o_tabstop - (col % *o_tabstop) - 1;
-	}
-	else
-	{
-		return col;
-	}
-}
-
-
-/* This function is similar to idx2col except that it takes care of sideways
- * scrolling - for the given line, at least.
- */
-int mark2phys(m, text, inputting)
-	MARK	m;		/* a mark to convert */
-	char	*text;		/* the line that m refers to */
-	int	inputting;	/* boolean: caled from input() ? */
-{
-	int	i;
-
-	i = idx2col(m, text, inputting);
-	while (i < leftcol)
-	{
-		leftcol -= *o_sidescroll;
-		mustredraw = TRUE;
-		redrawrange(1L, INFINITY, INFINITY);
-	}
-	while (i > rightcol)
-	{
-		leftcol += *o_sidescroll;
-		mustredraw = TRUE;
-		redrawrange(1L, INFINITY, INFINITY);
-	}
-	physrow = markline(m) - topline;
-	physcol = i - leftcol;
-	if (*o_number)
-		physcol += 8;
-
-	return physcol;
-}
-
-/* This function draws a single line of text on the screen.  The screen's
- * cursor is assumed to be located at the leftmost column of the appropriate
- * row.
- */
-static void drawtext(text, lno, clr)
-	REG char	*text;	/* the text to draw */
-	long		lno;	/* the number of the line to draw */
-	int		clr;	/* boolean: do a clrtoeol? */
-{
-	REG int		col;	/* column number */
-	REG int		i;
-	REG int		tabstop;	/* *o_tabstop */
-	REG int		limitcol;	/* leftcol or leftcol + COLS */
-	int		abnormal;	/* boolean: charattr != A_NORMAL? */
-#ifndef NO_VISIBLE
-	int		rev;		/* boolean: standout mode, too? */
-	int		idx = 0;
-#endif
-	char		numstr[9];
-
-	/* show the line number, if necessary */
-	if (*o_number)
-	{
-		sprintf(numstr, "%6ld |", lno);
-		qaddstr(numstr);
-	}
-
-#ifndef NO_SENTENCE
-	/* if we're hiding format lines, and this is one of them, then hide it */
-	if (*o_hideformat && *text == '.')
-	{
-		clrtoeol();
-#if OSK
-		qaddch('\l');
-#else
-		qaddch('\n');
-#endif
-		return;
-	}
-#endif
-
-	/* move some things into registers... */
-	limitcol = leftcol;
-	tabstop = *o_tabstop;
-	abnormal = FALSE;
-
-#ifndef CRUNCH
-	if (clr)
-		clrtoeol();
-#endif
-
-	/* skip stuff that was scrolled off left edge */
-	for (col = 0;
-	     (i = *text) && col < limitcol; /* yes, ASSIGNMENT! */
-	     text++)
-	{
-#ifndef NO_VISIBLE
-		idx++;
-#endif
-		if (i == '\t' && !*o_list)
-		{
-			col = col + tabstop - (col % tabstop);
-		}
-		else if (i >= 0 && i < ' ' || i == '\177')
-		{
-			col += 2;
-		}
-#ifndef NO_CHARATTR
-		else if (i == '\\' && text[1] == 'f' && text[2] && *o_charattr)
-		{
-			text += 2; /* plus one more as part of "for" loop */
-
-			/* since this attribute might carry over, we need it */
-			switch (*text)
-			{
-			  case 'R':
-			  case 'P':
-				attrset(A_NORMAL);
-				abnormal = FALSE;
-				break;
-
-			  case 'B':
-				attrset(A_BOLD);
-				abnormal = TRUE;
-				break;
-
-			  case 'U':
-				attrset(A_UNDERLINE);
-				abnormal = TRUE;
-				break;
-
-			  case 'I':
-				attrset(A_ALTCHARSET);
-				abnormal = TRUE;
-				break;
-			}
-		}
-#endif
-		else
-		{
-			col++;
-		}
-	}
-
-#ifndef NO_VISIBLE
-	/* Should we start hiliting at the first char of this line? */
-	if ((lno > vizlow && lno <= vizhigh
-	    || lno == vizlow && vizleft < idx)
-	   && !(lno == vizhigh && vizright < idx))
-	{
-		do_VISIBLE();
-		rev = TRUE;
-	}
-#endif
-
-	/* adjust for control char that was partially visible */
-	while (col > limitcol)
-	{
-		qaddch(' ');
-		limitcol++;
-	}
-
-	/* now for the visible characters */
-	limitcol = leftcol + COLS;
-	if (*o_number)
-		limitcol -= 8;
-	for (; (i = *text) && col < limitcol; text++)
-	{
-#ifndef NO_VISIBLE
-		/* maybe turn hilite on/off in the middle of the line */
-		if (lno == vizlow && vizleft == idx)
-		{
-			do_VISIBLE();
-			rev = TRUE;
-		}
-		if (lno == vizhigh && vizright == idx)
-		{
-			do_SE();
-			rev = FALSE;
-		}
-		idx++;
-
-		/* if hiliting, never emit physical tabs */
-		if (rev && i == '\t' && !*o_list)
-		{
-			i = col + tabstop - (col % tabstop);
-			do
-			{
-				qaddch(' ');
-				col++;
-			} while (col < i);
-		}
-		else
-#endif /* !NO_VISIBLE */
-		if (i == '\t' && !*o_list)
-		{
-			i = col + tabstop - (col % tabstop);
-			if (i < limitcol)
-			{
-#ifdef CRUNCH
-				if (!clr && has_PT && !((i - leftcol) & 7))
-#else
-				if (has_PT && !((i - leftcol) & 7))
-#endif
-				{
-					do
-					{
-						qaddch('\t');
-						col += 8; /* not exact! */
-					} while (col < i);
-					col = i; /* NOW it is exact */
-				}
-				else
-				{
-					do
-					{
-						qaddch(' ');
-						col++;
-					} while (col < i);
-				}
-			}
-			else /* tab ending after screen? next line! */
-			{
-				col = limitcol;
-				if (has_AM)
-				{
-					addch('\n');	/* GB */
-				}
-			}
-		}
-		else if (i >= 0 && i < ' ' || i == '\177')
-		{
-			col += 2;
-			qaddch('^');
-			if (col <= limitcol)
-			{
-				qaddch(i ^ '@');
-			}
-		}
-#ifndef NO_CHARATTR
-		else if (i == '\\' && text[1] == 'f' && text[2] && *o_charattr)
-		{
-			text += 2; /* plus one more as part of "for" loop */
-			switch (*text)
-			{
-			  case 'R':
-			  case 'P':
-				attrset(A_NORMAL);
-				abnormal = FALSE;
-				break;
-
-			  case 'B':
-				attrset(A_BOLD);
-				abnormal = TRUE;
-				break;
-
-			  case 'U':
-				attrset(A_UNDERLINE);
-				abnormal = TRUE;
-				break;
-
-			  case 'I':
-				attrset(A_ALTCHARSET);
-				abnormal = TRUE;
-				break;
-			}
-		}
-#endif
-		else
-		{
-			col++;
-			qaddch(i);
-		}
-	}
-
-	/* get ready for the next line */
-#ifndef NO_CHARATTR
-	if (abnormal)
-	{
-		attrset(A_NORMAL);
-	}
-#endif
-	if (*o_list && col < limitcol)
-	{
-		qaddch('$');
-		col++;
-	}
-
-#ifndef NO_VISIBLE
-	/* did we hilite this whole line?  If so, STOP! */
-	if (rev)
-	{
-		do_SE();
-	}
-#endif
-
-#ifdef CRUNCH
-	if (clr && col < limitcol)
-	{
-		clrtoeol();
-	}
-#endif
-	if (!has_AM || col < limitcol)
-	{
-		addch('\n');
-	}
-
-	wqrefresh();
-}
-
-
-#ifndef CRUNCH
-static void nudgecursor(same, scan, new, lno)
-	int	same;	/* number of chars to be skipped over */
-	char	*scan;	/* where the same chars end */
-	char	*new;	/* where the visible part of the line starts */
-	long	lno;	/* line number of this line */
-{
-	int	col;
-
-	if (same > 0)
-	{
-		if (same < 5)
-		{
-			/* move the cursor by overwriting */
-			while (same > 0)
-			{
-				qaddch(scan[-same]);
-				same--;
-			}
-		}
-		else
-		{
-			/* move the cursor by calling move() */
-			col = (int)(scan - new);
-			if (*o_number)
-				col += 8;
-			move((int)(lno - topline), col);
-		}
-	}
-}
-#endif /* not CRUNCH */
-
-/* This function draws a single line of text on the screen, possibly with
- * some cursor optimization.  The cursor is repositioned before drawing
- * begins, so its position before doesn't really matter.
- */
-static void smartdrawtext(text, lno, showit)
-	REG char	*text;	/* the text to draw */
-	long		lno;	/* line number of the text */
-	int		showit;	/* boolean: output line? (else just remember it) */
-{
-#ifdef CRUNCH
-	move((int)(lno - topline), 0);
-	if (showit)
-	{
-		drawtext(text, lno, TRUE);
-	}
-#else /* not CRUNCH */
-	static char	old[256];	/* how the line looked last time */
-	char		new[256];	/* how it looks now */
-	char		*build;		/* used to put chars into new[] */
-	char		*scan;		/* used for moving thru new[] or old[] */
-	char		*end;		/* last non-blank changed char */
-	char		*shift;		/* used to insert/delete chars */
-	int		same;		/* length of a run of unchanged chars */
-	int		limitcol;
-	int		col;
-	int		i;
-	char		numstr[9];
-
-# ifndef NO_CHARATTR
-	/* if this line has attributes, do it the dumb way instead */
-	if (hasattr(lno, text))
-	{
-		move((int)(lno - topline), 0);
-		drawtext(text, lno, TRUE);
-		return;
-	}
-# endif
-# ifndef NO_SENTENCE
-	/* if this line is a format line, & we're hiding format lines, then
-	 * let the dumb drawtext() function handle it
-	 */
-	if (*o_hideformat && *text == '.')
-	{
-		move((int)(lno - topline), 0);
-		drawtext(text, lno, TRUE);
-		return;
-	}
-# endif
-# ifndef NO_VISIBLE
-	if (vizchange)
-	{
-		move((int)(lno - topline), 0);
-		drawtext(text, lno, TRUE);
-		smartlno = 0L;
-		return;
-	}
-# endif
-
-	/* skip stuff that was scrolled off left edge */
-	limitcol = leftcol;
-	for (col = 0;
-	     (i = *text) && col < limitcol; /* yes, ASSIGNMENT! */
-	     text++)
-	{
-		if (i == '\t' && !*o_list)
-		{
-			col = col + *o_tabstop - (col % *o_tabstop);
-		}
-		else if (i >= 0 && i < ' ' || i == '\177')
-		{
-			col += 2;
-		}
-		else
-		{
-			col++;
-		}
-	}
-
-	/* adjust for control char that was partially visible */
-	build = new;
-	while (col > limitcol)
-	{
-		*build++ = ' ';
-		limitcol++;
-	}
-
-	/* now for the visible characters */
-	limitcol = leftcol + COLS;
-	if (*o_number)
-		limitcol -= 8;
-	for (; (i = *text) && col < limitcol; text++)
-	{
-		if (i == '\t' && !*o_list)
-		{
-			i = col + *o_tabstop - (col % *o_tabstop);
-			while (col < i && col < limitcol)
-			{
-				*build++ = ' ';
-				col++;
-			}
-		}
-		else if (i >= 0 && i < ' ' || i == '\177')
-		{
-			col += 2;
-			*build++ = '^';
-			if (col <= limitcol)
-			{
-				*build++ = (i ^ '@');
-			}
-		}
-		else
-		{
-			col++;
-			*build++ = i;
-		}
-	}
-	if (col < limitcol && *o_list)
-	{
-		*build++ = '$';
-		col++;
-	}
-	end = build;
-	while (col < limitcol)
-	{
-		*build++ = ' ';
-		col++;
-	}
-
-	/* if we're just supposed to remember this line, then remember it */
-	if (!showit)
-	{
-		smartlno = lno;
-		strncpy(old, new, COLS);
-		return;
-	}
-
-	/* locate the last non-blank character */
-	while (end > new && end[-1] == ' ')
-	{
-		end--;
-	}
-
-	/* can we optimize the displaying of this line? */
-	if (lno != smartlno)
-	{
-		/* nope, can't optimize - different line */
-		move((int)(lno - topline), 0);
-
-		/* show the line number, if necessary */
-		if (*o_number)
-		{
-			sprintf(numstr, "%6ld |", lno);
-			qaddstr(numstr);
-		}
-
-		/* show the new line */
-		for (scan = new, build = old; scan < end; )
-		{
-			qaddch(*scan);
-			*build++ = *scan++;
-		}
-		if (end < new + COLS - (*o_number ? 8 : 0))
-		{
-			clrtoeol();
-			while (build < old + COLS)
-			{
-				*build++ = ' ';
-			}
-		}
-		smartlno = lno;
-		return;
-	}
-
-	/* skip any initial unchanged characters */
-	for (scan = new, build = old; scan < end && *scan == *build; scan++, build++)
-	{
-	}
-	i = (scan - new);
-	if (*o_number)
-		i += 8;
-	move((int)(lno - topline), i);
-
-	/* The in-between characters must be changed */
-	same = 0;
-	while (scan < end)
-	{
-		/* is this character a match? */
-		if (scan[0] == build[0])
-		{
-			same++;
-		}
-		else /* do we want to insert? */
-		if (scan < end - 1 && scan[1] == build[0] && (has_IC || has_IM))
-		{
-			nudgecursor(same, scan, new, lno);
-			same = 0;
-
-			insch(*scan);
-			for (shift = old + COLS; --shift > build; )
-			{
-				shift[0] = shift[-1];
-			}
-			*build = *scan;
-		}
-		else /* do we want to delete? */
-		if (build < old + COLS - 1 && scan[0] == build[1] && has_DC)
-		{
-			nudgecursor(same, scan, new, lno);
-			same = 0;
-
-			delch();
-			same++;
-			for (shift = build; shift < old + COLS - 1; shift++)
-			{
-				shift[0] = shift[1];
-			}
-			if (*o_number)
-				shift -= 8;
-			*shift = ' ';
-		}
-		else /* we must overwrite */
-		{
-			nudgecursor(same, scan, new, lno);
-			same = 0;
-
-			addch(*scan);
-			*build = *scan;
-		}
-
-		build++;
-		scan++;
-	}
-
-	/* maybe clear to EOL */
-	end = old + COLS - (*o_number ? 8 : 0);
-	while (build < end && *build == ' ')
-	{
-		build++;
-	}
-	if (build < end)
-	{
-		nudgecursor(same, scan, new, lno);
-		same = 0;
-
-		clrtoeol();
-		while (build < old + COLS)
-		{
-			*build++ = ' ';
-		}
-	}
-#endif /* not CRUNCH */
-}
-
-
-/* This function is used in visual mode for drawing the screen (or just parts
- * of the screen, if that's all thats needed).  It also takes care of
- * scrolling.
- */
-void redraw(curs, inputting)
-	MARK	curs;		/* where to leave the screen's cursor */
-	int	inputting;	/* boolean: being called from input() ? */
-{
-	char		*text;		/* a line of text to display */
-	static long	chgs;		/* previous changes level */
-	long		l;
-	int		i;
-#ifndef CRUNCH
-	static long	showtop;	/* top line in window */
-	static long	showbottom;	/* bottom line in window */
-#endif
-
-	/* if curs == MARK_UNSET, then we should reset internal vars */
-	if (curs == MARK_UNSET)
-	{
-		if (topline < 1 || topline > nlines)
-		{
-			topline = 1L;
-		}
-		else
-		{
-			move(LINES - 1, 0);
-			clrtoeol();
-		}
-		leftcol = 0;
-		mustredraw = TRUE;
-		redrawafter = INFINITY;
-		preredraw = 0L;
-		postredraw = 0L;
-		chgs = 0;
-		smartlno = 0L;
-#ifndef NO_VISIBLE
-		vizlow = vizhigh = 0L;
-		vizchange = FALSE;
-#endif
-#ifndef CRUNCH
-		showtop = 0;
-		showbottom = INFINITY;
-#endif
-		return;
-	}
-
-#ifndef NO_VISIBLE
-	/* adjustments to hilited area may force extra lines to be redrawn. */
-	setviz(curs);
-#endif
-
-	/* figure out which column the cursor will be in */
-	l = markline(curs);
-	text = fetchline(l);
-	mark2phys(curs, text, inputting);
-
-#ifndef NO_COLOR
-	fixcolor();
-#endif
-
-	/* adjust topline, if necessary, to get the cursor on the screen */
-	if (l >= topline && l <= botline)
-	{
-		/* it is on the screen already */
-
-		/* if the file was changed but !mustredraw, then redraw line */
-		if (!mustredraw && (chgs != changes
-#ifndef NO_VISIBLE
-			|| V_from
-#endif
-#ifndef CRUNCH
-			|| l < showtop || l > showbottom
-#endif
-							))
-		{
-			smartdrawtext(text, l, (chgs != changes));
-		}
-	}
-	else if (l < topline && l > topline - LINES && (has_SR || has_AL))
-	{
-		/* near top - scroll down */
-		if (!mustredraw)
-		{
-			move(0,0);
-			while (l < topline)
-			{
-				topline--;
-				if (has_SR)
-				{
-					do_SR();
-				}
-				else
-				{
-					insertln();
-				}
-				text = fetchline(topline);
-				drawtext(text, topline, FALSE);
-				do_UP();
-			}
-
-			/* blank out the last line */
-			move(LINES - 1, 0);
-			clrtoeol();
-		}
-		else
-		{
-			topline = l;
-			redrawrange(0L, INFINITY, INFINITY);
-		}
-	}
-	else if (l > topline && l < botline + LINES)
-	{
-		/* near bottom -- scroll up */
-		if (!mustredraw)
-		{
-			move(LINES - 1,0);
-			clrtoeol();
-			while (l > botline)
-			{
-				topline++; /* <-- also adjusts botline */
-				text = fetchline(botline);
-				drawtext(text, botline, FALSE);
-			}
-#ifndef CRUNCH
-			showbottom = l;
-#endif
-		}
-		else
-		{
-			topline = l - (LINES - 2);
-			redrawrange(0L, INFINITY, INFINITY);
-		}
-	}
-	else
-	{
-		/* distant line - center it & force a redraw */
-		topline = l - (LINES / 2) - 1;
-		if (topline < 1)
-		{
-			topline = 1;
-		}
-		redrawrange(0L, INFINITY, INFINITY);
-		changes++;
-	}
-
-#ifndef CRUNCH
-	/* make sure the current line is included in the "window" */
-	if (l < showtop)
-	{
-		redrawrange(l, showtop, showtop);
-		showtop = l;
-	}
-	if (l > showbottom)
-	{
-		redrawrange(showbottom, l, l);
-		showbottom = l;
-	}
-#endif
-
-
-	/* Now... do we really have to redraw? */
-	if (mustredraw)
-	{
-		/* If redrawfter (and friends) aren't set, assume we should
-		 * redraw everything.
-		 */
-		if (redrawafter == INFINITY)
-		{
-			redrawafter = 0L;
-			preredraw = postredraw = INFINITY;
-		}
-
-#ifndef CRUNCH
-		/* shrink the window, if possible */
-		if (showtop < topline)
-		{
-			showtop = topline;
-		}
-		if (showbottom > botline)
-		{
-			showbottom = botline;
-		}
-		if (postredraw == INFINITY)
-		{
-			/* these will be set to more reasonable values later */
-			showtop = INFINITY;
-			showbottom = 0L;
-		}
-#endif
-
-		/* adjust smartlno to correspond with inserted/deleted lines */
-		if (smartlno >= redrawafter)
-		{
-			if (smartlno < preredraw && postredraw != preredraw) /*!!!*/
-			{
-				smartlno = 0L;
-			}
-			else
-			{
-				smartlno += (postredraw - preredraw);
-			}
-		}
-
-		/* should we insert some lines into the screen? */
-		if (preredraw < postredraw && preredraw <= botline)
-		{
-			/* lines were inserted into the file */
-
-			/* decide where insertion should start */
-			if (preredraw < topline)
-			{
-				l = topline;
-			}
-			else
-			{
-				l = preredraw;
-			}
-
-			/* insert the lines... maybe */
-			if (l + postredraw - preredraw > botline || !has_AL || *o_number)
-			{
-				/* Whoa!  a whole screen full - just redraw */
-				preredraw = postredraw = INFINITY;
-			}
-			else
-			{
-				/* really insert 'em */
-				move((int)(l - topline), 0);
-				for (i = postredraw - preredraw; i > 0; i--)
-				{
-					insertln();
-				}
-
-				/* NOTE: the contents of those lines will be
-				 * drawn as part of the regular redraw loop.
-				 */
-
-				/* clear the last line */
-				move(LINES - 1, 0);
-				clrtoeol();
-			}
-		}
-
-		/* do we want to delete some lines from the screen? */
-		if (preredraw > postredraw && postredraw <= botline)
-		{
-			if (preredraw > botline || !has_DL || *o_number)
-			{
-				postredraw = preredraw = INFINITY;
-			}
-			else /* we'd best delete some lines from the screen */
-			{
-				/* clear the last line, so it doesn't look
-				 * ugly as it gets pulled up into the screen
-				 */
-				move(LINES - 1, 0);
-				clrtoeol();
-
-				/* delete the lines */
-				move((int)(postredraw - topline), 0);
-			 	for (l = postredraw;
-				     l < preredraw && l <= botline;
-				     l++)
-				{
-					deleteln();
-				}
-
-				/* draw the lines that are now newly visible
-				 * at the bottom of the screen
-				 */
-				i = LINES - 1 + (postredraw - preredraw);
-				move(i, 0);
-				for (l = topline + i; l <= botline; l++)
-				{
-					/* clear this line */
-					clrtoeol();
-
-					/* draw the line, or ~ for non-lines */
-					if (l <= nlines)
-					{
-						text = fetchline(l);
-						drawtext(text, l, FALSE);
-					}
-					else
-					{
-						addstr("~\n");
-					}
-				}
-			}
-		}
-
-		/* redraw the current line */
-		l = markline(curs);
-		pfetch(l);
-		smartdrawtext(ptext, l, TRUE);
-
-#ifndef CRUNCH
-		/* decide which lines must be in the "window" around the cursor */
-		l = markline(curs);
-		if ((*o_window & 0xff) + 1 == LINES)
-		{
-			showtop = 1;
-			showbottom = INFINITY;
-		}
-		else if (l < showtop || l > showbottom)
-		{
-			l -= (*o_window & 0xff) / 2;
-			if (l < topline)
-			{
-				l = topline;
-			}
-			if (l < showtop)
-			{
-				showtop = l;
-			}
-			l += (*o_window & 0xff) - 1;
-			if (l > botline)
-			{
-				showtop = showtop - l + botline;
-				l = botline;
-			}
-			if (l > showbottom)
-			{
-				showbottom = l;
-			}
-		}
-#endif
-
-		/* decide where we should start redrawing from */
-		if (redrawafter < topline)
-		{
-			l = topline;
-		}
-		else
-		{
-			l = redrawafter;
-		}
-		if (l <= botline && l < postredraw && (l != smartlno || botline != smartlno))
-		{
-			/* draw the other lines */
-			move((int)(l - topline), 0);
-			for (; l <= botline && l < postredraw; l++)
-			{
-				/* we already drew the current line, so skip it now */
-				if (l == smartlno)
-				{
-#if OSK
-					qaddch('\l');
-#else
-					qaddch('\n');
-#endif
-					continue;
-				}
-
-				/* draw the line, or ~ for non-lines */
-				if (l > nlines)
-				{
-					qaddch('~');
-					clrtoeol();
-					addch('\n');
-				}
-#ifndef CRUNCH
-				else if (l < showtop || l > showbottom)
-				{
-					qaddch('@');
-					clrtoeol();
-					addch('\n');
-				}
-#endif
-				else
-				{
-					text = fetchline(l);
-					drawtext(text, l, TRUE);
-				}
-			}
-		}
-
-		mustredraw = FALSE;
-	}
-
-	/* force total (non-partial) redraw next time if not set */
-	redrawafter = INFINITY;
-	preredraw = 0L;
-	postredraw = 0L;
-
-	/* move the cursor to where it belongs */
-	move((int)(markline(curs) - topline), physcol);
-	wqrefresh();
-
-	chgs = changes;
-}
Index: trunk/minix/commands/elvis/ref.c
===================================================================
--- trunk/minix/commands/elvis/ref.c	(revision 9)
+++ 	(revision )
@@ -1,521 +1,0 @@
-/* ref2.c */
-
-/* This is a totally rewritten version of ref.  This version looks for the
- * desired function name in the "tags" file, and then reads the header out
- * from the source file.  There is no longer any need for a "refs" file.
- *
- * Usage:	ref [-a] [-t] [-f file] [-c class] tag
- * Options:	-t	   output tag info, not the description
- *		-f file	   default filename for static functions
- *		-c class   default class names for class functions
- */
-
-#include <stdio.h>
-#include "config.h"
-extern char	*getenv();
-extern char	*fgets();
-
-
-/* This is the default path that is searched for tags */
-#if OSK
-# define DEFTAGPATH ".:/dd/defs:/dd/defs/sys:/dd/usr/src/lib:../lib:/dd/usr/lib"
-#else
-# if ANY_UNIX
-#  define DEFTAGPATH ".:/usr/include:/usr/include/sys:/usr/src/lib:../lib:/usr/local/lib"
-# else
-#  if MSDOS || TOS
-#   define DEFTAGPATH ".;C:\\include;C:\\include\\sys;C:\\lib;..\\lib"
-#   define SEP ';'
-#  else
-#   if AMIGA
-#    define DEFTAGPATH ".;Include:;Include:sys"
-#    define SEP ';'
-#   else /* any other OS */
-#    define DEFTAGPATH "."
-#   endif
-#  endif
-# endif
-#endif
-
-#ifndef SEP
-# define SEP ':'
-#endif
-
-
-/* These variables reflect the command-line options given by the user. */
-int	taginfo;	/* boolean: give only the tag info? (not header?) */
-char	*def_file;	/* default filename for static functions */
-char	*def_class;	/* default classname for class members */
-int	colons;		/* #colons in tag: 0=normal, 1=static, 2=member */
-
-/* This function checks for a tag in the "tags" file of given directory.
- * If the tag is found, then it returns a pointer to a static buffer which
- * contains the filename, a tab character, and a linespec for finding the
- * the tag.  If the tag is not found in the "tags" file, or if the "tags"
- * file cannot be opened or doesn't exist, then this function returns NULL.
- */
-char *cktagdir(tag, dir)
-	char	*tag;	/* name of the tag to look for */
-	char	*dir;	/* name of the directory to check */
-{
-	char	buf[BLKSIZE];
-	static char found[BLKSIZE];
-	FILE	*tfile;
-	int	len;
-
-#if AMIGA
-	if (dir[strlen(dir) - 1] == COLON)
-	    sprintf(buf, "%s%s", dir, TAGS);   /* no slash after colon. */
-	else
-#endif
-	/* construct the name of the "tags" file in this directory */
-	sprintf(buf, "%s%c%s", dir, SLASH, TAGS);
-
-	/* Try to open the tags file.  Return NULL if can't open */
-#if AMIGA
-	if (buf[0] == '.' && buf[1] == SLASH)
-	    tfile = fopen(&buf[2], "r");
-	else
-#endif
-	tfile = fopen(buf, "r");
-	if (!tfile)
-	{
-		return (char *)0;
-	}
-
-	/* compute the length of the tagname once */
-	len = strlen(tag);
-
-	/* read lines until we get the one for this tag */
-	found[0] = '\0';
-	while (fgets(buf, sizeof buf, tfile))
-	{
-		/* is this the one we want? */
-		if (!strncmp(buf, tag, len) && buf[len] == '\t')
-		{
-			/* we've found a match -- remember it */
-			strcpy(found, buf);
-
-			/* if there is no default file, or this match is in
-			 * the default file, then we've definitely found the
-			 * one we want.  Break out of the loop now.
-			 */
-			if (!def_file || !strncmp(&buf[len + 1], def_file, strlen(def_file)))
-			{
-				break;
-			}
-		}
-	}
-
-	/* we're through reading */
-	fclose(tfile);
-
-	/* if there's anything in found[], use it */
-	if (found[0])
-	{
-		return &found[len + 1];
-	}
-
-	/* else we didn't find it */
-	return (char *)0;
-}
-
-/* This function reads a single textline from a binary file.  It returns
- * the number of bytes read, or 0 at EOF.
- */
-int getline(buf, limit, fp)
-	char	*buf;	/* buffer to read into */
-	int	limit;	/* maximum characters to read */
-	FILE	*fp;	/* binary stream to read from */
-{
-	int	bytes;	/* number of bytes read so far */
-	int	ch;	/* single character from file */
-
-	for (bytes = 0, ch = 0; ch != '\n' && --limit > 0 && (ch = getc(fp)) != EOF; bytes++)
-	{
-#if MSDOS || TOS
-		/* since this is a binary file, we'll need to manually strip CR's */
-		if (ch == '\r')
-		{
-			continue;
-		}
-#endif
-		*buf++ = ch;
-	}
-	*buf = '\0';
-
-	return bytes;
-}
-
-
-/* This function reads a source file, looking for a given tag.  If it finds
- * the tag, then it displays it and returns TRUE.  Otherwise it returns FALSE.
- * To display the tag, it attempts to output any introductory comment, the
- * tag line itself, and any arguments.  Arguments are assumed to immediately
- * follow the tag line, and start with whitespace.  Comments are assumed to
- * start with lines that begin with "/*", "//", "(*", or "--", and end at the
- * tag line or at a blank line.
- */
-int lookup(dir, entry)
-	char	*dir;	/* name of the directory that contains the source */
-	char	*entry;	/* source filename, <Tab>, linespec */
-{
-	char	buf[BLKSIZE];	/* pathname of sourcefile */
-	long	lnum;		/* line number */
-	long	here;		/* seek position where current line began */
-	long	comment;	/* seek position of introductory comment, or -1L */
-	FILE	*sfile;		/* used for reading the source file */
-	int	len;		/* length of string */
-	char	*ptr;
-
-
-	/* construct the pathname of the source file */
-	strcpy(buf, dir);
-	ptr = buf + strlen(buf);
-#if AMIGA
-	if (ptr[-1] != COLON)
-#endif
-	*ptr++ = SLASH;
-	while (*entry != '\t')
-	{
-		*ptr++ = *entry++;
-	}
-	*ptr = '\0';
-	entry++;
-
-	/* searching for string or number? */
-	if (*entry >= '0' && *entry <= '9')
-	{
-		/* given a specific line number */
-		lnum = atol(entry);
-		entry = (char *)0;
-	}
-	else
-	{
-		/* given a string -- strip off "/^" and "$/\n" */
-		entry += 2;
-		len = strlen(entry) - 2;
-		if (entry[len - 1] == '$')
-		{
-			entry[len - 1] = '\n';
-		}
-		lnum = 0L;
-	}
-
-	/* Open the file.  Note that we open the file in binary mode even
-	 * though we know it is a text file, because ftell() and fseek()
-	 * don't work on text files.
-	 */
-#if MSDOS || TOS
-	sfile = fopen(buf, "rb");
-#else
-# if AMIGA
-	if (buf[0] == '.' && buf[1] == SLASH)
-	    sfile = fopen(&buf[2], "r");
-	else
-# endif
-	sfile = fopen(buf, "r");
-#endif
-	if (!sfile)
-	{
-		/* can't open the real source file.  Try "refs" instead */
-#if AMIGA
-		if (dir[strlen(dir) - 1] == COLON)
-			sprintf(buf, "%srefs", dir);
-		else
-#endif
-		sprintf(buf, "%s%crefs", dir, SLASH);
-#if MSDOS || TOS
-		sfile = fopen(buf, "rb");
-#else
-# if AMIGA
-		if (buf[0] == '.' && buf[1] == SLASH)
-		    sfile = fopen(&buf[2], "r");
-		else
-# endif
-		sfile = fopen(buf, "r");
-#endif
-		if (!sfile)
-		{
-			/* failed! */
-			return 0;
-		}
-	}
-
-	/* search the file */
-	for (comment = -1L; here = ftell(sfile), getline(buf, BLKSIZE, sfile) > 0; )
-	{
-		/* Is this the start/end of a comment? */
-		if (comment == -1L)
-		{
-			/* starting a comment? */
-			if (buf[0] == '/' && buf[1] == '*'
-			 || buf[0] == '/' && buf[1] == '/'
-			 || buf[0] == '(' && buf[1] == '*'
-			 || buf[0] == '-' && buf[1] == '-')
-			{
-				comment = here;
-			}
-		}
-		else
-		{
-			/* ending a comment? */
-			if (buf[0] == '\n' || buf[0] == '#')
-			{
-				comment = -1L;
-			}
-		}
-
-		/* is this the tag line? */
-		if (--lnum == 0L || (entry && !strncmp(buf, entry, len)))
-		{
-			/* if there were introductory comments, show them */
-			if (comment != -1L)
-			{
-				fseek(sfile, comment, 0);
-				while (comment != here)
-				{
-					getline(buf, BLKSIZE, sfile);
-					fputs(buf, stdout);
-					comment = ftell(sfile);
-				}
-
-				/* re-fetch the tag line */
-				fgets(buf, BLKSIZE, sfile);
-			}
-
-			/* show the tag line */
-			fputs(buf, stdout);
-
-			/* show any argument lines */
-			while (getline(buf, BLKSIZE, sfile) > 0
-			    && buf[0] != '#'
-			    && strchr(buf, '{') == (char *)0)
-			{
-				fputs(buf, stdout);
-			}
-
-			/* Done!  Close the file, and return TRUE */
-			fclose(sfile);
-			return 1;
-		}
-	}
-
-	/* not found -- return FALSE */
-	return 0;
-}
-
-/* This function searches through the entire search path for a given tag.
- * If it finds the tag, then it displays the info and returns TRUE;
- * otherwise it returns FALSE.
- */
-int find(tag)
-	char	*tag;	/* the tag to look up */
-{
-	char	*tagpath;
-	char	dir[80];
-	char	*ptr;
-	int	len;
-
-	if (colons == 1)
-	{
-		/* looking for static function -- only look in current dir */
-		tagpath = ".";
-	}
-	else
-	{
-		/* get the tagpath from the environment.  Default to DEFTAGPATH */
-		tagpath = getenv("TAGPATH");
-		if (!tagpath)
-		{
-			tagpath = DEFTAGPATH;
-		}
-	}
-
-	/* for each entry in the path... */
-	while (*tagpath)
-	{
-		/* Copy the entry into the dir[] buffer */
-		for (ptr = dir; *tagpath && *tagpath != SEP; tagpath++)
-		{
-			*ptr++ = *tagpath;
-		}
-		if (*tagpath == SEP)
-		{
-			tagpath++;
-		}
-
-		/* if the entry ended with "/tags", then strip that off */
-		len = strlen(TAGS);
-		if (&dir[len] < ptr && ptr[-len - 1] == SLASH && !strncmp(&ptr[-len], TAGS, len))
-		{
-			ptr -= len + 1;
-		}
-
-		/* if the entry is now an empty string, then assume "." */
-		if (ptr == dir)
-		{
-			*ptr++ = '.';
-		}
-		*ptr = '\0';
-
-		/* look for the tag in this path.  If found, then display it
-		 * and exit.
-		 */
-		ptr = cktagdir(tag, dir);
-		if (ptr)
-		{
-			/* just supposed to display tag info? */
-			if (taginfo)
-			{
-				/* then do only that! */
-				if (strcmp(dir, "."))
-				{
-					printf("%s%c%s", dir, SLASH, ptr);
-				}
-				else
-				{
-					/* avoid leading "./" if possible */
-					fputs(ptr, stdout);
-				}
-				return 1;
-			}
-			else
-			{
-				/* else look up the declaration of the thing */
-				return lookup(dir, ptr);
-			}
-		}
-	}
-
-	/* if we get here, then the tag wasn't found anywhere */
-	return 0;
-}
-
-void usage()
-{
-	fputs("usage: ref [-a] [-t] [-c class] [-f file] tag\n", stderr);
-	fputs("   -a        function's args may be flush against left margin\n", stderr);
-	fputs("   -t        output tag info, instead of the function header\n", stderr);
-	fputs("   -f File   tag might be a static function in File\n", stderr);
-	fputs("   -c Class  tag might be a member of class Class\n", stderr);
-	exit(2);
-}
-
-
-int countcolons(str)
-	char	*str;
-{
-	while (*str != ':' && *str)
-	{
-		str++;
-	}
-	if (str[0] != ':')
-	{
-		return 0;
-	}
-	else if (str[1] != ':')
-	{
-		return 1;
-	}
-	return 2;
-}
-
-int main(argc, argv)
-	int	argc;
-	char	**argv;
-{
-	char	def_tag[100];	/* used to build tag name with default file/class */
-	int	i;
-
-	/* parse flags */
-	for (i = 1; i < argc && argv[i][0] == '-'; i++)
-	{
-		switch (argv[i][1])
-		{
-		  case 't':
-			taginfo = 1;
-			break;
-
-		  case 'f':
-			if (argv[i][2])
-			{
-				def_file = &argv[i][2];
-			}
-			else if (++i < argc)
-			{
-				def_file = argv[i];
-			}
-			else
-			{
-				usage();
-			}
-			break;
-
-		  case 'c':
-			if (argv[i][2])
-			{
-				def_class = &argv[i][2];
-			}
-			else if (++i < argc)
-			{
-				def_class = argv[i];
-			}
-			else
-			{
-				usage();
-			}
-			break;
-
-		  default:
-			usage();
-		}
-	}
-
-	/* if no tag was given, complain */
-	if (i + 1 != argc)
-	{
-		usage();
-	}
-
-	/* does the tag have an explicit class or file? */
-	colons = countcolons(argv[i]);
-
-	/* if not, then maybe try some defaults */
-	if (colons == 0)
-	{
-		/* try a static function in the file first */
-		if (def_file)
-		{
-			sprintf(def_tag, "%s:%s", def_file, argv[i]);
-			colons = 1;
-			if (find(def_tag))
-			{
-				exit(0);
-			}
-		}
-
-		/* try a member function for a class */
-		if (def_class)
-		{
-			sprintf(def_tag, "%s::%s", def_class, argv[i]);
-			colons = 2;
-			if (find(def_tag))
-			{
-				exit(0);
-			}
-		}
-
-		/* oh, well */
-		colons = 0;
-	}
-
-	/* find the tag */
-	if (find(argv[i]))
-	{
-		exit(0);
-	}
-
-	exit(1);
-	/*NOTREACHED*/
-}
Index: trunk/minix/commands/elvis/regexp.c
===================================================================
--- trunk/minix/commands/elvis/regexp.c	(revision 9)
+++ 	(revision )
@@ -1,934 +1,0 @@
-/* regexp.c */
-
-/* This file contains the code that compiles regular expressions and executes
- * them.  It supports the same syntax and features as vi's regular expression
- * code.  Specifically, the meta characters are:
- *	^	matches the beginning of a line
- *	$	matches the end of a line
- *	\<	matches the beginning of a word
- *	\>	matches the end of a word
- *	.	matches any single character
- *	[]	matches any character in a character class
- *	\(	delimits the start of a subexpression
- *	\)	delimits the end of a subexpression
- *	*	repeats the preceding 0 or more times
- * NOTE: You cannot follow a \) with a *.
- *
- * The physical structure of a compiled RE is as follows:
- *	- First, there is a one-byte value that says how many character classes
- *	  are used in this regular expression
- *	- Next, each character class is stored as a bitmap that is 256 bits
- *	  (32 bytes) long.
- *	- A mixture of literal characters and compiled meta characters follows.
- *	  This begins with M_BEGIN(0) and ends with M_END(0).  All meta chars
- *	  are stored as a \n followed by a one-byte code, so they take up two
- *	  bytes apiece.  Literal characters take up one byte apiece.  \n can't
- *	  be used as a literal character.
- *
- * If NO_MAGIC is defined, then a different set of functions is used instead.
- * That right, this file contains TWO versions of the code.
- */
-
-#include <setjmp.h>
-#include "config.h"
-#include "ctype.h"
-#include "vi.h"
-#include "regexp.h"
-
-
-
-static char	*previous;	/* the previous regexp, used when null regexp is given */
-
-
-#ifndef NO_MAGIC
-/* THE REAL REGEXP PACKAGE IS USED UNLESS "NO_MAGIC" IS DEFINED */
-
-/* These are used to classify or recognize meta-characters */
-#define META		'\0'
-#define BASE_META(m)	((m) - 256)
-#define INT_META(c)	((c) + 256)
-#define IS_META(m)	((m) >= 256)
-#define IS_CLASS(m)	((m) >= M_CLASS(0) && (m) <= M_CLASS(9))
-#define IS_START(m)	((m) >= M_START(0) && (m) <= M_START(9))
-#define IS_END(m)	((m) >= M_END(0) && (m) <= M_END(9))
-#define IS_CLOSURE(m)	((m) >= M_SPLAT && (m) <= M_RANGE)
-#define ADD_META(s,m)	(*(s)++ = META, *(s)++ = BASE_META(m))
-#define GET_META(s)	(*(s) == META ? INT_META(*++(s)) : *s)
-
-/* These are the internal codes used for each type of meta-character */
-#define M_BEGLINE	256		/* internal code for ^ */
-#define M_ENDLINE	257		/* internal code for $ */
-#define M_BEGWORD	258		/* internal code for \< */
-#define M_ENDWORD	259		/* internal code for \> */
-#define M_ANY		260		/* internal code for . */
-#define M_SPLAT		261		/* internal code for * */
-#define M_PLUS		262		/* internal code for \+ */
-#define M_QMARK		263		/* internal code for \? */
-#define M_RANGE		264		/* internal code for \{ */
-#define M_CLASS(n)	(265+(n))	/* internal code for [] */
-#define M_START(n)	(275+(n))	/* internal code for \( */
-#define M_END(n)	(285+(n))	/* internal code for \) */
-
-/* These are used during compilation */
-static int	class_cnt;	/* used to assign class IDs */
-static int	start_cnt;	/* used to assign start IDs */
-static int	end_stk[NSUBEXP];/* used to assign end IDs */
-static int	end_sp;
-static char	*retext;	/* points to the text being compiled */
-
-/* error-handling stuff */
-jmp_buf	errorhandler;
-#define FAIL(why)	regerror(why); longjmp(errorhandler, 1)
-
-
-
-
-
-/* This function builds a bitmap for a particular class */
-static char *makeclass(text, bmap)
-	REG char	*text;	/* start of the class */
-	REG char	*bmap;	/* the bitmap */
-{
-	REG int		i;
-	int		complement = 0;
-
-
-	/* zero the bitmap */
-	for (i = 0; bmap && i < 32; i++)
-	{
-		bmap[i] = 0;
-	}
-
-	/* see if we're going to complement this class */
-	if (*text == '^')
-	{
-		text++;
-		complement = 1;
-	}
-
-	/* add in the characters */
-	while (*text && *text != ']')
-	{
-		/* is this a span of characters? */
-		if (text[1] == '-' && text[2])
-		{
-			/* spans can't be backwards */
-			if (text[0] > text[2])
-			{
-				FAIL("Backwards span in []");
-			}
-
-			/* add each character in the span to the bitmap */
-			for (i = text[0]; bmap && i <= text[2]; i++)
-			{
-				bmap[i >> 3] |= (1 << (i & 7));
-			}
-
-			/* move past this span */
-			text += 3;
-		}
-		else
-		{
-			/* add this single character to the span */
-			i = *text++;
-			if (bmap)
-			{
-				bmap[i >> 3] |= (1 << (i & 7));
-			}
-		}
-	}
-
-	/* make sure the closing ] is missing */
-	if (*text++ != ']')
-	{
-		FAIL("] missing");
-	}
-
-	/* if we're supposed to complement this class, then do so */
-	if (complement && bmap)
-	{
-		for (i = 0; i < 32; i++)
-		{
-			bmap[i] = ~bmap[i];
-		}
-	}
-
-	return text;
-}
-
-
-
-
-/* This function gets the next character or meta character from a string.
- * The pointer is incremented by 1, or by 2 for \-quoted characters.  For [],
- * a bitmap is generated via makeclass() (if re is given), and the
- * character-class text is skipped.
- */
-static int gettoken(sptr, re)
-	char	**sptr;
-	regexp	*re;
-{
-	int	c;
-
-	c = **sptr;
-	++*sptr;
-	if (c == '\\')
-	{
-		c = **sptr;
-		++*sptr;
-		switch (c)
-		{
-		  case '<':
-			return M_BEGWORD;
-
-		  case '>':
-			return M_ENDWORD;
-
-		  case '(':
-			if (start_cnt >= NSUBEXP)
-			{
-				FAIL("Too many \\(s");
-			}
-			end_stk[end_sp++] = start_cnt;
-			return M_START(start_cnt++);
-
-		  case ')':
-			if (end_sp <= 0)
-			{
-				FAIL("Mismatched \\)");
-			}
-			return M_END(end_stk[--end_sp]);
-
-		  case '*':
-			return (*o_magic ? c : M_SPLAT);
-
-		  case '.':
-			return (*o_magic ? c : M_ANY);
-
-		  case '+':
-			return M_PLUS;
-
-		  case '?':
-			return M_QMARK;
-#ifndef CRUNCH
-		  case '{':
-			return M_RANGE;
-#endif
-		  default:
-			return c;
-		}
-	}
-	else if (*o_magic)
-	{
-		switch (c)
-		{
-		  case '^':
-			if (*sptr == retext + 1)
-			{
-				return M_BEGLINE;
-			}
-			return c;
-
-		  case '$':
-			if (!**sptr)
-			{
-				return M_ENDLINE;
-			}
-			return c;
-
-		  case '.':
-			return M_ANY;
-
-		  case '*':
-			return M_SPLAT;
-
-		  case '[':
-			/* make sure we don't have too many classes */
-			if (class_cnt >= 10)
-			{
-				FAIL("Too many []s");
-			}
-
-			/* process the character list for this class */
-			if (re)
-			{
-				/* generate the bitmap for this class */
-				*sptr = makeclass(*sptr, re->program + 1 + 32 * class_cnt);
-			}
-			else
-			{
-				/* skip to end of the class */
-				*sptr = makeclass(*sptr, (char *)0);
-			}
-			return M_CLASS(class_cnt++);
-
-		  default:
-			return c;
-		}
-	}
-	else	/* unquoted nomagic */
-	{
-		switch (c)
-		{
-		  case '^':
-			if (*sptr == retext + 1)
-			{
-				return M_BEGLINE;
-			}
-			return c;
-
-		  case '$':
-			if (!**sptr)
-			{
-				return M_ENDLINE;
-			}
-			return c;
-
-		  default:
-			return c;
-		}
-	}
-	/*NOTREACHED*/
-}
-
-
-
-
-/* This function calculates the number of bytes that will be needed for a
- * compiled RE.  Its argument is the uncompiled version.  It is not clever
- * about catching syntax errors; that is done in a later pass.
- */
-static unsigned calcsize(text)
-	char		*text;
-{
-	unsigned	size;
-	int		token;
-
-	retext = text;
-	class_cnt = 0;
-	start_cnt = 1;
-	end_sp = 0;
-	size = 5;
-	while ((token = gettoken(&text, (regexp *)0)) != 0)
-	{
-		if (IS_CLASS(token))
-		{
-			size += 34;
-		}
-#ifndef CRUNCH
-		else if (token == M_RANGE)
-		{
-			size += 4;
-			while ((token = gettoken(&text, (regexp *)0)) != 0
-			    && token != '}')
-			{
-			}
-			if (!token)
-			{
-				return size;
-			}
-		}
-#endif
-		else if (IS_META(token))
-		{
-			size += 2;
-		}
-		else
-		{
-			size++;
-		}
-	}
-
-	return size;
-}
-
-
-
-/* This function compiles a regexp. */
-regexp *regcomp(exp)
-	char		*exp;
-{
-	int		needfirst;
-	unsigned	size;
-	int		token;
-	int		peek;
-	char		*build;
-	regexp		*re;
-#ifndef CRUNCH
-	int		from;
-	int		to;
-	int		digit;
-#endif
-
-
-	/* prepare for error handling */
-	re = (regexp *)0;
-	if (setjmp(errorhandler))
-	{
-		if (re)
-		{
-			free(re);
-		}
-		return (regexp *)0;
-	}
-
-	/* if an empty regexp string was given, use the previous one */
-	if (*exp == 0)
-	{
-		if (!previous)
-		{
-			FAIL("No previous RE");
-		}
-		exp = previous;
-	}
-	else /* non-empty regexp given, so remember it */
-	{
-		if (previous)
-			free(previous);
-		previous = (char *)malloc((unsigned)(strlen(exp) + 1));
-		if (previous)
-			strcpy(previous, exp);
-	}
-
-	/* allocate memory */
-	class_cnt = 0;
-	start_cnt = 1;
-	end_sp = 0;
-	retext = exp;
-	size = calcsize(exp) + sizeof(regexp) + 10; /* !!! 10 bytes for slop */
-#ifdef lint
-	re = ((regexp *)0) + size;
-#else
-	re = (regexp *)malloc((unsigned)size);
-#endif
-	if (!re)
-	{
-		FAIL("Not enough memory for this RE");
-	}
-
-	/* compile it */
-	build = &re->program[1 + 32 * class_cnt];
-	re->program[0] = class_cnt;
-	for (token = 0; token < NSUBEXP; token++)
-	{
-		re->startp[token] = re->endp[token] = (char *)0;
-	}
-	re->first = 0;
-	re->bol = 0;
-	re->minlen = 0;
-	needfirst = 1;
-	class_cnt = 0;
-	start_cnt = 1;
-	end_sp = 0;
-	retext = exp;
-	for (token = M_START(0), peek = gettoken(&exp, re);
-	     token;
-	     token = peek, peek = gettoken(&exp, re))
-	{
-		/* special processing for the closure operator */
-		if (IS_CLOSURE(peek))
-		{
-			/* detect misuse of closure operator */
-			if (IS_START(token))
-			{
-				FAIL("Closure operator follows nothing");
-			}
-			else if (IS_META(token) && token != M_ANY && !IS_CLASS(token))
-			{
-				FAIL("Closure operators can only follow a normal character or . or []");
-			}
-
-#ifndef CRUNCH
-			/* if \{ \} then read the range */
-			if (peek == M_RANGE)
-			{
-				from = 0;
-				for (digit = gettoken(&exp, re);
-				     !IS_META(digit) && isdigit(digit);
-				     digit = gettoken(&exp, re))
-				{
-					from = from * 10 + digit - '0';
-				}
-				if (digit == '}')
-				{
-					to = from;
-				}
-				else if (digit == ',')
-				{
-					to = 0;
-					for (digit = gettoken(&exp, re);
-					     !IS_META(digit) && isdigit(digit);
-					     digit = gettoken(&exp, re))
-					{
-						to = to * 10 + digit - '0';
-					}
-					if (to == 0)
-					{
-						to = 255;
-					}
-				}
-				if (digit != '}')
-				{
-					FAIL("Bad characters after \\{");
-				}
-				else if (to < from || to == 0 || from >= 255)
-				{
-					FAIL("Invalid range for \\{ \\}");
-				}
-				re->minlen += from;
-			}
-			else
-#endif
-			if (peek != M_SPLAT)
-			{
-				re->minlen++;
-			}
-
-			/* it is okay -- make it prefix instead of postfix */
-			ADD_META(build, peek);
-#ifndef CRUNCH
-			if (peek == M_RANGE)
-			{
-				*build++ = from;
-				*build++ = (to < 255 ? to : 255);
-			}
-#endif
-			
-
-			/* take care of "needfirst" - is this the first char? */
-			if (needfirst && peek == M_PLUS && !IS_META(token))
-			{
-				re->first = token;
-			}
-			needfirst = 0;
-
-			/* we used "peek" -- need to refill it */
-			peek = gettoken(&exp, re);
-			if (IS_CLOSURE(peek))
-			{
-				FAIL("* or \\+ or \\? doubled up");
-			}
-		}
-		else if (!IS_META(token))
-		{
-			/* normal char is NOT argument of closure */
-			if (needfirst)
-			{
-				re->first = token;
-				needfirst = 0;
-			}
-			re->minlen++;
-		}
-		else if (token == M_ANY || IS_CLASS(token))
-		{
-			/* . or [] is NOT argument of closure */
-			needfirst = 0;
-			re->minlen++;
-		}
-
-		/* the "token" character is not closure -- process it normally */
-		if (token == M_BEGLINE)
-		{
-			/* set the BOL flag instead of storing M_BEGLINE */
-			re->bol = 1;
-		}
-		else if (IS_META(token))
-		{
-			ADD_META(build, token);
-		}
-		else
-		{
-			*build++ = token;
-		}
-	}
-
-	/* end it with a \) which MUST MATCH the opening \( */
-	ADD_META(build, M_END(0));
-	if (end_sp > 0)
-	{
-		FAIL("Not enough \\)s");
-	}
-
-	return re;
-}
-
-
-
-/*---------------------------------------------------------------------------*/
-
-
-/* This function checks for a match between a character and a token which is
- * known to represent a single character.  It returns 0 if they match, or
- * 1 if they don't.
- */
-int match1(re, ch, token)
-	regexp		*re;
-	REG char	ch;
-	REG int		token;
-{
-	if (!ch)
-	{
-		/* the end of a line can't match any RE of width 1 */
-		return 1;
-	}
-	if (token == M_ANY)
-	{
-		return 0;
-	}
-	else if (IS_CLASS(token))
-	{
-		if (re->program[1 + 32 * (token - M_CLASS(0)) + (ch >> 3)] & (1 << (ch & 7)))
-			return 0;
-	}
-	else if (ch == token || *o_ignorecase && tolower(ch) == tolower(token))
-	{
-		return 0;
-	}
-	return 1;
-}
-
-
-
-/* This function checks characters up to and including the next closure, at
- * which point it does a recursive call to check the rest of it.  This function
- * returns 0 if everything matches, or 1 if something doesn't match.
- */
-int match(re, str, prog, here)
-	regexp		*re;	/* the regular expression */
-	char		*str;	/* the string */
-	REG char	*prog;	/* a portion of re->program, an compiled RE */
-	REG char	*here;	/* a portion of str, the string to compare it to */
-{
-	REG int		token;	/* the roken pointed to by prog */
-	REG int		nmatched;/* counter, used during closure matching */ 
-	REG int		closure;/* the token denoting the type of closure */
-	int		from;	/* minimum number of matches in closure */
-	int		to;	/* maximum number of matches in closure */
-
-	for (token = GET_META(prog); !IS_CLOSURE(token); prog++, token = GET_META(prog))
-	{
-		switch (token)
-		{
-		/*case M_BEGLINE: can't happen; re->bol is used instead */
-		  case M_ENDLINE:
-			if (*here)
-				return 1;
-			break;
-
-		  case M_BEGWORD:
-			if (here != str &&
-			   (here[-1] == '_' || isalnum(here[-1])))
-				return 1;
-			break;
-
-		  case M_ENDWORD:
-			if (here[0] == '_' || isalnum(here[0]))
-				return 1;
-			break;
-
-		  case M_START(0):
-		  case M_START(1):
-		  case M_START(2):
-		  case M_START(3):
-		  case M_START(4):
-		  case M_START(5):
-		  case M_START(6):
-		  case M_START(7):
-		  case M_START(8):
-		  case M_START(9):
-			re->startp[token - M_START(0)] = (char *)here;
-			break;
-
-		  case M_END(0):
-		  case M_END(1):
-		  case M_END(2):
-		  case M_END(3):
-		  case M_END(4):
-		  case M_END(5):
-		  case M_END(6):
-		  case M_END(7):
-		  case M_END(8):
-		  case M_END(9):
-			re->endp[token - M_END(0)] = (char *)here;
-			if (token == M_END(0))
-			{
-				return 0;
-			}
-			break;
-
-		  default: /* literal, M_CLASS(n), or M_ANY */
-			if (match1(re, *here, token) != 0)
-				return 1;
-			here++;
-		}
-	}
-
-	/* C L O S U R E */
-
-	/* step 1: see what we have to match against, and move "prog" to point
-	 * to the remainder of the compiled RE.
-	 */
-	closure = token;
-	prog++;
-	switch (closure)
-	{
-	  case M_SPLAT:
-		from = 0;
-		to = strlen(str);	/* infinity */
-		break;
-
-	  case M_PLUS:
-		from = 1;
-		to = strlen(str);	/* infinity */
-		break;
-
-	  case M_QMARK:
-		from = 0;
-		to = 1;
-		break;
-
-#ifndef CRUNCH
-	  case M_RANGE:
-		from = UCHAR(*prog++);
-		to = UCHAR(*prog++);
-		if (to == 255)
-		{
-			to = strlen(str); /* infinity */
-		}
-		break;
-#endif
-	}
-	token = GET_META(prog);
-	prog++;
-
-	/* step 2: see how many times we can match that token against the string */
-	for (nmatched = 0;
-	     nmatched < to && *here && match1(re, *here, token) == 0;
-	     nmatched++, here++)
-	{
-	}
-
-	/* step 3: try to match the remainder, and back off if it doesn't */
-	while (nmatched >= from && match(re, str, prog, here) != 0)
-	{
-		nmatched--;
-		here--;
-	}
-
-	/* so how did it work out? */
-	if (nmatched >= from)
-		return 0;
-	return 1;
-}
-
-
-
-/* This function searches through a string for text that matches an RE. */
-int regexec(re, str, bol)
-	regexp	*re;	/* the compiled regexp to search for */
-	char	*str;	/* the string to search through */
-	int	bol;	/* boolean: does str start at the beginning of a line? */
-{
-	char	*prog;	/* the entry point of re->program */
-	int	len;	/* length of the string */
-	REG char	*here;
-
-	/* if must start at the beginning of a line, and this isn't, then fail */
-	if (re->bol && !bol)
-	{
-		return 0;
-	}
-
-	len = strlen(str);
-	prog = re->program + 1 + 32 * re->program[0];
-
-	/* search for the RE in the string */
-	if (re->bol)
-	{
-		/* must occur at BOL */
-		if ((re->first
-			&& match1(re, *(char *)str, re->first))/* wrong first letter? */
-		 || len < re->minlen			/* not long enough? */
-		 || match(re, (char *)str, prog, str))	/* doesn't match? */
-			return 0;			/* THEN FAIL! */
-	}
-#ifndef CRUNCH
-	else if (!*o_ignorecase)
-	{
-		/* can occur anywhere in the line, noignorecase */
-		for (here = (char *)str;
-		     (re->first && re->first != *here)
-			|| match(re, (char *)str, prog, here);
-		     here++, len--)
-		{
-			if (len < re->minlen)
-				return 0;
-		}
-	}
-#endif
-	else
-	{
-		/* can occur anywhere in the line, ignorecase */
-		for (here = (char *)str;
-		     (re->first && match1(re, *here, (int)re->first))
-			|| match(re, (char *)str, prog, here);
-		     here++, len--)
-		{
-			if (len < re->minlen)
-				return 0;
-		}
-	}
-
-	/* if we didn't fail, then we must have succeeded */
-	return 1;
-}
-
-/*============================================================================*/
-#else /* NO_MAGIC */
-
-regexp *regcomp(exp)
-	char	*exp;
-{
-	char	*src;
-	char	*dest;
-	regexp	*re;
-	int	i;
-
-	/* allocate a big enough regexp structure */
-#ifdef lint
-	re = (regexp *)0;
-#else
-	re = (regexp *)malloc((unsigned)(strlen(exp) + 1 + sizeof(struct regexp)));
-#endif
-	if (!re)
-	{
-		regerror("Could not malloc a regexp structure");
-		return (regexp *)0;
-	}
-
-	/* initialize all fields of the structure */
-	for (i = 0; i < NSUBEXP; i++)
-	{
-		re->startp[i] = re->endp[i] = (char *)0;
-	}
-	re->minlen = 0;
-	re->first = 0;
-	re->bol = 0;
-
-	/* copy the string into it, translating ^ and $ as needed */
-	for (src = exp, dest = re->program + 1; *src; src++)
-	{
-		switch (*src)
-		{
-		  case '^':
-			if (src == exp)
-			{
-				re->bol += 1;
-			}
-			else
-			{
-				*dest++ = '^';
-				re->minlen++;
-			}
-			break;
-
-		  case '$':
-			if (!src[1])
-			{
-				re->bol += 2;
-			}
-			else
-			{
-				*dest++ = '$';
-				re->minlen++;
-			}
-			break;
-
-		  case '\\':
-			if (src[1])
-			{
-				*dest++ = *++src;
-				re->minlen++;
-			}
-			else
-			{
-				regerror("extra \\ at end of regular expression");
-			}
-			break;
-
-		  default:
-			*dest++ = *src;
-			re->minlen++;
-		}
-	}
-	*dest = '\0';
-
-	return re;
-}
-
-
-/* This "helper" function checks for a match at a given location.  It returns
- * 1 if it matches, 0 if it doesn't match here but might match later on in the
- * string, or -1 if it could not possibly match
- */
-static int reghelp(prog, string, bolflag)
-	struct regexp	*prog;
-	char		*string;
-	int		bolflag;
-{
-	char		*scan;
-	char		*str;
-
-	/* if ^, then require bolflag */
-	if ((prog->bol & 1) && !bolflag)
-	{
-		return -1;
-	}
-
-	/* if it matches, then it will start here */
-	prog->startp[0] = string;
-
-	/* compare, possibly ignoring case */
-	if (*o_ignorecase)
-	{
-		for (scan = &prog->program[1]; *scan; scan++, string++)
-			if (tolower(*scan) != tolower(*string))
-				return *string ? 0 : -1;
-	}
-	else
-	{
-		for (scan = &prog->program[1]; *scan; scan++, string++)
-			if (*scan != *string)
-				return *string ? 0 : -1;
-	}
-
-	/* if $, then require string to end here, too */
-	if ((prog->bol & 2) && *string)
-	{
-		return 0;
-	}
-
-	/* if we get to here, it matches */
-	prog->endp[0] = string;
-	return 1;
-}
-
-
-
-int regexec(prog, string, bolflag)
-	struct regexp	*prog;
-	char		*string;
-	int		bolflag;
-{
-	int		rc;
-
-	/* keep trying to match it */
-	for (rc = reghelp(prog, string, bolflag); rc == 0; rc = reghelp(prog, string, 0))
-	{
-		string++;
-	}
-
-	/* did we match? */
-	return rc == 1;
-}
-#endif
Index: trunk/minix/commands/elvis/regexp.h
===================================================================
--- trunk/minix/commands/elvis/regexp.h	(revision 9)
+++ 	(revision )
@@ -1,21 +1,0 @@
-/*
- * Definitions etc. for regexp(3) routines.
- *
- * Caveat:  this is V8 regexp(3) [actually, a reimplementation thereof],
- * not the System V one.
- */
-#define NSUBEXP  10
-
-typedef struct regexp {
-	char	*startp[NSUBEXP];
-	char	*endp[NSUBEXP];
-	int	minlen;		/* length of shortest possible match */
-	char	first;		/* first character, if known; else \0 */
-	char	bol;		/* boolean: must start at beginning of line? */
-	char	program[1];	/* Unwarranted chumminess with compiler. */
-} regexp;
-
-extern regexp *regcomp();
-extern int regexec();
-extern void regsub();
-extern void regerror();
Index: trunk/minix/commands/elvis/regsub.c
===================================================================
--- trunk/minix/commands/elvis/regsub.c	(revision 9)
+++ 	(revision )
@@ -1,243 +1,0 @@
-/* regsub.c */
-
-/* This file contains the regsub() function, which performs substitutions
- * after a regexp match has been found.
- */
-
-#include "config.h"
-#include "ctype.h"
-#include "vi.h"
-#include "regexp.h"
-
-
-/* perform substitutions after a regexp match */
-void regsub(re, src, dst)
-	regexp		*re;	/* the regexp with pointers into matched text */
-	REG char	*src;	/* the replacement string */
-	REG char	*dst;	/* where to put the result of the subst */
-{
-	REG char	*cpy;	/* pointer to start of text to copy */
-	REG char	*end;	/* pointer to end of text to copy */
-	REG char	c;
-	char		*start;
-#ifndef CRUNCH
-	int		mod = 0;/* used to track \U, \L, \u, \l, and \E */
-	int		len;	/* used to calculate length of subst string */
-	static char	*prev;	/* a copy of the text from the previous subst */
-
-	/* replace \~ (or maybe ~) by previous substitution text */
-
-	/* step 1: calculate the length of the new substitution text */
-	for (len = strlen(src), c = '\0', cpy = src; *cpy; cpy++)
-	{
-# ifdef NO_MAGIC
-		if (c == '\\' && *cpy == '~')
-# else
-		if (c == (*o_magic ? '\0' : '\\') && *cpy == '~')
-# endif
-		{
-			if (!prev)
-			{
-				regerror("No prev text to substitute for ~");
-				return;
-			}
-			len += strlen(prev) - 1;
-# ifndef NO_MAGIC
-			if (!*o_magic)
-# endif
-				len -= 1; /* because we lose the \ too */
-		}
-
-		/* watch backslash quoting */
-		if (c != '\\' && *cpy == '\\')
-			c = '\\';
-		else
-			c = '\0';
-	}
-
-	/* allocate memory for the ~ed version of src */
-	start = cpy = (char *)malloc((unsigned)(len + 1));
-	if (!cpy)
-	{
-		regerror("Not enough memory for ~ expansion");
-		return;
-	}
-
-	/* copy src into start, replacing the ~s by the previous text */
-	while (*src)
-	{
-# ifndef NO_MAGIC
-		if (*o_magic && *src == '~')
-		{
-			strcpy(cpy, prev);
-			cpy += strlen(prev);
-			src++;
-		}
-		else if (!*o_magic && *src == '\\' && *(src + 1) == '~')
-# else /* NO_MAGIC */
-		if (*src == '\\' && *(src + 1) == '~')
-# endif /* NO_MAGIC */
-		{
-			strcpy(cpy, prev);
-			cpy += strlen(prev);
-			src += 2;
-		}
-		else
-		{
-			*cpy++ = *src++;
-		}
-	}
-	*cpy = '\0';
-#ifdef DEBUG
-	if ((int)(cpy - start) != len)
-	{
-		msg("Bug in regsub.c! Predicted length = %d, Actual length = %d", len, (int)(cpy - start));
-	}
-#endif
-
-	/* remember this as the "previous" for next time */
-	if (prev)
-		free(prev);
-	prev = src = start;
-
-#endif /* undef CRUNCH */
-
-	start = src;
-	while ((c = *src++) != '\0')
-	{
-#ifndef NO_MAGIC
-		/* recognize any meta characters */
-		if (c == '&' && *o_magic)
-		{
-			cpy = re->startp[0];
-			end = re->endp[0];
-		}
-		else
-#endif /* not NO_MAGIC */
-		if (c == '\\')
-		{
-			c = *src++;
-			switch (c)
-			{
-#ifndef NO_MAGIC
-			  case '0':
-			  case '1':
-			  case '2':
-			  case '3':
-			  case '4':
-			  case '5':
-			  case '6':
-			  case '7':
-			  case '8':
-			  case '9':
-				/* \0 thru \9 mean "copy subexpression" */
-				c -= '0';
-				cpy = re->startp[c];
-				end = re->endp[c];
-				break;
-# ifndef CRUNCH
-			  case 'U':
-			  case 'u':
-			  case 'L':
-			  case 'l':
-				/* \U and \L mean "convert to upper/lowercase" */
-				mod = c;
-				continue;
-
-			  case 'E':
-			  case 'e':
-				/* \E ends the \U or \L */
-				mod = 0;
-				continue;
-# endif /* not CRUNCH */
-			  case '&':
-				/* "\&" means "original text" */
-				if (*o_magic)
-				{
-					*dst++ = c;
-					continue;
-				}
-				cpy = re->startp[0];
-				end = re->endp[0];
-				break;
-
-#else /* NO_MAGIC */
-			  case '&':
-				/* "\&" means "original text" */
-				cpy = re->startp[0];
-				end = re->endp[0];
-				break;
-#endif /* NO_MAGIC */
-			  default:
-				/* ordinary char preceded by backslash */
-				*dst++ = c;
-				continue;
-			}
-		}
-#ifndef CRUNCH
-# if OSK
-		else if (c == '\l')
-# else
-		else if (c == '\r')
-# endif
-		{
-			/* transliterate ^M into newline */
-			*dst++ = '\n';
-			continue;
-		}
-#endif /* !CRUNCH */
-		else
-		{
-			/* ordinary character, so just copy it */
-			*dst++ = c;
-			continue;
-		}
-
-		/* Note: to reach this point in the code, we must have evaded
-		 * all "continue" statements.  To do that, we must have hit
-		 * a metacharacter that involves copying.
-		 */
-
-		/* if there is nothing to copy, loop */
-		if (!cpy)
-			continue;
-
-		/* copy over a portion of the original */
-		while (cpy < end)
-		{
-#ifndef NO_MAGIC
-# ifndef CRUNCH
-			switch (mod)
-			{
-			  case 'U':
-			  case 'u':
-				/* convert to uppercase */
-				*dst++ = toupper(*cpy++);
-				break;
-
-			  case 'L':
-			  case 'l':
-				/* convert to lowercase */
-				*dst++ = tolower(*cpy++);
-				break;
-
-			  default:
-				/* copy without any conversion */
-				*dst++ = *cpy++;
-			}
-
-			/* \u and \l end automatically after the first char */
-			if (mod && (mod == 'u' || mod == 'l'))
-			{
-				mod = 0;
-			}
-# else /* CRUNCH */
-			*dst++ = *cpy++;
-# endif /* CRUNCH */
-#else /* NO_MAGIC */
-			*dst++ = *cpy++;
-#endif /* NO_MAGIC */
-		}
-	}
-	*dst = '\0';
-}
Index: trunk/minix/commands/elvis/system.c
===================================================================
--- trunk/minix/commands/elvis/system.c	(revision 9)
+++ 	(revision )
@@ -1,423 +1,0 @@
-/* system.c  -- UNIX version */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains a new version of the system() function and related stuff.
- *
- * Entry points are:
- *	system(cmd)		- run a single shell command
- *	wildcard(names)		- expand wildcard characters in filanames
- *	filter(m,n,cmd,back)	- run text lines through a filter program
- *
- * This is probably the single least portable file in the program.  The code
- * shown here should work correctly if it links at all; it will work on UNIX
- * and any O.S./Compiler combination which adheres to UNIX forking conventions.
- */
-
-#include "config.h"
-#include "vi.h"
-extern char	**environ;
-
-#if ANY_UNIX
-
-/* This is a new version of the system() function.  The only difference
- * between this one and the library one is: this one uses the o_shell option.
- */
-int system(cmd)
-	char	*cmd;	/* a command to run */
-{
-	int	pid;	/* process ID of child */
-	int	died;
-	int	status;	/* exit status of the command */
-
-
-	signal(SIGINT, SIG_IGN);
-	pid = fork();
-	switch (pid)
-	{
-	  case -1:						/* error */
-		msg("fork() failed");
-		status = -1;
-		break;
-
-	  case 0:						/* child */
-		/* for the child, close all files except stdin/out/err */
-		for (status = 3; status < 60 && (close(status), errno != EINVAL); status++)
-		{
-		}
-
-		signal(SIGINT, SIG_DFL);
-		if (cmd == o_shell)
-		{
-			execle(o_shell, o_shell, (char *)0, environ);
-		}
-		else
-		{
-			execle(o_shell, o_shell, "-c", cmd, (char *)0, environ);
-		}
-		msg("execle(\"%s\", ...) failed", o_shell);
-		exit(1); /* if we get here, the exec failed */
-
-	  default:						/* parent */
-		do
-		{
-			died = wait(&status);
-		} while (died >= 0 && died != pid);
-		if (died < 0)
-		{
-			status = -1;
-		}
-#if __GNUC__ || _ANSI
-		signal(SIGINT, (void (*)()) trapint);
-#else
-		signal(SIGINT, trapint);
-#endif
-	}
-
-	return status;
-}
-
-/* This private function opens a pipe from a filter.  It is similar to the
- * system() function above, and to popen(cmd, "r").
- */
-int rpipe(cmd, in)
-	char	*cmd;	/* the filter command to use */
-	int	in;	/* the fd to use for stdin */
-{
-	int	r0w1[2];/* the pipe fd's */
-
-	/* make the pipe */
-	if (pipe(r0w1) < 0)
-	{
-		return -1;	/* pipe failed */
-	}
-
-	/* The parent process (elvis) ignores signals while the filter runs.
-	 * The child (the filter program) will reset this, so that it can
-	 * catch the signal.
-	 */
-	signal(SIGINT, SIG_IGN);
-
-	switch (fork())
-	{
-	  case -1:						/* error */
-		return -1;
-
-	  case 0:						/* child */
-		/* close the "read" end of the pipe */
-		close(r0w1[0]);
-
-		/* redirect stdout to go to the "write" end of the pipe */
-		close(1);
-		dup(r0w1[1]);
-		close(2);
-		dup(r0w1[1]);
-		close(r0w1[1]);
-
-		/* redirect stdin */
-		if (in != 0)
-		{
-			close(0);
-			dup(in);
-			close(in);
-		}
-
-		/* the filter should accept SIGINT signals */
-		signal(SIGINT, SIG_DFL);
-
-		/* exec the shell to run the command */
-		execle(o_shell, o_shell, "-c", cmd, (char *)0, environ);
-		exit(1); /* if we get here, exec failed */
-
-	  default:						/* parent */
-		/* close the "write" end of the pipe */	
-		close(r0w1[1]);
-
-		return r0w1[0];
-	}
-}
-
-#endif /* non-DOS */
-
-#if OSK
-
-/* This private function opens a pipe from a filter.  It is similar to the
- * system() function above, and to popen(cmd, "r").
- */
-int rpipe(cmd, in)
-	char	*cmd;	/* the filter command to use */
-	int	in;	/* the fd to use for stdin */
-{
-	return osk_popen(cmd, "r", in, 0);
-}	
-#endif
-
-#if ANY_UNIX || OSK
-
-/* This function closes the pipe opened by rpipe(), and returns 0 for success */
-int rpclose(fd)
-	int	fd;
-{
-	int	status;
-
-	close(fd);
-	wait(&status);
-#if __GNUC__ || _ANSI
-	signal(SIGINT, (void (*)()) trapint);
-#else
-	signal(SIGINT, trapint);
-#endif
-	return status;
-}
-
-#endif /* non-DOS */
-
-/* This function expands wildcards in a filename or filenames.  It does this
- * by running the "echo" command on the filenames via the shell; it is assumed
- * that the shell will expand the names for you.  If for any reason it can't
- * run echo, then it returns the names unmodified.
- */
-
-#if MSDOS || TOS
-#define	PROG	"wildcard "
-#define	PROGLEN	9
-#include <string.h>
-#else
-#define	PROG	"echo "
-#define	PROGLEN	5
-#endif
-
-#if !AMIGA
-char *wildcard(names)
-	char	*names;
-{
-
-# if VMS
-/* 
-   We could use expand() [vmswild.c], but what's the point on VMS? 
-   Anyway, echo is the wrong thing to do, it takes too long to build
-   a subprocess on VMS and any "echo" program would have to be supplied
-   by elvis.  More importantly, many VMS utilities expand names 
-   themselves (the shell doesn't do any expansion) so the concept is
-   non-native.  jdc
-*/
-	return names;
-# else
-
-	int	i, j, fd;
-	REG char *s, *d;
-
-
-	/* build the echo command */
-	if (names != tmpblk.c)
-	{
-		/* the names aren't in tmpblk.c, so we can do it the easy way */
-		strcpy(tmpblk.c, PROG);
-		strcat(tmpblk.c, names);
-	}
-	else
-	{
-		/* the names are already in tmpblk.c, so shift them to make
-		 * room for the word "echo "
-		 */
-		for (s = names + strlen(names) + 1, d = s + PROGLEN; s > names; )
-		{
-			*--d = *--s;
-		}
-		strncpy(names, PROG, PROGLEN);
-	}
-
-	/* run the command & read the resulting names */
-	fd = rpipe(tmpblk.c, 0);
-	if (fd < 0) return names;
-	i = 0;
-	do
-	{
-		j = tread(fd, tmpblk.c + i, BLKSIZE - i);
-		i += j;
-	} while (j > 0);
-
-	/* successful? */
-	if (rpclose(fd) == 0 && j == 0 && i < BLKSIZE && i > 0)
-	{
-		tmpblk.c[i-1] = '\0'; /* "i-1" so we clip off the newline */
-		return tmpblk.c;
-	}
-	else
-	{
-		return names;
-	}
-# endif
-}
-#endif
-
-/* This function runs a range of lines through a filter program, and replaces
- * the original text with the filtered version.  As a special case, if "to"
- * is MARK_UNSET, then it runs the filter program with stdin coming from
- * /dev/null, and inserts any output lines.
- */
-int filter(from, to, cmd, back)
-	MARK	from, to;	/* the range of lines to filter */
-	char	*cmd;		/* the filter command */
-	int	back;		/* boolean: will we read lines back? */
-{
-	int	scratch;	/* fd of the scratch file */
-	int	fd;		/* fd of the pipe from the filter */
-	char	scrout[50];	/* name of the scratch out file */
-	MARK	new;		/* place where new text should go */
-	long	sent, rcvd;	/* number of lines sent/received */
-	int	i, j;
-
-	/* write the lines (if specified) to a temp file */
-	if (to)
-	{
-		/* we have lines */
-#if MSDOS || TOS
-		strcpy(scrout, o_directory);
-		if ((i=strlen(scrout)) && !strchr("\\/:", scrout[i-1]))
-			scrout[i++]=SLASH;
-		strcpy(scrout+i, SCRATCHOUT+3);
-#else
-		sprintf(scrout, SCRATCHOUT, o_directory);
-#endif
-		mktemp(scrout);
-		cmd_write(from, to, CMD_BANG, FALSE, scrout);
-		sent = markline(to) - markline(from) + 1L;
-
-		/* use those lines as stdin */
-		scratch = open(scrout, O_RDONLY);
-		if (scratch < 0)
-		{
-			unlink(scrout);
-			return -1;
-		}
-	}
-	else
-	{
-		scratch = 0;
-		sent = 0L;
-	}
-
-	/* start the filter program */
-#if VMS
-	/* 
-	   VMS doesn't know a thing about file descriptor 0.  The rpipe
-	   concept is non-portable.  Hence we need a file name argument.
-	*/
-	fd = rpipe(cmd, scratch, scrout);
-#else
-	fd = rpipe(cmd, scratch);
-#endif
-	if (fd < 0)
-	{
-		if (to)
-		{
-			close(scratch);
-			unlink(scrout);
-		}
-		return -1;
-	}
-
-	if (back)
-	{
-		ChangeText
-		{
-			/* adjust MARKs for whole lines, and set "new" */
-			from &= ~(BLKSIZE - 1);
-			if (to)
-			{
-				to &= ~(BLKSIZE - 1);
-				to += BLKSIZE;
-				new = to;
-			}
-			else
-			{
-				new = from + BLKSIZE;
-			}
-
-#if VMS
-/* Reading from a VMS mailbox (pipe) is record oriented... */
-# define tread vms_pread
-#endif
-
-			/* repeatedly read in new text and add it */
-			rcvd = 0L;
-			while ((i = tread(fd, tmpblk.c, BLKSIZE - 1)) > 0)
-			{
-				tmpblk.c[i] = '\0';
-				add(new, tmpblk.c);
-#if VMS
-				/* What!  An advantage to record oriented reads? */
-				new += (i - 1);
-				new = (new & ~(BLKSIZE - 1)) + BLKSIZE;
-				rcvd++;
-#else
-				for (i = 0; tmpblk.c[i]; i++)
-				{
-					if (tmpblk.c[i] == '\n')
-					{
-						new = (new & ~(BLKSIZE - 1)) + BLKSIZE;
-						rcvd++;
-					}
-					else
-					{
-						new++;
-					}
-				}
-#endif
-			}
-		}
-
-		/* delete old text, if any */
-		if (to)
-		{
-			cut(from, to);
-			delete(from, to);
-		}
-	}
-	else
-	{
-		/* read the command's output, and copy it to the screen */
-		while ((i = tread(fd, tmpblk.c, BLKSIZE - 1)) > 0)
-		{
-			for (j = 0; j < i; j++)
-			{
-				addch(tmpblk.c[j]);
-			}
-		}
-		rcvd = 0;
-	}
-
-	/* Reporting... */
-	if (sent >= *o_report || rcvd >= *o_report)
-	{
-		if (sent > 0L && rcvd > 0L)
-		{
-			msg("%ld lines out, %ld lines back", sent, rcvd);
-		}
-		else if (sent > 0)
-		{
-			msg("%ld lines written to filter", sent);
-		}
-		else
-		{
-			msg("%ld lines read from filter", rcvd);
-		}
-	}
-	rptlines = 0L;
-
-	/* cleanup */
-	rpclose(fd);
-	if (to)
-	{
-		close(scratch);
-		unlink(scrout);
-	}
-	return 0;
-}
Index: trunk/minix/commands/elvis/tinyprnt.c
===================================================================
--- trunk/minix/commands/elvis/tinyprnt.c	(revision 9)
+++ 	(revision )
@@ -1,230 +1,0 @@
-/* tinyprnt.c */
-
-#if OSK
-#define sprintf Sprintf
-#endif
-
-/* This is a limited version of sprintf().  It is useful for Minix-PC and
- * Coherent-286 because those systems are both limited to 64k+64k and the
- * standard sprintf() is just too damn big.
- *
- * It should also be useful for OS-9 because OS-9's sprintf() doesn't
- * understand the true meaning of asterisks in a format string.  This one
- * does.
- */
-
-/* Place-holders in format strings look like "%<pad><clip><type>".
- *
- * The <pad> adds space to the front (or, if negative, to the back) of the
- * output value, to pad it to a given width.  If <pad> is absent, then 0 is
- * assumed.  If <pad> is an asterisk, then the next argument is assumed to
- * be an (int) which used as the pad width.
- *
- * The <clip> string can be absent, in which case no clipping is done.
- * However, if it is present, then it should be either a "." followed by
- * a number, or a "." followed by an asterisk.  The asterisk means that the
- * next argument is an (int) which should be used as the pad width.  Clipping
- * only affects strings; for other data types it is ignored.
- *
- * The <type> is one of "s" for strings, "c" for characters (really ints that
- * are assumed to be legal char values), "d" for ints, "ld" for long ints, or
- * "%" to output a percent sign.
- */
-
-/* NOTE: Variable argument lists are handled by direct stack-twiddling. Sorry! */
-
-static void cvtnum(buf, num, base)
-	char		*buf;	/* where to store the number */
-	unsigned long	num;	/* the number to convert */
-	int		base;	/* either 8, 10, or 16 */
-{
-	static char	digits[] = "0123456789abcdef";
-	unsigned long	tmp;
-
-	/* if the number is 0, then just stuff a "0" into the buffer */
-	if (num == 0L)
-	{
-		buf[0] = '0';
-		buf[1] = '\0';
-		return;
-	}
-
-	/* use tmp to figure out how many digits we'll need */
-	for (tmp = num; tmp > 0; tmp /= base)
-	{
-		buf++;
-	}
-
-	/* mark the spot that will be the end of the string */
-	*buf = '\0';
-
-	/* generate all digits, as needed */
-	for (tmp = num; tmp > 0; tmp /= base)
-	{
-		*--buf = digits[tmp % base];
-	}
-}
-
-int sprintf(buf, fmt, argref)
-	char	*buf;	/* where to deposit the formatted output */
-	char	*fmt;	/* the format string */
-	int	argref;	/* the first argument is located at &argref */
-{
-	char	*argptr;/* pointer to next argument on the stack */
-	int	pad;	/* value of the pad string */
-	int	clip;	/* value of the clip string */
-	long	num;	/* a binary number being converted to ASCII digits */
-	long	digit;	/* used during conversion */
-	char	*src, *dst;
-
-	/* make argptr point to the first argument after the format string */
-	argptr = (char *)&argref;
-
-	/* loop through the whole format string */
-	while (*fmt)
-	{
-		/* if not part of a place-holder, then copy it literally */
-		if (*fmt != '%')
-		{
-			*buf++ = *fmt++;
-			continue;
-		}
-
-		/* found a place-holder!  Get <pad> value */
-		fmt++;
-		if ('*' == *fmt)
-		{
-			pad = *((int *)argptr)++;
-			fmt++;
-		}
-		else if (*fmt == '-' || (*fmt >= '0' && *fmt <= '9'))
-		{
-			pad = atol(fmt);
-			do
-			{
-				fmt++;
-			} while (*fmt >= '0' && *fmt <= '9');
-		}
-		else
-		{
-			pad = 0;
-		}
-
-		/* get a <clip> value */
-		if (*fmt == '.')
-		{
-			fmt++;
-			if ('*' == *fmt)
-			{
-				clip = *((int *)argptr)++;
-				fmt++;
-			}
-			else if (*fmt >= '0' && *fmt <= '9')
-			{
-				clip = atol(fmt);
-				do
-				{
-					fmt++;
-				} while (*fmt >= '0' && *fmt <= '9');
-			}
-		}
-		else
-		{
-			clip = 0;
-		}
-
-		/* handle <type>, possibly noticing <clip> */
-		switch (*fmt++)
-		{
-		  case 'c':
-			buf[0] = *((int *)argptr)++;
-			buf[1] = '\0';
-			break;
-
-		  case 's':
-			src = *((char **)argptr)++;
-			if (!src)
-			{
-				src = "(null)";
-			}
-			if (clip)
-			{
-				strncpy(buf, src, clip);
-				buf[clip] = '\0';
-			}
-			else
-			{
-				strcpy(buf, src);
-			}
-			break;
-
-		  case 'l':
-			fmt++; /* to skip the "d" in "%ld" */
-			num = *((long *)argptr)++;
-			dst = buf;
-			if (num < 0)
-			{
-				*dst++ = '-';
-				num = -num;
-			}
-			cvtnum(dst, num, 10);
-			break;
-
-		  case 'x':
-			num = *((int *)argptr)++;
-			cvtnum(buf, num, 16);
-			break;
-
-		  case 'd':
-			num = *((int *)argptr)++;
-			dst = buf;
-			if (num < 0)
-			{
-				*dst++ = '-';
-				num = -num;
-			}
-			cvtnum(dst, num, 10);
-			break;
-
-		  default:
-			buf[0] = fmt[-1];
-			buf[1] = '\0';
-		}
-
-		/* now fix the padding, if the value is too short */
-		clip = strlen(buf);
-		if (pad < 0)
-		{
-			/* add spaces after the value */
-			pad = -pad - clip;
-			for (buf += clip; pad > 0; pad--)
-			{
-				*buf++ = ' ';
-			}
-			*buf = '\0';
-		}
-		else
-		{
-			/* add spaces before the value */
-			pad -= clip;
-			if (pad > 0)
-			{
-				src = buf + clip;
-				dst = src + pad;
-				*dst = '\0';
-				while (src > buf)
-				{
-					*--dst = *--src;
-				}
-				while (dst > buf)
-				{
-					*--dst = ' ';
-				}
-			}
-			buf += strlen(buf);
-		}
-	}
-
-	/* mark the end of the output string */
-	*buf = '\0';
-}
Index: trunk/minix/commands/elvis/tinytcap.c
===================================================================
--- trunk/minix/commands/elvis/tinytcap.c	(revision 9)
+++ 	(revision )
@@ -1,388 +1,0 @@
-/* tinytcap.c */
-
-/* This file contains functions which simulate the termcap functions.
- *
- * It doesn't access a "termcap" file.  Instead, it uses an initialized array
- * of strings to store the entries.  Any string that doesn't start with a ':'
- * is taken to be the name of a type of terminal.  Any string that does start
- * with a ':' is interpretted as the list of fields describing all of the
- * terminal types that precede it.
- *
- * Note: since these are C strings, you can't use special sequences like
- * ^M or \E in the fields; your C compiler won't understand them.  Also,
- * at run time there is no way to tell the difference between ':' and '\072'
- * so I sure hope your terminal definition doesn't require a ':' character.
- *
- * getenv(TERM) on VMS checks the SET TERM device setting.  To implement
- * non-standard terminals set the logical ELVIS_TERM in VMS. (jdc)
- *
- * Other possible terminal types are...
- * 	TERM_WYSE925	- "wyse925", a Wyse 50 terminal emulating Televideo 925
- * ... or you could set $TERMCAP to the terminal's description string, which
- * $TERM set up to match it.
- *
- * Note that you can include several terminal types at the same time.  Elvis
- * chooses which entry to use at runtime, based primarily on the value of $TERM.
- */
-
-
-#include "config.h"
-extern char *getenv();
-
-/* decide which terminal descriptions should *always* be included. */
-#if MSDOS
-# define	TERM_NANSI
-# define	TERM_DOSANSI
-# if RAINBOW
-#  define	TERM_RAINBOW
-# endif
-#endif
-
-#if VMS
-# define	TERM_VT100
-# define	TERM_VT100W
-# define	TERM_VT52
-#endif
-
-#if AMIGA
-# define	TERM_AMIGA	/* Internal Amiga termcap entry */
-/* # define	TERM_VT52	/* The rest of these are here for those */
-# define	TERM_VT100	/* people who want to use elvis over an */
-/* # define	TERM_NANSI	/* AUX: port (serial.device). */
-/* # define	TERM_DOSANSI	/* Take out all but AMIGA to save memory. */
-/* # define	TERM_MINIX	/* Vanilla ANSI? */
-/* # define	TERM_925	/* Hang a terminal off your Amiga */
-#endif
-
-#if MINIX || UNIXV
-# define	TERM_MINIX
-#endif
-
-#if COHERENT
-# define	TERM_COHERENT
-#endif
-
-#if TOS
-# define	TERM_ATARI
-#endif
-
-static char *termcap[] =
-{
-#ifdef TERM_AMIGA
-"AA",
-"amiga",
-"Amiga ANSI",
-/* Amiga termcap modified from version 1.3 by Kent Polk */
-":co#80:li#24:am:bs:bw:xn:\
-:AL=\233%dL:DC=\233%dP:DL=\233%dM:DO=\233%dB:\
-:LE=\233%dD:RI=\233%dC:SF=\233%dS:SR=\233%dT:UP=\233%dA:IC=\233%d@:\
-:ae=\2330m:al=\233L:as=\2333m:bl=\007:bt=\233Z:cd=\233J:\
-:ce=\233K:cl=\013:cm=\233%i%d;%dH:dc=\233P:dl=\233M:do=\233B:\
-:kb=^H:ho=\233H:ic=\233@:is=\23320l:\
-:mb=\2337;2m:md=\2331m:me=\2330m:mh=\2332m:mk=\2338m:mr=\2337m:nd=\233C:\
-:rs=\033c:se=\2330m:sf=\233S:so=\2337m:sb=\233T:sr=\233T:ue=\23323m:\
-:up=\233A:us=\2334m:vb=\007:ve=\233\040p:vi=\2330\040p:\
-:k1=\2330~:k2=\2331~:k3=\2332~:k4=\2333~:k5=\2334~:\
-:k6=\2335~:k7=\2336~:k8=\2337~:k9=\2338~:k0=\2339~:\
-:s1=\23310~:s2=\23311~:s3=\23312~:s4=\23313~:s5=\23314~:\
-:s6=\23315~:s7=\23316~:s8=\23317~:s9=\23318~:s0=\23319~:\
-:kd=\233B:kl=\233D:kn#10:kr=\233C:ku=\233A:le=\233D:\
-:kP=\233T:kN=\233S:kh=\233\040A:kH=\233\040@:",
-#endif
-
-#ifdef TERM_NANSI
-"fansi",
-"nnansi",
-"nansi",
-"pcbios",
-":al=\033[L:dl=\033[M:am:bs:ce=\033[K:cl=\033[2J:\
-:cm=\033[%i%d;%dH:co#80:do=\033[B:\
-:k1=#;:k2=#<:k3=#=:k4=#>:k5=#?:k6=#@:k7=#A:k8=#B:k9=#C:k0=#D:\
-:s1=#T:s2=#U:s3=#V:s4=#W:s5=#X:s6=#Y:s7=#Z:s8=#[:s9=#\\:s0=#]:\
-:c1=#^:c2=#_:c3=#`:c4=#a:c5=#b:c6=#c:c7=#d:c8=#e:c9=#f:c0=#g:\
-:a1=#h:a2=#i:a3=#j:a4=#k:a5=#l:a6=#m:a7=#n:a8=#o:a9=#p:a0=#q:\
-:kd=#P:kh=#G:kH=#O:kI=#R:kl=#K:kN=#Q:kP=#I:kr=#M:ku=#H:\
-:li#25:md=\033[1m:me=\033[m:nd=\033[C:se=\033[m:so=\033[7m:\
-:ue=\033[m:up=\033[A:us=\033[4m:",
-#endif
-
-#ifdef TERM_DOSANSI
-#if !ANY_UNIX
-"ansi",
-#endif
-"dosansi",
-":am:bs:ce=\033[K:cl=\033[2J:\
-:cm=\033[%i%d;%dH:co#80:do=\033[B:\
-:k1=#;:k2=#<:k3=#=:k4=#>:k5=#?:k6=#@:k7=#A:k8=#B:k9=#C:k0=#D:\
-:s1=#T:s2=#U:s3=#V:s4=#W:s5=#X:s6=#Y:s7=#Z:s8=#[:s9=#\\:s0=#]:\
-:c1=#^:c2=#_:c3=#`:c4=#a:c5=#b:c6=#c:c7=#d:c8=#e:c9=#f:c0=#g:\
-:a1=#h:a2=#i:a3=#j:a4=#k:a5=#l:a6=#m:a7=#n:a8=#o:a9=#p:a0=#q:\
-:kd=#P:kh=#G:kH=#O:kI=#R:kl=#K:kN=#Q:kP=#I:kr=#M:ku=#H:\
-:li#25:md=\033[1m:me=\033[m:nd=\033[C:se=\033[m:so=\033[7m:\
-:ue=\033[m:up=\033[A:us=\033[4m:",
-#endif
-
-#ifdef TERM_RAINBOW
-"vt220",
-"rainbow",
-":al=\033[L:dl=\033[M:am:bs:ce=\033[K:cl=\033[2J:\
-:cm=\033[%i%d;%dH:co#80:do=\033[B:kd=\033[B:kl=\033[D:\
-:kr=\033[C:ku=\033[A:kP=\033[5~:kN=\033[6~:kI=\033[2~:\
-:li#24:md=\033[1m:me=\033[m:nd=\033[C:se=\033[m:so=\033[7m:\
-:ue=\033[m:up=\033[A:us=\033[4m:xn:",
-#endif
-
-#ifdef TERM_VT100
-"vt100-80",
-"vt200-80",
-"vt300-80",
-"vt101-80",
-"vt102-80",
-":al=\033[L:am:bs:ce=\033[K:cl=\033[2J:cm=\033[%i%d;%dH:\
-:co#80:dl=\033[M:do=\033[B:k0=\033[20~:k1=\033[1~:\
-:k2=\033[2~:k3=\033[3~:k4=\033[4~:k5=\033[5~:k6=\033[6~:\
-:k7=\033[17~:k8=\033[18~:k9=\033[19~:kd=\033[B:kh=\033[H:\
-:kH=\033[Y:kI=\033[I:kl=\033[D:kN=\033[U:kP=\033[V:\
-:kr=\033[C:ku=\033[A:li#24:md=\033[1m:me=\033[m:nd=\033[C:\
-:se=\033[m:so=\033[7m:ti=\033[1;24r\033[24;1H:\
-:ue=\033[m:up=\033[A:us=\033[4m:xn:",
-#endif
-
-#ifdef TERM_VT100W
-"vt100-w",
-"vt200-w",
-"vt300-w",
-"vt101-w",
-"vt102-w",
-"vt100-132",
-"vt200-132",
-"vt300-132",
-"vt101-132",
-"vt102-132",
-":al=\033[L:am:bs:ce=\033[K:cl=\033[2J:cm=\033[%i%d;%dH:\
-:co#132:dl=\033[M:do=\033[B:k0=\033[20~:k1=\033[1~:\
-:k2=\033[2~:k3=\033[3~:k4=\033[4~:k5=\033[5~:k6=\033[6~:\
-:k7=\033[17~:k8=\033[18~:k9=\033[19~:kd=\033[B:kh=\033[H:\
-:kH=\033[Y:kI=\033[I:kl=\033[D:kN=\033[U:kP=\033[V:\
-:kr=\033[C:ku=\033[A:li#24:md=\033[1m:me=\033[m:nd=\033[C:\
-:se=\033[m:so=\033[7m:ti=\033[1;24r\033[24;1H:\
-:ue=\033[m:up=\033[A:us=\033[4m:xn:",
-#endif
-
-#ifdef TERM_VT52
-"vt52",
-":do=\n:le=\b:up=\033A:nd=\033C:cm=\033Y%+ %+ :ti=\033e\033v:\
-:sr=\033I:cd=\033J:ce=\033K:cl=\033H\033J:co#80:li#24:\
-:ku=\033A:kd=\033B:kr=\033C:kl=\033D:kb=\b:pt:am:xn:bs:",
-#endif
-
-#ifdef TERM_MINIX
-"minix",
-"ansi",
-"AT386",
-":al=\033[L:am:bs:ce=\033[K:cl=\033[2J:cm=\033[%i%d;%dH:\
-:co#80:dl=\033[M:do=\033[B:k0=\033[20~:k1=\033[1~:\
-:k2=\033[2~:k3=\033[3~:k4=\033[4~:k5=\033[5~:k6=\033[6~:\
-:k7=\033[17~:k8=\033[18~:k9=\033[19~:kd=\033[B:kh=\033[H:\
-:kH=\033[Y:kI=\033[I:kl=\033[D:kN=\033[U:kP=\033[V:\
-:kr=\033[C:ku=\033[A:li#25:md=\033[1m:me=\033[m:nd=\033[C:\
-:se=\033[m:so=\033[7m:ue=\033[m:up=\033[A:us=\033[4m:",
-#endif /* MINIX */
-
-#ifdef TERM_COHERENT
-"coherent",
-"ansipc",
-":al=\033[L:am:bs:ce=\033[K:cl=\033[2J:cm=\033[%i%d;%dH:\
-:co#80:dl=\033[M:do=\033[B:k0=\033[0x:k1=\033[1x:k2=\033[2x:\
-:k3=\033[3x:k4=\033[4x:k5=\033[5x:k6=\033[6x:\
-:k7=\033[7x:k8=\033[8x:k9=\033[9x:kd=\033[B:kh=\033[H:\
-:kH=\033[24H:kI=\033[@:kl=\033[D:kN=\033[U:kP=\033[V:\
-:kr=\033[C:ku=\033[A:li#24:md=\033[1m:me=\033[m:\
-:nd=\033[C:se=\033[m:so=\033[7m:ue=\033[m:up=\033[A:\
-:us=\033[4m:",
-#endif /* COHERENT */
-
-#ifdef TERM_ATARI
-"atari-st",
-"vt52",
-":al=\033L:am:bs:ce=\033K:cl=\033E:cm=\033Y%i%+ %+ :\
-:co#80:dl=\033M:do=\033B:\
-:k1=#;:k2=#<:k3=#=:k4=#>:k5=#?:k6=#@:k7=#A:k8=#B:k9=#C:k0=#D:\
-:s1=#T:s2=#U:s3=#V:s4=#W:s5=#X:s6=#Y:s7=#Z:s8=#[:s9=#\\:s0=#]:\
-:c1=#^:c2=#_:c3=#`:c4=#a:c5=#b:c6=#c:c7=#d:c8=#e:c9=#f:c0=#g:\
-:a1=#h:a2=#i:a3=#j:a4=#k:a5=#l:a6=#m:a7=#n:a8=#o:a9=#p:a0=#q:\
-kd=#P:kh=#G:kI=#R:kl=#K:kr=#M:ku=#H:li#25:nd=\033C:se=\033q:\
-:so=\033p:te=:ti=\033e\033v:up=\033A:",
-#endif
-
-#ifdef TERM_925
-"wyse925",
-":xn@:\
-:hs:am:bs:co#80:li#24:cm=\033=%+ %+ :cl=\033*:cd=\033y:\
-:ce=\033t:is=\033l\033\":\
-:al=\033E:dl=\033R:im=:ei=:ic=\033Q:dc=\033W:\
-:ho=\036:nd=\014:bt=\033I:pt:so=\033G4:se=\033G0:sg#1:us=\033G8:ue=\033G0:ug#1:\
-:up=\013:do=\026:kb=\010:ku=\013:kd=\026:kl=\010:kr=\014:\
-:kh=\036:ma=\026\012\014 :\
-:k1=\001@\r:k2=\001A\r:k3=\001B\r:k4=\001C\r:k5=\001D\r:k6=\001E\r:k7=\001F\r:\
-:k8=\001G\r:k9=\001H\r:k0=\001I\r:ko=ic,dc,al,dl,cl,ce,cd,bt:\
-:ts=\033f:fs=\033g:ds=\033h:sr=\033j:",  /* was :xn: for tvi925 alone*/
-#endif
-
-(char *)0
-};
-
-
-static char *fields;
-
-
-/*ARGSUSED*/
-int tgetent(bp, name)
-	char	*bp;	/* buffer for storing the entry -- ignored */
-	char	*name;	/* name of the entry */
-{
-	int	i;
-
-	/* if TERMCAP is defined, and seems to match, then use it */
-	fields = getenv("TERMCAP");
-	if (fields)
-	{
-		for (i = 0; fields[i] && fields[i] != ':'; i++)
-		{
-			if (!strncmp(fields + i, name, strlen(name)))
-			{
-				return 1;
-			}
-		}
-	}
-
-	/* locate the entry in termcap[] */
-	for (i = 0; termcap[i] && strcmp(termcap[i], name); i++)
-	{
-	}
-	if (!termcap[i])
-	{
-		return 0;
-	}
-
-	/* search forward for fields */
-	while (termcap[i][0] != ':')
-	{
-		i++;
-	}
-	fields = termcap[i];
-	return 1;
-}
-
-
-static char *find(id, vtype)
-	char	*id;	/* name of a value to locate */
-	int	vtype;	/* '=' for strings, '#' for numbers, or 0 for bools */
-{
-	int	i;
-
-	/* search for a ':' followed by the two-letter id */
-	for (i = 0; fields[i]; i++)
-	{
-		if (fields[i] == ':'
-		 && fields[i + 1] == id[0]
-		 && fields[i + 2] == id[1])
-		{
-			/* if correct type, then return its value */
-			if (fields[i + 3] == vtype)
-				return &fields[i + 4];
-			else
-				return (char *)0;
-		}
-	}
-	return (char *)0;
-}
-
-int tgetnum(id)
-	char	*id;
-{
-	id = find(id, '#');
-	if (id)
-	{
-		return atoi(id);
-	}
-	return -1;
-}
-
-int tgetflag(id)
-	char	*id;
-{
-	if (find(id, ':'))
-	{
-		return 1;
-	}
-	return 0;
-}
-
-/*ARGSUSED*/
-char *tgetstr(id, bp)
-	char	*id;
-	char	**bp;	/* pointer to pointer to buffer - ignored */
-{
-	char	*cpy;
-
-	/* find the string */
-	id = find(id, '=');
-	if (!id)
-	{
-		return (char *)0;
-	}
-
-	/* copy it into the buffer, and terminate it with NUL */
-	for (cpy = *bp; *id != ':'; )
-	{
-		if (id[0] == '\\' && id[1] == 'E')
-			*cpy++ = '\033', id += 2;
-		else
-			*cpy++ = *id++;
-	}
-	*cpy++ = '\0';
-
-	/* update the bp pointer */
-	id = *bp;
-	*bp = cpy;
-
-	/* return a pointer to the copy of the string */
-	return id;
-}
-
-/*ARGSUSED*/
-char *tgoto(cm, destcol, destrow)
-	char	*cm;	/* cursor movement string -- ignored */
-	int	destcol;/* destination column, 0 - 79 */
-	int	destrow;/* destination row, 0 - 24 */
-{
-	static char buf[30];
-
-#ifdef CRUNCH
-# if TOS
-	sprintf(buf, "\033Y%c%c", ' ' + destrow, ' ' + destcol);
-# else
-	sprintf(buf, "\033[%d;%dH", destrow + 1, destcol + 1);
-# endif
-#else
-	if (cm[1] == 'Y' || cm[1] == '=')
-		sprintf(buf, "\033%c%c%c", cm[1], ' ' + destrow, ' ' + destcol);
-	else
-		sprintf(buf, "\033[%d;%dH", destrow + 1, destcol + 1);
-#endif
-	return buf;
-}
-
-/*ARGSUSED*/
-void tputs(cp, affcnt, outfn)
-	char	*cp;		/* the string to output */
-	int	affcnt;		/* number of affected lines -- ignored */
-	int	(*outfn)();	/* the output function */
-{
-	while (*cp)
-	{
-		(*outfn)(*cp);
-		cp++;
-	}
-}
Index: trunk/minix/commands/elvis/tio.c
===================================================================
--- trunk/minix/commands/elvis/tio.c	(revision 9)
+++ 	(revision )
@@ -1,1026 +1,0 @@
-/* tio.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains terminal I/O functions */
-
-#include "config.h"
-#include "vi.h"
-#include "ctype.h"
-
-
-/* This function reads in a line from the terminal. */
-int vgets(prompt, buf, bsize)
-	char	prompt;	/* the prompt character, or '\0' for none */
-	char	*buf;	/* buffer into which the string is read */
-	int	bsize;	/* size of the buffer */
-{
-	int	len;	/* how much we've read so far */
-	int	ch;	/* a character from the user */
-	int	quoted;	/* is the next char quoted? */
-	int	tab;	/* column position of cursor */
-	char	widths[132];	/* widths of characters */
-	int	word;	/* index of first letter of word */
-#ifndef NO_DIGRAPH
-	int	erased;	/* 0, or first char of a digraph */
-#endif
-
-	/* show the prompt */
-	move(LINES - 1, 0);
-	tab = 0;
-	if (prompt)
-	{
-		addch(prompt);
-		tab = 1;
-	}
-	clrtoeol();
-	refresh();
-
-	/* read in the line */
-#ifndef NO_DIGRAPH
-	erased =
-#endif
-	quoted = len = 0;
-	for (;;)
-	{
-#ifndef NO_ABBR
-		if (quoted || mode == MODE_EX)
-		{
-			ch = getkey(0);
-		}
-		else
-		{
-			/* maybe expand an abbreviation while getting key */
-			for (word = len; --word >= 0 && isalnum(buf[word]); )
-			{
-			}
-			word++;
-			ch = getabkey(WHEN_EX, &buf[word], len - word);
-		}
-#else
-		ch = getkey(0);
-#endif
-#ifndef NO_EXTENSIONS
-		if (ch == ctrl('O'))
-		{
-			ch = getkey(quoted ? 0 : WHEN_EX);
-		}
-#endif
-
-		/* some special conversions */
-		if (ch == ctrl('D') && len == 0)
-			ch = ctrl('[');
-#ifndef NO_DIGRAPH
-		if (*o_digraph && erased != 0 && ch != '\b')
-		{
-			ch = digraph(erased, ch);
-			erased = 0;
-		}
-#endif
-
-		/* inhibit detection of special chars (except ^J) after a ^V */
-		if (quoted && ch != '\n')
-		{
-			ch |= 256;
-		}
-
-		/* process the character */
-		switch(ch)
-		{
-		  case ctrl('V'):
-			qaddch('^');
-			qaddch('\b');
-			quoted = TRUE;
-			break;
-
-		  case ctrl('['):
-			return -1;
-
-		  case '\n':
-#if OSK
-		  case '\l':
-#else
-		  case '\r':
-#endif
-			clrtoeol();
-			goto BreakBreak;
-
-		  case '\b':
-			if (len > 0)
-			{
-				len--;
-#ifndef NO_DIGRAPH
-				erased = buf[len];
-#endif
-				for (ch = widths[len]; ch > 0; ch--)
-					addch('\b');
-				if (mode == MODE_EX)
-				{
-					clrtoeol();
-				}
-				tab -= widths[len];
-			}
-			else
-			{
-				return -1;
-			}
-			break;
-
-		  default:
-			/* strip off quotation bit */
-			if (ch & 256)
-			{
-				ch &= ~256;
-				qaddch(' ');
-				qaddch('\b');
-			}
-
-			/* add & echo the char */
-			if (len < bsize - 1)
-			{
-				if (ch == '\t' && !quoted)
-				{
-					widths[len] = *o_tabstop - (tab % *o_tabstop);
-					addstr("        " + 8 - widths[len]);
-					tab += widths[len];
-				}
-				else if (ch > 0 && ch < ' ') /* > 0 by GB */
-				{
-					addch('^');
-					addch(ch + '@');
-					widths[len] = 2;
-					tab += 2;
-				}
-				else if (ch == '\177')
-				{
-					addch('^');
-					addch('?');
-					widths[len] = 2;
-					tab += 2;
-				}
-				else
-				{
-					addch(ch);
-					widths[len] = 1;
-					tab++;
-				}
-				buf[len++] = ch;
-			}
-			else
-			{
-				beep();
-			}
-			quoted = FALSE;
-		}
-	}
-BreakBreak:
-	refresh();
-	buf[len] = '\0';
-	return len;
-}
-
-
-static int	manymsgs; /* This variable keeps msgs from overwriting each other */
-static char	pmsg[80]; /* previous message (waiting to be displayed) */
-
-
-static int showmsg()
-{
-	/* if there is no message to show, then don't */
-	if (!manymsgs)
-		return FALSE;
-
-	/* display the message */
-	move(LINES - 1, 0);
-	if (*pmsg)
-	{
-		standout();
-		qaddch(' ');
-		qaddstr(pmsg);
-		qaddch(' ');
-		standend();
-	}
-	clrtoeol();
-
-	manymsgs = FALSE;
-	return TRUE;
-}
-
-
-void endmsgs()
-{
-	if (manymsgs)
-	{
-		showmsg();
-		addch('\n');
-	}
-}
-
-/* Write a message in an appropriate way.  This should really be a varargs
- * function, but there is no such thing as vwprintw.  Hack!!!
- *
- * In MODE_EX or MODE_COLON, the message is written immediately, with a
- * newline at the end.
- *
- * In MODE_VI, the message is stored in a character buffer.  It is not
- * displayed until getkey() is called.  msg() will call getkey() itself,
- * if necessary, to prevent messages from being lost.
- *
- * msg("")		- clears the message line
- * msg("%s %d", ...)	- does a printf onto the message line
- */
-/*VARARGS1*/
-void msg(fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7)
-	char	*fmt;
-	long	arg1, arg2, arg3, arg4, arg5, arg6, arg7;
-{
-	if (mode != MODE_VI)
-	{
-		sprintf(pmsg, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-		qaddstr(pmsg);
-		addch('\n');
-		exrefresh();
-	}
-	else
-	{
-		/* wait for keypress between consecutive msgs */
-		if (manymsgs)
-		{
-			getkey(WHEN_MSG);
-		}
-
-		/* real message */
-		sprintf(pmsg, fmt, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
-		if (*fmt)
-		{
-			manymsgs = TRUE;
-		}
-	}
-}
-
-
-/* This function calls refresh() if the option exrefresh is set */
-void exrefresh()
-{
-	char	*scan;
-
-	/* If this ex command wrote ANYTHING set exwrote so vi's  :  command
-	 * can tell that it must wait for a user keystroke before redrawing.
-	 */
-	for (scan=kbuf; scan<stdscr; scan++)
-		if (*scan == '\n')
-			exwrote = TRUE;
-
-	/* now we do the refresh thing */
-	if (*o_exrefresh)
-	{
-		refresh();
-	}
-	else
-	{
-		wqrefresh();
-	}
-	if (mode != MODE_VI)
-	{
-		manymsgs = FALSE;
-	}
-}
-
-
-/* This structure is used to store maps and abbreviations.  The distinction
- * between them is that maps are stored in the list referenced by the "maps"
- * pointer, while abbreviations are referenced by the "abbrs" pointer.
- */
-typedef struct _map
-{
-	struct _map	*next;	/* another abbreviation */
-	short		len;	/* length of the "rawin" characters */
-	short		flags;	/* various flags */
-	char		*label;	/* label of the map/abbr, or NULL */
-	char		*rawin;	/* the "rawin" characters */
-	char		*cooked;/* the "cooked" characters */
-} MAP;
-
-static char	keybuf[KEYBUFSIZE];
-static int	cend;	/* end of input characters */
-static int	user;	/* from user through end are chars typed by user */
-static int	next;	/* index of the next character to be returned */
-static MAP	*match;	/* the matching map, found by countmatch() */
-static MAP	*maps;	/* the map table */
-#ifndef NO_ABBR
-static MAP	*abbrs;	/* the abbreviation table */
-#endif
-
-
-
-/* ring the terminal's bell */
-void beep()
-{
-	/* do a visible/audible bell */
-	if (*o_flash)
-	{
-		do_VB();
-		refresh();
-	}
-	else if (*o_errorbells)
-	{
-		ttywrite("\007", 1);
-	}
-
-	/* discard any buffered input, and abort macros */
-	next = user = cend;
-}
-
-
-
-/* This function replaces a "rawin" character sequence with the "cooked" version,
- * by modifying the internal type-ahead buffer.
- */
-void execmap(rawlen, cookedstr, visual)
-	int	rawlen;		/* length of rawin text -- string to delete */
-	char	*cookedstr;	/* the cooked text -- string to insert */
-	int	visual;		/* boolean -- chars to be executed in visual mode? */
-{
-	int	cookedlen;
-	char	*src, *dst;
-	int	i;
-
-	/* find the length of the cooked string */
-	cookedlen = strlen(cookedstr);
-#ifndef NO_EXTENSIONS
-	if (visual)
-	{
-		cookedlen *= 2;
-	}
-#endif
-
-	/* if too big to fit in type-ahead buffer, then don't do it */
-	if (cookedlen + (cend - next) - rawlen > KEYBUFSIZE)
-	{
-		return;
-	}
-
-	/* shift to make room for cookedstr at the front of keybuf */
-	src = &keybuf[next + rawlen];
-	dst = &keybuf[cookedlen];
-	i = cend - (next + rawlen);
-	if (src >= dst)
-	{
-		while (i-- > 0)
-		{
-			*dst++ = *src++;
-		}
-	}
-	else
-	{
-		src += i;
-		dst += i;
-		while (i-- > 0)
-		{
-			*--dst = *--src;
-		}
-	}
-
-	/* insert cookedstr, and adjust offsets */
-	cend += cookedlen - rawlen - next;
-	user += cookedlen - rawlen - next;
-	next = 0;
-	for (dst = keybuf, src = cookedstr; *src; )
-	{
-#ifndef NO_EXTENSIONS
-		if (visual)
-		{
-			*dst++ = ctrl('O');
-			cookedlen--;
-		}
-#endif
-		*dst++ = *src++;
-	}
-
-#ifdef DEBUG2
-	{
-#include <stdio.h>
-		FILE	*debout;
-		int		i;
-
-		debout = fopen("debug.out", "a");
-		fprintf(debout, "After execmap(%d, \"%s\", %d)...\n", rawlen, cookedstr, visual);
-		for (i = 0; i < cend; i++)
-		{
-			if (i == next) fprintf(debout, "(next)");
-			if (i == user) fprintf(debout, "(user)");
-			if (UCHAR(keybuf[i]) < ' ')
-				fprintf(debout, "^%c", keybuf[i] ^ '@');
-			else
-				fprintf(debout, "%c", keybuf[i]);
-		}
-		fprintf(debout, "(end)\n");
-		fclose(debout);
-	}
-#endif
-}
-
-/* This function calls ttyread().  If necessary, it will also redraw the screen,
- * change the cursor shape, display the mode, and update the ruler.  If the
- * number of characters read is 0, and we didn't time-out, then it exits because
- * we've apparently reached the end of an EX script.
- */
-static int fillkeybuf(when, timeout)
-	int	when;	/* mixture of WHEN_XXX flags */
-	int	timeout;/* timeout in 1/10 second increments, or 0 */
-{
-	int	nkeys;
-#ifndef NO_SHOWMODE
-	static int	oldwhen;	/* "when" from last time */
-	static int	oldleft;
-	static long	oldtop;
-	static long	oldnlines;
-	char		*str;
-#endif
-#ifndef NO_CURSORSHAPE
-	static int	oldcurs;
-#endif
-
-#ifdef DEBUG
-	watch();
-#endif
-
-
-#ifndef NO_CURSORSHAPE
-	/* make sure the cursor is the right shape */
-	if (has_CQ)
-	{
-		if (when != oldcurs)
-		{
-			switch (when)
-			{
-			  case WHEN_EX:		do_CX();	break;
-			  case WHEN_VICMD:	do_CV();	break;
-			  case WHEN_VIINP:	do_CI();	break;
-			  case WHEN_VIREP:	do_CR();	break;
-			}
-			oldcurs = when;
-		}
-	}
-#endif
-
-#ifndef NO_SHOWMODE
-	/* if "showmode" then say which mode we're in */
-	if (*o_smd && (when & WHENMASK))
-	{
-		/* redraw the screen before we check to see whether the
-		 * "showmode" message needs to be redrawn.
-		 */
-		redraw(cursor, !(when & WHEN_VICMD));
-
-		/* now the "topline" test should be valid */
-		if (when != oldwhen || topline != oldtop || leftcol != oldleft || nlines != oldnlines)
-		{
-			oldwhen = when;
-			oldtop = topline;
-			oldleft = leftcol;
-			oldnlines = nlines;
-
-			if (when & WHEN_VICMD)	    str = "Command";
-			else if (when & WHEN_VIINP) str = " Input ";
-			else if (when & WHEN_VIREP) str = "Replace";
-			else if (when & WHEN_REP1)  str = " Rep 1 ";
-			else if (when & WHEN_CUT)   str = "BufName";
-			else if (when & WHEN_MARK)  str = "Mark AZ";
-			else if (when & WHEN_CHAR)  str = "Dest Ch";
-			else			    str = (char *)0;
-
-			if (str)
-			{
-				move(LINES - 1, COLS - 10);
-				standout();
-				qaddstr(str);
-				standend();
-			}
-		}
-	}
-#endif
-
-#ifndef NO_EXTENSIONS
-	/* maybe display the ruler */
-	if (*o_ruler && (when & (WHEN_VICMD|WHEN_VIINP|WHEN_VIREP)))
-	{
-		char	buf[20];
-
-		redraw(cursor, !(when & WHEN_VICMD));
-		pfetch(markline(cursor));
-		sprintf(buf, "%7ld,%-4d", markline(cursor), 1 + idx2col(cursor, ptext, when & (WHEN_VIINP|WHEN_VIREP)));
-		move(LINES - 1, COLS - 22);
-		addstr(buf);
-	}
-#endif
-
-	/* redraw, so the cursor is in the right place */
-	if (when & WHENMASK)
-	{
-		redraw(cursor, !(when & (WHENMASK & ~(WHEN_VIREP|WHEN_VIINP))));
-	}
-
-	/* Okay, now we can finally read the rawin keystrokes */
-	refresh();
-	nkeys = ttyread(keybuf + cend, sizeof keybuf - cend, timeout);
-
-	/* if nkeys == 0 then we've reached EOF of an ex script. */
-	if (nkeys == 0 && timeout == 0)
-	{
-		tmpabort(TRUE);
-		move(LINES - 1, 0);
-		clrtoeol();
-		refresh();
-		endwin();
-		exit(1);
-	}
-
-	cend += nkeys;
-	user += nkeys;
-	return nkeys;
-}
-
-
-/* This function counts the number of maps that could match the characters
- * between &keybuf[next] and &keybuf[cend], including incomplete matches.
- * The longest comlete match is remembered via the "match" variable.
- */
-static int countmatch(when)
-	int	when;	/* mixture of WHEN_XXX flags */
-{
-	MAP	*map;
-	int	count;
-
-	/* clear the "match" variable */
-	match = (MAP *)0;
-
-	/* check every map */
-	for (count = 0, map = maps; map; map = map->next)
-	{
-		/* can't match if wrong mode */
-		if ((map->flags & when) == 0)
-		{
-			continue;
-		}
-
-		/* would this be a complete match? */
-		if (map->len <= cend - next)
-		{
-			/* Yes, it would be.  Now does it really match? */
-			if (!strncmp(map->rawin, &keybuf[next], map->len))
-			{
-				count++;
-
-				/* if this is the longest complete match,
-				 * then remember it.
-				 */
-				if (!match || match->len < map->len)
-				{
-					match = map;
-				}
-			}
-		}
-		else
-		{
-			/* No, it wouldn't.  But check for partial match */
-			if (!strncmp(map->rawin, &keybuf[next], cend - next))
-			{
-				count++;
-			}
-		}
-	}
-	return count;
-}
-
-
-#ifndef NO_ABBR
-/* This function checks to see whether a word is an abbreviation.  If it is,
- * then an appropriate number of backspoace characters is inserted into the
- * type-ahead buffer, followed by the expanded form of the abbreviation.
- */
-static void expandabbr(word, wlen)
-	char	*word;
-	int	wlen;
-{
-	MAP	*abbr;
-
-	/* if the next character wouldn't end the word, then don't expand */
-	if (isalnum(keybuf[next]) || keybuf[next] == ctrl('V'))
-	{
-		return;
-	}
-
-	/* find the abbreviation, if any */
-	for (abbr = abbrs;
-	     abbr && (abbr->len != wlen || strncmp(abbr->rawin, word, wlen));
-	     abbr = abbr->next)
-	{
-	}
-
-	/* If an abbreviation was found, then expand it by inserting the long
-	 * version into the type-ahead buffer, and then inserting (in front of
-	 * the long version) enough backspaces to erase to the short version.
-	 */
-	if (abbr)
-	{
-		execmap(0, abbr->cooked, FALSE);
-		while (wlen > 15)
-		{
-			execmap(0, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b", FALSE);
-			wlen -= 15;
-		}
-		if (wlen > 0)
-		{
-			execmap(0, "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b" + 15 - wlen, FALSE);
-		}
-	}
-}
-#endif
-
-
-/* This function calls getabkey() without attempting to expand abbreviations */
-int getkey(when)
-	int	when;	/* mixture of WHEN_XXX flags */
-{
-	return getabkey(when, "", 0);
-}
-
-
-/* This is it.  This function returns keystrokes one-at-a-time, after mapping
- * and abbreviations have been taken into account.
- */
-int getabkey(when, word, wlen)
-	int	when;	/* mixture of WHEN_XXX flags */
-	char	*word;	/* a word that may need to be expanded as an abbr */
-	int	wlen;	/* length of "word" -- since "word" might not have \0 */
-{
-	int	matches;
-
-	/* if this key is needed for delay between multiple error messages,
-	 * then reset the manymsgs flag and abort any mapped key sequence.
-	 */
-	if (showmsg())
-	{
-		if (when == WHEN_MSG)
-		{
-#ifndef CRUNCH
-			if (!*o_more)
-			{
-				refresh();
-				return ' ';
-			}
-#endif
-			qaddstr("[More...]");
-			refresh();
-			execmap(user, "", FALSE);
-		}
-	}
-
-#ifdef DEBUG
-	/* periodically check for screwed up internal tables */
-	watch();
-#endif
-
-	/* if buffer empty, read some characters without timeout */
-	if (next >= cend)
-	{
-		next = user = cend = 0;
-		fillkeybuf(when, 0);
-	}
-
-	/* try to map the key, unless already mapped and not ":set noremap" */
-	if (next >= user || *o_remap)
-	{
-		do
-		{
-			do
-			{
-				matches = countmatch(when);
-			} while (matches > 1 && fillkeybuf(when, *o_keytime) > 0);
-			if (matches == 1)
-			{
-				execmap(match->len, match->cooked,
-					(match->flags & WHEN_INMV) != 0 
-					 && (when & (WHEN_VIINP|WHEN_VIREP)) != 0);
-			}
-		} while (*o_remap && matches == 1);
-	}
-
-#ifndef NO_ABBR
-	/* try to expand an abbreviation, except in visual command mode */
-	if (wlen > 0 && (mode & (WHEN_EX|WHEN_VIINP|WHEN_VIREP)) != 0)
-	{
-		expandabbr(word, wlen);
-	}
-#endif
-
-	/* ERASEKEY should always be mapped to '\b'. */
-	if (keybuf[next] == ERASEKEY)
-	{
-		keybuf[next] = '\b';
-	}
-
-	/* return the next key */
-	return keybuf[next++];
-}
-
-/* This function maps or unmaps a key */
-void mapkey(rawin, cooked, when, name)
-	char	*rawin;	/* the input key sequence, before mapping */
-	char	*cooked;/* after mapping -- or NULL to remove map */
-	short	when;	/* bitmap of when mapping should happen */
-	char	*name;	/* name of the key, NULL for no name, "abbr" for abbr */
-{
-	MAP	**head;	/* head of list of maps or abbreviations */
-	MAP	*scan;	/* used for scanning through the list */
-	MAP	*prev;	/* used during deletions */
-
-	/* Is this a map or an abbreviation?  Choose the right list. */
-#ifndef NO_ABBR
-	head = ((!name || strcmp(name, "abbr")) ? &maps : &abbrs);
-#else
-	head = &maps;
-#endif
-
-	/* try to find the map in the list */
-	for (scan = *head, prev = (MAP *)0;
-	     scan && (strcmp(rawin, scan->rawin) ||
-		!(scan->flags & when & (WHEN_EX|WHEN_VICMD|WHEN_VIINP|WHEN_VIREP)));
-	     prev = scan, scan = scan->next)
-	{
-	}
-
-	/* trying to map? (not unmap) */
-	if (cooked && *cooked)
-	{
-		/* if map starts with "visual ", then mark it as a visual map */
-		if (head == &maps && !strncmp(cooked, "visual ", 7))
-		{
-			cooked += 7;
-			when |= WHEN_INMV;
-		}
-
-		/* "visual" maps always work in input mode */
-		if (when & WHEN_INMV)
-		{
-			when |= WHEN_VIINP|WHEN_VIREP|WHEN_POPUP;
-		}
-
-		/* if not already in the list, then allocate a new structure */
-		if (!scan)
-		{
-			scan = (MAP *)malloc(sizeof(MAP));
-			scan->len = strlen(rawin);
-			scan->rawin = malloc(scan->len + 1);
-			strcpy(scan->rawin, rawin);
-			scan->flags = when;
-			scan->label = name;
-			if (*head)
-			{
-				prev->next = scan;
-			}
-			else
-			{
-				*head = scan;
-			}
-			scan->next = (MAP *)0;
-		}
-		else /* recycle old structure */
-		{
-			free(scan->cooked);
-		}
-		scan->cooked = malloc(strlen(cooked) + 1);
-		strcpy(scan->cooked, cooked);
-	}
-	else /* unmapping */
-	{
-		/* if nothing to unmap, then exit silently */
-		if (!scan)
-		{
-			return;
-		}
-
-		/* unlink the structure from the list */
-		if (prev)
-		{
-			prev->next = scan->next;
-		}
-		else
-		{
-			*head = scan->next;
-		}
-
-		/* free it, and the strings that it refers to */
-		free(scan->rawin);
-		free(scan->cooked);
-		free(scan);
-	}
-}
-
-
-/* This function returns a printable version of a string.  It uses tmpblk.c */
-char *printable(str)
-	char	*str;	/* the string to convert */
-{
-	char	*build;	/* used for building the string */
-
-	for (build = tmpblk.c; *str; str++)
-	{
-#if AMIGA
-		if (*str == '\233')
-		{
-			*build++ = '<';
-			*build++ = 'C';
-			*build++ = 'S';
-			*build++ = 'I';
-			*build++ = '>';
-		} else 
-#endif
-		if (UCHAR(*str) < ' ' || *str == '\177')
-		{
-			*build++ = '^';
-			*build++ = *str ^ '@';
-		}
-		else
-		{
-			*build++ = *str;
-		}
-	}
-	*build = '\0';
-	return tmpblk.c;
-}
-
-/* This function displays the contents of either the map table or the
- * abbreviation table.  User commands call this function as follows:
- *	:map	dumpkey(WHEN_VICMD, FALSE);
- *	:map!	dumpkey(WHEN_VIREP|WHEN_VIINP, FALSE);
- *	:abbr	dumpkey(WHEN_VIINP|WHEN_VIREP, TRUE);
- *	:abbr!	dumpkey(WHEN_EX|WHEN_VIINP|WHEN_VIREP, TRUE);
- */
-void dumpkey(when, abbr)
-	int	when;	/* WHEN_XXXX of mappings to be dumped */
-	int	abbr;	/* boolean: dump abbreviations instead of maps? */
-{
-	MAP	*scan;
-	char	*str;
-	int	len;
-
-#ifndef NO_ABBR
-	for (scan = (abbr ? abbrs : maps); scan; scan = scan->next)
-#else
-	for (scan = maps; scan; scan = scan->next)
-#endif
-	{
-		/* skip entries that don't match "when" */
-		if ((scan->flags & when) == 0)
-		{
-			continue;
-		}
-
-		/* dump the key label, if any */
-		if (!abbr)
-		{
-			len = 8;
-			if (scan->label)
-			{
-				qaddstr(scan->label);
-				len -= strlen(scan->label);
-			}
-			do
-			{
-				qaddch(' ');
-			} while (len-- > 0);
-		}
-
-		/* dump the rawin version */
-		str = printable(scan->rawin);
-		qaddstr(str);
-		len = strlen(str);
-		do
-		{
-			qaddch(' ');
-		} while (len++ < 8);
-			
-		/* dump the mapped version */
-#ifndef NO_EXTENSIONS
-		if ((scan->flags & WHEN_INMV) && (when & (WHEN_VIINP|WHEN_VIREP)))
-		{
-			qaddstr("visual ");
-		}
-#endif
-		str = printable(scan->cooked);
-		qaddstr(str);
-		addch('\n');
-		exrefresh();
-	}
-}
-
-#ifndef NO_MKEXRC
-
-static safequote(str)
-	char	*str;
-{
-	char	*build;
-
-	build = tmpblk.c + strlen(tmpblk.c);
-	while (*str)
-	{
-		if (*str <= ' ' && *str >= 1 || *str == '|')
-		{
-			*build++ = ctrl('V');
-		}
-		*build++ = *str++;
-	}
-	*build = '\0';
-}
-
-/* This function saves the contents of either the map table or the
- * abbreviation table into a file.  Both the "bang" and "no bang" versions
- * are saved.
- *	:map	dumpkey(WHEN_VICMD, FALSE);
- *	:map!	dumpkey(WHEN_VIREP|WHEN_VIINP, FALSE);
- *	:abbr	dumpkey(WHEN_VIINP|WHEN_VIREP, TRUE);
- *	:abbr!	dumpkey(WHEN_EX|WHEN_VIINP|WHEN_VIREP, TRUE);
- */
-savemaps(fd, abbr)
-	int	fd;	/* file descriptor of an open file to write to */
-	int	abbr;	/* boolean: do abbr table? (else do map table) */
-{
-	MAP	*scan;
-	char	*str;
-	int	bang;
-	int	when;
-	int	len;
-
-# ifndef NO_ABBR
-	for (scan = (abbr ? abbrs : maps); scan; scan = scan->next)
-# else
-	for (scan = maps; scan; scan = scan->next)
-# endif
-	{
-		/* skip maps that have labels, except for function keys */
-		if (scan->label && *scan->label != '#')
-		{
-			continue;
-		}
-
-		for (bang = 0; bang < 2; bang++)
-		{
-			/* decide which "when" flags we want */
-# ifndef NO_ABBR
-			if (abbr)
-				when = (bang ? WHEN_EX|WHEN_VIINP|WHEN_VIREP : WHEN_VIINP|WHEN_VIREP);
-			else
-# endif
-				when = (bang ? WHEN_VIREP|WHEN_VIINP : WHEN_VICMD);
-
-			/* skip entries that don't match "when" */
-			if ((scan->flags & when) == 0)
-			{
-				continue;
-			}
-
-			/* write a "map" or "abbr" command name */
-# ifndef NO_ABBR
-			if (abbr)
-				strcpy(tmpblk.c, "abbr");
-			else
-# endif
-				strcpy(tmpblk.c, "map");
-
-			/* maybe write a bang.  Definitely write a space */
-			if (bang)
-				strcat(tmpblk.c, "! ");
-			else
-				strcat(tmpblk.c, " ");
-
-			/* write the rawin version */
-# ifndef NO_FKEY
-			if (scan->label)
-				strcat(tmpblk.c, scan->label);
-			else
-# endif
-				safequote(scan->rawin);
-			strcat(tmpblk.c, " ");
-				
-			/* dump the mapped version */
-# ifndef NO_EXTENSIONS
-			if ((scan->flags & WHEN_INMV) && (when & (WHEN_VIINP|WHEN_VIREP)))
-			{
-				strcat(tmpblk.c, "visual ");
-			}
-# endif
-			safequote(scan->cooked);
-			strcat(tmpblk.c, "\n");
-			twrite(fd, tmpblk.c, strlen(tmpblk.c));
-		}
-	}
-}
-#endif
Index: trunk/minix/commands/elvis/tmp.c
===================================================================
--- trunk/minix/commands/elvis/tmp.c	(revision 9)
+++ 	(revision )
@@ -1,759 +1,0 @@
-/* tmp.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains functions which create & readback a TMPFILE */
-
-
-#include "config.h"
-#include "vi.h"
-#if TOS
-# include <stat.h>
-#else
-# if OSK
-#  include "osk.h"
-# else
-#  if AMIGA
-#   include "amistat.h"
-#  else
-#   include <sys/stat.h>
-#  endif
-# endif
-#endif
-#if TURBOC
-# include <process.h>
-#endif
-
-#ifndef NO_MODELINES
-static void do_modelines(l, stop)
-	long	l;	/* line number to start at */
-	long	stop;	/* line number to stop at */
-{
-	char	*str;	/* used to scan through the line */
-	char	*start;	/* points to the start of the line */
-	char	buf[80];
-
-	/* if modelines are disabled, then do nothing */
-	if (!*o_modelines)
-	{
-		return;
-	}
-
-	/* for each line... */
-	for (; l <= stop; l++)
-	{
-		/* for each position in the line.. */
-		for (str = fetchline(l); *str; str++)
-		{
-			/* if it is the start of a modeline command... */
-			if ((str[0] == 'e' && str[1] == 'x'
-			  || str[0] == 'v' && str[1] == 'i')
-			  && str[2] == ':')
-			{
-				start = str += 3;
-
-				/* find the end */
-				for (str = start + strlen(start); *--str != ':'; )
-				{
-				}
-
-				/* if it is a well-formed modeline, execute it */
-				if (str > start && str - start < sizeof buf)
-				{
-					strncpy(buf, start, (int)(str - start));
-					exstring(buf, str - start, '\\');
-					break;
-				}
-			}
-		}
-	}
-}
-#endif
-
-
-/* The FAIL() macro prints an error message and then exits. */
-#define FAIL(why,arg)	mode = MODE_EX; msg(why, arg); endwin(); exit(9)
-
-/* This is the name of the temp file */
-static char	tmpname[80];
-
-/* This function creates the temp file and copies the original file into it.
- * Returns if successful, or stops execution if it fails.
- */
-int tmpstart(filename)
-	char		*filename; /* name of the original file */
-{
-	int		origfd;	/* fd used for reading the original file */
-	struct stat	statb;	/* stat buffer, used to examine inode */
-	REG BLK		*this;	/* pointer to the current block buffer */
-	REG BLK		*next;	/* pointer to the next block buffer */
-	int		inbuf;	/* number of characters in a buffer */
-	int		nread;	/* number of bytes read */
-	REG int		j, k;
-	int		i;
-	long		nbytes;
-
-	/* switching to a different file certainly counts as a change */
-	changes++;
-	redraw(MARK_UNSET, FALSE);
-
-	/* open the original file for reading */
-	*origname = '\0';
-	if (filename && *filename)
-	{
-		strcpy(origname, filename);
-		origfd = open(origname, O_RDONLY);
-		if (origfd < 0 && errno != ENOENT)
-		{
-			msg("Can't open \"%s\"", origname);
-			return tmpstart("");
-		}
-		if (origfd >= 0)
-		{
-			if (stat(origname, &statb) < 0)
-			{
-				FAIL("Can't stat \"%s\"", origname);
-			}
-#if TOS
-			if (origfd >= 0 && (statb.st_mode & S_IJDIR))
-#else
-# if OSK
-			if (origfd >= 0 && (statb.st_mode & S_IFDIR))
-# else
-			if (origfd >= 0 && (statb.st_mode & S_IFMT) != S_IFREG)
-# endif
-#endif
-			{
-				msg("\"%s\" is not a regular file", origname);
-				return tmpstart("");
-			}
-		}
-		else
-		{
-			stat(".", &statb);
-		}
-		if (origfd >= 0)
-		{
-			origtime = statb.st_mtime;
-#if OSK
-			if (*o_readonly || !(statb.st_mode &
-				  ((getuid() >> 16) == 0 ? S_IOWRITE | S_IWRITE :
-				  ((statb.st_gid != (getuid() >> 16) ? S_IOWRITE : S_IWRITE)))))
-#endif
-#if AMIGA || MSDOS || (TOS && defined(__GNUC__))
-			if (*o_readonly || !(statb.st_mode & S_IWRITE))
-#endif
-#if TOS && !defined(__GNUC__)
-			if (*o_readonly || (statb.st_mode & S_IJRON))
-#endif
-#if ANY_UNIX
-			if (*o_readonly || !(statb.st_mode &
-				  ((geteuid() == 0) ? 0222 :
-				  ((statb.st_uid != geteuid() ? 0022 : 0200)))))
-#endif
-#if VMS
-			if (*o_readonly)
-#endif
-			{
-				setflag(file, READONLY);
-			}
-		}
-		else
-		{
-			origtime = 0L;
-		}
-	}
-	else
-	{
-		setflag(file, NOFILE);
-		origfd = -1;
-		origtime = 0L;
-		stat(".", &statb);
-	}
-
-	/* make a name for the tmp file */
-	tmpnum++;
-#if MSDOS || TOS
-	/* MS-Dos doesn't allow multiple slashes, but supports drives
-	 * with current directories.
-	 * This relies on TMPNAME beginning with "%s\\"!!!!
-	 */
-	strcpy(tmpname, o_directory);
-	if ((i = strlen(tmpname)) && !strchr(":/\\", tmpname[i-1]))
-		tmpname[i++]=SLASH;
-	sprintf(tmpname+i, TMPNAME+3, getpid(), tmpnum);
-#else
-	sprintf(tmpname, TMPNAME, o_directory, getpid(), tmpnum);
-#endif
-
-	/* make sure nobody else is editing the same file */
-	if (access(tmpname, 0) == 0)
-	{
-		FAIL("Temp file \"%s\" already exists?", tmpname);
-	}
-
-	/* create the temp file */
-#if ANY_UNIX
-	close(creat(tmpname, 0600));		/* only we can read it */
-#else
-	close(creat(tmpname, FILEPERMS));	/* anybody body can read it, alas */
-#endif
-	tmpfd = open(tmpname, O_RDWR | O_BINARY);
-	if (tmpfd < 0)
-	{
-		FAIL("Can't create temp file... Does directory \"%s\" exist?", o_directory);
-		return 1;
-	}
-
-	/* allocate space for the header in the file */
-	write(tmpfd, hdr.c, (unsigned)BLKSIZE);
-	write(tmpfd, tmpblk.c, (unsigned)BLKSIZE);
-
-#ifndef NO_RECYCLE
-	/* initialize the block allocator */
-	/* This must already be done here, before the first attempt
-	 * to write to the new file! GB */
-	garbage();
-#endif
-
-	/* initialize lnum[] */
-	for (i = 1; i < MAXBLKS; i++)
-	{
-		lnum[i] = INFINITY;
-	}
-	lnum[0] = 0;
-
-	/* if there is no original file, then create a 1-line file */
-	if (origfd < 0)
-	{
-		hdr.n[0] = 0;	/* invalid inode# denotes new file */
-
-		this = blkget(1); 	/* get the new text block */
-		strcpy(this->c, "\n");	/* put a line in it */
-
-		lnum[1] = 1L;	/* block 1 ends with line 1 */
-		nlines = 1L;	/* there is 1 line in the file */
-		nbytes = 1L;
-
-		if (*origname)
-		{
-			msg("\"%s\" [NEW FILE]  1 line, 1 char", origname);
-		}
-		else
-		{
-			msg("\"[NO FILE]\"  1 line, 1 char");
-		}
-	}
-	else /* there is an original file -- read it in */
-	{
-		nbytes = nlines = 0;
-
-		/* preallocate 1 "next" buffer */
-		i = 1;
-		next = blkget(i);
-		inbuf = 0;
-
-		/* loop, moving blocks from orig to tmp */
-		for (;;)
-		{
-			/* "next" buffer becomes "this" buffer */
-			this = next;
-
-			/* read [more] text into this block */
-			nread = tread(origfd, &this->c[inbuf], BLKSIZE - 1 - inbuf);
-			if (nread < 0)
-			{
-				close(origfd);
-				close(tmpfd);
-				tmpfd = -1;
-				unlink(tmpname);
-				FAIL("Error reading \"%s\"", origname);
-			}
-
-			/* convert NUL characters to something else */
-			for (j = k = inbuf; k < inbuf + nread; k++)
-			{
-				if (!this->c[k])
-				{
-					setflag(file, HADNUL);
-					this->c[j++] = 0x80;
-				}
-#ifndef CRUNCH
-				else if (*o_beautify && this->c[k] < ' ' && this->c[k] > 0)
-				{
-					if (this->c[k] == '\t'
-					 || this->c[k] == '\n'
-					 || this->c[k] == '\f')
-					{
-						this->c[j++] = this->c[k];
-					}
-					else if (this->c[k] == '\b')
-					{
-						/* delete '\b', but complain */
-						setflag(file, HADBS);
-					}
-					/* else silently delete control char */
-				}
-#endif
-				else
-				{
-					this->c[j++] = this->c[k];
-				}
-			}
-			inbuf = j;
-
-			/* if the buffer is empty, quit */
-			if (inbuf == 0)
-			{
-				goto FoundEOF;
-			}
-
-#if MSDOS || TOS
-/* BAH! MS text mode read fills inbuf, then compresses eliminating \r
-   but leaving garbage at end of buf. The same is true for TURBOC. GB. */
-
-			memset(this->c + inbuf, '\0', BLKSIZE - inbuf);
-#endif
-
-			/* search backward for last newline */
-			for (k = inbuf; --k >= 0 && this->c[k] != '\n';)
-			{
-			}
-			if (k++ < 0)
-			{
-				if (inbuf >= BLKSIZE - 1)
-				{
-					k = 80;
-				}
-				else
-				{
-					k = inbuf;
-				}
-			}
-
-			/* allocate next buffer */
-			next = blkget(++i);
-
-			/* move fragmentary last line to next buffer */
-			inbuf -= k;
-			for (j = 0; k < BLKSIZE; j++, k++)
-			{
-				next->c[j] = this->c[k];
-				this->c[k] = 0;
-			}
-
-			/* if necessary, add a newline to this buf */
-			for (k = BLKSIZE - inbuf; --k >= 0 && !this->c[k]; )
-			{
-			}
-			if (this->c[k] != '\n')
-			{
-				setflag(file, ADDEDNL);
-				this->c[k + 1] = '\n';
-			}
-
-			/* count the lines in this block */
-			for (k = 0; k < BLKSIZE && this->c[k]; k++)
-			{
-				if (this->c[k] == '\n')
-				{
-					nlines++;
-				}
-				nbytes++;
-			}
-			lnum[i - 1] = nlines;
-		}
-FoundEOF:
-
-		/* if this is a zero-length file, add 1 line */
-		if (nlines == 0)
-		{
-			this = blkget(1); 	/* get the new text block */
-			strcpy(this->c, "\n");	/* put a line in it */
-
-			lnum[1] = 1;	/* block 1 ends with line 1 */
-			nlines = 1;	/* there is 1 line in the file */
-			nbytes = 1;
-		}
-
-#if MSDOS || TOS
-		/* each line has an extra CR that we didn't count yet */
-		nbytes += nlines;
-#endif
-
-		/* report the number of lines in the file */
-		msg("\"%s\" %s %ld line%s, %ld char%s",
-			origname,
-			(tstflag(file, READONLY) ? "[READONLY]" : ""),
-			nlines,
-			nlines == 1 ? "" : "s",
-			nbytes,
-			nbytes == 1 ? "" : "s");
-	}
-
-	/* initialize the cursor to start of line 1 */
-	cursor = MARK_FIRST;
-
-	/* close the original file */
-	close(origfd);
-
-	/* any other messages? */
-	if (tstflag(file, HADNUL))
-	{
-		msg("This file contained NULs.  They've been changed to \\x80 chars");
-	}
-	if (tstflag(file, ADDEDNL))
-	{
-		msg("Newline characters have been inserted to break up long lines");
-	}
-#ifndef CRUNCH
-	if (tstflag(file, HADBS))
-	{
-		msg("Backspace characters deleted due to ':set beautify'");
-	}
-#endif
-
-	storename(origname);
-
-#ifndef NO_MODELINES
-	if (nlines > 10)
-	{
-		do_modelines(1L, 5L);
-		do_modelines(nlines - 4L, nlines);
-	}
-	else
-	{
-		do_modelines(1L, nlines);
-	}
-#endif
-
-	/* force all blocks out onto the disk, to support file recovery */
-	blksync();
-
-	return 0;
-}
-
-
-
-/* This function copies the temp file back onto an original file.
- * Returns TRUE if successful, or FALSE if the file could NOT be saved.
- */
-int tmpsave(filename, bang)
-	char	*filename;	/* the name to save it to */
-	int	bang;		/* forced write? */
-{
-	int		fd;	/* fd of the file we're writing to */
-	REG int		len;	/* length of a text block */
-	REG BLK		*this;	/* a text block */
-	long		bytes;	/* byte counter */
-	REG int		i;
-
-	/* if no filename is given, assume the original file name */
-	if (!filename || !*filename)
-	{
-		filename = origname;
-	}
-
-	/* if still no file name, then fail */
-	if (!*filename)
-	{
-		msg("Don't know a name for this file -- NOT WRITTEN");
-		return FALSE;
-	}
-
-	/* can't rewrite a READONLY file */
-#if AMIGA
-	if (!strcmp(filename, origname) && tstflag(file, READONLY) && !bang)
-#else
-	if (!strcmp(filename, origname) && *o_readonly && !bang)
-#endif
-	{
-		msg("\"%s\" [READONLY] -- NOT WRITTEN", filename);
-		return FALSE;
-	}
-
-	/* open the file */
-	if (*filename == '>' && filename[1] == '>')
-	{
-		filename += 2;
-		while (*filename == ' ' || *filename == '\t')
-		{
-			filename++;
-		}
-#ifdef O_APPEND
-		fd = open(filename, O_WRONLY|O_APPEND);
-#else
-		fd = open(filename, O_WRONLY);
-		lseek(fd, 0L, 2);
-#endif
-	}
-	else
-	{
-		/* either the file must not exist, or it must be the original
-		 * file, or we must have a bang, or "writeany" must be set.
-		 */
-		if (strcmp(filename, origname) && access(filename, 0) == 0 && !bang
-#ifndef CRUNCH
-		    && !*o_writeany
-#endif
-				   )
-		{
-			msg("File already exists - Use :w! to overwrite");
-			return FALSE;
-		}
-#if VMS
-		/* Create a new VMS version of this file. */
-		{ 
-		char *strrchr(), *ptr = strrchr(filename,';');
-		if (ptr) *ptr = '\0';  /* Snip off any ;number in the name */
-		}
-#endif
-		fd = creat(filename, FILEPERMS);
-	}
-	if (fd < 0)
-	{
-		msg("Can't write to \"%s\" -- NOT WRITTEN", filename);
-		return FALSE;
-	}
-
-	/* write each text block to the file */
-	bytes = 0L;
-	for (i = 1; i < MAXBLKS && (this = blkget(i)) && this->c[0]; i++)
-	{
-		for (len = 0; len < BLKSIZE && this->c[len]; len++)
-		{
-		}
-		if (twrite(fd, this->c, len) < len)
-		{
-			msg("Trouble writing to \"%s\"", filename);
-			if (!strcmp(filename, origname))
-			{
-				setflag(file, MODIFIED);
-			}
-			close(fd);
-			return FALSE;
-		}
-		bytes += len;
-	}
-
-	/* reset the "modified" flag, but not the "undoable" flag */
-	clrflag(file, MODIFIED);
-	significant = FALSE;
-
-	/* report lines & characters */
-#if MSDOS || TOS
-	bytes += nlines; /* for the inserted carriage returns */
-#endif
-	msg("Wrote \"%s\"  %ld lines, %ld characters", filename, nlines, bytes);
-
-	/* close the file */
-	close(fd);
-
-	return TRUE;
-}
-
-
-/* This function deletes the temporary file.  If the file has been modified
- * and "bang" is FALSE, then it returns FALSE without doing anything; else
- * it returns TRUE.
- *
- * If the "autowrite" option is set, then instead of returning FALSE when
- * the file has been modified and "bang" is false, it will call tmpend().
- */
-int tmpabort(bang)
-	int	bang;
-{
-	/* if there is no file, return successfully */
-	if (tmpfd < 0)
-	{
-		return TRUE;
-	}
-
-	/* see if we must return FALSE -- can't quit */
-	if (!bang && tstflag(file, MODIFIED))
-	{
-		/* if "autowrite" is set, then act like tmpend() */
-		if (*o_autowrite)
-			return tmpend(bang);
-		else
-			return FALSE;
-	}
-
-	/* delete the tmp file */
-	cutswitch();
-	strcpy(prevorig, origname);
-	prevline = markline(cursor);
-	*origname = '\0';
-	origtime = 0L;
-	blkinit();
-	nlines = 0;
-	initflags();
-	return TRUE;
-}
-
-/* This function saves the file if it has been modified, and then deletes
- * the temporary file. Returns TRUE if successful, or FALSE if the file
- * needs to be saved but can't be.  When it returns FALSE, it will not have
- * deleted the tmp file, either.
- */
-int tmpend(bang)
-	int	bang;
-{
-	/* save the file if it has been modified */
-	if (tstflag(file, MODIFIED) && !tmpsave((char *)0, FALSE) && !bang)
-	{
-		return FALSE;
-	}
-
-	/* delete the tmp file */
-	tmpabort(TRUE);
-
-	return TRUE;
-}
-
-
-/* If the tmp file has been changed, then this function will force those
- * changes to be written to the disk, so that the tmp file will survive a
- * system crash or power failure.
- */
-#if AMIGA || MSDOS || TOS
-sync()
-{
-	/* MS-DOS and TOS don't flush their buffers until the file is closed,
-	 * so here we close the tmp file and then immediately reopen it.
-	 */
-	close(tmpfd);
-	tmpfd = open(tmpname, O_RDWR | O_BINARY);
-	return 0;
-}
-#endif
-
-
-/* This function stores the file's name in the second block of the temp file.
- * SLEAZE ALERT!  SLEAZE ALERT!  The "tmpblk" buffer is probably being used
- * to store the arguments to a command, so we can't use it here.  Instead,
- * we'll borrow the buffer that is used for "shift-U".
- */
-storename(name)
-	char	*name;	/* the name of the file - normally origname */
-{
-#ifndef CRUNCH
-	int	len;
-	char	*ptr;
-#endif
-
-	/* we're going to clobber the U_text buffer, so reset U_line */
-	U_line = 0L;
-
-	if (!name)
-	{
-		strncpy(U_text, "", BLKSIZE);
-		U_text[1] = 127;
-	}
-#ifndef CRUNCH
-	else if (*name != SLASH)
-	{
-		/* get the directory name */
-		ptr = getcwd(U_text, BLKSIZE);
-		if (ptr != U_text)
-		{
-			strcpy(U_text, ptr);
-		}
-
-		/* append a slash to the directory name */
-		len = strlen(U_text);
-		U_text[len++] = SLASH;
-
-		/* append the filename, padded with heaps o' NULs */
-		strncpy(U_text + len, *name ? name : "foo", BLKSIZE - len);
-	}
-#endif
-	else
-	{
-		/* copy the filename into U_text */
-		strncpy(U_text, *name ? name : "foo", BLKSIZE);
-	}
-
-	if (tmpfd >= 0)
-	{
-		/* write the name out to second block of the temp file */
-		lseek(tmpfd, (long)BLKSIZE, 0);
-		write(tmpfd, U_text, (unsigned)BLKSIZE);
-	}
-	return 0;
-}
-
-
-
-/* This function handles deadly signals.  It restores sanity to the terminal
- * preserves the current temp file, and deletes any old temp files.
- */
-int deathtrap(sig)
-	int	sig;	/* the deadly signal that we caught */
-{
-	char	*why;
-
-	/* restore the terminal's sanity */
-	endwin();
-
-#ifdef CRUNCH
-	why = "-Elvis died";
-#else
-	/* give a more specific description of how Elvis died */
-	switch (sig)
-	{
-# ifdef SIGHUP
-	  case SIGHUP:	why = "-the modem lost its carrier";		break;
-# endif
-# ifndef DEBUG
-#  ifdef SIGILL
-	  case SIGILL:	why = "-Elvis hit an illegal instruction";	break;
-#  endif
-#  ifdef SIGBUS
-	  case SIGBUS:	why = "-Elvis had a bus error";			break;
-#  endif
-#  if defined(SIGSEGV) && !defined(TOS)
-	  case SIGSEGV:	why = "-Elvis had a segmentation violation";	break;
-#  endif
-#  ifdef SIGSYS
-	  case SIGSYS:	why = "-Elvis munged a system call";		break;
-#  endif
-# endif /* !DEBUG */
-# ifdef SIGPIPE
-	  case SIGPIPE:	why = "-the pipe reader died";			break;
-# endif
-# ifdef SIGTERM
-	  case SIGTERM:	why = "-Elvis was terminated";			break;
-# endif
-# if !MINIX
-#  ifdef SIGUSR1
-	  case SIGUSR1:	why = "-Elvis was killed via SIGUSR1";		break;
-#  endif
-#  ifdef SIGUSR2
-	  case SIGUSR2:	why = "-Elvis was killed via SIGUSR2";		break;
-#  endif
-# endif
-	  default:	why = "-Elvis died";				break;
-	}
-#endif
-
-	/* if we had a temp file going, then preserve it */
-	if (tmpnum > 0 && tmpfd >= 0)
-	{
-		close(tmpfd);
-		sprintf(tmpblk.c, "%s \"%s\" %s", PRESERVE, why, tmpname);
-		system(tmpblk.c);
-	}
-
-	/* delete any old temp files */
-	cutend();
-
-	/* exit with the proper exit status */
-	exit(sig);
-}
Index: trunk/minix/commands/elvis/unix.c
===================================================================
--- trunk/minix/commands/elvis/unix.c	(revision 9)
+++ 	(revision )
@@ -1,226 +1,0 @@
-/* unix.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the unix-specific versions the ttyread() functions.
- * There are actually three versions of ttyread() defined here, because
- * BSD, SysV, and V7 all need quite different implementations.
- */
-
-#include "config.h"
-#if ANY_UNIX
-# include "vi.h"
-
-# if BSD
-/* For BSD, we use select() to wait for characters to become available,
- * and then do a read() to actually get the characters.  We also try to
- * handle SIGWINCH -- if the signal arrives during the select() call, then
- * we adjust the o_columns and o_lines variables, and fake a control-L.
- */
-#  include <sys/types.h>
-#  include <sys/time.h>
-int ttyread(buf, len, time)
-	char	*buf;	/* where to store the gotten characters */
-	int	len;	/* maximum number of characters to read */
-	int	time;	/* maximum time to allow for reading */
-{
-	fd_set	rd;	/* the file descriptors that we want to read from */
-	static	tty;	/* 'y' if reading from tty, or 'n' if not a tty */
-	int	i;
-	struct timeval t;
-	struct timeval *tp;
-
-
-	/* do we know whether this is a tty or not? */
-	if (!tty)
-	{
-		tty = (isatty(0) ? 'y' : 'n');
-	}
-
-	/* compute the timeout value */
-	if (time)
-	{
-		t.tv_sec = time / 10;
-		t.tv_usec = (time % 10) * 100000L;
-		tp = &t;
-	}
-	else
-	{
-		tp = (struct timeval *)0;
-	}
-
-	/* loop until we get characters or a definite EOF */
-	for (;;)
-	{
-		if (tty == 'y')
-		{
-			/* wait until timeout or characters are available */
-			FD_ZERO(&rd);
-			FD_SET(0, &rd);
-			i = select(1, &rd, (fd_set *)0, (fd_set *)0, tp);
-		}
-		else
-		{
-			/* if reading from a file or pipe, never timeout!
-			 * (This also affects the way that EOF is detected)
-			 */
-			i = 1;
-		}
-	
-		/* react accordingly... */
-		switch (i)
-		{
-		  case -1:	/* assume we got an EINTR because of SIGWINCH */
-			if (*o_lines != LINES || *o_columns != COLS)
-			{
-				*o_lines = LINES;
-				*o_columns = COLS;
-#ifndef CRUNCH
-				if (!wset)
-				{
-					*o_window = LINES - 1;
-				}
-#endif
-				if (mode != MODE_EX)
-				{
-					/* pretend the user hit ^L */
-					*buf = ctrl('L');
-					return 1;
-				}
-			}
-			break;
-	
-		  case 0:	/* timeout */
-			return 0;
-	
-		  default:	/* characters available */
-			return read(0, buf, len);
-		}
-	}
-}
-# else
-
-# if M_SYSV
-/* For System-V or Coherent, we use VMIN/VTIME to implement the timeout.
- * For no timeout, VMIN should be 1 and VTIME should be 0; for timeout,
- * VMIN should be 0 and VTIME should be the timeout value.
- */
-#  include <termio.h>
-int ttyread(buf, len, time)
-	char	*buf;	/* where to store the gotten characters */
-	int	len;	/* maximum number of characters to read */
-	int	time;	/* maximum time to allow for reading */
-{
-	struct termio tio;
-	int	bytes;	/* number of bytes actually read */
-
-	/* arrange for timeout */
-	ioctl(0, TCGETA, &tio);
-	if (time)
-	{
-		tio.c_cc[VMIN] = 0;
-		tio.c_cc[VTIME] = time;
-	}
-	else
-	{
-		tio.c_cc[VMIN] = 1;
-		tio.c_cc[VTIME] = 0;
-	}
-	ioctl(0, TCSETA, &tio);
-
-	/* Perform the read.  Loop if EINTR error happens */
-	while ((bytes = read(0, buf, len)) < 0)
-	{
-		/* probably EINTR error because a SIGWINCH was received */
-		if (*o_lines != LINES || *o_columns != COLS)
-		{
-			*o_lines = LINES;
-			*o_columns = COLS;
-#ifndef CRUNCH
-			if (!wset)
-			{
-				*o_window = LINES - 1;
-			}
-#endif
-			if (mode != MODE_EX)
-			{
-				/* pretend the user hit ^L */
-				*buf = ctrl('L');
-				return 1;
-			}
-		}
-	}
-
-	/* return the number of bytes read */
-	return bytes;
-
-	/* NOTE: The terminal may be left in a timeout-mode after this function
-	 * returns.  This shouldn't be a problem since Elvis *NEVER* tries to
-	 * read from the keyboard except through this function.
-	 */
-}
-
-# else /* any other version of UNIX, assume it is V7 compatible */
-
-/* For V7 UNIX (including Minix) we set an alarm() before doing a blocking
- * read(), and assume that the SIGALRM signal will cause the read() function
- * to give up.
- */
-
-#include <setjmp.h>
-
-static jmp_buf env;
-
-/*ARGSUSED*/
-int dummy(signo)
-	int	signo;
-{
-	longjmp(env, 1);
-}
-int ttyread(buf, len, time)
-	char	*buf;	/* where to store the gotten characters */
-	int	len;	/* maximum number of characters to read */
-	int	time;	/* maximum time to allow for reading */
-{
-	/* arrange for timeout */
-#if __GNUC__ || _ANSI
-	signal(SIGALRM, (void (*)()) dummy);
-#else
-	signal(SIGALRM, dummy);
-#endif
-	alarm(time);
-
-	/* perform the blocking read */
-	if (setjmp(env) == 0)
-	{
-		len = read(0, buf, len);
-	}
-	else /* I guess we timed out */
-	{
-		len = 0;
-	}
-
-	/* cancel the alarm */
-#if _ANSI
-	signal(SIGALRM, (void (*)())dummy); /* work around a bug in Minix */
-#else
-	signal(SIGALRM, dummy);		    /* work around a bug in Minix */
-#endif
-	alarm(0);
-
-	/* return the number of bytes read */
-	if (len < 0)
-		len = 0;
-	return len;
-}
-
-# endif /* !(M_SYSV || COHERENT) */
-# endif /* !BSD */
-
-#endif /* ANY_UNIX */
Index: trunk/minix/commands/elvis/vars.c
===================================================================
--- trunk/minix/commands/elvis/vars.c	(revision 9)
+++ 	(revision )
@@ -1,115 +1,0 @@
-/* vars.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains variables which weren't happy anyplace else */
-
-#include "config.h"
-#include "vi.h"
-
-/*------------------------------------------------------------------------*/
-
-/* used to remember whether the file has been modified */
-struct _viflags	viflags;
-
-/* used to access the tmp file */
-long		lnum[MAXBLKS];
-long		nlines;
-int		tmpfd = -1;
-int		tmpnum;
-#ifndef CRUNCH
-int		wset = FALSE;
-#endif
-
-/* used to keep track of the current file & alternate file */
-long		origtime;
-char		origname[256];
-char		prevorig[256];
-long		prevline = 1;
-
-/* used to track various places in the text */
-MARK		mark[NMARKS];	/* marks 'a through 'z, plus mark '' */
-MARK		cursor;		/* the cursor position within the file */
-
-/* which mode of the editor we're in */
-int		mode;		/* vi mode? ex mode? quitting? */
-
-/* used to manage the args list */
-char		args[BLKSIZE];	/* list of filenames to edit */
-int		argno;		/* index of current file in args list */
-int		nargs;		/* number of filenames in args[] */
-
-/* dummy var, never explicitly referenced */
-int		bavar;		/* used only in BeforeAfter macros */
-
-/* used to detect changes that invalidate cached text/blocks */
-long		changes;	/* incremented when file is changed */
-int		significant;	/* boolean: was a *REAL* change made? */
-
-/* used to support the pfetch() macro */
-int		plen;		/* length of the line */
-long		pline;		/* line number that len refers to */
-long		pchgs;		/* "changes" level that len refers to */
-char		*ptext;		/* text of previous line, if valid */
-
-/* misc temporary storage - mostly for strings */
-BLK		tmpblk;		/* a block used to accumulate changes */
-
-/* screen oriented stuff */
-long		topline;	/* file line number of top line */
-int		leftcol;	/* column number of left col */
-int		physcol;	/* physical column number that cursor is on */
-int		physrow;	/* physical row number that cursor is on */
-
-/* used to help minimize that "[Hit a key to continue]" message */
-int		exwrote;	/* Boolean: was the last ex command wordy? */
-
-/* This variable affects the behaviour of certain functions -- most importantly
- * the input function.
- */
-int		doingdot;	/* boolean: are we doing the "." command? */
-
-/* This variable affects the behaviour of the ":s" command, and it is also
- * used to detect & prohibit nesting of ":g" commands
- */
-int		doingglobal;	/* boolean: are doing a ":g" command? */
-
-/* This variable is zeroed before a command executes, and later ORed with the
- * command's flags after the command has been executed.  It is used to force
- * certain flags to be TRUE for *some* invocations of a particular command.
- * For example, "/regexp/+offset" forces the LNMD flag, and sometimes a "p"
- * or "P" command will force FRNT.
- */
-int		force_flags;
-
-/* These are used for reporting multi-line changes to the user */
-long		rptlines;	/* number of lines affected by a command */
-char		*rptlabel;	/* description of how lines were affected */
-
-/* These store info that pertains to the shift-U command */
-long	U_line;			/* line# of the undoable line, or 0l for none */
-char	U_text[BLKSIZE];	/* contents of the undoable line */
-
-
-#ifndef NO_VISIBLE
-/* These are used to implement the 'v' and 'V' commands */
-MARK	V_from;			/* starting point for v or V */
-int	V_linemd;		/* boolean: doing line-mode version? (V, not v) */
-#endif
-
-/* Bigger stack req'ed for TOS and TURBOC */
-
-#if TOS
-long	_stksize = 16384;
-#endif
-
-#if TURBOC
-#include <dos.h>
-extern unsigned _stklen = 16384U;
-#endif
Index: trunk/minix/commands/elvis/vcmd.c
===================================================================
--- trunk/minix/commands/elvis/vcmd.c	(revision 9)
+++ 	(revision )
@@ -1,975 +1,0 @@
-/* vcmd.c */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-/* This file contains the functions that handle VI commands */
-
-
-#include "config.h"
-#include "ctype.h"
-#include "vi.h"
-#if MSDOS
-# include <process.h>
-# include <string.h>
-#endif
-#if TOS
-# include <osbind.h>
-# include <string.h>
-#endif
-#if OSK
-# include <stdio.h>
-#endif
-
-
-/* This function puts the editor in EX mode */
-MARK v_quit()
-{
-	move(LINES - 1, 0);
-	mode = MODE_EX;
-	return cursor;
-}
-
-/* This function causes the screen to be redrawn */
-MARK v_redraw()
-{
-	redraw(MARK_UNSET, FALSE);
-	return cursor;
-}
-
-/* This function executes a string of EX commands, and waits for a user keystroke
- * before returning to the VI screen.  If that keystroke is another ':', then
- * another EX command is read and executed.
- */
-/*ARGSUSED*/
-MARK v_1ex(m, text)
-	MARK	m;	/* the current line */
-	char	*text;	/* the first command to execute */
-{
-	/* run the command.  be careful about modes & output */
-	exwrote = (mode == MODE_COLON);
-	doexcmd(text);
-	exrefresh();
-
-	/* if mode is no longer MODE_VI, then we should quit right away! */
-	if (mode != MODE_VI && mode != MODE_COLON)
-		return cursor;
-
-	/* The command did some output.  Wait for a keystoke. */
-	if (exwrote)
-	{
-		mode = MODE_VI;	
-		msg("[Hit <RETURN> to continue]");
-		if (getkey(0) == ':')
-		{	mode = MODE_COLON;
-			addch('\n');
-		}
-		else
-			redraw(MARK_UNSET, FALSE);
-	}
-
-	return cursor;
-}
-
-/* This function undoes the last change */
-/*ARGSUSED*/
-MARK v_undo(m)
-	MARK	m;	/* (ignored) */
-{
-	if (undo())
-	{
-		redraw(MARK_UNSET, FALSE);
-	}
-	return cursor;
-}
-
-/* This function deletes the character(s) that the cursor is on */
-MARK v_xchar(m, cnt, cmd)
-	MARK	m;	/* where to start deletions */
-	long	cnt;	/* number of chars to delete */
-	int	cmd;	/* either 'x' or 'X' */
-{
-	DEFAULT(1);
-
-	/* for 'X', adjust so chars are deleted *BEFORE* cursor */
-	if (cmd == 'X')
-	{
-		if (markidx(m) < cnt)
-			return MARK_UNSET;
-		m -= cnt;
-	}
-
-	/* make sure we don't try to delete more thars than there are */
-	pfetch(markline(m));
-	if (markidx(m + cnt) > plen)
-	{
-		cnt = plen - markidx(m);
-	}
-	if (cnt == 0L)
-	{
-		return MARK_UNSET;
-	}
-
-	/* do it */
-	ChangeText
-	{
-		cut(m, m + cnt);
-		delete(m, m + cnt);
-	}
-	return m;
-}
-
-/* This function defines a mark */
-/*ARGSUSED*/
-MARK v_mark(m, count, key)
-	MARK	m;	/* where the mark will be */
-	long	count;	/* (ignored) */
-	int	key;	/* the ASCII label of the mark */
-{
-	if (key < 'a' || key > 'z')
-	{
-		msg("Marks must be from a to z");
-	}
-	else
-	{
-		mark[key - 'a'] = m;
-	}
-	return m;
-}
-
-/* This function toggles upper & lower case letters */
-MARK v_ulcase(m, cnt)
-	MARK	m;	/* where to make the change */
-	long	cnt;	/* number of chars to flip */
-{
-	REG char 	*pos;
-	REG int		j;
-
-	DEFAULT(1);
-
-	/* fetch the current version of the line */
-	pfetch(markline(m));
-
-	/* for each position in the line */
-	for (j = 0, pos = &ptext[markidx(m)]; j < cnt && *pos; j++, pos++)
-	{
-		if (isupper(*pos))
-		{
-			tmpblk.c[j] = tolower(*pos);
-		}
-		else
-		{
-			tmpblk.c[j] = toupper(*pos);
-		}
-	}
-
-	/* if the new text is different from the old, then change it */
-	if (strncmp(tmpblk.c, &ptext[markidx(m)], j))
-	{
-		ChangeText
-		{
-			tmpblk.c[j] = '\0';
-			change(m, m + j, tmpblk.c);
-		}
-	}
-
-	return m + j;
-}
-
-
-MARK v_replace(m, cnt, key)
-	MARK	m;	/* first char to be replaced */
-	long	cnt;	/* number of chars to replace */
-	int	key;	/* what to replace them with */
-{
-	REG char	*text;
-	REG int		i;
-
-	DEFAULT(1);
-
-	/* map ^M to '\n' */
-	if (key == '\r')
-	{
-		key = '\n';
-	}
-
-	/* make sure the resulting line isn't too long */
-	if (cnt > BLKSIZE - 2 - markidx(m))
-	{
-		cnt = BLKSIZE - 2 - markidx(m);
-	}
-
-	/* build a string of the desired character with the desired length */
-	for (text = tmpblk.c, i = cnt; i > 0; i--)
-	{
-		*text++ = key;
-	}
-	*text = '\0';
-
-	/* make sure cnt doesn't extend past EOL */
-	pfetch(markline(m));
-	key = markidx(m);
-	if (key + cnt > plen)
-	{
-		cnt = plen - key;
-	}
-
-	/* do the replacement */
-	ChangeText
-	{
-		change(m, m + cnt, tmpblk.c);
-	}
-
-	if (*tmpblk.c == '\n')
-	{
-		return (m & ~(BLKSIZE - 1)) + cnt * BLKSIZE;
-	}
-	else
-	{
-		return m + cnt - 1;
-	}
-}
-
-MARK v_overtype(m)
-	MARK		m;	/* where to start overtyping */
-{
-	MARK		end;	/* end of a substitution */
-	static long	width;	/* width of a single-line replace */
-
-	/* the "doingdot" version of replace is really a substitution */
-	if (doingdot)
-	{
-		/* was the last one really repeatable? */
-		if (width < 0)
-		{
-			msg("Can't repeat a multi-line overtype command");
-			return MARK_UNSET;
-		}
-
-		/* replacing nothing by nothing?  Don't bother */
-		if (width == 0)
-		{
-			return m;
-		}
-
-		/* replace some chars by repeated text */
-		return v_subst(m, width);
-	}
-
-	/* Normally, we input starting here, in replace mode */
-	ChangeText
-	{
-		end = input(m, m, WHEN_VIREP, FALSE);
-	}
-
-	/* if we ended on the same line we started on, then this
-	 * overtype is repeatable via the dot key.
-	 */
-	if (markline(end) == markline(m) && end >= m - 1L)
-	{
-		width = end - m + 1L;
-	}
-	else /* it isn't repeatable */
-	{
-		width = -1L;
-	}
-
-	return end;
-}
-
-
-/* This function selects which cut buffer to use */
-/*ARGSUSED*/
-MARK v_selcut(m, cnt, key)
-	MARK	m;
-	long	cnt;
-	int	key;
-{
-	cutname(key);
-	return m;
-}
-
-/* This function pastes text from a cut buffer */
-/*ARGSUSED*/
-MARK v_paste(m, cnt, cmd)
-	MARK	m;	/* where to paste the text */
-	long	cnt;	/* (ignored) */
-	int	cmd;	/* either 'p' or 'P' */
-{
-	MARK	dest;
-
-	ChangeText
-	{
-		/* paste the text, and find out where it ends */
-		dest = paste(m, cmd == 'p', TRUE);
-
-		/* was that a line-mode paste? */
-		if (dest && markline(dest) != markline(m))
-		{
-			/* line-mode pastes leave the cursor at the front
-			 * of the first pasted line.
-			 */
-			dest = m;
-			if (cmd == 'p')
-			{
-				dest += BLKSIZE;
-			}
-			force_flags |= FRNT;
-		}
-	}
-	return dest;
-}
-
-/* This function yanks text into a cut buffer */
-MARK v_yank(m, n)
-	MARK	m, n;	/* range of text to yank */
-{
-	cut(m, n);
-	return m;
-}
-
-/* This function deletes a range of text */
-MARK v_delete(m, n)
-	MARK	m, n;	/* range of text to delete */
-{
-	/* illegal to try and delete nothing */
-	if (n <= m)
-	{
-		return MARK_UNSET;
-	}
-
-	/* Do it */
-	ChangeText
-	{
-		cut(m, n);
-		delete(m, n);
-	}
-	return m;
-}
-
-
-/* This starts input mode without deleting anything */
-MARK v_insert(m, cnt, key)
-	MARK	m;	/* where to start (sort of) */
-	long	cnt;	/* repeat how many times? */
-	int	key;	/* what command is this for? {a,A,i,I,o,O} */
-{
-	int	wasdot;
-	long	reps;
-	int	above;	/* boolean: new line going above old line? */
-
-	DEFAULT(1);
-
-	ChangeText
-	{
-		/* tweak the insertion point, based on command key */
-		above = FALSE;
-		switch (key)
-		{
-		  case 'i':
-			break;
-
-		  case 'a':
-			pfetch(markline(m));
-			if (plen > 0)
-			{
-				m++;
-			}
-			break;
-
-		  case 'I':
-			m = m_front(m, 1L);
-			break;
-
-		  case 'A':
-			pfetch(markline(m));
-			m = (m & ~(BLKSIZE - 1)) + plen;
-			break;
-
-		  case 'O':
-			m &= ~(BLKSIZE - 1);
-			add(m, "\n");
-			above = TRUE;
-			break;
-
-		  case 'o':
-			m = (m & ~(BLKSIZE - 1)) + BLKSIZE;
-			add(m, "\n");
-			break;
-		}
-
-		/* insert the same text once or more */
-		for (reps = cnt, wasdot = doingdot; reps > 0; reps--, doingdot = TRUE)
-		{
-			m = input(m, m, WHEN_VIINP, above) + 1;
-		}
-		if (markidx(m) > 0)
-		{
-			m--;
-		}
-
-		doingdot = wasdot;
-	}
-
-#ifndef CRUNCH
-# ifndef NO_EXTENSIONS
-	if (key == 'i' && *o_inputmode && mode == MODE_VI)
-	{
-		msg("Now in command mode!  To return to input mode, hit <i>");
-	}
-# endif
-#endif
-
-	return m;
-}
-
-/* This starts input mode with some text deleted */
-MARK v_change(m, n)
-	MARK	m, n;	/* the range of text to change */
-{
-	int	lnmode;	/* is this a line-mode change? */
-
-	/* swap them if they're in reverse order */
-	if (m > n)
-	{
-		MARK	tmp;
-		tmp = m;
-		m = n;
-		n = tmp;
-	}
-
-	/* for line mode, retain the last newline char */
-	lnmode = (markidx(m) == 0 && markidx(n) == 0 && m != n);
-	if (lnmode)
-	{
-		n -= BLKSIZE;
-		pfetch(markline(n));
-		n = (n & ~(BLKSIZE - 1)) + plen;
-	}
-
-	ChangeText
-	{
-		cut(m, n);
-		m = input(m, n, WHEN_VIINP, FALSE);
-	}
-
-	return m;
-}
-
-/* This function replaces a given number of characters with input */
-MARK v_subst(m, cnt)
-	MARK	m;	/* where substitutions start */
-	long	cnt;	/* number of chars to replace */
-{
-	DEFAULT(1);
-
-	/* make sure we don't try replacing past EOL */
-	pfetch(markline(m));
-	if (markidx(m) + cnt > plen)
-	{
-		cnt = plen - markidx(m);
-	}
-
-	/* Go for it! */
-	ChangeText
-	{
-		cut(m, m + cnt);
-		m = input(m, m + cnt, WHEN_VIINP, FALSE);
-	}
-	return m;
-}
-
-/* This calls the ex "join" command to join some lines together */
-MARK v_join(m, cnt)
-	MARK	m;	/* the first line to be joined */
-	long	cnt;	/* number of other lines to join */
-{
-	MARK	joint;	/* where the lines were joined */
-
-	DEFAULT(1);
-
-	/* figure out where the joint will be */
-	pfetch(markline(m));
-	joint = (m & ~(BLKSIZE - 1)) + plen;
-
-	/* join the lines */
-	cmd_join(m, m + MARK_AT_LINE(cnt), CMD_JOIN, 0, "");
-
-	/* the cursor should be left at the joint */
-	return joint;
-}
-
-
-/* This calls the ex "<" command to shift some lines left */
-MARK v_lshift(m, n)
-	MARK	m, n;	/* range of lines to shift */
-{
-	/* adjust for inclusive endmarks in ex */
-	n -= BLKSIZE;
-
-	cmd_shift(m, n, CMD_SHIFTL, FALSE, (char *)0);
-
-	return m;
-}
-
-/* This calls the ex ">" command to shift some lines right */
-MARK v_rshift(m, n)
-	MARK	m, n;	/* range of lines to shift */
-{
-	/* adjust for inclusive endmarks in ex */
-	n -= BLKSIZE;
-
-	cmd_shift(m, n, CMD_SHIFTR, FALSE, (char *)0);
-
-	return m;
-}
-
-/* This filters some lines through a preset program, to reformat them */
-MARK v_reformat(m, n)
-	MARK	m, n;	/* range of lines to shift */
-{
-	/* adjust for inclusive endmarks in ex */
-	n -= BLKSIZE;
-
-	/* run the filter command */
-	filter(m, n, o_equalprg, TRUE);
-
-	redraw(MARK_UNSET, FALSE);
-	return m;
-}
-
-
-/* This runs some lines through a filter program */
-MARK v_filter(m, n)
-	MARK	m, n;	/* range of lines to shift */
-{
-	char	cmdln[150];	/* a shell command line */
-
-	/* adjust for inclusive endmarks in ex */
-	n -= BLKSIZE;
-
-	if (vgets('!', cmdln, sizeof(cmdln)) > 0)
-	{
-		filter(m, n, cmdln, TRUE);
-	}
-
-	redraw(MARK_UNSET, FALSE);
-	return m;
-}
-
-
-/* This function runs the ex "file" command to show the file's status */
-MARK v_status()
-{
-	cmd_file(cursor, cursor, CMD_FILE, 0, "");
-	return cursor;
-}
-
-
-/* This function runs the ":&" command to repeat the previous :s// */
-MARK v_again(m, n)
-	MARK	m, n;
-{
-	cmd_substitute(m, n - BLKSIZE, CMD_SUBAGAIN, TRUE, "");
-	return cursor;
-}
-
-
-
-/* This function switches to the previous file, if possible */
-MARK v_switch()
-{
-	if (!*prevorig)
-		msg("No previous file");
-	else
-	{	strcpy(tmpblk.c, prevorig);
-		cmd_edit(cursor, cursor, CMD_EDIT, 0, tmpblk.c);
-	}
-	return cursor;
-}
-
-/* This function does a tag search on a keyword */
-/*ARGSUSED*/
-MARK v_tag(keyword, m, cnt)
-	char	*keyword;
-	MARK	m;
-	long	cnt;
-{
-	/* move the cursor to the start of the tag name, where m is */
-	cursor = m;
-
-	/* perform the tag search */
-	cmd_tag(cursor, cursor, CMD_TAG, 0, keyword);
-
-	return cursor;
-}
-
-#ifndef NO_EXTENSIONS
-/* This function looks up a keyword by calling the helpprog program */
-/*ARGSUSED*/
-MARK v_keyword(keyword, m, cnt)
-	char	*keyword;
-	MARK	m;
-	long	cnt;
-{
-	int	waswarn;
-	char	cmdline[130];
-
-	move(LINES - 1, 0);
-	addstr("---------------------------------------------------------\n");
-	clrtoeol();
-	refresh();
-	sprintf(cmdline, "%s %s", o_keywordprg, keyword);
-	waswarn = *o_warn;
-	*o_warn = FALSE;
-	suspend_curses();
-	if (system(cmdline))
-	{
-		addstr("<<< failed >>>\n");
-	}
-	resume_curses(FALSE);
-	mode = MODE_VI;
-	redraw(MARK_UNSET, FALSE);
-	*o_warn = waswarn;
-
-	return m;
-}
-
-
-
-MARK v_increment(keyword, m, cnt)
-	char	*keyword;
-	MARK	m;
-	long	cnt;
-{
-	static	sign;
-	char	newval[12];
-	long	atol();
-
-	DEFAULT(1);
-
-	/* get one more keystroke, unless doingdot */
-	if (!doingdot)
-	{
-		sign = getkey(0);
-	}
-
-	/* adjust the number, based on that second keystroke */
-	switch (sign)
-	{
-	  case '+':
-	  case '#':
-		cnt = atol(keyword) + cnt;
-		break;
-
-	  case '-':
-		cnt = atol(keyword) - cnt;
-		break;
-
-	  case '=':
-		break;
-
-	  default:
-		return MARK_UNSET;
-	}
-	sprintf(newval, "%ld", cnt);
-
-	ChangeText
-	{
-		change(m, m + strlen(keyword), newval);
-	}
-
-	return m;
-}
-#endif
-
-
-/* This function acts like the EX command "xit" */
-/*ARGSUSED*/
-MARK v_xit(m, cnt, key)
-	MARK	m;	/* ignored */
-	long	cnt;	/* ignored */
-	int	key;	/* must be a second 'Z' */
-{
-	/* if second char wasn't 'Z', fail */
-	if (key != 'Z')
-	{
-		return MARK_UNSET;
-	}
-
-	/* move the cursor to the bottom of the screen */
-	move(LINES - 1, 0);
-	clrtoeol();
-
-	/* do the xit command */
-	cmd_xit(m, m, CMD_XIT, FALSE, "");
-
-	/* return the cursor */
-	return m;
-}
-
-
-/* This function undoes changes to a single line, if possible */
-MARK v_undoline(m)
-	MARK	m;	/* where we hope to undo the change */
-{
-	/* make sure we have the right line in the buffer */
-	if (markline(m) != U_line)
-	{
-		return MARK_UNSET;
-	}
-
-	/* fix it */
-	ChangeText
-	{
-		strcat(U_text, "\n");
-		change(MARK_AT_LINE(U_line), MARK_AT_LINE(U_line + 1), U_text);
-	}
-
-	/* nothing in the buffer anymore */
-	U_line = -1L;
-
-	/* return, with the cursor at the front of the line */
-	return m & ~(BLKSIZE - 1);
-}
-
-
-#ifndef NO_ERRLIST
-MARK v_errlist(m)
-	MARK	m;
-{
-	cmd_errlist(m, m, CMD_ERRLIST, FALSE, "");
-	return cursor;
-}
-#endif
-
-
-#ifndef NO_AT
-/*ARGSUSED*/
-MARK v_at(m, cnt, key)
-	MARK	m;
-	long	cnt;
-	int	key;
-{
-	int	size;
-
-	size = cb2str(key, tmpblk.c, BLKSIZE);
-	if (size <= 0 || size == BLKSIZE)
-	{
-		return MARK_UNSET;
-	}
-
-	execmap(0, tmpblk.c, FALSE);
-	return cursor;
-}
-#endif
-
-
-#ifdef SIGTSTP
-MARK v_suspend()
-{
-	cmd_suspend(MARK_UNSET, MARK_UNSET, CMD_SUSPEND, FALSE, "");
-	return MARK_UNSET;
-}
-#endif
-
-
-#ifndef NO_VISIBLE
-/*ARGSUSED*/
-MARK v_start(m, cnt, cmd)
-	MARK	m;	/* starting point for a v or V command */
-	long	cnt;	/* ignored */
-	int	cmd;	/* either 'v' or 'V' */
-{
-	if (V_from)
-	{
-		V_from = MARK_UNSET;
-	}
-	else
-	{
-		V_from = m;
-		V_linemd = isupper(cmd);
-	}
-	return m;
-}
-#endif
-
-#ifndef NO_POPUP
-# define MENU_HEIGHT 11
-# define MENU_WIDTH  23
-MARK v_popup(m, n)
-	MARK		m, n;	/* the range of text to change */
-{
-	int		i;
-	int		y, x;	/* position where the window will pop up at */
-	int		key;	/* keystroke from the user */
-	int		sel;	/* index of the selected operation */
-	static int	dfltsel;/* default value of sel */
-	static char	*labels[11] =
-	{
-		"ESC cancel!         ",
-		" d  delete (cut)    ",
-		" y  yank (copy)     ",
-		" p  paste after     ",
-		" P  paste before    ",
-		" >  more indented   ",
-		" <  less indented   ",
-		" =  reformat        ",
-		" !  external filter ",
-		" ZZ save & exit     ",
-		" u  undo previous   "
-	};
-
-	/* try to position the menu near the cursor */
-	x = physcol - (MENU_WIDTH / 2);
-	if (x < 0)
-		x = 0;
-	else if (x + MENU_WIDTH + 2 > COLS)
-		x = COLS - MENU_WIDTH - 2;
-	if (markline(cursor) < topline || markline(cursor) > botline)
-		y = 0;
-	else if (markline(cursor) + 1L + MENU_HEIGHT > botline)
-		y = (int)(markline(cursor) - topline) - MENU_HEIGHT;
-	else
-		y = (int)(markline(cursor) - topline) + 1L;
-
-	/* draw the menu */
-	for (sel = 0; sel < MENU_HEIGHT; sel++)
-	{
-		move(y + sel, x);
-		do_POPUP();
-		if (sel == dfltsel)
-			qaddstr("-->");
-		else
-			qaddstr("   ");
-		qaddstr(labels[sel]);
-		do_SE();
-	}
-
-	/* get a selection */
-	move(y + dfltsel, x + 4);
-	for (sel = dfltsel; (key = getkey(WHEN_POPUP)) != '\\' && key != '\r'; )
-	{
-		/* erase the selection arrow */
-		move(y + sel, x);
-		do_POPUP();
-		qaddstr("   ");
-		qaddstr(labels[sel]);
-		do_SE();
-
-		/* process the user's keystroke */
-		if (key == 'j' && sel < MENU_HEIGHT - 1)
-		{
-			sel++;
-		}
-		else if (key == 'k' && sel > 0)
-		{
-			sel--;
-		}
-		else if (key == '\033')
-		{
-			sel = 0;
-			break;
-		}
-		else
-		{
-			for (i = 1; i < MENU_HEIGHT && labels[i][1] != key; i++)
-			{
-			}
-			if (i < MENU_HEIGHT)
-			{
-				sel = i;
-				break;
-			}
-		}
-
-		/* redraw the arrow, possibly in a new place */
-		move(y + sel, x);
-		do_POPUP();
-		qaddstr("-->");
-		qaddstr(labels[sel]);
-		do_SE();
-		move(y + sel, x + 4);
-	}
-
-	/* in most cases, the default selection is "paste after" */
-	dfltsel = 3;
-
-	/* perform the appropriate action */
-	switch (sel)
-	{
-	  case 0:
-		m = cursor;
-		dfltsel = 0;
-		break;
-
-	  case 1: /* delete (cut) */
-		m = v_delete(m, n);
-		break;
-
-	  case 2: /* yank (copy) */
-		m = v_yank(m, n);
-		break;
-
-	  case 3: /* paste after */
-		m = v_paste(n, 1L, 'P');
-		break;
-
-	  case 4: /* paste before */
-		m = v_paste(m, 1L, 'P');
-		dfltsel = 4;
-		break;
-
-	  case 5: /* more indented */
-		m = v_rshift(m, n);
-		dfltsel = 5;
-		break;
-
-	  case 6: /* less indented */
-		m = v_lshift(m, n);
-		dfltsel = 6;
-		break;
-
-	  case 7: /* reformat */
-		m = v_reformat(m, n);
-		dfltsel = 7;
-		break;
-
-	  case 8: /* external filter */
-		m = v_filter(m, n);
-		dfltsel = 0;
-		break;
-
-	  case 9: /* save & exit */
-		/* get confirmation first */
-		do
-		{
-			key = getkey(0);
-		} while (key != '\\' && key != 'Z' && key != '\r'    /* good */
-		      && key != '\033');			     /* bad  */
-		if (key != '\033')
-		{
-			m = v_xit(m, 0L, 'Z');
-		}
-		break;
-
-	  case 10: /* undo previous */
-		m = v_undo(m);
-		dfltsel = 9;
-		break;
-	}
-
-	/* arrange for the menu to be erased (except that "chg from kbd"
-	 * already erased it, and "save & exit" doesn't care)
-	 */
-	if (sel != 5 && sel != 9)
-		redraw(MARK_UNSET, FALSE);
-
-	return m;
-}
-#endif /* undef NO_POPUP */
Index: trunk/minix/commands/elvis/vi.c
===================================================================
--- trunk/minix/commands/elvis/vi.c	(revision 9)
+++ 	(revision )
@@ -1,815 +1,0 @@
-/* vi.c */
-
-/* Author:
- *	Steve Kirkendall
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-
-#include "config.h"
-#include "ctype.h"
-#include "vi.h"
-
-
-
-/* This array describes what each key does */
-#define NO_FUNC		(MARK (*)())0
-
-#define NO_ARGS		0
-#define CURSOR		1
-#define CURSOR_CNT_KEY	2
-#define CURSOR_MOVED	3
-#define CURSOR_EOL	4
-#define ZERO		5
-#define DIGIT		6
-#define CURSOR_TEXT	7
-#define KEYWORD		8
-#define ARGSMASK	0x0f
-#define	C_C_K_REP1	(CURSOR_CNT_KEY | 0x10)
-#define C_C_K_CUT	(CURSOR_CNT_KEY | 0x20)
-#define C_C_K_MARK	(CURSOR_CNT_KEY | 0x30)
-#define C_C_K_CHAR	(CURSOR_CNT_KEY | 0x40)
-#ifndef NO_SHOWMODE
-static int keymodes[] = {0, WHEN_REP1, WHEN_CUT, WHEN_MARK, WHEN_CHAR};
-# define KEYMODE(args) (keymodes[(args) >> 4])
-#else
-# define KEYMODE(args) 0
-#endif
-
-static struct keystru
-{
-	MARK	(*func)();	/* the function to run */
-	uchar	args;		/* description of the args needed */
-#ifndef NO_VISIBLE
-	short	flags;
-#else
-	uchar	flags;		/* other stuff */
-#endif
-}
-	vikeys[] =
-{
-/* NUL not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#ifndef NO_EXTENSIONS
-/* ^A  find cursor word */	{m_wsrch,	KEYWORD,	MVMT|NREL|VIZ},
-#else
-/* ^A  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/* ^B  page backward	*/	{m_scroll,	CURSOR,		FRNT|VIZ},
-/* ^C  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^D  scroll dn 1/2page*/	{m_scroll,	CURSOR,		NCOL|VIZ},
-/* ^E  scroll up	*/	{m_scroll,	CURSOR,		NCOL|VIZ},
-/* ^F  page forward	*/	{m_scroll,	CURSOR,		FRNT|VIZ},
-/* ^G  show file status	*/	{v_status,	NO_ARGS, 	NO_FLAGS},
-/* ^H  move left, like h*/	{m_left,	CURSOR,		MVMT|VIZ},
-/* ^I  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^J  move down	*/	{m_updnto,	CURSOR,		MVMT|LNMD|VIZ|INCL},
-/* ^K  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^L  redraw screen	*/	{v_redraw,	NO_ARGS,	NO_FLAGS|VIZ},
-/* ^M  mv front next ln */	{m_updnto,	CURSOR,		MVMT|FRNT|LNMD|VIZ|INCL},
-/* ^N  move down	*/	{m_updnto,	CURSOR,		MVMT|LNMD|VIZ|INCL|NCOL},
-/* ^O  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^P  move up		*/	{m_updnto,	CURSOR,		MVMT|LNMD|VIZ|INCL|NCOL},
-/* ^Q  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^R  redraw screen	*/	{v_redraw,	NO_ARGS,	NO_FLAGS|VIZ},
-/* ^S  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^T  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^U  scroll up 1/2page*/	{m_scroll,	CURSOR,		NCOL|VIZ},
-/* ^V  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^W  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^X  move to phys col	*/	{m_tocol,	CURSOR,		MVMT|NREL|VIZ},
-/* ^Y  scroll down	*/	{m_scroll,	CURSOR,		NCOL|VIZ},
-#ifdef SIGTSTP
-/* ^Z  suspend elvis	*/	{v_suspend,	NO_ARGS,	NO_FLAGS},
-#else
-/* ^Z  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/* ESC not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^\  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* ^]  keyword is tag	*/	{v_tag,		KEYWORD,	NO_FLAGS},
-/* ^^  previous file	*/	{v_switch,	CURSOR,		NO_FLAGS},
-/* ^_  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/* SPC move right,like l*/	{m_right,	CURSOR,		MVMT|INCL|VIZ},
-/*  !  run thru filter	*/	{v_filter,	CURSOR_MOVED,	FRNT|LNMD|INCL|VIZ},
-/*  "  select cut buffer*/	{v_selcut,	C_C_K_CUT,	PTMV|VIZ},
-#ifndef NO_EXTENSIONS
-/*  #  increment number	*/	{v_increment,	KEYWORD,	SDOT},
-#else
-/*  #  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  $  move to rear	*/	{m_rear,	CURSOR,		MVMT|INCL|VIZ},
-/*  %  move to match	*/	{m_match,	CURSOR,		MVMT|INCL|VIZ},
-/*  &  repeat subst	*/	{v_again,	CURSOR_MOVED,	SDOT|NCOL|LNMD|INCL},
-/*  '  move to a mark	*/	{m_tomark,	C_C_K_MARK,	MVMT|FRNT|NREL|LNMD|INCL|VIZ},
-#ifndef NO_SENTENCE
-/*  (  mv back sentence	*/	{m_sentence,	CURSOR,		MVMT|VIZ},
-/*  )  mv fwd sentence	*/	{m_sentence,	CURSOR,		MVMT|VIZ},
-#else
-/*  (  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/*  )  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-#ifndef NO_ERRLIST
-/*  *  errlist		*/	{v_errlist,	CURSOR,		FRNT|NREL},
-#else
-/*  *  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  +  mv front next ln */	{m_updnto,	CURSOR,		MVMT|FRNT|LNMD|VIZ|INCL},
-#ifndef NO_CHARSEARCH
-/*  ,  reverse [fFtT] cmd*/	{m__ch,		CURSOR,		MVMT|INCL|VIZ},
-#else
-/*  ,  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  -  mv front prev ln	*/	{m_updnto,	CURSOR,		MVMT|FRNT|LNMD|VIZ|INCL},
-/*  .  special...	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/*  /  forward search	*/	{m_fsrch,	CURSOR_TEXT,	MVMT|NREL|VIZ},
-/*  0  part of count?	*/	{NO_FUNC,	ZERO,		MVMT|PTMV|VIZ},
-/*  1  part of count	*/	{NO_FUNC,	DIGIT,		PTMV|VIZ},
-/*  2  part of count	*/	{NO_FUNC,	DIGIT,		PTMV|VIZ},
-/*  3  part of count	*/	{NO_FUNC,	DIGIT,		PTMV|VIZ},
-/*  4  part of count	*/	{NO_FUNC,	DIGIT,		PTMV|VIZ},
-/*  5  part of count	*/	{NO_FUNC,	DIGIT,		PTMV|VIZ},
-/*  6  part of count	*/	{NO_FUNC,	DIGIT,		PTMV|VIZ},
-/*  7  part of count	*/	{NO_FUNC,	DIGIT,		PTMV|VIZ},
-/*  8  part of count	*/	{NO_FUNC,	DIGIT,		PTMV|VIZ},
-/*  9  part of count	*/	{NO_FUNC,	DIGIT,		PTMV|VIZ},
-/*  :  run single EX cmd*/	{v_1ex,		CURSOR_TEXT,	NO_FLAGS},
-#ifndef NO_CHARSEARCH
-/*  ;  repeat [fFtT] cmd*/	{m__ch,		CURSOR,		MVMT|INCL|VIZ},
-#else
-/*  ;  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS|VIZ},
-#endif
-/*  <  shift text left	*/	{v_lshift,	CURSOR_MOVED,	SDOT|FRNT|LNMD|INCL|VIZ},
-/*  =  preset filter	*/	{v_reformat,	CURSOR_MOVED,	SDOT|FRNT|LNMD|INCL|VIZ},
-/*  >  shift text right	*/	{v_rshift,	CURSOR_MOVED,	SDOT|FRNT|LNMD|INCL|VIZ},
-/*  ?  backward search	*/	{m_bsrch,	CURSOR_TEXT,	MVMT|NREL|VIZ},
-#ifndef NO_AT
-/*  @  execute a cutbuf */	{v_at,		C_C_K_CUT,	NO_FLAGS},
-#else
-/*  @  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  A  append at EOL	*/	{v_insert,	CURSOR,		SDOT},
-/*  B  move back Word	*/	{m_bword,	CURSOR,		MVMT|VIZ},
-/*  C  change to EOL	*/	{v_change,	CURSOR_EOL,	SDOT},
-/*  D  delete to EOL	*/	{v_delete,	CURSOR_EOL,	SDOT},
-/*  E  move end of Word	*/	{m_eword,	CURSOR,		MVMT|INCL|VIZ},
-#ifndef NO_CHARSEARCH
-/*  F  move bk to char	*/	{m_Fch,		C_C_K_CHAR,	MVMT|INCL|VIZ},
-#else
-/*  F  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  G  move to line #	*/	{m_updnto,	CURSOR,		MVMT|NREL|LNMD|FRNT|INCL|VIZ},
-/*  H  move to row	*/	{m_row,		CURSOR,		MVMT|LNMD|FRNT|VIZ|INCL},
-/*  I  insert at front	*/	{v_insert,	CURSOR,		SDOT},
-/*  J  join lines	*/	{v_join,	CURSOR,		SDOT},
-#ifndef NO_EXTENSIONS
-/*  K  look up keyword	*/	{v_keyword,	KEYWORD,	NO_FLAGS},
-#else
-/*  K  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  L  move to last row	*/	{m_row,		CURSOR,		MVMT|LNMD|FRNT|VIZ|INCL},
-/*  M  move to mid row	*/	{m_row,		CURSOR,		MVMT|LNMD|FRNT|VIZ|INCL},
-/*  N  reverse prev srch*/	{m_Nsrch,	CURSOR,		MVMT|NREL|VIZ},
-/*  O  insert above line*/	{v_insert,	CURSOR,		SDOT},
-/*  P  paste before	*/	{v_paste,	CURSOR,		SDOT},
-/*  Q  quit to EX mode	*/	{v_quit,	NO_ARGS,	NO_FLAGS},
-/*  R  overtype		*/	{v_overtype,	CURSOR,		SDOT},
-/*  S  change line	*/	{v_change,	CURSOR_MOVED,	SDOT},
-#ifndef NO_CHARSEARCH
-/*  T  move bk to char	*/	{m_Tch,		C_C_K_CHAR,	MVMT|INCL|VIZ},
-#else
-/*  T  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  U  undo whole line	*/	{v_undoline,	CURSOR,		FRNT},
-#ifndef NO_VISIBLE
-/*  V  start visible	*/	{v_start,	CURSOR,		INCL|LNMD|VIZ},
-#else
-/*  V  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  W  move forward Word*/	{m_fword,	CURSOR,		MVMT|INCL|VIZ},
-/*  X  delete to left	*/	{v_xchar,	CURSOR,		SDOT},
-/*  Y  yank text	*/	{v_yank,	CURSOR_MOVED,	NCOL},
-/*  Z  save file & exit	*/	{v_xit,		CURSOR_CNT_KEY,	NO_FLAGS},
-/*  [  move back section*/	{m_paragraph,	CURSOR,		MVMT|LNMD|NREL|VIZ},
-#ifndef NO_POPUP
-/*  \  pop-up menu	*/	{v_popup,	CURSOR_MOVED,	VIZ},
-#else
-/*  \  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  ]  move fwd section */	{m_paragraph,	CURSOR,		MVMT|LNMD|NREL|VIZ},
-/*  ^  move to front	*/	{m_front,	CURSOR,		MVMT|VIZ},
-/*  _  current line	*/	{m_updnto,	CURSOR,		MVMT|LNMD|FRNT|INCL},
-/*  `  move to mark	*/	{m_tomark,	C_C_K_MARK,	MVMT|NREL|VIZ},
-/*  a  append at cursor	*/	{v_insert,	CURSOR,		SDOT},
-/*  b  move back word	*/	{m_bword,	CURSOR,		MVMT|VIZ},
-/*  c  change text	*/	{v_change,	CURSOR_MOVED,	SDOT|VIZ},
-/*  d  delete op	*/	{v_delete,	CURSOR_MOVED,	SDOT|VIZ},
-/*  e  move end word	*/	{m_eword,	CURSOR,		MVMT|INCL|VIZ},
-#ifndef NO_CHARSEARCH
-/*  f  move fwd for char*/	{m_fch,		C_C_K_CHAR,	MVMT|INCL|VIZ},
-#else
-/*  f  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  g  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/*  h  move left	*/	{m_left,	CURSOR,		MVMT|VIZ},
-/*  i  insert at cursor	*/	{v_insert,	CURSOR,		SDOT},
-/*  j  move down	*/	{m_updnto,	CURSOR,		MVMT|NCOL|LNMD|VIZ|INCL},
-/*  k  move up		*/	{m_updnto,	CURSOR,		MVMT|NCOL|LNMD|VIZ|INCL},
-/*  l  move right	*/	{m_right,	CURSOR,		MVMT|INCL|VIZ},
-/*  m  define a mark	*/	{v_mark,	C_C_K_MARK,	NO_FLAGS},
-/*  n  repeat prev srch	*/	{m_nsrch,	CURSOR, 	MVMT|NREL|VIZ},
-/*  o  insert below line*/	{v_insert,	CURSOR,		SDOT},
-/*  p  paste after	*/	{v_paste,	CURSOR,		SDOT},
-/*  q  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-/*  r  replace chars	*/	{v_replace,	C_C_K_REP1,	SDOT},
-/*  s  subst N chars	*/	{v_subst,	CURSOR,		SDOT},
-#ifndef NO_CHARSEARCH
-/*  t  move fwd to char	*/	{m_tch,		C_C_K_CHAR,	MVMT|INCL|VIZ},
-#else
-/*  t  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  u  undo		*/	{v_undo,	CURSOR,		NO_FLAGS},
-#ifndef NO_VISIBLE
-/*  v  start visible	*/	{v_start,	CURSOR,		INCL|VIZ},
-#else
-/*  v  not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS},
-#endif
-/*  w  move fwd word	*/	{m_fword,	CURSOR,		MVMT|INCL|VIZ},
-/*  x  delete character	*/	{v_xchar,	CURSOR,		SDOT},
-/*  y  yank text	*/	{v_yank,	CURSOR_MOVED,	NCOL|VIZ},
-/*  z  adjust scrn row	*/	{m_z, 		CURSOR_CNT_KEY,	NCOL|VIZ},
-/*  {  back paragraph	*/	{m_paragraph,	CURSOR,		MVMT|LNMD|VIZ},
-/*  |  move to column	*/	{m_tocol,	CURSOR,		MVMT|NREL|VIZ},
-/*  }  fwd paragraph	*/	{m_paragraph,	CURSOR,		MVMT|LNMD|VIZ},
-/*  ~  upper/lowercase	*/	{v_ulcase,	CURSOR,		SDOT},
-/* DEL not defined	*/	{NO_FUNC,	NO_ARGS,	NO_FLAGS}
-};
-
-
-
-void vi()
-{
-	REG int			key;	/* keystroke from user */
-	long			count;	/* numeric argument to some functions */
-	REG struct keystru	*keyptr;/* pointer to vikeys[] element */
-	MARK			tcurs;	/* temporary cursor */
-	int			prevkey;/* previous key, if d/c/y/</>/! */
-	MARK			range;	/* start of range for d/c/y/</>/! */
-	char			text[132];
-	int			dotkey;	/* last "key" of a change */
-	int			dotpkey;/* last "prevkey" of a change */
-	int			dotkey2;/* last extra "getkey()" of a change */
-	int			dotcnt;	/* last "count" of a change */
-	int			firstkey;
-	REG int			i;
-
-	/* tell the redraw() function to start from scratch */
-	redraw(MARK_UNSET, FALSE);
-
-#ifdef lint
-	/* lint says that "range" might be used before it is set.  This
-	 * can't really happen due to the way "range" and "prevkey" are used,
-	 * but lint doesn't know that.  This line is here ONLY to keep lint
-	 * happy.
-	 */
-	range = 0L;
-#endif
-
-	/* safeguard against '.' with no previous command */
-	dotkey = dotpkey = dotkey2 = dotcnt = 0;
-
-	/* go immediately into insert mode, if ":set inputmode" */
-	firstkey = 0;
-#ifndef NO_EXTENSIONS
-	if (*o_inputmode)
-	{
-		firstkey = 'i';
-	}
-#endif
-
-	/* Repeatedly handle VI commands */
-	for (count = 0, prevkey = '\0'; mode == MODE_VI; )
-	{
-		/* if we've moved off the undoable line, then we can't undo it at all */
-		if (markline(cursor) != U_line)
-		{
-			U_line = 0L;
-		}
-
-		/* report any changes from the previous command */
-		if (rptlines >= *o_report)
-		{
-			redraw(cursor, FALSE);
-			msg("%ld line%s %s", rptlines, (rptlines==1?"":"s"), rptlabel);
-		}
-		rptlines = 0L;
-
-		/* get the next command key.  It must be ASCII */
-		if (firstkey)
-		{
-			key = firstkey;
-			firstkey = 0;
-		}
-		else
-		{
-			do
-			{
-				key = getkey(WHEN_VICMD);
-			} while (key < 0 || key > 127);
-		}
-
-		/* Convert a doubled-up operator such as "dd" into "d_" */
-		if (prevkey && key == prevkey)
-		{
-			key = '_';
-		}
-
-		/* look up the structure describing this command */
-		keyptr = &vikeys[key];
-
-		/* '&' and uppercase operators always act like doubled */
-		if (!prevkey && keyptr->args == CURSOR_MOVED
-			&& (key == '&' || isupper(key)))
-		{
-			range = cursor;
-			prevkey = key;
-			key = '_';
-			keyptr = &vikeys[key];
-		}
-
-#ifndef NO_VISIBLE
-		/* if we're in the middle of a v/V command, reject commands
-		 * that aren't operators or movement commands
-		 */
-		if (V_from && !(keyptr->flags & VIZ))
-		{
-			beep();
-			prevkey = 0;
-			count = 0;
-			continue;
-		}
-#endif
-
-		/* if we're in the middle of a d/c/y/</>/! command, reject
-		 * anything but movement.
-		 */
-		if (prevkey && !(keyptr->flags & (MVMT|PTMV)))
-		{
-			beep();
-			prevkey = 0;
-			count = 0;
-			continue;
-		}
-
-		/* set the "dot" variables, if we're supposed to */
-		if (((keyptr->flags & SDOT)
-			|| (prevkey && vikeys[prevkey].flags & SDOT))
-#ifndef NO_VISIBLE
-		    && !V_from
-#endif
-		)
-		{
-			dotkey = key;
-			dotpkey = prevkey;
-			dotkey2 = '\0';
-			dotcnt = count;
-
-			/* remember the line before any changes are made */
-			if (U_line != markline(cursor))
-			{
-				U_line = markline(cursor);
-				strcpy(U_text, fetchline(U_line));
-			}
-		}
-
-		/* if this is "." then set other vars from the "dot" vars */
-		if (key == '.')
-		{
-			key = dotkey;
-			keyptr = &vikeys[key];
-			prevkey = dotpkey;
-			if (prevkey)
-			{
-				range = cursor;
-			}
-			if (count == 0)
-			{
-				count = dotcnt;
-			}
-			doingdot = TRUE;
-
-			/* remember the line before any changes are made */
-			if (U_line != markline(cursor))
-			{
-				U_line = markline(cursor);
-				strcpy(U_text, fetchline(U_line));
-			}
-		}
-		else
-		{
-			doingdot = FALSE;
-		}
-
-		/* process the key as a command */
-		tcurs = cursor;
-		force_flags = NO_FLAGS;
-		switch (keyptr->args & ARGSMASK)
-		{
-		  case ZERO:
-			if (count == 0)
-			{
-				tcurs = cursor & ~(BLKSIZE - 1);
-				break;
-			}
-			/* else fall through & treat like other digits... */
-
-		  case DIGIT:
-			count = count * 10 + key - '0';
-			break;
-
-		  case KEYWORD:
-			/* if not on a keyword, fail */
-			pfetch(markline(cursor));
-			key = markidx(cursor);
-			if (!isalnum(ptext[key]))
-			{
-				tcurs = MARK_UNSET;
-				break;
-			}
-
-			/* find the start of the keyword */
-			while (key > 0 && isalnum(ptext[key - 1]))
-			{
-				key--;
-			}
-			tcurs = (cursor & ~(BLKSIZE - 1)) + key;
-
-			/* copy it into a buffer, and NUL-terminate it */
-			i = 0;
-			do
-			{
-				text[i++] = ptext[key++];
-			} while (isalnum(ptext[key]));
-			text[i] = '\0';
-
-			/* call the function */
-			tcurs = (*keyptr->func)(text, tcurs, count);
-			count = 0L;
-			break;
-
-		  case NO_ARGS:
-			if (keyptr->func)
-			{
-				(*keyptr->func)();
-			}
-			else
-			{
-				beep();
-			}
-			count = 0L;
-			break;
-	
-		  case CURSOR:
-			tcurs = (*keyptr->func)(cursor, count, key, prevkey);
-			count = 0L;
-			break;
-
-		  case CURSOR_CNT_KEY:
-			if (doingdot)
-			{
-				tcurs = (*keyptr->func)(cursor, count, dotkey2);
-			}
-			else
-			{
-				/* get a key */
-				i = getkey(KEYMODE(keyptr->args));
-				if (i == '\033') /* ESC */
-				{
-					count = 0;
-					tcurs = MARK_UNSET;
-					break; /* exit from "case CURSOR_CNT_KEY" */
-				}
-				else if (i == ctrl('V'))
-				{
-					i = getkey(0);
-				}
-
-				/* if part of an SDOT command, remember it */
-				 if (keyptr->flags & SDOT
-				 || (prevkey && vikeys[prevkey].flags & SDOT))
-				{
-					dotkey2 = i;
-				}
-
-				/* do it */
-				tcurs = (*keyptr->func)(cursor, count, i);
-			}
-			count = 0L;
-			break;
-	
-		  case CURSOR_MOVED:
-#ifndef NO_VISIBLE
-			if (V_from)
-			{
-				range = cursor;
-				tcurs = V_from;
-				count = 0L;
-				prevkey = key;
-				key = (V_linemd ? 'V' : 'v');
-				keyptr = &vikeys[key];
-			}
-			else
-#endif
-			{
-				prevkey = key;
-				range = cursor;
-				force_flags = LNMD|INCL;
-			}
-			break;
-
-		  case CURSOR_EOL:
-			prevkey = key;
-			/* a zero-length line needs special treatment */
-			pfetch(markline(cursor));
-			if (plen == 0)
-			{
-				/* act on a zero-length section of text */
-				range = tcurs = cursor;
-				key = '0';
-			}
-			else
-			{
-				/* act like CURSOR_MOVED with '$' movement */
-				range = cursor;
-				tcurs = m_rear(cursor, 1L);
-				key = '$';
-			}
-			count = 0L;
-			keyptr = &vikeys[key];
-			break;
-
-		  case CURSOR_TEXT:
-		  	do
-		  	{	
-				text[0] = key;
-				if (vgets(key, text + 1, sizeof text - 1) >= 0)
-				{
-					/* reassure user that <CR> was hit */
-					qaddch('\r');
-					refresh();
-
-					/* call the function with the text */
-					tcurs = (*keyptr->func)(cursor, text);
-				}
-				else
-				{
-					if (exwrote || mode == MODE_COLON)
-					{
-						redraw(MARK_UNSET, FALSE);
-					}
-					mode = MODE_VI;
-				}
-			} while (mode == MODE_COLON);
-			count = 0L;
-			break;
-		}
-
-		/* if that command took us out of vi mode, then exit the loop
-		 * NOW, without tweaking the cursor or anything.  This is very
-		 * important when mode == MODE_QUIT.
-		 */
-		if (mode != MODE_VI)
-		{
-			break;
-		}
-
-		/* now move the cursor, as appropriate */
-		if (keyptr->args == CURSOR_MOVED)
-		{
-			/* the < and > keys have FRNT,
-			 * but it shouldn't be applied yet
-			 */
-			tcurs = adjmove(cursor, tcurs, 0);
-		}
-		else
-		{
-			tcurs = adjmove(cursor, tcurs, (int)keyptr->flags | force_flags);
-		}
-
-		/* was that the end of a d/c/y/</>/! command? */
-		if (prevkey && ((keyptr->flags & MVMT)
-#ifndef NO_VISIBLE
-					       || V_from
-#endif
-				) && count == 0L)
-		{
-#ifndef NO_VISIBLE
-			/* turn off the hilight */
-			V_from = 0L;
-#endif
-
-			/* if the movement command failed, cancel operation */
-			if (tcurs == MARK_UNSET)
-			{
-				prevkey = 0;
-				count = 0;
-				continue;
-			}
-
-			/* make sure range=front and tcurs=rear.  Either way,
-			 * leave cursor=range since that's where we started.
-			 */
-			cursor = range;
-			if (tcurs < range)
-			{
-				range = tcurs;
-				tcurs = cursor;
-			}
-
-			/* The 'w' and 'W' destinations should never take us
-			 * to the front of a line.  Instead, they should take
-			 * us only to the end of the preceding line.
-			 */
-			if ((keyptr->flags & (MVMT|NREL|LNMD|FRNT|INCL)) == MVMT
-			  && markline(range) < markline(tcurs)
-			  && (markline(tcurs) > nlines || tcurs == m_front(tcurs, 0L)))
-			{
-				tcurs = (tcurs & ~(BLKSIZE - 1)) - BLKSIZE;
-				pfetch(markline(tcurs));
-				tcurs += plen;
-			}
-
-			/* adjust for line mode & inclusion of last char/line */
-			i = (keyptr->flags | vikeys[prevkey].flags);
-			switch ((i | force_flags) & (INCL|LNMD))
-			{
-			  case INCL:
-				tcurs++;
-				break;
-
-			  case INCL|LNMD:
-				tcurs += BLKSIZE;
-				/* fall through... */
-
-			  case LNMD:
-				range &= ~(BLKSIZE - 1);
-				tcurs &= ~(BLKSIZE - 1);
-				break;
-			}
-
-			/* run the function */
-			tcurs = (*vikeys[prevkey].func)(range, tcurs);
-			if (mode == MODE_VI)
-			{
-				(void)adjmove(cursor, cursor, 0);
-				cursor = adjmove(cursor, tcurs, (int)vikeys[prevkey].flags);
-			}
-
-			/* cleanup */
-			prevkey = 0;
-		}
-		else if (!prevkey)
-		{
-			if (tcurs != MARK_UNSET)
-				cursor = tcurs;
-		}
-	}
-}
-
-/* This function adjusts the MARK value that they return; here we make sure
- * it isn't past the end of the line, and that the column hasn't been
- * *accidentally* changed.
- */
-MARK adjmove(old, new, flags)
-	MARK		old;	/* the cursor position before the command */
-	REG MARK	new;	/* the cursor position after the command */
-	int		flags;	/* various flags regarding cursor mvmt */
-{
-	static int	colno;	/* the column number that we want */
-	REG char	*text;	/* used to scan through the line's text */
-	REG int		i;
-
-#ifdef DEBUG
-	watch();
-#endif
-
-	/* if the command failed, bag it! */
-	if (new == MARK_UNSET)
-	{
-		beep();
-		return old;
-	}
-
-	/* if this is a non-relative movement, set the '' mark */
-	if (flags & NREL)
-	{
-		mark[26] = old;
-	}
-
-	/* make sure it isn't past the end of the file */
-	if (markline(new) < 1)
-	{
-		new = MARK_FIRST;
-	}
-	else if (markline(new) > nlines)
-	{
-		new = MARK_LAST;
-	}
-
-	/* fetch the new line */
-	pfetch(markline(new));
-
-	/* move to the front, if we're supposed to */
-	if (flags & FRNT)
-	{
-		new = m_front(new, 1L);
-	}
-
-	/* change the column#, or change the mark to suit the column# */
-	if (!(flags & NCOL))
-	{
-		/* change the column# */
-		i = markidx(new);
-		if (i == BLKSIZE - 1)
-		{
-			new &= ~(BLKSIZE - 1);
-			if (plen > 0)
-			{
-				new += plen - 1;
-			}
-			colno = BLKSIZE * 8; /* one heck of a big colno */
-		}
-		else if (plen > 0)
-		{
-			if (i >= plen)
-			{
-				new = (new & ~(BLKSIZE - 1)) + plen - 1;
-			}
-			colno = idx2col(new, ptext, FALSE);
-		}
-		else
-		{
-			new &= ~(BLKSIZE - 1);
-			colno = 0;
-		}
-	}
-	else
-	{
-		/* adjust the mark to get as close as possible to column# */
-		for (i = 0, text = ptext; i <= colno && *text; text++)
-		{
-			if (*text == '\t' && !*o_list)
-			{
-				i += *o_tabstop - (i % *o_tabstop);
-			}
-			else if (UCHAR(*text) < ' ' || *text == 127)
-			{
-				i += 2;
-			}
-#ifndef NO_CHARATTR
-			else if (*o_charattr && text[0] == '\\' && text[1] == 'f' && text[2])
-			{
-				text += 2; /* plus one more in "for()" stmt */
-			}
-#endif
-			else
-			{
-				i++;
-			}
-		}
-		if (text > ptext)
-		{
-			text--;
-		}
-		new = (new & ~(BLKSIZE - 1)) + (int)(text - ptext);
-	}
-
-	return new;
-}
-
-
-#ifdef DEBUG
-watch()
-{
-	static wasset;
-
-	if (*origname)
-	{
-		wasset = TRUE;
-	}
-	else if (wasset)
-	{
-		mode = MODE_EX;
-		msg("origname was clobbered");
-		endwin();
-		abort();
-	}
-
-	if (wasset && nlines == 0)
-	{
-		mode = MODE_EX;
-		msg("nlines=0");
-		endwin();
-		abort();
-	}
-}
-#endif
Index: trunk/minix/commands/elvis/vi.h
===================================================================
--- trunk/minix/commands/elvis/vi.h	(revision 9)
+++ 	(revision )
@@ -1,596 +1,0 @@
-/* vi.h */
-
-/* Author:
- *	Steve Kirkendall
- *	14407 SW Teal Blvd. #C
- *	Beaverton, OR 97005
- *	kirkenda@cs.pdx.edu
- */
-
-#define VERSION "ELVIS 1.5, by Steve Kirkendall (23 March 1992)"
-#define COPYING	"This version of ELVIS is freely redistributable."
-
-#include <errno.h>
-extern int errno;
-#if TOS && !defined(__GNUC__)
-#define ENOENT (-AEFILNF)
-#endif
-
-#if TOS || VMS
-# include <types.h>
-# define O_RDONLY	0
-# define O_WRONLY	1
-# define O_RDWR		2
-# ifdef __GNUC__
-#  define S_IJDIR	S_IFDIR
-# endif
-#else
-# if OSK
-#  include <modes.h>
-#  define O_RDONLY	S_IREAD
-#  define O_WRONLY	S_IWRITE
-#  define O_RDWR	(S_IREAD | S_IWRITE)
-#  define ENOENT	E_PNNF
-#  define sprintf	Sprintf
-# else
-#  include <sys/types.h>
-#  if COHERENT
-#   include <sys/fcntl.h>
-#  else
-#   include <fcntl.h>
-#  endif
-# endif
-#endif
-
-#ifndef O_BINARY
-# define O_BINARY	0
-#endif
-
-#include "curses.h"
-
-#include <signal.h>
-
-/*------------------------------------------------------------------------*/
-/* Miscellaneous constants.						  */
-
-#define INFINITY	2000000001L	/* a very large integer */
-#define LONGKEY		10		/* longest possible raw :map key */
-#ifndef MAXRCLEN
-# define MAXRCLEN	1000		/* longest possible :@ command */
-#endif
-
-/*------------------------------------------------------------------------*/
-/* These describe how temporary files are divided into blocks             */
-
-#define MAXBLKS	(BLKSIZE / sizeof(unsigned short))
-typedef union
-{
-	char		c[BLKSIZE];	/* for text blocks */
-	unsigned short	n[MAXBLKS];	/* for the header block */
-}
-	BLK;
-
-/*------------------------------------------------------------------------*/
-/* These are used manipulate BLK buffers.                                 */
-
-extern BLK	hdr;		/* buffer for the header block */
-extern BLK	*blkget();	/* given index into hdr.c[], reads block */
-extern BLK	*blkadd();	/* inserts a new block into hdr.c[] */
-
-/*------------------------------------------------------------------------*/
-/* These are used to keep track of various flags                          */
-extern struct _viflags
-{
-	short	file;		/* file flags */
-}
-	viflags;
-
-/* file flags */
-#define NEWFILE		0x0001	/* the file was just created */
-#define READONLY	0x0002	/* the file is read-only */
-#define HADNUL		0x0004	/* the file contained NUL characters */
-#define MODIFIED	0x0008	/* the file has been modified, but not saved */
-#define NOFILE		0x0010	/* no name is known for the current text */
-#define ADDEDNL		0x0020	/* newlines were added to the file */
-#define HADBS		0x0040	/* backspace chars were lost from the file */
-#define UNDOABLE	0x0080	/* file has been modified */
-#define NOTEDITED	0x0100	/* the :file command has been used */
-
-/* macros used to set/clear/test flags */
-#define setflag(x,y)	viflags.x |= y
-#define clrflag(x,y)	viflags.x &= ~y
-#define tstflag(x,y)	(viflags.x & y)
-#define initflags()	viflags.file = 0;
-
-/* The options */
-extern char	o_autoindent[1];
-extern char	o_autoprint[1];
-extern char	o_autotab[1];
-extern char	o_autowrite[1];
-extern char	o_columns[3];
-extern char	o_directory[30];
-extern char	o_edcompatible[1];
-extern char	o_equalprg[80];
-extern char	o_errorbells[1];
-extern char	o_exrefresh[1];
-extern char	o_ignorecase[1];
-extern char	o_keytime[3];
-extern char	o_keywordprg[80];
-extern char	o_lines[3];
-extern char	o_list[1];
-extern char	o_number[1];
-extern char	o_readonly[1];
-extern char	o_remap[1];
-extern char	o_report[3];
-extern char	o_scroll[3];
-extern char	o_shell[60];
-extern char	o_shiftwidth[3];
-extern char	o_sidescroll[3];
-extern char	o_sync[1];
-extern char	o_tabstop[3];
-extern char	o_term[30];
-extern char	o_flash[1];
-extern char	o_warn[1];
-extern char	o_wrapscan[1];
-
-#ifndef CRUNCH
-extern char	o_beautify[1];
-extern char	o_exrc[1];
-extern char	o_mesg[1];
-extern char	o_more[1];
-extern char	o_novice[1];
-extern char	o_prompt[1];
-extern char	o_taglength[3];
-extern char	o_terse[1];
-extern char	o_window[3];
-extern char	o_wrapmargin[3];
-extern char	o_writeany[1];
-#endif
-
-#ifndef NO_ERRLIST
-extern char	o_cc[30];
-extern char	o_make[30];
-#endif
-
-#ifndef NO_CHARATTR
-extern char	o_charattr[1];
-#endif
-
-#ifndef NO_DIGRAPH
-extern char	o_digraph[1];
-extern char	o_flipcase[80];
-#endif
-
-#ifndef NO_SENTENCE
-extern char	o_hideformat[1];
-#endif
-
-#ifndef NO_EXTENSIONS
-extern char	o_inputmode[1];
-extern char	o_ruler[1];
-#endif
-
-#ifndef NO_MAGIC
-extern char	o_magic[1];
-#endif
-
-#ifndef NO_MODELINES
-extern char	o_modelines[1];
-#endif
-
-#ifndef NO_SENTENCE
-extern char	o_paragraphs[30];
-extern char	o_sections[30];
-#endif
-
-#if MSDOS
-extern char	o_pcbios[1];
-#endif
-
-#ifndef NO_SHOWMATCH
-extern char	o_showmatch[1];
-#endif
-
-#ifndef	NO_SHOWMODE
-extern char	o_smd[1];
-#endif
-
-/*------------------------------------------------------------------------*/
-/* These help support the single-line multi-change "undo" -- shift-U      */
-
-extern char	U_text[BLKSIZE];
-extern long	U_line;
-
-/*------------------------------------------------------------------------*/
-/* These are used to refer to places in the text 			  */
-
-typedef long	MARK;
-#define markline(x)	(long)((x) / BLKSIZE)
-#define markidx(x)	(int)((x) & (BLKSIZE - 1))
-#define MARK_UNSET	((MARK)0)
-#define MARK_FIRST	((MARK)BLKSIZE)
-#define MARK_LAST	((MARK)(nlines * BLKSIZE))
-#define MARK_AT_LINE(x)	((MARK)(x) * BLKSIZE)
-
-#define NMARKS	29
-extern MARK	mark[NMARKS];	/* marks a-z, plus mark ' and two temps */
-extern MARK	cursor;		/* mark where line is */
-
-/*------------------------------------------------------------------------*/
-/* These are used to keep track of the current & previous files.	  */
-
-extern long	origtime;	/* modification date&time of the current file */
-extern char	origname[256];	/* name of the current file */
-extern char	prevorig[256];	/* name of the preceding file */
-extern long	prevline;	/* line number from preceding file */
-
-/*------------------------------------------------------------------------*/
-/* misc housekeeping variables & functions				  */
-
-extern int	tmpfd;		/* fd used to access the tmp file */
-extern int	tmpnum;		/* counter used to generate unique filenames */
-extern long	lnum[MAXBLKS];	/* last line# of each block */
-extern long	nlines;		/* number of lines in the file */
-extern char	args[BLKSIZE];	/* file names given on the command line */
-extern int	argno;		/* the current element of args[] */
-extern int	nargs;		/* number of filenames in args */
-extern long	changes;	/* counts changes, to prohibit short-cuts */
-extern int	significant;	/* boolean: was a *REAL* change made? */
-extern BLK	tmpblk;		/* a block used to accumulate changes */
-extern long	topline;	/* file line number of top line */
-extern int	leftcol;	/* column number of left col */
-#define		botline	 (topline + LINES - 2)
-#define		rightcol (leftcol + COLS - (*o_number ? 9 : 1))
-extern int	physcol;	/* physical column number that cursor is on */
-extern int	physrow;	/* physical row number that cursor is on */
-extern int	exwrote;	/* used to detect verbose ex commands */
-extern int	doingdot;	/* boolean: are we doing the "." command? */
-extern int	doingglobal;	/* boolean: are doing a ":g" command? */
-extern long	rptlines;	/* number of lines affected by a command */
-extern char	*rptlabel;	/* description of how lines were affected */
-extern char	*fetchline();	/* read a given line from tmp file */
-extern char	*parseptrn();	/* isolate a regexp in a line */
-extern MARK	paste();	/* paste from cut buffer to a given point */
-extern char	*wildcard();	/* expand wildcards in filenames */
-extern MARK	input();	/* inserts characters from keyboard */
-extern char	*linespec();	/* finds the end of a /regexp/ string */
-#define		ctrl(ch) ((ch)&037)
-#ifndef NO_RECYCLE
-extern long	allocate();	/* allocate a free block of the tmp file */
-#endif
-extern int	trapint();	/* trap handler for SIGINT */
-extern int	deathtrap();	/* trap handler for deadly signals */
-extern void	blkdirty();	/* marks a block as being "dirty" */
-extern void	blkflush();	/* writes a single dirty block to the disk */
-extern void	blksync();	/* forces all "dirty" blocks to disk */
-extern void	blkinit();	/* resets the block cache to "empty" state */
-extern void	beep();		/* rings the terminal's bell */
-extern void	exrefresh();	/* writes text to the screen */
-extern void	msg();		/* writes a printf-style message to the screen */
-extern void	endmsgs();	/* if "manymsgs" is set, then scroll up 1 line */
-extern void	garbage();	/* reclaims any garbage blocks */
-extern void	redraw();	/* updates the screen after a change */
-extern void	resume_curses();/* puts the terminal in "cbreak" mode */
-extern void	beforedo();	/* saves current revision before a new change */
-extern void	afterdo();	/* marks end of a beforedo() change */
-extern void	abortdo();	/* like "afterdo()" followed by "undo()" */
-extern int	undo();		/* restores file to previous undo() */
-extern void	dumpkey();	/* lists key mappings to the screen */
-extern void	mapkey();	/* defines a new key mapping */
-extern void	savekeys();	/* lists key mappings to a file */
-extern void	redrawrange();	/* records clues from modify.c */
-extern void	cut();		/* saves text in a cut buffer */
-extern void	delete();	/* deletes text */
-extern void	add();		/* adds text */
-extern void	change();	/* deletes text, and then adds other text */
-extern void	cutswitch();	/* updates cut buffers when we switch files */
-extern void	do_abbr();	/* defines or lists abbreviations */
-extern void	do_digraph();	/* defines or lists digraphs */
-extern void	exstring();	/* execute a string as EX commands */
-extern void	dumpopts();
-extern void	setopts();
-extern void	saveopts();
-extern void	savedigs();
-extern void	saveabbr();
-extern void	savecolor();
-extern void	cutname();
-extern void	cutname();
-extern void	initopts();
-extern void	cutend();
-#ifndef CRUNCH
-extern int	wset;		/* boolean: has the "window" size been set? */
-#endif
-
-/*------------------------------------------------------------------------*/
-/* macros that are used as control structures                             */
-
-#define BeforeAfter(before, after) for((before),bavar=1;bavar;(after),bavar=0)
-#define ChangeText	BeforeAfter(beforedo(FALSE),afterdo())
-
-extern int	bavar;		/* used only in BeforeAfter macros */
-
-/*------------------------------------------------------------------------*/
-/* These are the movement commands.  Each accepts a mark for the starting */
-/* location & number and returns a mark for the destination.		  */
-
-extern MARK	m_updnto();		/* k j G */
-extern MARK	m_right();		/* h */
-extern MARK	m_left();		/* l */
-extern MARK	m_tocol();		/* | */
-extern MARK	m_front();		/* ^ */
-extern MARK	m_rear();		/* $ */
-extern MARK	m_fword();		/* w */
-extern MARK	m_bword();		/* b */
-extern MARK	m_eword();		/* e */
-extern MARK	m_paragraph();		/* { } [[ ]] */
-extern MARK	m_match();		/* % */
-#ifndef NO_SENTENCE
- extern MARK	m_sentence();		/* ( ) */
-#endif
-extern MARK	m_tomark();		/* 'm */
-#ifndef NO_EXTENSIONS
-extern MARK	m_wsrch();		/* ^A */
-#endif
-extern MARK	m_nsrch();		/* n */
-extern MARK	m_Nsrch();		/* N */
-extern MARK	m_fsrch();		/* /regexp */
-extern MARK	m_bsrch();		/* ?regexp */
-#ifndef NO_CHARSEARCH
- extern MARK	m__ch();		/* ; , */
- extern MARK	m_fch();		/* f */
- extern MARK	m_tch();		/* t */
- extern MARK	m_Fch();		/* F */
- extern MARK	m_Tch();		/* T */
-#endif
-extern MARK	m_row();		/* H L M */
-extern MARK	m_z();			/* z */
-extern MARK	m_scroll();		/* ^B ^F ^E ^Y ^U ^D */
-
-/* Some stuff that is used by movement functions... */
-
-extern MARK	adjmove();		/* a helper fn, used by move fns */
-
-/* This macro is used to set the default value of cnt */
-#define DEFAULT(val)	if (cnt < 1) cnt = (val)
-
-/* These are used to minimize calls to fetchline() */
-extern int	plen;	/* length of the line */
-extern long	pline;	/* line number that len refers to */
-extern long	pchgs;	/* "changes" level that len refers to */
-extern char	*ptext;	/* text of previous line, if valid */
-extern void	pfetch();
-extern char	digraph();
-
-/* This is used to build a MARK that corresponds to a specific point in the
- * line that was most recently pfetch'ed.
- */
-#define buildmark(text)	(MARK)(BLKSIZE * pline + (int)((text) - ptext))
-
-
-/*------------------------------------------------------------------------*/
-/* These are used to handle EX commands.				  */
-
-#define  CMD_NULL	0	/* NOT A VALID COMMAND */
-#define  CMD_ABBR	1	/* "define an abbreviation" */
-#define  CMD_ARGS	2	/* "show me the args" */
-#define  CMD_APPEND	3	/* "insert lines after this line" */
-#define  CMD_AT		4	/* "execute a cut buffer's contents via EX" */
-#define  CMD_BANG	5	/* "run a single shell command" */
-#define  CMD_CC		6	/* "run `cc` and then do CMD_ERRLIST" */
-#define  CMD_CD		7	/* "change directories" */
-#define  CMD_CHANGE	8	/* "change some lines" */
-#define	 CMD_COLOR	9	/* "change the default colors" */
-#define  CMD_COPY	10	/* "copy the selected text to a given place" */
-#define  CMD_DELETE	11	/* "delete the selected text" */
-#define  CMD_DIGRAPH	12	/* "add a digraph, or display them all" */
-#define  CMD_EDIT	13	/* "switch to a different file" */
-#define  CMD_EQUAL	14	/* "display a line number" */
-#define  CMD_ERRLIST	15	/* "locate the next error in a list" */
-#define  CMD_FILE	16	/* "show the file's status" */
-#define  CMD_GLOBAL	17	/* "globally search & do a command" */
-#define  CMD_INSERT	18	/* "insert lines before the current line" */
-#define  CMD_JOIN	19	/* "join the selected line & the one after" */
-#define  CMD_LIST	20	/* "print lines, making control chars visible" */
-#define  CMD_MAKE	21	/* "run `make` and then do CMD_ERRLIST" */
-#define  CMD_MAP	22	/* "adjust the keyboard map" */
-#define  CMD_MARK	23	/* "mark this line" */
-#define  CMD_MKEXRC	24	/* "make a .exrc file" */
-#define  CMD_MOVE	25	/* "move the selected text to a given place" */
-#define  CMD_NEXT	26	/* "switch to next file in args" */
-#define  CMD_NUMBER	27	/* "print lines from the file w/ line numbers" */
-#define  CMD_PRESERVE	28	/* "act as though vi crashed" */
-#define  CMD_PREVIOUS	29	/* "switch to the previous file in args" */
-#define  CMD_PRINT	30	/* "print the selected text" */
-#define  CMD_PUT	31	/* "insert any cut lines before this line" */
-#define  CMD_QUIT	32	/* "quit without writing the file" */
-#define  CMD_READ	33	/* "append the given file after this line */
-#define  CMD_RECOVER	34	/* "recover file after vi crashes" - USE -r FLAG */
-#define  CMD_REWIND	35	/* "rewind to first file" */
-#define  CMD_SET	36	/* "set a variable's value" */
-#define  CMD_SHELL	37	/* "run some lines through a command" */
-#define  CMD_SHIFTL	38	/* "shift lines left" */
-#define  CMD_SHIFTR	39	/* "shift lines right" */
-#define  CMD_SOURCE	40	/* "interpret a file's contents as ex commands" */
-#define  CMD_STOP	41	/* same as CMD_SUSPEND */
-#define  CMD_SUBAGAIN	42	/* "repeat the previous substitution" */
-#define  CMD_SUBSTITUTE	43	/* "substitute text in this line" */
-#define  CMD_SUSPEND	44	/* "suspend the vi session" */
-#define  CMD_TR		45	/* "transliterate chars in the selected lines" */
-#define  CMD_TAG	46	/* "go to a particular tag" */
-#define  CMD_UNABBR	47	/* "remove an abbreviation definition" */
-#define  CMD_UNDO	48	/* "undo the previous command" */
-#define  CMD_UNMAP	49	/* "remove a key sequence map */
-#define  CMD_VERSION	50	/* "describe which version this is" */
-#define  CMD_VGLOBAL	51	/* "apply a cmd to lines NOT containing an RE" */
-#define  CMD_VISUAL	52	/* "go into visual mode" */
-#define  CMD_WQUIT	53	/* "write this file out (any case) & quit" */
-#define  CMD_WRITE	54	/* "write the selected(?) text to a given file" */
-#define  CMD_XIT	55	/* "write this file out (if modified) & quit" */
-#define  CMD_YANK	56	/* "copy the selected text into the cut buffer" */
-#ifdef DEBUG
-# define CMD_DEBUG	57	/* access to internal data structures */
-# define CMD_VALIDATE	58	/* check for internal consistency */
-#endif
-typedef int CMD;
-
-extern void	ex();
-extern void	vi();
-extern void	doexcmd();
-
-extern void	cmd_append();
-extern void	cmd_args();
-#ifndef NO_AT
-extern void	cmd_at();
-#endif
-extern void	cmd_cd();
-#ifndef NO_COLOR
-extern void	cmd_color();
-#endif
-extern void	cmd_delete();
-#ifndef NO_DIGRAPH
-extern void	cmd_digraph();
-#endif
-extern void	cmd_edit();
-#ifndef NO_ERRLIST
-extern void	cmd_errlist();
-#endif
-extern void	cmd_file();
-extern void	cmd_global();
-extern void	cmd_join();
-extern void	cmd_mark();
-#ifndef NO_ERRLIST
-extern void	cmd_make();
-#endif
-extern void	cmd_map();
-#ifndef NO_MKEXRC
-extern void	cmd_mkexrc();
-#endif
-extern void	cmd_next();
-extern void	cmd_print();
-extern void	cmd_put();
-extern void	cmd_read();
-extern void	cmd_set();
-extern void	cmd_shell();
-extern void	cmd_shift();
-extern void	cmd_source();
-extern void	cmd_substitute();
-extern void	cmd_tag();
-extern void	cmd_undo();
-extern void	cmd_version();
-extern void	cmd_write();
-extern void	cmd_xit();
-extern void	cmd_move();
-#ifdef DEBUG
-extern void	cmd_debug();
-extern void	cmd_validate();
-#endif
-#ifdef SIGTSTP
-extern void	cmd_suspend();
-#endif
-
-/*----------------------------------------------------------------------*/
-/* These are used to handle VI commands 				*/
-
-extern MARK	v_1ex();	/* : */
-extern MARK	v_mark();	/* m */
-extern MARK	v_quit();	/* Q */
-extern MARK	v_redraw();	/* ^L ^R */
-extern MARK	v_ulcase();	/* ~ */
-extern MARK	v_undo();	/* u */
-extern MARK	v_xchar();	/* x X */
-extern MARK	v_replace();	/* r */
-extern MARK	v_overtype();	/* R */
-extern MARK	v_selcut();	/* " */
-extern MARK	v_paste();	/* p P */
-extern MARK	v_yank();	/* y Y */
-extern MARK	v_delete();	/* d D */
-extern MARK	v_join();	/* J */
-extern MARK	v_insert();	/* a A i I o O */
-extern MARK	v_change();	/* c C */
-extern MARK	v_subst();	/* s */
-extern MARK	v_lshift();	/* < */
-extern MARK	v_rshift();	/* > */
-extern MARK	v_reformat();	/* = */
-extern MARK	v_filter();	/* ! */
-extern MARK	v_status();	/* ^G */
-extern MARK	v_switch();	/* ^^ */
-extern MARK	v_tag();	/* ^] */
-extern MARK	v_xit();	/* ZZ */
-extern MARK	v_undoline();	/* U */
-extern MARK	v_again();	/* & */
-#ifndef NO_EXTENSIONS
- extern MARK	v_keyword();	/* K */
- extern MARK	v_increment();	/* * */
-#endif
-#ifndef NO_ERRLIST
- extern MARK	v_errlist();	/* * */
-#endif
-#ifndef NO_AT
- extern MARK	v_at();		/* @ */
-#endif
-#ifdef SIGTSTP
- extern MARK	v_suspend();	/* ^Z */
-#endif
-#ifndef NO_POPUP
- extern MARK	v_popup();	/* \ */
-#endif
-
-/*----------------------------------------------------------------------*/
-/* These flags describe the quirks of the individual visual commands */
-#define NO_FLAGS	0x00
-#define	MVMT		0x01	/* this is a movement command */
-#define PTMV		0x02	/* this can be *part* of a movement command */
-#define FRNT		0x04	/* after move, go to front of line */
-#define INCL		0x08	/* include last char when used with c/d/y */
-#define LNMD		0x10	/* use line mode of c/d/y */
-#define NCOL		0x20	/* this command can't change the column# */
-#define NREL		0x40	/* this is "non-relative" -- set the '' mark */
-#define SDOT		0x80	/* set the "dot" variables, for the "." cmd */
-#ifndef NO_VISIBLE
-# define VIZ		0x100	/* commands which can be used with 'v' */
-#else
-# define VIZ		0
-#endif
-
-/* This variable is zeroed before a command executes, and later ORed with the
- * command's flags after the command has been executed.  It is used to force
- * certain flags to be TRUE for *some* invocations of a particular command.
- * For example, "/regexp/+offset" forces the LNMD flag, and sometimes a "p"
- * or "P" command will force FRNT.
- */
-extern int	force_flags;
-
-/*----------------------------------------------------------------------*/
-/* These describe what mode we're in */
-
-#define MODE_EX		1	/* executing ex commands */
-#define	MODE_VI		2	/* executing vi commands */
-#define	MODE_COLON	3	/* executing an ex command from vi mode */
-#define	MODE_QUIT	4
-extern int	mode;
-
-#define WHEN_VICMD	1	/* getkey: we're reading a VI command */
-#define WHEN_VIINP	2	/* getkey: we're in VI's INPUT mode */
-#define WHEN_VIREP	4	/* getkey: we're in VI's REPLACE mode */
-#define WHEN_EX		8	/* getkey: we're in EX mode */
-#define WHEN_MSG	16	/* getkey: we're at a "more" prompt */
-#define WHEN_POPUP	32	/* getkey: we're in the pop-up menu */
-#define WHEN_REP1	64	/* getkey: we're getting a single char for 'r' */
-#define WHEN_CUT	128	/* getkey: we're getting a cut buffer name */
-#define WHEN_MARK	256	/* getkey: we're getting a mark name */
-#define WHEN_CHAR	512	/* getkey: we're getting a destination for f/F/t/T */
-#define WHEN_INMV	4096	/* in input mode, interpret the key in VICMD mode */
-#define WHEN_FREE	8192	/* free the keymap after doing it once */
-#define WHENMASK	(WHEN_VICMD|WHEN_VIINP|WHEN_VIREP|WHEN_REP1|WHEN_CUT|WHEN_MARK|WHEN_CHAR)
-
-#ifndef NO_VISIBLE
-extern MARK	V_from;
-extern int	V_linemd;
-extern MARK	v_start();
-#endif
-
-#ifdef DEBUG
-# define malloc(size)	dbmalloc(size, __FILE__, __LINE__)
-# define free(ptr)	dbfree(ptr, __FILE__, __LINE__)
-extern char *dbmalloc();
-#endif
