aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>2000-04-15 04:41:27 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>2000-04-15 04:41:27 +0000
commitc80476e4c3e6730697b9424f88dfa74d1907cabd (patch)
tree7679c440a91912ee9586cee3ebab24596c0fe1c4
downloadsrc-c80476e4c3e6730697b9424f88dfa74d1907cabd.tar.gz
src-c80476e4c3e6730697b9424f88dfa74d1907cabd.zip
Import the latest version of the 44BSD C-shell -- tcsh-6.09.vendor/tcsh/6.09
Notes
Notes: svn path=/vendor/tcsh/dist/; revision=59243 svn path=/vendor/tcsh/6.09/; revision=59245; tag=vendor/tcsh/6.09
-rw-r--r--contrib/tcsh/FAQ211
-rw-r--r--contrib/tcsh/Fixes1435
-rw-r--r--contrib/tcsh/Imakefile622
-rwxr-xr-xcontrib/tcsh/MAKEDIFFS41
-rwxr-xr-xcontrib/tcsh/MAKESHAR121
-rw-r--r--contrib/tcsh/Makefile.in628
-rw-r--r--contrib/tcsh/Makefile.std625
-rw-r--r--contrib/tcsh/Makefile.vms594
-rw-r--r--contrib/tcsh/NewThings169
-rw-r--r--contrib/tcsh/Ported1016
-rw-r--r--contrib/tcsh/README207
-rw-r--r--contrib/tcsh/README.imake9
-rw-r--r--contrib/tcsh/WishList40
-rw-r--r--contrib/tcsh/Y2K10
-rw-r--r--contrib/tcsh/complete.tcsh708
-rw-r--r--contrib/tcsh/config.h.in1
-rw-r--r--contrib/tcsh/config_f.h193
-rw-r--r--contrib/tcsh/csh-mode.el935
-rw-r--r--contrib/tcsh/ed.chared.c4005
-rw-r--r--contrib/tcsh/ed.decls.h274
-rw-r--r--contrib/tcsh/ed.defns.c1949
-rw-r--r--contrib/tcsh/ed.h254
-rw-r--r--contrib/tcsh/ed.init.c736
-rw-r--r--contrib/tcsh/ed.inputl.c903
-rw-r--r--contrib/tcsh/ed.refresh.c1317
-rw-r--r--contrib/tcsh/ed.screen.c1706
-rw-r--r--contrib/tcsh/ed.term.c1150
-rw-r--r--contrib/tcsh/ed.term.h492
-rw-r--r--contrib/tcsh/ed.xmap.c844
-rw-r--r--contrib/tcsh/eight-bit.me143
-rw-r--r--contrib/tcsh/gethost.c344
-rw-r--r--contrib/tcsh/glob.3326
-rw-r--r--contrib/tcsh/glob.c723
-rw-r--r--contrib/tcsh/glob.h71
-rw-r--r--contrib/tcsh/host.defs1121
-rw-r--r--contrib/tcsh/imake.config65
-rwxr-xr-xcontrib/tcsh/install-sh251
-rw-r--r--contrib/tcsh/ma.setp.c618
-rw-r--r--contrib/tcsh/mi.termios.c393
-rw-r--r--contrib/tcsh/mi.varargs.h15
-rw-r--r--contrib/tcsh/mi.wait.h44
-rw-r--r--contrib/tcsh/nls/C/set1140
-rw-r--r--contrib/tcsh/nls/C/set108
-rw-r--r--contrib/tcsh/nls/C/set1110
-rw-r--r--contrib/tcsh/nls/C/set124
-rw-r--r--contrib/tcsh/nls/C/set1313
-rw-r--r--contrib/tcsh/nls/C/set146
-rw-r--r--contrib/tcsh/nls/C/set157
-rw-r--r--contrib/tcsh/nls/C/set1613
-rw-r--r--contrib/tcsh/nls/C/set1716
-rw-r--r--contrib/tcsh/nls/C/set184
-rw-r--r--contrib/tcsh/nls/C/set1915
-rw-r--r--contrib/tcsh/nls/C/set2111
-rw-r--r--contrib/tcsh/nls/C/set2041
-rw-r--r--contrib/tcsh/nls/C/set215
-rw-r--r--contrib/tcsh/nls/C/set2217
-rw-r--r--contrib/tcsh/nls/C/set2334
-rw-r--r--contrib/tcsh/nls/C/set244
-rw-r--r--contrib/tcsh/nls/C/set256
-rw-r--r--contrib/tcsh/nls/C/set2615
-rw-r--r--contrib/tcsh/nls/C/set278
-rw-r--r--contrib/tcsh/nls/C/set294
-rw-r--r--contrib/tcsh/nls/C/set3117
-rw-r--r--contrib/tcsh/nls/C/set3016
-rw-r--r--contrib/tcsh/nls/C/set317
-rw-r--r--contrib/tcsh/nls/C/set445
-rw-r--r--contrib/tcsh/nls/C/set54
-rw-r--r--contrib/tcsh/nls/C/set611
-rw-r--r--contrib/tcsh/nls/C/set730
-rw-r--r--contrib/tcsh/nls/C/set85
-rw-r--r--contrib/tcsh/nls/C/set912
-rw-r--r--contrib/tcsh/nls/Makefile21
-rw-r--r--contrib/tcsh/nls/french/set1140
-rw-r--r--contrib/tcsh/nls/french/set108
-rw-r--r--contrib/tcsh/nls/french/set1110
-rw-r--r--contrib/tcsh/nls/french/set124
-rw-r--r--contrib/tcsh/nls/french/set1313
-rw-r--r--contrib/tcsh/nls/french/set146
-rw-r--r--contrib/tcsh/nls/french/set157
-rw-r--r--contrib/tcsh/nls/french/set1613
-rw-r--r--contrib/tcsh/nls/french/set1716
-rw-r--r--contrib/tcsh/nls/french/set184
-rw-r--r--contrib/tcsh/nls/french/set1915
-rw-r--r--contrib/tcsh/nls/french/set294
-rw-r--r--contrib/tcsh/nls/french/set2041
-rw-r--r--contrib/tcsh/nls/french/set215
-rw-r--r--contrib/tcsh/nls/french/set2217
-rw-r--r--contrib/tcsh/nls/french/set2334
-rw-r--r--contrib/tcsh/nls/french/set244
-rw-r--r--contrib/tcsh/nls/french/set256
-rw-r--r--contrib/tcsh/nls/french/set2615
-rw-r--r--contrib/tcsh/nls/french/set278
-rw-r--r--contrib/tcsh/nls/french/set294
-rw-r--r--contrib/tcsh/nls/french/set3117
-rw-r--r--contrib/tcsh/nls/french/set3016
-rw-r--r--contrib/tcsh/nls/french/set317
-rw-r--r--contrib/tcsh/nls/french/set445
-rw-r--r--contrib/tcsh/nls/french/set54
-rw-r--r--contrib/tcsh/nls/french/set611
-rw-r--r--contrib/tcsh/nls/french/set730
-rw-r--r--contrib/tcsh/nls/french/set85
-rw-r--r--contrib/tcsh/nls/french/set912
-rw-r--r--contrib/tcsh/nls/german/set1140
-rw-r--r--contrib/tcsh/nls/german/set109
-rw-r--r--contrib/tcsh/nls/german/set1110
-rw-r--r--contrib/tcsh/nls/german/set124
-rw-r--r--contrib/tcsh/nls/german/set1313
-rw-r--r--contrib/tcsh/nls/german/set146
-rw-r--r--contrib/tcsh/nls/german/set157
-rw-r--r--contrib/tcsh/nls/german/set1613
-rw-r--r--contrib/tcsh/nls/german/set1716
-rw-r--r--contrib/tcsh/nls/german/set184
-rw-r--r--contrib/tcsh/nls/german/set1915
-rw-r--r--contrib/tcsh/nls/german/set294
-rw-r--r--contrib/tcsh/nls/german/set2041
-rw-r--r--contrib/tcsh/nls/german/set215
-rw-r--r--contrib/tcsh/nls/german/set2217
-rw-r--r--contrib/tcsh/nls/german/set2334
-rw-r--r--contrib/tcsh/nls/german/set244
-rw-r--r--contrib/tcsh/nls/german/set256
-rw-r--r--contrib/tcsh/nls/german/set2615
-rw-r--r--contrib/tcsh/nls/german/set278
-rw-r--r--contrib/tcsh/nls/german/set294
-rw-r--r--contrib/tcsh/nls/german/set3117
-rw-r--r--contrib/tcsh/nls/german/set3016
-rw-r--r--contrib/tcsh/nls/german/set317
-rw-r--r--contrib/tcsh/nls/german/set445
-rw-r--r--contrib/tcsh/nls/german/set54
-rw-r--r--contrib/tcsh/nls/german/set611
-rw-r--r--contrib/tcsh/nls/german/set730
-rw-r--r--contrib/tcsh/nls/german/set85
-rw-r--r--contrib/tcsh/nls/german/set912
-rw-r--r--contrib/tcsh/nls/greek/set1140
-rw-r--r--contrib/tcsh/nls/greek/set108
-rw-r--r--contrib/tcsh/nls/greek/set1110
-rw-r--r--contrib/tcsh/nls/greek/set124
-rw-r--r--contrib/tcsh/nls/greek/set1313
-rw-r--r--contrib/tcsh/nls/greek/set146
-rw-r--r--contrib/tcsh/nls/greek/set157
-rw-r--r--contrib/tcsh/nls/greek/set1613
-rw-r--r--contrib/tcsh/nls/greek/set1716
-rw-r--r--contrib/tcsh/nls/greek/set184
-rw-r--r--contrib/tcsh/nls/greek/set1915
-rw-r--r--contrib/tcsh/nls/greek/set294
-rw-r--r--contrib/tcsh/nls/greek/set2041
-rw-r--r--contrib/tcsh/nls/greek/set215
-rw-r--r--contrib/tcsh/nls/greek/set2218
-rw-r--r--contrib/tcsh/nls/greek/set2331
-rw-r--r--contrib/tcsh/nls/greek/set244
-rw-r--r--contrib/tcsh/nls/greek/set256
-rw-r--r--contrib/tcsh/nls/greek/set2615
-rw-r--r--contrib/tcsh/nls/greek/set278
-rw-r--r--contrib/tcsh/nls/greek/set294
-rw-r--r--contrib/tcsh/nls/greek/set3118
-rw-r--r--contrib/tcsh/nls/greek/set3016
-rw-r--r--contrib/tcsh/nls/greek/set317
-rw-r--r--contrib/tcsh/nls/greek/set445
-rw-r--r--contrib/tcsh/nls/greek/set54
-rw-r--r--contrib/tcsh/nls/greek/set611
-rw-r--r--contrib/tcsh/nls/greek/set730
-rw-r--r--contrib/tcsh/nls/greek/set85
-rw-r--r--contrib/tcsh/nls/greek/set912
-rw-r--r--contrib/tcsh/nls/italian/set1140
-rw-r--r--contrib/tcsh/nls/italian/set108
-rw-r--r--contrib/tcsh/nls/italian/set1110
-rw-r--r--contrib/tcsh/nls/italian/set124
-rw-r--r--contrib/tcsh/nls/italian/set1313
-rw-r--r--contrib/tcsh/nls/italian/set146
-rw-r--r--contrib/tcsh/nls/italian/set157
-rw-r--r--contrib/tcsh/nls/italian/set1613
-rw-r--r--contrib/tcsh/nls/italian/set1716
-rw-r--r--contrib/tcsh/nls/italian/set184
-rw-r--r--contrib/tcsh/nls/italian/set1915
-rw-r--r--contrib/tcsh/nls/italian/set294
-rw-r--r--contrib/tcsh/nls/italian/set2041
-rw-r--r--contrib/tcsh/nls/italian/set215
-rw-r--r--contrib/tcsh/nls/italian/set2217
-rw-r--r--contrib/tcsh/nls/italian/set2334
-rw-r--r--contrib/tcsh/nls/italian/set244
-rw-r--r--contrib/tcsh/nls/italian/set256
-rw-r--r--contrib/tcsh/nls/italian/set2615
-rw-r--r--contrib/tcsh/nls/italian/set278
-rw-r--r--contrib/tcsh/nls/italian/set294
-rw-r--r--contrib/tcsh/nls/italian/set3117
-rw-r--r--contrib/tcsh/nls/italian/set3016
-rw-r--r--contrib/tcsh/nls/italian/set317
-rw-r--r--contrib/tcsh/nls/italian/set445
-rw-r--r--contrib/tcsh/nls/italian/set54
-rw-r--r--contrib/tcsh/nls/italian/set611
-rw-r--r--contrib/tcsh/nls/italian/set730
-rw-r--r--contrib/tcsh/nls/italian/set85
-rw-r--r--contrib/tcsh/nls/italian/set912
-rw-r--r--contrib/tcsh/nls/ja/set1139
-rw-r--r--contrib/tcsh/nls/ja/set108
-rw-r--r--contrib/tcsh/nls/ja/set1110
-rw-r--r--contrib/tcsh/nls/ja/set124
-rw-r--r--contrib/tcsh/nls/ja/set1312
-rw-r--r--contrib/tcsh/nls/ja/set157
-rw-r--r--contrib/tcsh/nls/ja/set1613
-rw-r--r--contrib/tcsh/nls/ja/set1715
-rw-r--r--contrib/tcsh/nls/ja/set184
-rw-r--r--contrib/tcsh/nls/ja/set294
-rw-r--r--contrib/tcsh/nls/ja/set215
-rw-r--r--contrib/tcsh/nls/ja/set244
-rw-r--r--contrib/tcsh/nls/ja/set294
-rw-r--r--contrib/tcsh/nls/ja/set3016
-rw-r--r--contrib/tcsh/nls/ja/set54
-rw-r--r--contrib/tcsh/nls/ja/set611
-rw-r--r--contrib/tcsh/nls/ja/set85
-rw-r--r--contrib/tcsh/nls/spanish/set1140
-rw-r--r--contrib/tcsh/nls/spanish/set108
-rw-r--r--contrib/tcsh/nls/spanish/set1110
-rw-r--r--contrib/tcsh/nls/spanish/set124
-rw-r--r--contrib/tcsh/nls/spanish/set1313
-rw-r--r--contrib/tcsh/nls/spanish/set146
-rw-r--r--contrib/tcsh/nls/spanish/set157
-rw-r--r--contrib/tcsh/nls/spanish/set1613
-rw-r--r--contrib/tcsh/nls/spanish/set1716
-rw-r--r--contrib/tcsh/nls/spanish/set184
-rw-r--r--contrib/tcsh/nls/spanish/set1915
-rw-r--r--contrib/tcsh/nls/spanish/set292
-rw-r--r--contrib/tcsh/nls/spanish/set2042
-rw-r--r--contrib/tcsh/nls/spanish/set215
-rw-r--r--contrib/tcsh/nls/spanish/set2217
-rw-r--r--contrib/tcsh/nls/spanish/set2334
-rw-r--r--contrib/tcsh/nls/spanish/set244
-rw-r--r--contrib/tcsh/nls/spanish/set256
-rw-r--r--contrib/tcsh/nls/spanish/set2615
-rw-r--r--contrib/tcsh/nls/spanish/set278
-rw-r--r--contrib/tcsh/nls/spanish/set294
-rw-r--r--contrib/tcsh/nls/spanish/set3117
-rw-r--r--contrib/tcsh/nls/spanish/set3016
-rw-r--r--contrib/tcsh/nls/spanish/set317
-rw-r--r--contrib/tcsh/nls/spanish/set445
-rw-r--r--contrib/tcsh/nls/spanish/set54
-rw-r--r--contrib/tcsh/nls/spanish/set611
-rw-r--r--contrib/tcsh/nls/spanish/set730
-rw-r--r--contrib/tcsh/nls/spanish/set85
-rw-r--r--contrib/tcsh/nls/spanish/set912
-rw-r--r--contrib/tcsh/patchlevel.h14
-rw-r--r--contrib/tcsh/pathnames.h169
-rw-r--r--contrib/tcsh/sh.c2441
-rw-r--r--contrib/tcsh/sh.char.c1206
-rw-r--r--contrib/tcsh/sh.char.h250
-rw-r--r--contrib/tcsh/sh.decls.h380
-rw-r--r--contrib/tcsh/sh.dir.c1381
-rw-r--r--contrib/tcsh/sh.dir.h61
-rw-r--r--contrib/tcsh/sh.dol.c1150
-rw-r--r--contrib/tcsh/sh.err.c522
-rw-r--r--contrib/tcsh/sh.exec.c1262
-rw-r--r--contrib/tcsh/sh.exp.c1107
-rw-r--r--contrib/tcsh/sh.file.c848
-rw-r--r--contrib/tcsh/sh.func.c2401
-rw-r--r--contrib/tcsh/sh.glob.c1111
-rw-r--r--contrib/tcsh/sh.h1228
-rw-r--r--contrib/tcsh/sh.hist.c477
-rw-r--r--contrib/tcsh/sh.init.c1074
-rw-r--r--contrib/tcsh/sh.lex.c1891
-rw-r--r--contrib/tcsh/sh.misc.c516
-rw-r--r--contrib/tcsh/sh.parse.c706
-rw-r--r--contrib/tcsh/sh.print.c278
-rw-r--r--contrib/tcsh/sh.proc.c2184
-rw-r--r--contrib/tcsh/sh.proc.h137
-rw-r--r--contrib/tcsh/sh.sem.c975
-rw-r--r--contrib/tcsh/sh.set.c1209
-rw-r--r--contrib/tcsh/sh.time.c711
-rw-r--r--contrib/tcsh/sh.types.h608
-rw-r--r--contrib/tcsh/snames.h88
-rw-r--r--contrib/tcsh/src.desc72
-rw-r--r--contrib/tcsh/tc.alloc.c637
-rw-r--r--contrib/tcsh/tc.bind.c1079
-rw-r--r--contrib/tcsh/tc.const.c406
-rw-r--r--contrib/tcsh/tc.decls.h335
-rw-r--r--contrib/tcsh/tc.disc.c200
-rw-r--r--contrib/tcsh/tc.func.c2125
-rw-r--r--contrib/tcsh/tc.h53
-rw-r--r--contrib/tcsh/tc.os.c1474
-rw-r--r--contrib/tcsh/tc.os.h754
-rw-r--r--contrib/tcsh/tc.printf.c415
-rw-r--r--contrib/tcsh/tc.prompt.c614
-rw-r--r--contrib/tcsh/tc.sched.c288
-rw-r--r--contrib/tcsh/tc.sig.c418
-rw-r--r--contrib/tcsh/tc.sig.h226
-rw-r--r--contrib/tcsh/tc.str.c427
-rw-r--r--contrib/tcsh/tc.vers.c169
-rw-r--r--contrib/tcsh/tc.wait.h159
-rw-r--r--contrib/tcsh/tc.who.c679
-rw-r--r--contrib/tcsh/tcsh.man5078
-rw-r--r--contrib/tcsh/tcsh.man2html859
-rw-r--r--contrib/tcsh/termcap.vms51
-rw-r--r--contrib/tcsh/tw.color.c346
-rw-r--r--contrib/tcsh/tw.comp.c626
-rw-r--r--contrib/tcsh/tw.decls.h126
-rw-r--r--contrib/tcsh/tw.h110
-rw-r--r--contrib/tcsh/tw.help.c206
-rw-r--r--contrib/tcsh/tw.init.c1087
-rw-r--r--contrib/tcsh/tw.parse.c2232
-rw-r--r--contrib/tcsh/tw.spell.c168
-rw-r--r--contrib/tcsh/vms.termcap.c337
299 files changed, 78108 insertions, 0 deletions
diff --git a/contrib/tcsh/FAQ b/contrib/tcsh/FAQ
new file mode 100644
index 000000000000..86fea4a3e5d6
--- /dev/null
+++ b/contrib/tcsh/FAQ
@@ -0,0 +1,211 @@
+
+Last Updated:
+Fri Mar 12 12:53:43 EST 1999
+
+This is for people who do not read the manual!
+
+So far people who don't read manuals don't read this either... I may
+call it README.*PLEASE* in the future, but then the same people won't
+be able to get ftp it... :-)
+
+1. Why is the meta key broken in tcsh-5.20 and up?
+
+ On some machines the tty is not set up to pass 8 bit characters by default.
+ Tcsh 5.19 used to try to determine if pass8 should be set by looking at
+ the terminal's meta key. Unfortunately there is no good way of determining
+ if the terminal can really pass 8 characters or not. Consider if you are
+ logged in through a modem line with 7 bits and parity and your terminal
+ has a meta key. Then tcsh 5.19 would set wrongly set pass8.
+
+ If you did like the previous behavior you can add in /etc/csh.login, or
+ in .login:
+
+ if ( $?tcsh && $?prompt ) then
+ if ( "`echotc meta`" == "yes" ) then
+ stty pass8
+ endif
+ endif
+
+ If you don't have pass8, maybe something like
+
+ stty -parity -evenp -oddp cs8 -istrip (rs6000)
+ or
+ stty -parenb -istrip cs8
+
+ would work..
+
+2. I ran 'dbxtool &' and 'shelltool &' from tcsh, and they end up in cbreak
+ and no echo mode?
+
+ These programs are broken. Background jobs should not try to look at the
+ tty. What happens is that dbxtool looks in stderr to inherit the tty
+ setups, but tcsh sets up the tty in cbreak and -echo modes, so that it
+ can do line editing. This cannot be fixed because tcsh cannot give away
+ the tty. A work-around is:
+
+ dbxtool < /dev/null >& /dev/null &
+ or
+ /usr/etc/setsid dbxtool &
+
+ If that does not work, for dbxtool at least you can add "sh stty sane"
+ in your .dbxinit
+
+3. I tried to compile tcsh and it cannot find <locale.h>?
+
+ Your system does not support NLS. Undefine NLS in config_f.h and it
+ should work fine.
+
+4. Where can I get csh sources?
+
+ Csh sources are now available with the 4.4BSD networking distributions.
+ You don't need csh sources to compile tcsh-6.0x.
+
+5. I just made tcsh my login shell, and I cannot ftp any more?
+
+ Newer versions of the ftp daemon check for the validity of the
+ user's shell before they allow logins. The list of valid login
+ shells is either hardcoded or it is usually in a file called
+ /etc/shells. If it is hard-coded, then you are out of luck and
+ your best bet is to get a newer version of ftpd. Otherwise add
+ tcsh to the list of shells. [For AIX this file is called
+ /etc/security/login.cfg]. Remember that the full path is required.
+ If there is no /etc/shells, and you are creating one, remember to
+ add /bin/csh, /bin/sh, and any other valid shells for your system,
+ so that other people can ftp too :-)
+
+6. I am using SunView/OpenWindows and editing is screwed up. In
+ particular my arrow keys and backspace don't work right. What
+ am I doing wrong?
+
+ Well, cmdtool tries to do its own command line editing and the
+ effect you get is one of using an editor inside an editor. Both
+ try to interpret the arrow key sequences and cmdtool wins since
+ it gets them first. The solutions are in my order of preference:
+
+ 1 Don't use suntools
+ 2 Use shelltool instead of cmdtool.
+ 3 Unset edit in tcsh.
+
+6b. On a SPARCstation running Solaris 2.x and OpenWindows 3.1,
+ inside a cmdtool, the short-cut key sequence to clear log
+ (i.e. Meta-e or Diamond-e) doesn't work: it just echos 'e'
+
+6c. On a SPARCstation running Solaris 2.x and OpenWindows 3.1,
+ maketool (within SPARCworks) doesn't work: it just does
+ a `cd' to the working directory then stops.
+
+ The workaround for 6b and 6c is doing "unset edit."
+ Using shelltool instead of cmdtool doesn't fix 6c.
+
+7. I rlogin to another machine, and then no matter what I tell 'stty'
+ I cannot get it to pass 8 bit characters?
+
+ Maybe you need to use 'rlogin -8' to tell rlogin to pass 8
+ bit characters.
+
+8. Where do I get the public domain directory library?
+
+ Anonymous ftp to prep.ai.mit.edu:/pub/gnu/dirent.tar.Z
+
+9. I compiled tcsh using gcc, and when I start up it says:
+ tcsh: Warning no access to tty (Invalid Argument).
+ Thus no job control in this shell
+
+ Your <sys/ioctl.h> file is not ansi compliant. You have one of 3 choices:
+ a. Run fixincludes from the gcc distribution.
+ b. Add -traditional to the gcc flags.
+ c. Compile with cc.
+
+10. I compiled tcsh with the SunOS unbundled compiler and now things
+ get echo'ed twice.
+
+ It is a bug in the unbundled optimizer. Lower the optimization level.
+
+11. How can I use the arrow keys with hpterm?
+ Hp terminals use the arrow keys internally. You can tell hpterm not
+ to do that, by sending it the termcap sequence smkx. Since this
+ has to be done all the time, the easiest thing is to put it as an
+ alias for precmd, or inside the prompt:
+
+ if ($term == "hp") then
+ set prompt="%{`echotc smkx`%}$prompt"
+ endif
+
+ Note that by doing that you cannot use pgup and pgdn to scroll...
+ Also if you are using termcap, replace "smkx" with "ks"...
+
+12. On POSIX machines ^C and ^Z will do not work when tcsh is a login
+ shell?
+ Make sure that the interrupt character is set to ^C and suspend
+ is set to ^Z; 'stty -a' will show you the current stty settings;
+ 'stty intr ^C susp ^Z' will set them to ^C and ^Z respectively.
+
+13. I am trying to compile tcsh and I am getting compile errors that
+ look like:
+
+ >sh.c:???: `STR???' undeclared, outside of functions [gcc]
+ or
+ >"sh.c", line ???: STR??? undefined [cc]
+
+ You interrupted make, while it was making the automatically
+ generated headers. Type 'make clean; make'
+
+14. On the cray, sometimes the CR/LF mapping gets screwed up.
+
+ You are probably logged in to the cray via telnet. Cray's
+ telnetd implements line mode selection the telnet client
+ you are using does not implement telnet line mode.
+ This cause the Cray's telnetd to try to use KLUDGELINEMODE.
+ You can turn off telnet line mode from the cray side by
+ doing a "stty -extproc", or you can get the Cray AIC to build
+ a telnetd without KLUDGELINEMODE, or you can compile
+ a new telnet client (from the BSD net2 tape), or at least
+ on the suns use: 'mode character'.
+
+
+15. On AU/X, I made tcsh my startup shell, but the mac desktop is not
+ starting up (no X11 or Finder), and I only get console emulation.
+
+ This is another manifestation of item 5. Just add the pathname
+ to tcsh in /etc/shells and everything should work fine.
+
+16. On machines that use YP (NIS) tilde expansion might end up in /dev/null
+ If this happens complain to your vendor, to get a new version of NIS.
+ You can fix that in tcsh by defining YPBUGS in config.h
+
+17. Script on SGI 4.0.5 does not give us a tty, so we cannot have job
+ control. Their csh does not have job control either. Try:
+ % script
+ % cat > /dev/tty
+
+18. I start tcsh and it takes a couple of minutes to get the prompt.
+ You have defined REMOTEHOST and your DNS is not responding. Either
+ undefine REMOTEHOST and recompile or fix your DNS.
+
+19. If you need help generating your .cshrc file, check out:
+ http://www.imada.ou.dk/~blackie/dotfile/
+
+20. On POSIX systems the kernel will send hup signals to all the processes
+ in the foreground process group if 'stty hupcl' is set. For example
+ ./tcsh
+ echo $$
+ 591
+ ./tcsh
+ kill -6 591
+
+ Will kill everything, since hup will be sent to all tcsh processes.
+ To avoid that you can set stty -hupcl, but it is not recommended.
+
+21. When I rsh the meta key stops working on the remote machine.
+
+ Try using rsh -8; this option is undocumented on some systems,
+ but it works. If that does not work, get and use ssh/sshd. You'll
+ be better off from a security point of view anyway.
+
+22. Tcsh compiled under hp/ux-10.x does not pass resource limits correctly
+ when ran on hp/ux-11.x systems. This is a problem with lack of ABI
+ compatibility between the two systems. The only solution is to recompile.
+
+christos
+
+Everything else is a bug :-(
diff --git a/contrib/tcsh/Fixes b/contrib/tcsh/Fixes
new file mode 100644
index 000000000000..bdaf2cc04248
--- /dev/null
+++ b/contrib/tcsh/Fixes
@@ -0,0 +1,1435 @@
+ 65. V6.09.00 - 19990816
+ 64. Add csh emacs mode (Dan Harkless)
+ 63. Make sure the the glob buffer matches the word buffer size (Brian Biswas)
+ 62. Fix periodic to work without tperiod set (Kenny McCormack)
+ 61. V6.08.07 - 19990813
+ 60. Fix e_dabbrev_expand (Bjorn Knutsson)
+ 59. Make \builtin work again (by calling the command not the builtin)
+ 58. Add NLS_BUGS for OS's that keep file descriptors open for NLS (Ian Dowse)
+ 57. Make NONLSREBIND work after tcsh starts up.
+ 56. Fix AIX stupid exit bug. (Dan Harkless)
+ 55. More irix fixes (Kaveh)
+ 54. V6.08.06 - 19990701
+ 53. module command completion (Dan Nicolaescu)
+ 52. Man command completion enhancement (Tom)
+ 51. Fixes for irix configuration (Kaveh)
+ 50. Support \a and \e in echo command. From (Keith Thompson)
+ 49. Alpha configure nit from Kaveh
+ 48. V6.08.05 - 19990511
+ 47. In some system, when a builtin fails immediately after we start
+ tcsh and before we print any messages, NLS messages fail (some
+ descriptor might be closed) [FreeBSD, HP/UX?]. So we force reading
+ the NLS catalogs in errinit() (Yoshiyuki Sakakibara)
+ 46. typos in ja/set1 and ja/set29 (Yoshiyuki Sakakibara)
+ 45. "dspmbyte autoset trap" support to HP-UX 10.20. (Yoshiyuki Sakakibara)
+ 44. misnumbered NLS message in tw.help.c (Yoshiyuki Sakakibara)
+ 43. colorcat variable for NLS color messages (Yoshiyuki Sakakibara)
+ 42. autoconf fixes from Kaveh (and if it broke, me)
+ 41. SGI irix fixes from Glenn Coombs.
+ 40. Don't spin writing the history file when quota is exceeded (Rob McMahon)
+ 39. V6.08.04 - 19990419
+ 38. complete additions (John Gotts)
+ 37. Port to amiga with geek gadgets (Arto Huusko)
+ 36. Ignore case in setenv for windows (amol)
+ 35. Bug fixes for NT unc stuff (amol)
+ 34. Hash spell check (amol)
+ 33. V6.08.03 - 19990211
+ 32. Helpcommand documentation (Vladimir Alexiev)
+ 31. small Y2K fix [%y in prompt would be formatted as 10 not 00 at year 2000],
+ and new Itoa() code (Chris Torek)
+ 30. OpenBSD m68k patches (Paul DuBois)
+ 29. Avoid redefinition of getpeername on Solaris-2.7
+ 28. fix problems with savedups=erase, savehist=merge (Randy Gobbel)
+ 27. Don't set $shell to csh, if we were invoked as tcsh (Tomas Persson)
+ 26. added $_
+ 25. added postcmd
+ 24. V6.08.02 - 19981124
+ 23. document continue and continue_args
+ 22. wrong test in slowexec made NT optimization a noop (Amol)
+ 21. Rhapsody fixes + separate CFLAGS/CPPFLAGS (Wilfredo Sanchez)
+ 20. literals in both prompt at rprompt did not work properly (Taga Nayuta)
+ 19. multibyte deletion fixes (Yoshiyuki.Sakakibara)
+ 18. clean up key binding stuff for NT by moving the nt dependent code to
+ the NT source (amol)
+ 17. dspmbyte fixes for AIX, typos in man page and nls (Yoshiyuki Sakakibara)
+ 16. Convex fixes (Ron Echeverri)
+ 15. V6.08.01 - 19981025
+ 14. SX4 port; this adds many casts for machines where ptrdiff_t is 64 bits.
+ (Andreas Schott)
+ 13. U/Win port; does not work properly with U/Win 1.6, wait for the next
+ version (Chris Jones)
+ 12. Sgi does not need gethostname prototype (John Bogan)
+ 11. Logic in sh.dir.c was wrong for NT (Amol)
+ 10. HP_CXD_SPP stat64 fixes (Scott Garee)
+ 9. Documentation spelling fixes (Keith Thompson)
+ 8. Documentation fix for savedirs (Amol)
+ 7. Siemens OSD_POSIX fixes (Martin Kraemer)
+ 6. include <errno.h> for all the BSD's (Trevor Johnson)
+ 5. Multibyte display fixes for gnu ls (Taga Nayuta)
+ 4. Configure/Makefile hesiod and bindir fixes (Dan Winship)
+ 3. Use winnt not win32 in tc.os.h (Amol)
+ 2. Cygwin32 port (Raj Menon)
+ 1. Ported Fixes (Tom)
+
+ 95. V6.08.00 - 19981002
+ 94. where builtin nt fix (Amol)
+ 93. V6.07.13 - 19980926
+ 96. NT multibyte fixes (Amol)
+ 95. NeXT needs getcwd.
+ 94. fix new bug introduced by strncpy'fication in sh.dir.c (Taga Nayuta)
+ 93. V6.07.12 - 19980918
+ 92. add cray in configure script (Tom)
+ 91. nls fixes
+ 90. Avoid buffer overflows in directory code (kim)
+ 89. Add multibyte character display support (Yoshiyuki Sakakibara)
+ 88. Make tcsh use getcwd instead of getwd and supply a getcwd.
+ 87. Fix remotehost again (kim)
+ 86. V6.07.11 - 19980913
+ 85. Leave remotehost ip addresses alone (don't try to resolve them) (Kim)
+ 84. Read vs. force_read fixes (Amol)
+ 83. Make colorls if color is set before the first LS_COLORS setenv
+ (Taga Nayuta)
+ 82. Use _PATH_DEFPATH on BSD4_4 systems. (Jim Bernard)
+ 81. Cursor bounds checks (Michael Schroeder)
+ 80. Syntax error nits (Michael Schroeder)
+ 79. configure fixes (Michael Schroeder)
+ 78. V6.07.10 - 19980904
+ 77. Off by one error in NO_ERRORS...
+ 76. Japanese NLS messages (Yoshiyuki Sakakibara)
+ 75. Add ENXIO and EBADF in the test for write failures for Irix Zombies
+ (Ralf W. Grosse-Kunstleve)
+ 74. Missed a test for NOSTRCOLL in glob.c (Michael Liepelt)
+ 73. Another ABSOLUTEP change (Amol)
+ 72. Italian NLS messages (Massimo Bertozzi)
+ 71. WIN32 fixes for ntslowexec and color_ls literal printing in prompt (Amol)
+ 70. a few missed WIN32 merges (Amol)
+ 69. defined YPBUGS for sgi (Kaveh)
+ 68. V6.07.09 - 19980707
+ 67. Separate the nt builtins (Amol)
+ 66. completion fixes (Tom)
+ 65. color ls fixes (Taga Nayuta)
+ 64. V6.07.08 - 19980629
+ 63. add config.h.in (Kaveh)
+ 62. win32 updates (Amol)
+ 61. warning and portability cleanups on the new changes (Kaveh)
+ 60. V6.07.07 - 19980628
+ 59. Fast execute by-pass for win32 (Amol Deshpande)
+ 58. Clean up const usage a bit, and fix gcc 2.8.1 warnings.
+ 57. Use @bindir@ for DESTBIN in Makefile.in (Edgar Hoch)
+ 56. Avoid overflow in time builtin computation (Nobue Adachi)
+ 55. Color ls additions (Taga Nayuta)
+ 54. unsigned char vs. char warning fixes (Kaveh)
+ 53. Solaris 64 bit fixes (fix directory offset bug) (Thomas-Martin Kruel)
+ 52. More win32 patches (Amol)
+ 51. autoconf lossage from (Kaveh)
+ 50. V6.07.06 - 04/08/98
+ 49. Collation fix for globbing (Andrey A. Chernov)
+ 48. We might have NLS_CATALOGS and not LC_MESSAGES (Andrey A. Chernov)
+ 47. 4.4BSD header fixes (Andrey A. Chernov)
+ 46. Signed char prompt fixes (Andrey A. Chernov)
+ 45. Pattern match fix for directory searches (Mike Patnode)
+ 44. Pentium DGUX fixes (Miko Nahum)
+ 43. Spanish nls message catalogs (Luis Francisco Gonzalez)
+ 42. Fix trailing whitespace parsing in HASHBANG code (Martin Kraemer)
+ 41. Remove stray debuggin message from unmatched substitutions.
+ (from Amol Deshpande)
+ 40. Fix reversed arguments in Usagae message. (from Amol Deshpande)
+ 39. Fix bug introduced at tcsh-7.06.03 [expdollar] that affected %.n prompt
+ format.
+ 38. Fix typos introduced in last batch of changes.
+ 37. Fix interrupted script using onintr, exiting parent shell problem.
+ 36. Cleanup prototypes.
+ 35. V6.07.05 - 10/28/97
+ 34. Integrate Amol Deshpande's WINNT fixes to the tcsh source. Note that
+ this is not complete yet; we are missing the NT glue code and the message
+ catalogs.
+ 33. Fix ^T at the first character in the line (Chuck Silvers)
+ 32. Eliminate xsprintf and xvsprintf
+ 31. Qmail patch from (Matthew Zahorik)
+ 30. Added missing linux signals (Vadim Vygonets)
+ 29. fixed problem where complete complete 'p/*/t:*.txt/' would not honor
+ the pattern.
+ 28. Port to an EBCDIC machine: BS2000 by Siemens Nixdorf that has an
+ IBM/390 compatible processor (Martin.Kraemer)
+ 27. Detect when we have errors writing to stdout (Vadim Vygonets)
+ 26. Ignore quotes in the comparisons for builtins, so that \builtin works
+ (Amol Deshpande).
+ 25. HPUX, portability fixes; make sure that we have the right config file
+ (Jonathan Kamens)
+ 24. Don't do lookups for x displays and figure out ttys properly
+ (Leonard N. Zubkoff)
+ 23. make print_by_columns print in a single column when the output is not a tty
+ 22. use rlim_t for Solaris2 (Casper Dik)
+ 21. V6.07.04 - 05/04/97
+ 20. set -f -l patch (Michael Veksler)
+ 19. SGI patches (Tomasz J. Cholewo). Also fix completion code to take into
+ account aliases that start with a period.
+ 18. SCO patches (Boyd Lynn Gerber)
+ 17. Fujitsu patches (Toshiaki Nomura)
+ 16. autoconf patches (Kaveh Ghazi)
+ 15. BSDI patches (Paul Vixie)
+ 14. %Q formatting character addition.
+ 13. Fix set=#123; echo $i:s/#// (Quoting problem)
+ 12. V6.07.03 - 02/23/97
+ 11. Understand %$variable in the prompt.
+ 10. Quote directory names properly in .cshdirs
+ 9. USE_ACCESS and autoconfig patches from (Larry Schwimmer)
+ 8. Pyramid att config file (Andrew Lister)
+ 7. $rprompt code (Luke Mewburn)
+ 6. Kanji patches (Huw Rogers)
+ 5. Cray T3E port (Jorn Amundsen)
+ 4. Avoid html redirects in tcsh.man2html (from Kimmo)
+ 3. HP/UX 10.0 fix for filesize resource limit; don't scale by 512 anymore.
+ 2. Workaround for TIOCSTAT for NetBSD from lukem@netbsd.org
+ 1. Return exit status from 0..255 not -128...127, as POSIX mandates.
+
+V6.07.02, 10/27/96
+ 58. More configure fixes from Kaveh.
+ 57. Fix histdup=erase again: Don't renumber events, or access uninitialized
+ storage.
+ 56. 6.07.01 - 10/19/96
+ 55. Fix histdup=erase, where after some repetitions, we would get negative
+ history events (kim@gw.com)
+ 54. NLS fixes and typo in sh.err.c (Martin.Kraemer@deejai.mch.sni.de)
+ 53. Output history in raw format in the history file (mveksler@VNET.IBM.COM)
+ 52. Fix possible core dump when !:<tab> in autoexpand mode (rbrown@ERA.COM)
+ 51. 6.07.00 - 10/11/96
+ 50. Avoid stdio.h inclusion problem in SCO (gethost.c).
+ 49. A bit of housekeeping in host.defs
+ 48. 6.06.04 - 10/05/96
+ 47. Fix tellmewhat() code to return true if found.
+ 46. Change register foo to register int foo to avoid compiler warnings.
+ 45. Fix problem with sticky non editing mode from Casper Dik.
+ 44. history lex fix from Martin Kraemer; history events that ended with 0
+ were not properly parsed.
+ 43. SNI fixes from Martin Kraemer.
+ 42. SGI fixes from Ralf W. Grosse-Kunstleve.
+ 41. BSDI2.1 fixes from Paul Vixie.
+ 40. 6.06.03 - 09/24/96
+ 39. undef TIOCGLTC for HP/UX 10.0 from Michael Shroeder
+ 38. Sinix fixes
+ 37. 6.06.02 - 06/22/96
+ 36. Added implicitcd
+ 35. Added configure.in and Makefile.in from Kaveh.
+ 34. unset path, unsetenv PATH, ./foo did not work.
+ 33. Add VAR_NOGLOB, and use it to avoid globbing directory names when
+ cd'ing into them.
+ 32. Fix bug introduced in the new tty parsing code.
+ 31. Avoid pushing string back to the parsing string in ${ errors.
+ 30. Patches for the manual page from Dave.
+ 29. 6.06.01 - 05/24/96
+ 28. Use sysconf to get NCARGS if available Robert Daniel Kennedy
+ <kennedy@b0ru01.fnal.gov>
+ 27. Grab the program name and use that instead of tcsh in error messages.
+ 26. Fix histdup, so that it does not leave gaps in the event sequence.
+ 25. HP/UX v10.0 fixes: Don't use bsdtty.h and avoid clobbering memory
+ since SIGRT??? is defined as -1.
+ 24. Avoid coredumps when $TERMCAP exceeds 1024 characters
+ Michael Schroeder <Michael.Schroeder@informatik.uni-erlangen.de>
+ 23. Fix memory clobbering when SHORT_STRINGS is not defined.
+ Todd J Derr <infidel+@pitt.edu>
+ 22. Only restart stopped editors. Robert Webb <robertw@wormald.com.au>
+ 21. Recognize pts sysv ptys when checking to set autologout Bob Myers
+ <bob@intelenet.net>
+ 20. Magic space incomplete modified core dump fix. Chris Metcalf
+ <metcalf@catfish.lcs.mit.edu>, Bradley White <bww@fore.com>
+ 19. Linux nls fixes Rik Faith <faith@cs.unc.edu>
+ 18. SGI RS8000, Ported notes. Ralf W. Grosse-Kunstleve
+ <rwgk@laplace.csb.yale.edu>
+ 17. Greek nls messages. Aggelos P. Varvitsiotis <avarvit@cc.ece.ntua.gr>
+ 16. Imakefile linux and libcrypt fixes. Jonathan Kamens <jik@cam.ov.com>
+ 15. FreeBSD fixes Jukka Ukkonen <jau@jau.csc.fi>
+ 14. Expand the environment space for path Steve Kelem <steve.kelem@xilinx.com>
+ 13. Don't overwrite the environment randomly Steve Kelem
+ <steve.kelem@xilinx.com>
+ 12. Don't turn the editor on when we have dumb or unknown terminals. This
+ breaks emacs when compiled with terminfo Jonathan Kamens <jik@cam.ov.com>
+ 11. Fix F- parsing in tc.bind.c <bob@intelnet.net> (Bob Meyers)
+ 10. Added -T option in history to force timestamp printing. -h alone does
+ not print timestamps anymore for compatibility with csh.
+ 9. Typo in tc.bind.c [with -DOBSOLETE] (misplaced parenthesis)
+ 8. Recognize convex models properly.
+ 7. suppress the DING! option using the noding variable.
+ 6. negative nice values did not work.
+ 5. Harris CX/UX 7.x support.
+ 4. ERR_DMMODE was used on the crays but not defined. I changed the error
+ messages in tc.os.c to use ERR_STRING instead, and fixed a missing error
+ message in the catalogs. Someone will need to retranslate #30 and #31
+ in set23.
+ 3. Bug setting listflags... Workaround: set listflags=(A /bin/ls)
+ 2. Typo in Imakefile (# comment instead of c comment)
+ 1. Typo in ma.setp.c (missing parenthesis)
+
+
+V6.06.00, 05/13/95
+ 88. Cleanup off-by-one error ed.defns.c.
+ 87. 6.05.09 - 05/06/95
+ 86. Small memory leak in dosetenv()
+ 85. Make sure that the number of editing functions defined is correct
+ and abort otherwise.
+ 84. Completion Fixes from Tom
+ 83. Don't add yp stuff in the tilde cache [names that start with + or -]
+ 82. Don't let children catclose() in xexit(), because the parent will lose
+ access to the nls catalogs. From Michael.
+ 81. 6.05.08 - 04/29/95
+ 80. Update to the newest csh sh.file.c
+ 79. More completions from Tom.
+ 78. Fix the Imakefile to use XCOMM
+ 77. Update for AIX 3.2.
+ 76. French catalog from J.M.Vansteene@frcl.bull.fr (fwd Michael Schmidt)
+ 75. Nls fixes and small typos from Michael
+ 74. PDP11 BSD type fixes.
+ 73. More manual page fixes.
+ 72. 6.05.07 - 04/19/95
+ 71. More NLS catalog fixes.
+ 70. Bruce's jumbo patch.
+ 69. 6.05.06 - 03/15/95
+ 68. make clean does not clobber config.h if Makefile.std is used.
+ make veryclean does.
+ 67. New config define NISPLUS. Reportedly fixes vanishing output of ~expansion
+ on solaris 2.4.
+ 66. showdots has been removed; use listflags instead. [handles -x too]
+ 65. more nls catalog fixes.
+ 64. set histchars=,. did not have any effect in .cshrc
+ 63. fix "-c command" new core dump.
+ 62. more completions from Tom
+ 61. call catclose() before exiting, so that svr4 cleans up the symlinks before
+ exiting.
+ 60. Per's fix for insert-last-word
+ 59. Per's emacs abbreviation mode.
+ 58. Makefile fixes for catalog stuff.
+ 57. fixed again complete-word-raw and list-word-raw
+ 56. 6.05.05 - 03/11/95
+ 55. Made %?str work again
+ 54. IRIX sigalarm problem should be fixed
+ 53. complete-word-raw and list-word-raw should work
+ 52. nls catalogs complete reworking.
+ 51. sh.init.c: Signal complete rewrite.
+ 50. Signal fixes from Bruce.
+ 49. Added promptchars, like histchars; affect %# in the prompt. The first
+ char is for the user and the second is for root.
+ 48. 6.05.04 - 03/03/95
+ 47. Add NODOT config, $command [that holds the command passed with -c]
+ $GROUP and $group
+ 46. AFS fixes from Larry Schwimmer <rosebud@cyclone.Stanford.EDU>
+ 45. Real NLS catalogs from Michael Schmidt <michael@muc.de>
+ 44. patch to allow ^? binding.
+ 43. completion patch from Paul DuBois.
+ 42. Don't spell check in here docs.
+ 41. Incorrect normalization of usec in sh.time.c
+ 40. directory printing and option parsing fixes [from Paul DuBois]
+ 39. realloc_searchlen should be static to avoid conflicts with OS's that
+ use the same malloc package.
+ 38. LOGINFIRST now applies to /etc/csh.login
+ 37. Fixes in bind compatibility code to bindkey.
+ 36. 6.05.03 - 01/17/95
+ 35. Don't print the whole watchlist on startup. One can use explicitly
+ the log builtin for that.
+ 34. Don't display the $watch value in the log command.
+ 33. Don't delete the unmatched portion if we try to complete a spelling error.
+ 32. Solaris 2.4 workaround for isprint('\t') lossage (From Casper)
+ 31. Fixed csh bug: [Reported by Jaap]
+ set test="one\
+ two\
+ three"
+ echo "$test:q"
+ 30. Fixed the lossage in setting the looking mode in tw.parse.c before
+ calling t_search; $x/$y will not append the right suffix.
+ 29. Another attempt at the gethost timeout code.
+ 28. Cray dmmode and filetests -m -k [need documentation!]
+ 27. More manual patches.
+ 26. Don't glob the path; security problem and core-dump. [from beto]
+ 25. Avoid waiting for jobs that failed to restart, thus hanging the shell.
+ eg, run job in background, attach to debugger; kill it inside the
+ debugger. Get out of the debugger and you are stuck if you fg that job.
+ 24. 6.05.02 - 09/04/94
+ 23. remhost code could pass the wrong length to getpeername()
+ 22. too eager sed'ing broke convex getwarpbyvalue() to getwarpbyvarval()
+ 21. Fixed new bindings bug.
+ 20. Fixed bug in newgrp code; execv was called incorrectly.
+ 19. Take into account programmable completion hints when spell checking.
+ 18. Unconditionally change stty modes in Rawmode()
+ 17. Change date in $version to be ISO 8601 per Keith's suggestion
+ 16. Fixed portability problems in the new counted-strings codes (From Kaveh)
+ 15. Fixed binding problem with the new counted-strings code [all key bindings
+ ended up in the extended map]
+ 14. 6.05.01 - 07/08/94
+ 13. Changed key bindings to use counted strings instead of Null terminated
+ strings, so that binding ^@ works.
+ 12. Fix parsing bug, where words that contained keywords caused incorrect
+ word breaks:
+ switch (iftagd)
+ case iftagd:
+ echo It works
+ breaksw
+ default:
+ echo It is broken.
+ endsw
+ 11. Fix sh.c for systems with no job control. [the new hup builtin sends
+ SIGCONT].
+ 10. Don't add the suffix character when all completions fail, from michael
+ 9. Added histdup=erase, that deletes the oldest duplicate instead of
+ the newest.
+ 8. Don't call .logout recursively if we receive more than one hup,
+ and don't process hangups when we execute the .logout.
+ 7. $logout was set to a static string.
+ 6. Non printable binding listing was broken.
+ 5. Recursive sourced scripts would get mangled up because of input buffer
+ confusion (thanks michael)
+ 4. M-space should not be counted as a space. Leads to infinite loop in
+ word splitting.
+ 3. Pyramid fixes.
+ 2. Fixed '\' in sysv echo (from Mika)
+ 1. Missed fix_yp_bugs() when setting REMOTEHOST (From Casper)
+
+
+V6.05.00, 06/19/94
+113. 6.04.17 06/18/94
+112. Realloc debug fix from John.
+111. Completion fixes from Bruce.
+110. Added -b option to bind.
+109. Added tcsh.man2html from Dave. Looks great!
+108. 6.04.16 06/06/94
+107. Allow multi word glob in "`foo`" expressions.
+ > if ("`ls`" == "a b c") then
+106. Michaels lex() buffer patch version 2.
+ the previous version core-dumped with
+ > sleep | echo
+105. Fix seg fault in find_cmd, when path is unset.
+104. 6.04.15 05/28/94
+103. the previous =~ fix, was a bit broken.
+102. 6.04.14 05/25/94
+101. expression parser fix for !~ and =~.
+ if (foo =~ *) echo ok
+ the * was taken for a multiply and parsed as 0 * 0 returning 0.
+ and asked to match "foo" with "0"
+100. Michael's lex() buffer patch.
+ 99. Bruce's Jumbo cleanup
+ 98. fixed Imakefile for X11R6
+ 97. fixed argument parsing in source command.
+ 96. added $sched to format scheduled events.
+ 95. 6.04.13 05/07/94
+ 94. added expand-command
+ 93. Alpha OSF-2.0 fixes
+ 92. 6.04.12 04/28/94
+ 91. Ignoreeof patch from Bruce.
+ 90. Dan's completion fix.
+ 89. 6.04.11 04/12/94
+ 88. Don't source .logout when killed with -HUP unless we are a login shell.
+ [ actually $loginsh controls the behavior now ]
+ 87. ISC-4.0 posix exec() bug workaround
+ (from Jonathan Broome <jon@wilbur.uucp>)
+ 86. Dan's patch for complete=enhance
+ 85. Kaveh's patches for memset, host.defs, _{U,G}ID_T
+ 84. 6.04.10 03/29/94
+ 83. Pathname completion bug fixes...
+ 82. Completion pathname(p) changes: Completion 'C' -> 'X'.
+ Replaced 'p' with 'F' and added D,T,C.
+ 81. Next NLS fixes
+ (From Paul Nevai <nevai@ops.mps.ohio-state.edu>)
+ 80. make spelling correction obey the current histchars setting.
+ 79. Fix rounding in limits so that 0 is a true 0.
+ (From Ken Lalonde <ken@cs.berkeley.edu>)
+ 78. 6.04.09 03/12/94
+ 77. Alarm race with remotehost.
+ 76. If you have in your .cshrc
+ set savehist=(100 merge)
+ and execute
+ #!./tcsh
+ exec ps
+ you get no output; [fixed]
+ 75. setenv SHLVL -1; tcsh = Segmentation fault [fixed]
+ 74. 6.04.08 02/10/94
+ 73. new machtype, ostype, vendor
+ 72. execute .logout on hangup.
+ 71. more man page fixes.
+ 70. 6.04.07 02/04/94
+ 69. Dynamic hash changes, globbing for which command from Michael.
+ 68. INBUFSIZE fixes for history.
+ 67. printenv returns 1 when a variable is not found, like the non builtin one
+ 66. Add quotes to the mismatch array so that:
+ > touch foo
+ > mail "oo bar"
+ does not get corrected. The right fix would be to do correct parsing
+ and quote the space...
+ 65. NULL terminate mismatch[] array in ed.inputl.c, since it is used in
+ Strchr().
+ 64. renamed stat to filetest
+ 63. Afs and Hesiod patches.
+ 62. More manual page patches.
+ 61. 6.04.06 12/19/93
+ 60. Alarm for resolver timeouts (untested)
+ 59. Fixes for Henry Spenser's regex in the Makefiles
+ 58. Modifiers now work with $< and $< does not do :q by default.
+ [incompatibility with csh] and $< can be interrupted.
+ 57. Added $histdup.
+ 56. source /etc/.login for Solaris 2.x
+ 55. don't remove trailing spaces in history searches.
+ 54. dirs -L and dirs -S spurious warning elimination.
+ 53. man page fixes from David.
+ 52. Kimmo's patch [makefile, gcc warning, netdb.h include]
+ 51. 6.04.05 12/12/93
+ 50. rewrote srcunit() to use st_save and st_restore. The code was
+ too messy to be useful before.
+ 49. recdirs and rechist patches again!
+ 48. Harris hck port, and ISC imake update
+ 47. Eliminate the x windows :display.screen before looking for the
+ hostname in REMOTEHOST
+ 46. Patch for CDF filetype() recognition (hpux)
+ 45. 6.04.04 11/12/93
+ 44. Made =x obey nonomatch.
+ 43. Fixed rechist and recdirs not to depend on savehist and savedirs
+ 42. Removed aliases, bind, linedit builtins [ifdef'ed out as OBSOLETE]
+ 41. change REMHOST to REMOTEHOST for compatibility with SGI.
+ 40. $owd was not working correctly.
+ 39. Debugging printf elimination (from Kimmo)
+ 38. Typos in the new hup code in sh.c (from Matt)
+ 37. Imakefile fix for sequent (from Jaap)
+ 36. 6.04.03, 10/30/93
+ 35. New manual page in place.
+ 34. Fixed Makefile sed RE to work with gnu sed.
+ 33. Added hup builtin.
+ 32. Added $REMHOST in config_f.h
+ 31. Fixed random parsing bug in sh.exp.c in isa(). It checked cp[1]
+ without checking cp[0] first... (should propagate to 4.4BSD)
+ 30. More sh.exp.c fixes from Bruce
+ 29. Always exit when the user types exit.
+ cat | tcsh -f -s
+ exit
+ ls
+ 28. savedirs fix and readlink() null termination fix from Peter.
+ 27. Added -p flag (force dirs printing in all directory functions and $owd
+ variable
+ 26. Let $dirstack work by default without needing to be set.
+ 25. Fixed history -h to work with other history flags.
+ 24. Renamed ed-functions more consistently (dcs)
+ 23. Added missing filetests (dcs)
+ 22. Added NEWGRP define in config_f.h (dcs)
+ 21. More fixes for non blocking io recovery from Bruce
+ 20. 6.04.02, 10/08/93
+ 19. changed default prompt to %#
+ 18. New group 'g' completion.
+ 17. removed IIASA defs.
+ 16. fix for history -SL and dirs -SL to work when savedirs and savehist are
+ not set.
+ 15. fix magic-space to understand :p
+ 14. make :u,:l work for history.
+ 13. Fixes for non-blocking i/o recovery. trap all non blocking styles under
+ sunos.
+ 12. 6.04.01, 08/10/93
+ 11. Vi mode word moves [they work like vi and don't obey wordchars anymore].
+ 10. New file operators and stat builtin
+ 9. David's FIONREAD patch for SVR4
+ 8. Bruce's ignoreeof=n patch
+ 7. Dan's complete/correct enhancement
+ 6. Abort corrections patch.
+ 5. Print_by_columns, now does not use the rightmost column.
+ 4. Renamed config/config.$i to $i to avoid once and for all filename length
+ problems.
+ 3. bbn butterfly config
+ 2. Beto's proc fixes
+ 1. Bruce's bug fix for ed.chared.c, signals
+
+
+V6.04.00, 07/03/93
+ 92. Alpha prototypes, for gcc -Wall clean compile.
+ 91. Fixed alpha hashing. Did not work for directories > 31, Thanks to
+ Dan Mosedale <mosedale@genome.Stanford.EDU> for all the help!
+ 90. Added USE(a) for unused parameters, to avoid compiler warnings.
+ 89. 6.03.10, 06/25/93
+ 88. Makefile and lint patches from Bruce.
+ 87. Posixsig patch from Peter for svr4
+ 86. 6.03.09, 06/11/93
+ 85. signal handling broke with the last job control patch...
+ > (does-not-compute;)
+ would hang.
+ 84. don't quit after the first modifier fails:
+ > set i=aabbcc
+ > echo $i:s/a/A/:s/b/B/
+ AaBbcc
+ > echo $i:s/x/A/:s/b/B/
+ aabbcc
+ 83. Imakefile fixes for sequents from Jaap.
+ 82. Move past the bottom of input when we hit ^C, so that multi-line
+ input commands don't get trashed.
+ 81. Look only at the first word in ${EDITOR,VISUAL} to determine the
+ editor name.
+ 80. Last patch broke listmax.
+ 79. Remove extra sandbagging in exitstat(). Not needed anymore as value()
+ will never return NULL.
+ 78. Save $status before calling aliasrun() otherwise:
+ > alias precmd 'cd .'
+ > true
+ > echo $status
+ 0
+ > false
+ > echo $status
+ 0
+ 77. 6.03.08, 06/07/93
+ 76. missing prototypes/unused variables under SYSV4.
+ 75. savedirs should glob the filename argument.
+ 74. 6.03.07, 06/05/93
+ 73. Changed _Q, _Q1 macros in sh.lex.c, sh.dol.c, sh.char.? to _QF and _QB
+ because today 4.4BSD <ctype.h> defined _Q to be ``Phonetics''
+ 72. listmaxrows variable.
+ 71. set -r would not make existing variables readonly.
+ 70. print usernames with ~user where possible in dirs and job cwd's
+ 69. Mika's fixes (missing args in sh.c set(), linux Makefile, SIGCHLD)
+ 68. FIONREAD argument is int everywhere except on SunOS where it is long.
+ Tcsh used to think that it was long, and so it broke on the alpha where
+ sizeof(int) != sizeof(long)
+ 67. 6.03.06 05/16/93
+ 66. Pipeline fixes. This should get rid of the dreaded Stopped tty output
+ message.
+ 65. Michael's fix for history buffer cleanup:
+ > alias foo 'echo \!:1:h'
+ > foo a/b
+ a
+ > ^P [nothing happens]
+ 64. Unsigned long rlimit type for 64 bit machines (alpha)
+ 63. Fixed Imakefile for alpha
+ 62. tilde expansion now obeys $nonomatch
+ 61. readonly veriables. 'set -r x=3' will set x to a very sticky 3...
+ 60. Fixed bug in the new tab'ed completion that interfered with old listing.
+ 59. Fixed entry -> item in tw.parse.c
+ 58. Added -f option to unlimit
+ 57. Define __STDC__ in Imakefile for Irix
+ 56. Static redeclarations in tw.parse.c
+ 55. 6.03.05 04/26/93
+ 54. Don't echo history expansion in loops:
+ > alias junk 'foreach i (\!:2*) \
+ foreach? echo \!:1 $i; \
+ foreach? end'
+ > junk a b c d
+ echo a $i ;
+ a b
+ echo a $i ;
+ a c
+ echo a $i ;
+ a d
+ 53. Added complete-word-fwd and complete-word-back that scroll through
+ the list of possible completions... Neat addition from
+ jfink@csugrad.cs.vt.edu (Jeff "$DOTDIR" Fink)
+ 52. Workaround hpux9.01 broken optimizer in sh.glob.c where 'ls *' breaks.
+ 51. Michael's editor fix. With "magic margins" and 80 char width, try:
+ > set prompt=
+ <ESC>20a<CTRL>a<ESC>76b<CTRL>ac
+ 50. Reverted fix that does not glob the expanded back-quote text again.
+ 49. > cd /., echo $cwd
+ /.
+ Eliminate the . in this case...
+ 48. Matt's optimization in glob.c [retracted]
+ 47. Fixed bug with -S
+ 46. Renamed Makefile Makefile.std, and fixed the readme file
+ 45. 6.03.04 04/07/93
+ 44. Changed -s == !-z and -S == socket
+ 43. Fixed typo in sh.c, in phup [shpgrp != pr->pgrp]
+ 42. Multi-line aliases are not entered into the history when executed.
+ 41. Changed f_seek to a union to avoid gcc warnings on 4.4BSD
+ 40. Fixed 'unset home; dirs' bug
+ 39. fixed $HOME->$home memory problem.
+ 38. $?0 returns false now on interactive shells for csh compatibility.
+ 37. Default watch inteval was 10 hours not 10 minutes as advertized in the
+ manual!
+ 36. Fixed clobbered veriable warning from gcc-1.39 in tw.parse.c
+ 35. Fixed typo with INVPTR in sh.lex.c
+ 34. 6.03.03 03/04/93
+ 33. Eliminate 'Reset tty pgrp error message'. It is normal for the
+ walking process group stuff. Check about the killpg() above?
+ 32. More portability for 64 bit machines.
+ 31. Improved completion error messages.
+ 30. Fix bug with double globbing expansion on mirrored variables:
+ > setenv TERM '?vt100'
+ 29. Avoid hanging when writing to pipes etc. (From Paul Close)
+ 28. Typo in the $HOME->$home mirroring.
+ 27. %p %P 'p'recise time formats that include seconds for prompt strings.
+ 26. Signal list fixes from Paul Close. nsig is now a variable.
+ 25. 6.03.02 02/12/93
+ 24. NEC SX3 "entry" is a reserved word!, changed entry to item...
+ [this is as bad as cray typedefining "word" to int. Next thing I know,
+ I'll have to prefix all the variables with tcsh_!]
+ 23. xxx
+ 22. Protected all include files to avoid warnings from lcc.
+ 21. Finally resolved the job control problems with linux and ISC (from Beto)
+ 20. More HUP,XFSZ,XCPU fixes. (with Beto)
+ 19. Dcanon would not canonicalize correctly in case where dnormalize()
+ failed to find a directory, but the directory existed when not
+ crossing the symbolic link.
+ 18. sh.init.c fixes; give 65 signals for all POSIX machines.
+ 17. AMS mail fixes and cmu wm handling.
+ 16. Setenv would not ignore trim quoted names...
+ > alias foo 'setenv "\!:1" bar'
+ > setenv FOO 123
+ > foo FOO
+ > printenv
+ ...
+ FOO=123
+ FOO=bar
+ ...
+ 15. 6.03.01 08/01/93
+ 14. #undef SHORT_STRINGS gcc warning fixes...
+ 13. csh bug fix in foreach [quoteing problem]
+ > foreach i ("*")
+ > echo $i:q
+ > end
+ Should print *
+ 12. ls-F obeys showdots...
+ 11. After scheduled commands get executed, the editor could stay disabled
+ until the first enter.
+ 10. sigset() bug in ed.init.c; ^C could get disabled sometimes.
+ 9. Don't glob in dowhich(); otherwise \pat does not work if pat is aliased.
+ 8. When completion patterns are used $ and ~ expansion did not work right.
+ 7. Printenv builtin and long backquote expansion fix from Harald.
+ 6. $:-1, $:-0 enhancement from Paul and Michael.
+ 5. Lynx/OS patches
+ 4. Apollo bugs [Setenv -> tsetenv, typedef in pid_t]
+ 3. ^@ did not work correctly in bindkey.
+ 2. Fix vms/posix ifdefs in tc.alloc.c
+ 1. Elide gcc-2.3.1 warnings
+
+
+V6.03.00, 11/20/92
+102. Solaris2 patches, renamed sunosX to sosX to fit in 14 character filenames.
+101. 6.02.12 11/12/92
+100. Decreased BUFSIZE to 1K...
+99. Don't use sbrk() in tc.alloc.c on VMS
+98. EINTR error handling from Michael
+97. Overwrite mode takes effect immediately, not delayed by a command.
+96. Emx fixes.
+95. SIGHUP gain...
+94. Coherent times()/ <sys/file.h> fixes.
+93. 6.02.11 10/27/92
+92. Mach setpath fixes.
+91. Which now globs its arguments
+90. Again POSIX SIGHUP fixes... Maybe we got it right this time...
+89. Increased BUFSIZE to 4K. Smaller machines may want to decrease this.
+ [ Now one can edit up to 4K of buffer! ]. From Harald.
+88. : is now a true builtin that does nothing, instead of being treated like
+ the last character of a label. This is so it can take args. From Harald.
+87. More fixes for hpux limits from Harald.
+86. Login shell if ppid == 1 and argc == 1 for VMS.
+85. Typo in sh.exec.c from Harry.
+84. Per's editor fixes.
+83. 6.02.10 10/17/92
+82. Don't free STRNULL in freelex(). Update linked list in copylex() to
+ do the same insert as in lex().
+81. Fixed spurious tilde printing in %c prompt.
+80. Fixed dumb wild free in AddXKey...
+ (thanks Harald for the complex bindings! :-)
+ > bindkey "\e10z" expand-line # Any editor command will do
+ > bindkey -[cs] "\e10z" "foo" # Any string or command will do
+ Free(%x) ....
+79. coherent additions.
+78. fixes for hpux8 resource limits [Thanks Harald]
+77. 6.02.09 10/10/92
+76. More vms cleanups.
+75. Removed #include CONFIGH from sh.h. There was no way to make it work
+ under VMS/POSIX
+74. Added t completion (Gray Watson)
+73. Memory leaks in sh.dir.c and sh.glob.c [thanks purify :-)]
+72. IRIX 5.0 patches (from Paul Close)
+71. BSD resource limits for hpux8.0 (From Andreas Stolcke)
+70. NGROUPS_MAX fixes (from Matt Day)
+69. 6.02.08 10/04/92
+68. VMS port additions.
+67. Added $%var, which == strlen(var)
+66. Added ^X^I and ^X^D to override programmable listing+completion
+65. Added case insensitive globbing for OS/2
+64. FIOCLEX and FIONCLEX are only used if we don't have FD_CLOEXEC.
+63. Added emx termio support, and emx pathsep support; emx compiles and runs:
+ needs job-debugging and finishing touches.
+62. Horrible bug with the lex linked list; from Loic Grenie, grenie@ens.fr
+ > echo a !#
+ echoed 'echo a echo a echo'!
+61. Shell -w,-x were incompatible with the same for test [POSIX] (beto)
+60. builtin newgrp did not accept the - argument.
+59. FIOCLEX for the masses (POSIX FD_CLOEXEC addition)
+58. Old style csh completion bug fix [not used] (beto)
+57. A background process waiting for input from tty
+ blocks when being foregrounded doesn't read its input and
+ doesn't get <cntl-c> and <cntl-z> signals.
+ It can only be killed from another session. (beto)
+ > cat > foo
+ #!/bin/csh -f
+ echo ">>>>>>"
+ set x = $<
+ echo $x
+ ^D
+ > chmod +x foo
+ > foo &
+ > fg
+ ^Z,^C # Nothing happens
+56. history > 1000 fix (beto)
+55. 6.02.07 9/18/92
+54. Added e_stuff_char() to put back a character in cooked mode in
+ the input stream... Useful for status (^T)
+53. $? == $status and $# == $#argv like in the bourne shell.
+52. Added $dirstack. Problems: off by one since =0 == $cwd, but
+ $dirstack[1] == $cwd... Suggestions welcome.
+51. Leading spaces would confuse the run-help function.
+50. Don't expand imported environment variables:
+ > setenv HOME \*
+ > tcsh
+ > echo "$home"
+ > echo "$HOME"
+49. %C0n displays the number of directories omitted as /usr/local/bin /<2>bin/
+48. Added POSIXSIGS as a configuration option.
+47. Per's fixes for history format and arrow key binding.
+46. Expand-variables expands array variables too
+45. 6.02.06 8/14/92
+44. Separated limit stuff from BSDTIMES and added BSDLIMIT
+43. History searching inconsistent with HistLit:
+ > echo foo
+ foo
+ > ^foo^bar
+ bar
+ > ec[M-p]
+ echo foo
+42. 6.02.05 8/8/92
+41. sourcing a script that contains 'onintr -; onintr' would disable
+ interrupts on the command line
+40. cd ../... with symlinks=ignore would work !@#!@
+39. No more BACKPIPE for POSIX machines...
+38. SUNOS NLS bug workarounds...
+37. New HASHBANG define for #! emulation... even 386BSD does not have it
+ yet...
+36. Added new -b -c file operators from SGI csh.
+35. 6.02.04 7/23/92
+34. Walking process group fixes.
+33. $0 contains now argv[0] when we are not executing a shell script.
+32. New Getwd() was broken.
+31. 6.02.03 7/17/92
+30. We kill our last foreground process group on HUP, for POSIX systems.
+29. Walking process group fix.
+28. $shlvl gets reset to 1 for login shells.
+27. Macros can now involve multiple commands, i.e.
+ bindkey -s "^[OP" "ls\n^P"
+26. 6.02.02 7/6/92
+25. nostat accepts now a list shell patterns.
+24. Avoid print_exit_value in if ( { foo } )
+23. Symbolic key names for bindkey [arrow keys].
+22. Smarter getwd() that avoids some of the NFS hangs...
+21. Use memmove() where possible.
+20. 6.02.01 6/16/92
+19. Fix automatic correction to work with the new completion.
+18. Globbing bug with brace expansion, when arguments need to be realloced...
+ e.g. echo 134{6,7}{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
+17. shift and left operators update variables correcly ('shift path' did not
+ work)
+16. apollo fixes for cd.
+15. STRNULL <-> NULL bug fixes.
+14. %S in xprintf for short strings.
+13. history -LSc, dirs -LSc additions, builtins builtin [oxymoron]
+12. history formatting string, who formatting string, prompt formatting
+ all use tprintf() now.
+11. $history accepts a second formatting argument..
+10. History timestamps preserved in .history
+9. Backquotes were broken: echo hi | cat > `echo foo`
+8. SGI -t operator problem.
+7. Dnix fixes.
+6. Fix history file writing bug when autologout.
+5. Change from TCSETA to TCSETAW, since we affect the output.
+4. Per's fixes for display margin bugs.
+3. Linux fixes.
+2. Collapse adjacent stars in glob.c to avoid exponential behavior.
+1. Fixed parseescape to put ^ literally if not followed by alpha.
+
+
+V6.02.00, 5/15/92
+94. Default echo_style was not being set correctly.
+93. $< did not work correctly with NLS chars.
+92. 6.01.15 (5/11/92)
+91. Minor cleanups in refresh code.
+90. 6.01.14 (5/8/92)
+89. Print \n in the right margin always to be consistent.
+88. Linux patches.
+87. 6.01.13 (5/2/92)
+86. Fixes in listing and completion of non-unique commands.
+85. Fix =stack entries > 9... from Bill Petro
+84. Fix for last character at margin. [on terminals that have am & xm move
+ the cursor manually to the next line]
+83. Fix for complete completions
+82. small typo in tc.alloc.c from Mark Moraes.
+81. small typo in tw.parse.c from Richard.
+80. Man page fixes from Per.
+79. 6.01.12 (4/24/92) [release version for 6.02]
+78. Autosuffix was not getting reset all the time.
+77. Don't limit completion patterns to 1K.
+76. Naming changes in ed.screen.c from Justin.
+75. 6.01.11 (4/10/92)
+74. Fixed magic-space ! expand bug:
+ > echo a b123 45.{6,7}
+ > echo !:2!:3[magic-space]
+73. Work-around for apollo optimizer in tc.bind.c
+72. Problem with setjmp in tw.parse.c
+71. symlinks=expand from Yumin.
+70. tenematch() fixes from Michael;
+69. 6.01.10 (4/3/92)
+68. Fixed Gnmatch.
+67. Removed ignore_symlinks and chase_symlinks. Replaced by symlinks variable.
+66. Backquote from completion was broken for machines with no dup2()
+65. No $printexitvalue for `` jobs.
+64. Added ultrix stuff for PW_AUTH [from Mike Potter mpotter@lampf.lanl.gov]
+63. Fixed bug in Gnmatch(), added 'N' command 'x' completion.
+62. Fixed fg_proc_entry() so autologout gets disabled when a process
+ is foregrounded.
+61. 6.01.09 (3/26/92)
+60. source builtin takes arguments now that are passed in the script e.g.:
+ > ./tcsh -i a b c
+ > cat test
+ echo $argv
+ > echo $argv
+ a b c
+ > source test 1 2 3
+ 1 2 3
+ > echo $argv
+ a b c
+59. Eliminate $margin_bug, add more intelligent margin code [from Justin]
+58. expand_symlinks variable Urgh...
+57. SGI CONTROL() fixes...
+56. new dnormalize(), expand_symlinks flag.
+55. interrupting completion restores the current line. [from Marc]
+54. 6.01.08 (3/20/92)
+53. inputmode affects the first line too.
+52. Searches in vi do not destroy the current line.
+51. -drwX test enhancement.
+50. Generalized completion syntax and added more completion builtins.
+49. Don't print '\n' on the right margin if we can avoid it.
+48. 6.01.07 (3/9/92)
+47. New completion style. [[<pattern>[ ]],=<completion action>]
+46. 6.01.06 (3/7/92)
+45. complete styles are ignored after shell metachars eg.
+ > complete mail =u
+ > mail christos < [tab]
+ completes filenames.
+44. $echo_style is initialized to the default style of the machine.
+43. SGI 4.0 CTRL() macro is busted. So we ignore it.
+42. Fixed bug with the new margin code (thanks justin)
+41. Fixed mirroring of variables. Now set and setenv affect
+ HOME, TERM, PATH, SHLVL, USER and their csh counterparts. Unset affects
+ affects only the csh copies of the variables, and unsetenv only the
+ environment variables.
+40. Fixed gcc-2.0 warnings in sh.sem.c (needed for vfork() -O2 optimization)
+39. 6.01.05 (2/21/92)
+38. signal masking for BSD machines was still wrong in tw.init.c
+37. Added $margin_bug, and now the editor outputs on the rightmost
+ column by default. This should fix the xterm cut-n-paste problem.
+36. AU/X 2.0 and SGI compiles with POSIX as a default now.
+35. sysv_echo is gone too. Now we have a variable called echo_style
+ which can be set to "none", "bsd", "sysv", "both" that defines
+ the builtin echo_style. The default is "bsd" for systems with
+ SYSVREL == 0, "sysv" otherwise. This can be overriden in config.h
+ by defining ECHO_STYLE ro be BSD_ECHO, SYSV_ECHO, BOTH_ECHO,
+ or NONE_ECHO.
+34. asynchronous notification in run-fg-editor would try to change the
+ tty settings and print an extra prompt.
+ > set notify
+ > sleep 10 &
+ > vi^Z
+ > ^[^Z
+33. alias x /bin/true
+ x<esc>?
+ reported .//bin/true instead of /bin/true
+32. 6.01.04 (2/12/92)
+31. fixed vi_substitute_line
+30. binding completion addition.
+29. showdots=-A addition
+28. sysv_echo addition; deleted bsd_echo which is now the default.
+27. dunique could crash.
+26. Don't clear lines after an asynchronous notification, because it
+ might erase the message.
+25. 6.01.03 (1/29/92)
+24. `` were not working correctly when tcsh is started with 0,1,2 closed.
+23. Correction was picking up the wrong thing in cases like .rhosts hosts
+22. Correction with names with quoted spaces was broken.
+21. Added sysv_echo and bsd_echo.
+20. Added and documented the complete builtin.
+19. Added dunique and cd -.
+18. Per's fix for alarm functions. Things would break if time went backwards.
+17. Realloc bug fix (copy min of old and new size)
+16. Fix for csh compatible braces.
+15. Brace globbing and negation globbing for Gmatch.
+14. 6.01.02 (1/16/92)
+13. Completion builtin, new tw* files.
+12. 6.01.01 (1/6/92)
+11. Changed w_ fields in tc.who.c to who_ to avoid redefinitions in
+ <sys/wait.h> in some os's.
+10. Setting savehist to an empty string makes savehist use the value
+ in $history.
+9. echotc did not use the internal termcap descriptions.
+8. echotc did not work right for single argument termcap strings.
+7. DGUX needs SAVESIGVEC, updated type protection, and disabled CSWTCH.
+6. Changed SVID to SYSVREL, since there is no SVID == 4 (yet).
+5. Typo in tc.sig.h: UNRELSIGS was not getting defined.
+4. Globbing bug fix. tglob() should ignore globbing characters inside
+ backquotes otherwise things get expanded twice:
+ % echo 'bar?' > 'foo?'
+ % echo `cat foo\?`
+ echo: No match.
+3. Mach setpath fix.
+2. Alliant process group fix.
+1. Xenix fixes for broken vi and help path with no suffixes.
+
+
+V6.01.00, 12/19/91 [for comp.sources.unix]
+22. Restore the original prompt in automatic correction when the user
+ asks to re-edit the command.
+21. Better error for unreadable files in tw.parse.c
+20. Sequent patches.
+19. (V6.00.08 beta 12/14/91)
+18. Filenames containing # were spelled/expanded incorrectly.
+17. Stellar/stellix port.
+16. Hpux 8.0 has SIGWINDOW but we cannot get the window size. Protect
+ against window changes updating $LINES and $COLUMNS.
+15. Mach setpath did not work right.
+14. Mach does not need setenv in lib; in fact that does not work right.
+13. shell level gets decremented when we exec.
+12. restart_fg_editor picked the wrong editor if arg contained a slash.
+ e.g vi ~/.cshrc
+11. (V6.00.07 beta 12/08/91)
+10. Allow use of vfork() on systems that do not have job control.
+9. Avoid NUMCC from being defined twice.
+8. (V6.00.06 beta 12/05/91)
+7. SunOS3's FIOCLEX dups...
+6. Yet another globbing bug fix from Michael (echo .[^.])
+5. Ultrix now wants __ before cpp symbols.
+4. Workaround sun's header files inconsistency so tcsh can be compiled
+ with #undef POSIX
+3. Fixed limit stuff so that large values don't cause errors.
+2. Fixed =1 and ~user error messages (Per)
+1. (beta-5 6.00.04 == 6.00.05)
+
+$#*
+$#* New numbering scheme (The last 2 digits are reserved for beta releases
+$#* from now on. So we start at 6.00.06 which is 6.00.04 beta 6, and we are
+$#* going to release 6.01.00...
+$#*
+
+V6.00.04, (never released)
+34. (beta-5 11/25/91)
+33. Simplify code in BindArrowKeys()
+32. Get rid of the PNULL's
+31. Support for shadow password in locking code. (From Kimmo)
+30. Normalize-path editor function.
+29. (beta-4 11/21/91)
+28. minix additions
+27. bindkey fixes (-c addition, casting cleanups)
+26. (beta-3 11/16/91)
+25. Prompt length checking.
+24. Michael's fixes for the watching code. Tcsh could core dump when using
+ a corrupted utmp.
+23. overwrite mode flag, and autologout locking code.
+22. overwrite mode would still insert digits!
+21. Get the value of _POSIX_VDISABLE from pathconf...
+20. Hpux 8.0 fixes. Sigstack botches with shared libraries. Ansi mode
+ static initialization of structures with prototyped function pointers
+ gives spurious warnings...
+19. Onintr in /etc rc files is disabled.
+18. (beta-2 11/03/91)
+17. Multi-line aliases with `` bug fix.
+16. Sticky emacs overwrite mode.
+15. Autolist option.
+14. Fix for redirection with wildcard filanames.
+13. No error correction for multi-line commands.
+12. Esix-4 re-defines p_pid. Argh...
+11. (beta-1 10/28/91)
+10. Foreach loops were broken again.
+9. SUNOS localtime() bug does not only happen on the 8th byte. [Michael]
+8. sh.dir.c, memory corruption in dinit(). Thanks Michael.
+7. uts broken <sys/stat.h> work-around, and has a wait3()
+6. SGI (-t filename) extension, returns true when filename is a tty.
+5. 'default:' addition in all switch() statements.
+4. oflag was not being updated correctly in Rawmode()
+3. missing 'break;' in prompt code '%y'.
+2. infinite loop in :a<mod> code.
+1. hashstat was not reporting hits+misses
+
+
+V6.00.03, 10/21/91
+31. watch code now accepts shell patterns.
+30. new hashing code portability fixes.
+29. $foo:gs/:/ / fix and 'a' modifier addition.
+28. Added $! (the pid of the last background job forked)
+27. exec does not kill the shell when it fails.
+26. Irix4.0 decls.
+25. SVR4 uthost fixes from Kimmo Suominen
+24. Imake addition from marc
+23. New i-search from Per.
+22. ibmesa fixes
+21. convex fixes.
+20. t command for vi.
+19. SVR4 fixes (reverse pipeline and sigaction()) from David Dawes.
+18. New hashing from Marc
+17. Added : to the ~name separators so ~foo:~bar works.
+16. New ed.init.c. Added ed.term.c
+15. Still can't get the history exactly csh-like... !-2$ was broken...
+14. vi character searches.
+13. -Dvar=name command line option for the apollos.
+12. Prompt format changes for date/directory.
+11. Vi searches.
+10. Emacs i-search. [currently not bound]
+9. Vi additions ([dc]-{w,$,f<c>},Undo)
+8. tcsh -n parses now builtin structures.
+7. seek to the end on errors in loops.
+6. echotc -s was broken
+5. Better !event parsing. !foo;!bar was broken.
+4. foreach loops and if statements in aliases.
+3. .cshdirs would corrupt the heap if some directories were not there.
+2. System V echo was broken with \
+1. Fixed echo '!-1', history would eat the quote.
+
+V6.00.02, 08/05/91 [For comp.sources.unix]
+8. tcsh will always set $LOGNAME and $USER if not already set in the
+ environment.
+7. added $histfile.
+6. echo `echo` * and echo ~ {} were broken
+5. setty builtin addition
+4. Multiple : modifiers [experimental, disabled with -DCOMPAT]
+3. 7 bit fixes, and hp9000s500.
+2. #undef DEBUG in tc.alloc.c, so we continue if we get a bad free()
+1. getn() is now protected against NULL strings.
+
+V6.00.01, 07/16/91
+17. added beepcmd, and fixed small tenematch bugs.
+16. Renamed DUP2 flag to HAVEDUP2 cause AIXPS2 defines DUP2 already.
+15. More ANSI fixes, and mit additions (load-average)
+14. don't clear ECHOE, background programs might need it.
+13. Refresh bug fix...
+12. getpwent() should not be interrupted (yellow pages), cause it might
+ leave dangling pointers, that endpwent() will trash.
+11. ChangeSize is now responsible to set the screen size to something
+ sane, but it should not affect the environment if the information
+ it received is not valid
+10. Find out if we are running under emacs using $TERM. It is more
+ reliable.
+9. tcsh was broken if SHORT_STRINGS was not defined (glob() problem)
+8. If GetSize() fails it should always return reasonable screen sizes.
+7. globbing should not fail if one or more patterns match.
+6. increased the number of aliases in the loop detection code.
+5. DGUX has size_t and pid_t defined now...
+4. ESIX does not have EWOULDBLOCK or EAGAIN & POSIX... That was not handled
+ correctly.
+3. rs6000 needs BSDWAIT.
+2. Hpux susp key could not be changed.
+1. Apollo fixes.
+
+V6.00.00, 07/04/91
+45. Fixed quoting of VSTART/VSTOP on termios
+44. Memory leak every time you pipe in or out.
+43. echo {foo bar.[ch]}. Did not check for end of word.
+42. ANSI prototypes
+41. dmove() would leave the source descriptor open when using dup2()
+ e.g.
+ while (1)
+ echo foo >>! bar
+ end
+ runs out of file descriptors
+40. recursive `` expanded via aliases would abort.
+39. set home=../relative-path-name was broken.
+ e.g.
+ set home=../..; cd ..;
+ <abort>
+38. Incorrect error when changing to directory:
+ e.g.
+ mkdir not-in-cd-path; chmod -x not-in-cd-path; cd not-in-cd-path;
+ echoed:
+ not-in-cd-path: No such file or directory.
+ it should have said
+ not-in-cd-path: Permission denied.
+37. if ( \! =~ [\!] ) echo ok, did not echo ok. Quoting inside [] pattern.
+36. More than 127 jobs caused job # to go negative
+35. unsetenv <pattern> ... Added support for more than one pattern.
+34. More background process status report fixes.
+33. Apollo builtin support.
+32. Glob fix. echo '*' * was not handled properly.
+31. Glob fix. setenv FOO `sleep 1` would either cause a segmentation fault.
+ or print ambiguous.
+30. Glob fix. Quoted characters inside [] were not handled properly.
+29. Removed TELL and VMUNIX defines. I think we cannot compile on V6 anyway
+28. Overflow check for expansions.
+27. Added matchbeep, shell pattern history searching.
+26. Added code to handle /dev/std{in,out,err}
+25. Fixed POSIX speed handling in raw mode.
+24. Fixed a flushing bug in the filec code in sh.file.c
+23. Compiled and added hp9000s700 to the list of hosts.
+22. Fixed horrible bug in gmatch()
+ switch (4)
+ case [a-z]:
+ echo bug;
+ breaksw;
+ case 4:
+ echo ok;
+ breaksw;
+ endsw
+21. Fixes for _SEQUENT_ ut_host.
+20. FLUSHO added
+19. mkdir foo\`bar; cd foo\`bar; was broken
+18. EWOULDBLOCK == EAGAIN on RENO check for that too.
+17. Dword() simplified and removed the gotos.
+16. Hpux now compiles with POSIX. Moved the local chars modes in ed.init.c
+ after the tty modes.
+15. Process group fixes for POSIX
+14. We need <sys/filio.h> on the suns for FIOCLEX!!! We did not close
+ our file descriptors before...
+13. A/UX fixes.
+12. History events that start with a number are not necessarily numeric:
+ > !3d
+ 3d: Event not fount
+11. History loop detection added.
+ > alias a \!#
+ > b; a
+10. Alias loop detection code was ineffective on eager optimizers.
+ 9. All errors should now go through our table. Next step we should
+ add nls error messages.
+ 8. Unsetenv now globs its arguments! Before it did not...
+ 7. Added tilde cache and -l flag.
+ 6. Added autocorrect
+ 5. Fixed for so that background jobs in scripts get process groups
+ 4. Fixed amazing memory leak in setenv()...
+ 3. Added short2qstr() so that we can form quoted strings to be used with glob()
+ 2. str2short and short2str allocate space dynamically.
+ 1. Fixed bug related to the is*() routines called with shorts.
+ [only if NLS and SHORT_STRINGS are defined].
+ (The _ctype_ was getting indexed with shorts...)
+ 0. Complete overhaul. Brought in the 4.4 csh stuff. Separated most
+ tcsh and csh code except where I would have to add more global
+ variables. Compiled correctly with both lint and gcc -Wall on
+ a sparc running 4.1
+
+V5.20.03, 03/20/91. - Never released
+25. Kanji, SXA additions.
+24. (exec foo) should not fail if they are suspended jobs.
+23. Support kernel paging stuff on aix 370.
+22. Now we handle correctly the environment variables LINES, COLUMNS,
+ TERMCAP for window size changes...
+21. Tcsh 5.18c+ had broken NULL chars on scripts.
+ > cat > foo
+ #!/usr/local/bin/tcsh -f
+ echo "foo"
+ echo "^V^@"
+ echo "bar"
+ ^D
+ > chmod +x foo; foo
+ foo
+20. Posix has EAGAIN and not EWOULDBLOCK
+19. Don't set ECHOK; makes kill ^U ugly.
+18. $shell is SHELLPATH and not $SHELL any more.
+17. Added -n flag to cd, pushd, popd and dirs. Documented -l and -v
+ flags.
+16. Documented and fixed chase_symlinks and ignore_symlinks.
+15. Call endpwent() when you get interrupted...
+ cd ~chri<tab>^C
+ cd ~christos/<enter>
+ <stuck>
+14. Exec when you have suspended jobs asks for verification.
+13. Variable length fixes:
+ >set abcdefghijklmnopqrstuvwxyz=1
+ >echo $abcdefghijklmnopqrstuvwxyz
+ abcdefghijklmnopqrs: Undefined variable
+ Now we have better messages too...
+12. Icon fixes...
+11. Quote expanded glob and history chars too.
+10. If someone sets SHIN to O_NDELAY we died... Now we set it back...
+ 9. unset path; unsetenv PATH; ls-F; (poof) fixed...
+ 8. Patches for masscomp, and ${var123} lexical analysis fix...
+ 7. Patch for sunview bug: A partially covered suntool sends SIGWINCH every
+ time the text is scrolled, causing annoying redraw effects. Now tcsh
+ checks if the size really changed before doing anything.
+ 6. Interrupt in the middle of cwdcmd, and periodic does not remove the
+ aliases.
+ 5. prompt2 and prompt3 fixes:
+ Prompt2 now prints the status of the parser by default.
+ Prompt3 can now have the standard prompt escape sequences.
+ 4. eval file descriptor re-direction fix.
+ >set p='w | tail +3'
+ >eval $p
+ (originally | tail +3 was ignored)
+ 3. $edit != emacs anymore; it was misleading, 'set edit' enables editing
+ 'unset edit' disables it.
+ 2. PERROR define fix.
+ 1. irix3.3.1 line discipline fix.
+
+V5.20.02, 12/15/90.
+32. /etc/Logout added and merged with /etc/Login flag.
+31. Fixed tty chars in ed.init.c. Some of them were not handled correctly.
+30. Command execution does not leak memory any more, and doing
+ ~ four times does not core-dump.
+29. Fixed the notorious csh 'if(' bug (part of the convex fixes)
+28. Intelligent getwd() on startup, and canonicalization.
+27. Intelligent directory stack. Gets updated when $HOME changes.
+26. Directory stack/save-restore additions
+25. Convex Fixes.
+24. Fixed onlret, and echonl getting stuck on svid.
+23. Shouldn't leave tty in raw mode at auto-logout (e.g. when su'ing from a
+ csh, this is annoying).
+22. Some users had environment EMACS set to something, and with my bad fix
+ at pl 1 found that they didn't have echo... (of course, even before my
+ "fix", they didn't have editing...). Anyway, refined the check to be
+ for EMACS=t, which is what emacs sets when running a subshell.
+21. kill -CONT %job, would not update the status of the job, but it would
+ just restart it.
+20. Sequent fixes.
+19. AIX370 signal and TCF fixes.
+18. fixed ls-F -l, SIGINT problem.
+17. aix on the ps2 does not have strcoll() either.
+16. Bind [A - [D and OA to OD in vi mode to the arrow key functions
+ so that they work from insert mode.
+15. %~ was not working correctly for /home/news and /home/newsbin...
+14. Removed Rcs Log
+13. ISC unix fixes.
+12. sunos3.x wants <sys/dir.h> not <dirent.h>
+11. Remove precmd's, cwdcmd's and periodic cmds that had errors.
+10. Compile sunos4.1 using termio.
+ 9. Rs6000 line discipline fixes.
+ 8. T_Tabs was wrong for termio machines.
+ 7. Don't bind single keystroke arrow keys, when they are already bound!
+ 6. Test for newline and tab before deciding not to send shell scripts
+ to the bourne shell.
+ 5. Added LITERAL prompt stuff.
+ 4. Fixed gethostname() in sh.rest.c to return the nodename.
+ 3. Do not quote spell checked stuff. This is not very intelligent but
+ works better than before.
+ 2. Fixes for relative path components. (paths that start with a .)
+ 1. Fixed so that Rawmode() is not called when we are not editing
+ (breaks running under emacs)
+
+V5.20.01, 11/15/90.
+12. Recognize environment variables too.
+11. Always start in Rawmode()
+10. don't try to execute binary files using the bourne shell.
+ 9. Vi change to end of line updates correctly now.
+ 8. Prompt in continuation lines.
+ 7. Prompt in if statements fix.
+ 6. System V ^C works right now.
+ 5. ^Z works correctly in bindings
+ 4. Better error messages for variables.
+ 3. dinit() now is more robust.
+ 2. Added aux2.0 patches.
+ 1. Fixed bug with arrow key bindings in ed.screen.c. All the keys
+ were bound to up-history!
+
+V5.20.00, 11/10/90.
+26. Fixed system V and POSIX time reporting.
+25. Fixed ed.screen.c so that it does not use malloc().
+24. Fixed SIGWINCH on the iris
+23. Fixed ed.screen.c, so that settc works correcly. It used to set
+ the termcap with a string that was allocated from the stack!
+22. Fixed listing of commands, where the last command was not checked.
+21. Fixed which command. It did not work for
+ \<command>, if command was aliased.
+20. Eliminated CSH4.3 define. You've had enough time to upgrade from 4.2
+19. Fixed GotTermCaps to be called only once.
+18. Added bindkey -r
+17. Attributes were not getting reset correctly.
+16. history -t does not print the time-stamp.
+15. AddXkey, works now for single character xkeys.
+14. filetype() knows better about symlinks.
+13. ls-F works with filenames that have metachars
+12. Completion/spelling works with quoted things.
+11. Fixed refresh bug. Repeat by:
+ On an intelligent terminal that has insert and delete chars (xterm)
+ > orphan
+ > vi orphan.c
+ > ^P^P
+10. Fixed so that if we don't have a tty on stdin editing is disabled.
+ 9. Check for nested process forking, to avoid loops such as:
+ > alias foo 'set bar=`foo`'
+ > foo
+ 8. Fix setting of AsciiOnly (Per)
+ 7. tw.spell.c, defined F_OK for systems that don't have it.
+ 6. ourwait.h had typo in ifdef.
+ 5. BSD compilers need a cast to int for enums used in
+ switches (Matthew Day)
+ 4. Found the cause for the core-dump in long backquote
+ expansions (Mark Davies)
+ 3. Some externs in ed.h needed to be truly externs...
+ reported by Mark Davies, bug appeared only on hp9000s800.
+ 2. Changed $tcsh, and $version strings.
+ 1. Added internal sprintf function, renamed putchar to CSHputchar,
+ printf to CSHprintf, sprintf to CSHsprintf.
+
+V5.19.02, 10/23/90.
+36. Added /etc/cshrc for the SGI irises.
+35. Added expand-variables function.
+34. Documented $time in tcsh.man
+33. Shell variables are now 'recognized' when expanding/listing things.
+32. ls-F does not eat the last slash on the / directory!
+31. Strings bound to keys are printed inside double quotes.
+30. History now remembers the exact line, not just an unparsed version of
+ the tokens.
+29. Renamed itoa to Itoa(), so things in libc that use itoa() don't break.
+28. Ported to IBM aix/ps2.
+27. Fixed eval so that it forks when the output is piped
+ Repeat by:
+ > who | grep $user
+ > eval who | grep $user
+26. Fixed so that 'nice <builtin changing the working directory>' does not
+ nice or fork.
+ Consider doing:
+ nice cd /tmp && rm *.c (don't try it!!!)
+ [what actually happens is that nice has to fork, then the child executes
+ chdir, and the parent stays where it was]
+25. Added Dan's patches (nls, builtin bindkey, fixes to the editor).
+24. Added aix370, migrate, getspath, getspath, getxvers, setxvers
+23. Added builtin echotc, removed sl and el.
+22. Ported to 4.4 BSD. This involved changing the way lots of flags worked,
+ cleanup of the SVID stuff, and addition of more compilation flags.
+ Now POSIX can work whed BSD is defined...
+21. Fixed so that el, sl work. Actually they are to be removed soon and
+ be replaced with echotc.
+20. Avoid the Quoted Space hack for alias when printing jobs!
+ [aliases to the same name avoid further alias expansion, by
+ inserting a quoted space in front of the command. In SHORT_STRINGS
+ QUOTE is the 15th bit so print ignores it thinking it is the
+ end of the string. So we just skip the Quoted Space....]
+ Repeat by:
+ > set notify
+ > alias ls ls -F
+ > (ls) &
+ Prints Exit 0 (
+ Should print: Exit 0 ( ls -F )
+19. Fixed so that "", '', ``, all produce ': Command not found',
+ and not the spurious messages.
+ Repeat by:
+ > set path = (/bin /usr/bin .... .)
+ > ""
+ /some/path/name/: Command not found
+18. Enable the use of <ctype.h> macros if they exist and NLS is defined.
+ NLS code is not ready yet.
+17. Fixed rmstar and continue_jobs code, so that they are not compile
+ options, but shell variables. Now you need to 'set rmstar' to get
+ enable rmstar.
+16. Fixed SIGWINCH, SIGWINDOW, and setting of li, co, that broke
+ suntools, and others.
+ Repeat by:
+ Start a shelltool of size other than 80x34
+ > telltc
+ > stty -a
+ do not report the same number of lines and columns.
+15. More fixes to tw.parse.c, and tw.spell.c.
+14. More fixes to sh.char.c.
+13. Fixed coredump caused by ``.
+12. Fixed spell-line code..
+11. Trapped SIGCHLD in sh.sem.c, while forking. Still there is a small
+ race, but the probability of happening is smaller!
+10. Fixed sh.char.c to be ISO compliant.
+ 9. Added expand-glob
+ 8. Fixed ourwait.h for little endians.
+ 7. Fixed that foreach i (^D expands correctly.
+ 6. Fixed so that listmax is ignored in ls-F.
+ 5. Fixed spelling correction so that single letter words and words that
+ contain globbing chars do not get spell checked.
+ 4. Changed NeXT HOSTTYPE to next, since all HOSTTYPE's are lower case.
+ 3. Fixed symmetry, and changed symmetry HOSTTYPE from sequent to symmetry.
+ 2. Added boldfacing, underlining chars.
+ 1. Added IRIX3.3.1 support.
+
+V5.19.01, 9/26/90.
+ 7. Brought the README file up-to-date, and changed the bug report
+ address to point to me.
+ 6. sh.lex.c. In addla(), overflow computation was wrong.
+ 5. Fixed SHELLPATH, to be set correctly when $SHELL is not set.
+ 4. Fixed print statement in sh.proc.c that contained \215.
+ 3. Fixed the Makefile and MAKEDIFFS so that a tahoe diff can be made.
+ 2. RS6000: hacked around execv bug, and ed.init.c warning.
+ 1. Editor should not be enabled when we don't have a tty.
diff --git a/contrib/tcsh/Imakefile b/contrib/tcsh/Imakefile
new file mode 100644
index 000000000000..bb79bf5e8722
--- /dev/null
+++ b/contrib/tcsh/Imakefile
@@ -0,0 +1,622 @@
+XCOMM
+XCOMM $Id: Imakefile,v 1.76 1999/06/09 19:26:36 christos Exp $
+XCOMM
+XCOMM Imakefile for tcsh 6.08
+XCOMM Marc Horowitz, MIT SIPB
+XCOMM
+
+#ifdef DestDir
+#undef DestDir
+#endif
+#ifdef ManSuffix
+#undef ManSuffix
+#endif
+
+/* All config options go in a separate file. */
+
+#include "imake.config"
+
+#ifndef HasGcc
+# define HasGcc 0
+#endif
+
+#ifndef HasGcc2
+# define HasGcc2 0
+#endif
+
+/* This is a giant conditional block. It should be set up right for
+platforms which are in here, but it may need to be changed for new
+ones. Please send in your fixes and additions! */
+
+/**** tcsh configuration defines ****/
+
+/* specific platforms */
+
+#ifndef ConfigH
+# ifdef UltrixArchitecture
+# define ConfigH ultrix
+# endif
+
+# ifdef UxpArchitecture
+# define ConfigH sysv4
+# endif
+
+# ifdef LinuxArchitecture
+# define ConfigH linux
+# endif
+
+# ifdef AlphaArchitecture
+# ifndef LinuxArchitecture
+# define ConfigH decosf1
+# endif
+# if !HasGcc
+# define MyCflags -std1 -Olimit 2000
+# else
+# define NoCombineRegs
+# endif
+# endif
+
+# if defined(VaxArchitecture) && !defined(UltrixArchitecture)
+# define ConfigH bsd
+# endif
+
+# ifdef NeXTArchitecture
+# define ConfigH mach
+# endif
+
+# if defined(SunArchitecture)
+# if (OSMajorVersion == 3)
+# define ConfigH sunos35
+# else
+# if (OSMajorVersion == 4)
+# if (OSMinorVersion == 0)
+# define ConfigH sunos40
+# else /* OSMinorVersion == 1 */
+# if (OSTeenyVersion == 3)
+# define ConfigH sunos413
+# else /* OsTeenyVersion in [0,1,2] */
+# define ConfigH sunos41
+# endif
+# endif
+# define NoCombineRegs
+# else /* OSMajorVersion == 5 */
+# if (OSMinorVersion < 3)
+# if (OSMinorVersion < 2)
+# define ConfigH sol2
+# else
+# define ConfigH sol22
+# endif
+# else
+# if (OSMinorVersion < 4)
+# define ConfigH sol23
+# else
+# if (OSMinorVersion < 6)
+# define ConfigH sol24
+# else
+# define ConfigH sol26
+# endif
+# endif
+# endif
+# define NoCombineRegs
+# endif
+# endif
+# endif
+
+# ifdef HPArchitecture
+/* For some stupid reason makedepend on HP requires this */
+DEPENDFLAGS = -o.o
+# if (OSMajorVersion >= 8)
+# define ConfigH hpux8
+# else
+# define ConfigH hpux7
+# endif
+# endif
+
+# ifdef CrayArchitecture
+# define ConfigH cray
+# endif
+
+# ifdef SGIArchitecture
+# define ConfigH irix
+# define UseLibBSD
+# if (OSMajorVersion < 5)
+# ifdef you_are_using_yp
+# define UseSunLib
+# endif
+# if !HasGCC
+# define MyStdc -D__STDC__
+# if SGICompilerMajorVersion < 4
+CCOPTIONS=-float # We don't want -cckr and -prototypes
+# endif
+# endif
+# endif
+# if (OSMajorVersion == 6)
+# if (OSMinorVersion >= 2)
+# undef UseLibBSD
+# define ConfigH irix62
+# endif
+# endif
+# endif
+
+# ifdef IBMArchitecture
+# undef UseLibBSD
+# if (SystemV == YES)
+# define ConfigH aix
+# if OSMajorVersion < 3
+# if OSMinorVersion < 2
+# define UseLibBSD
+# endif
+# endif
+# else
+# define ConfigH bsd
+# define AOSArchitecture
+# endif
+# endif
+
+
+#ifdef AOSArchitecture
+#define MyStdc -U__STDC__
+#endif
+
+# if defined(MipsBsdArchitecture) || defined(MipsSysvArchitecture)
+# define ConfigH mips
+# endif
+
+# ifdef DguxArchitecture
+# define ConfigH dgux
+# endif
+
+# ifdef ConvexArchitecture
+# define ConfigH convex
+# endif
+
+# if defined(SQNTArchitecture) || defined(SequentArchitecture)
+# define ConfigH sequent
+# endif
+
+# ifdef MacIIArchitecture
+# define ConfigH mac2
+# endif
+
+# ifdef MinixArchitecture
+/* Maybe conditional on MACH? */
+SYSSRCS=mi.termios.c mi.wait.h mi.varargs.h
+SYSOBJS=mi.termios.${SUF}
+EXTF=ma.setp.c vms.termcap.c
+# else
+/* Maybe conditional on MACH? */
+SYSSRCS=ma.setp.c
+SYSOBJS=ma.setp.${SUF}
+EXTF=mi.termios.c mi.wait.h mi.varargs.h vms.termcap.c
+# endif
+
+# ifdef i386Isc
+# if IscVersion != 202
+# define ConfigH isc
+# define UseLibCposix
+# else
+# define ConfigH isc202
+# endif
+# endif /* i386Isc */
+
+# ifdef OpenBSDArchitecture
+# define ConfigH bsd4.4
+# endif /* OpenBsdArchitecture */
+
+# ifdef NetBSDArchitecture
+# define ConfigH bsd4.4
+# endif /* NetBsdArchitecture */
+
+# ifdef FreeBSDArchitecture
+# define ConfigH bsd4.4
+# endif /* FreeBsdArchitecture */
+
+# ifdef i386SVR4Architecture
+# define ConfigH sysv4
+# ifdef DELL
+# define NoCombineRegs
+# endif
+# endif
+
+#endif /* !ConfigH */
+
+/* generic os's */
+
+#ifndef ConfigH
+
+#if (SystemV == YES)
+#define ConfigH sysv3
+#else
+/* why this as a default? Why not? */
+#define ConfigH bsd
+#endif
+
+#endif /* !ConfigH */
+
+/**** libraries ****/
+
+#if (SystemV == NO) || defined(HPArchitecture) || \
+ defined(SQNTArchitecture) || defined(SequentArchitecture) || \
+ defined(MacIIArchitecture) || defined(UseLibTermcap)
+LIBTERMCAP = -ltermcap
+#else
+LIBTERMCAP =
+#endif
+
+#if defined(SQNTArchitecture) || defined(SequentArchitecture)
+LIBSQNT=-lsocket -linet -lnsl -lseq
+#endif
+
+/* This may not be good enough - I don't have access to enough systems
+to really test it. */
+#if (SystemV == YES) || defined(UseLibCurses) && !defined(HPArchitecture)
+LIBCURSES = -lcurses
+#else
+LIBCURSES =
+#endif
+
+#if defined(UseLibNet)
+LIBNET = -lnet
+#else
+LIBNET =
+#endif
+
+#if defined(UseLibSocket)
+LIBSOCKET = -lsocket
+#else
+LIBSOCKET =
+#endif
+
+#if defined(UseLibBSD)
+LIBBSD = -lbsd
+#else
+LIBBSD =
+#endif
+
+#if (defined(SGIArchitecture) && \
+ (OSMajorVersion == 3) && (OSMinorVersion == 3)) || \
+ defined(UseLibC_S)
+LIBC_S = -lc_s
+#else
+LIBC_S =
+#endif
+
+#if defined(UseLibSun)
+LIBSUN = -lsun
+#else
+LIBSUN =
+#endif
+
+#if defined(UseLibCposix)
+LIBCPOSIX = -lcposix
+#else
+LIBCPOSIX =
+#endif
+
+#if defined(UseLibInet)
+LIBINET = -linet
+#else
+LIBINET =
+#endif
+
+#if defined(UseLibDir)
+LIBDIRECT = -ldir
+#else
+LIBDIRECT =
+#endif
+
+#if defined(UseLibX)
+LIBX = -lx
+#else
+LIBX =
+#endif
+
+#if defined(UseLibIntl)
+LIBINTL = -lintl
+#else
+LIBINTL =
+#endif
+
+#if (HasLibCrypt == YES)
+LIBCRYPT = -lcrypt
+#else
+LIBCRYPT =
+#endif
+
+#if defined(MacIIArchitecture) || defined(UseLibPosix)
+LIBPOSIX = -lposix
+#else
+LIBPOSIX =
+#endif
+
+#if defined(ATTArchitecture) || defined(UseLibDirent)
+LIBDIRECTENT = -ldirent
+#else
+LIBDIRECTENT =
+#endif
+
+/* The order here is significant. Although nothing uses all of these,
+some platforms which use more than one do care about the order. */
+
+SYSLIBS = $(LIBPOSIX) $(LIBDIRECTENT) $(LIBTERMCAP) $(LIBCURSES) \
+ $(LIBNET) $(LIBINTL) $(LIBSOCKET) $(LIBSUN) $(LIBBSD) $(LIBCPOSIX) \
+ $(LIBINET) $(LIBDIRECT) $(LIBX) $(LIBC_S) $(LIBSQNT) $(LIBCRYPT)
+
+/* Past here, nothing should need to be changed to compile on a different
+platform, unless you have a really weird architecture. */
+
+#ifdef MyCC
+CC = MyCC
+#else
+# if HasGcc
+# if HasGcc2
+CC = gcc
+# else
+# ifdef NoCombineRegs
+CC = gcc -finline-functions -fstrength-reduce
+# else
+CC = gcc -fcombine-regs -finline-functions -fstrength-reduce
+# endif
+# endif
+# else
+CC = cc
+# endif
+#endif
+
+#ifdef HESIOD
+HESLIB = -L/usr/athena/lib -lhesiod
+/* it seems to me that the -I shouldn't be necessary, but there seems
+to be a bug in the Imake stuff, so here it is. */
+HESDEF = -DHESIOD -I/usr/athena/include
+#else
+HESLIB =
+HESDEF =
+#endif
+
+#ifdef AFS
+#ifndef AFSDIR
+AFSDIR = /usr/afsws
+#endif
+#ifdef AFS33
+#define AFS33LIB -laudit
+#else
+#define AFS33LIB
+#endif
+/* Auxilliary libs needed for AFS */
+/* Both HPUX and Solaris need the BSD libraries. We need -lc before
+ * the bsd library to avoid using any more of it than is necessary.
+ */
+#if defined(HPArchitecture)
+#define AFSAUXLIB -lc -lBSD
+/* This is probably a kludge, but so is imake. */
+#else
+#if defined(SunArchitecture) && (OSMajorVersion == 5)
+#define AFSAUXLIB -lsocket -lnsl -lc -lucb
+#else
+#define AFSAUXLIB
+#endif
+#endif /* AFSAUXLIB */
+AFSLIB = -L$(AFSDIR)/lib -L$(AFSDIR)/lib/afs -lkauth -lprot -lubik\
+ -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err\
+ $(AFSDIR)/lib/afs/util.a AFS33LIB AFSAUXLIB
+AFSDEF = -DAFS -I$(AFSDIR)/include
+#else
+AFSLIB =
+AFSDEF =
+#endif
+
+/* This is encore specific, but I don't know what encore's #define is,
+and it shouldn't hurt to have it here, so here it is */
+PARALLEL=12 # Make the multi-max run fast.
+
+#ifndef TcshTop
+#define TcshTop /usr/local
+#endif
+TCSHTOP = TcshTop
+
+#ifndef ManSuffix
+#define ManSuffix 1
+#endif
+MANSUFFIX = ManSuffix
+
+#ifdef TcshPath
+PATH_TCSHELL = TcshPath
+TCSHPATH = -D_PATH_TCSHELL='"$(PATH_TCSHELL)"'
+#else
+TCSHPATH =
+#endif
+
+#ifdef DestBin
+TCSH_BINDIR = DestBin
+#else
+TCSH_BINDIR = $(TCSHTOP)/bin
+#endif
+#ifdef DestMan
+TCSH_MANDIR = DestMan
+#else
+TCSH_MANDIR = $(TCSHTOP)/man/man$(MANSUFFIX)
+#endif
+
+LOCALLIBS =
+
+#ifndef MyCflags
+#define MyCflags
+#endif
+
+#ifndef MyDefines
+#define MyDefines
+#endif
+
+#ifndef MyIncludes
+#define MyIncludes
+#endif
+
+#ifndef MyStdc
+#define MyStdc
+#endif
+
+#ifdef CDebugFlags
+CDEBUGFLAGS = CDebugFlags
+#else
+# if HasGcc2
+CDEBUGFLAGS = -O2
+# else
+CDEBUGFLAGS = -O
+# endif
+#endif
+
+
+#ifdef HostType
+HOSTTYPE=HostType
+HTDEF = -DHOSTTYPE='"$(HOSTTYPE)"'
+#else
+HTDEF =
+#endif
+
+DEFINES = $(TCSHPATH) $(HESDEF) $(AFSDEF) $(HTDEF) MyDefines MyCflags MyStdc
+INCLUDES = -I. MyIncludes
+#ifdef MyLibs
+LDLIBS = MyLibs
+#endif
+
+SUF = o
+VERSION = 6.08
+
+SHSRCS= sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.char.c \
+ sh.exp.c sh.file.c sh.func.c sh.glob.c sh.hist.c sh.init.c \
+ sh.lex.c sh.misc.c sh.parse.c sh.print.c sh.proc.c sh.sem.c \
+ sh.set.c sh.time.c sh.char.h sh.dir.h sh.proc.h sh.h \
+ sh.decls.h glob.c glob.h ${SYSSRCS}
+SHOBJS= sh.${SUF} sh.dir.${SUF} sh.dol.${SUF} sh.err.${SUF} sh.exec.${SUF} \
+ sh.char.${SUF} sh.exp.${SUF} sh.func.${SUF} sh.glob.${SUF} \
+ sh.hist.${SUF} sh.init.${SUF} sh.lex.${SUF} sh.misc.${SUF} \
+ sh.parse.${SUF} sh.print.${SUF} sh.proc.${SUF} sh.sem.${SUF} \
+ sh.set.${SUF} sh.time.${SUF} glob.${SUF} ${SYSOBJS}
+
+TWSRCS= tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \
+ tw.comp.c tw.color.c
+TWOBJS= tw.help.${SUF} tw.init.${SUF} tw.parse.${SUF} tw.spell.${SUF} \
+ tw.comp.${SUF} tw.color.${SUF}
+
+EDSRCS= ed.chared.c ed.decls.h ed.defns.c ed.h ed.init.c ed.inputl.c \
+ ed.refresh.c ed.screen.c ed.xmap.c ed.term.c ed.term.h
+EDOBJS= ed.chared.${SUF} ed.refresh.${SUF} ed.screen.${SUF} ed.init.${SUF} \
+ ed.inputl.${SUF} ed.defns.${SUF} ed.xmap.${SUF} ed.term.${SUF}
+
+TCSRCS= tc.alloc.c tc.bind.c tc.const.c tc.decls.h tc.disc.c \
+ tc.func.c tc.os.c tc.os.h tc.printf.c tc.prompt.c \
+ tc.sched.c tc.sig.c tc.sig.h tc.str.c sh.types.h tc.vers.c tc.wait.h \
+ tc.who.c tc.h
+TCOBJS= tc.alloc.${SUF} tc.bind.${SUF} tc.const.${SUF} tc.defs.${SUF} \
+ tc.disc.${SUF} tc.func.${SUF} tc.os.${SUF} tc.printf.${SUF} \
+ tc.prompt.${SUF} tc.sched.${SUF} tc.sig.${SUF} tc.str.${SUF} \
+ tc.vers.${SUF} tc.who.${SUF}
+
+MISCF = Makefile.std Fixes MAKEDIFFS MAKESHAR NewThings README FAQ \
+ WishList config_f.h eight-bit.me glob.3 patchlevel.h \
+ pathnames.h tcsh.man Ported src.desc Imakefile imake.config \
+ README.imake complete.tcsh vmsreadme.txt Makefile.vms termcap.vms \
+ snames.h host.defs gethost.c tcsh.man2html Makefile.in configure.in \
+ Makefile.win32
+CONFSRCS=config/[a-z]*
+
+
+SRCS = $(SHSRCS) $(TWSRCS) $(EDSRCS) $(TCSRCS)
+OBJS = $(SHOBJS) $(TWOBJS) $(EDOBJS) $(TCOBJS)
+
+ALLSRCS= $(MISCF) $(SRCS) $(EXTF)
+
+AllTarget(tcsh)
+
+ed.defns.h: config.h ed.defns.c
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '#ifndef _h_ed_defns' >> $@
+ @echo '#define _h_ed_defns' >> $@
+ egrep '[FV]_' ed.defns.c | egrep '^#define' >> $@
+ @echo '#endif /* _h_ed_defns */' >> $@
+
+sh.err.h: config.h sh.err.c
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '#ifndef _h_sh_err' >> $@
+ @echo '#define _h_sh_err' >> $@
+ egrep 'ERR_' sh.err.c | egrep '^#define' >> $@
+ @echo '#endif /* _h_sh_err */' >> $@
+
+tc.const.h: config.h tc.const.c
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '#ifndef _h_tc_const' >> $@
+ @echo '#define _h_tc_const' >> $@
+ ${CC} -E $(INCLUDES) ${DEFINES} -D_h_tc_const tc.const.c | \
+ grep 'Char STR' | \
+ sed -e 's/Char \([a-zA-Z0-9_]*\)\[\].*/extern Char \1[];/' | \
+ sort >> $@
+ @echo '#endif /* _h_tc_const */' >> $@
+
+config.h: config_f.h
+ cp config/ConfigH config.h
+
+$(OBJS): sh.err.h tc.const.h ed.defns.h
+
+tar.Z:
+ rm -f tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | compress > tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+
+tar.gz:
+ rm -f tcsh-${VERSION}.tar.gz
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | gzip > tcsh-${VERSION}.tar.gz
+ rm -rf tcsh-${VERSION}
+
+shar:
+ rm -f tcsh-*.shar
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ MAKESHAR -v -n tcsh-${VERSION} tcsh-${VERSION} \
+ tcsh-${VERSION}/?* tcsh-${VERSION}/config/?* \
+ tcsh-${VERSION}/?*/set?*
+ rm -rf tcsh-${VERSION}
+
+catalogs:
+ @(cd nls; make catalogs)
+
+world:
+ $(MAKE) clean ; $(MAKE) depend ; $(MAKE) tcsh ; $(MAKE) install
+
+clean::
+ rm -f ed.defns.h sh.err.h tc.const.h config.h tc.defs.*
+ rm -f tcsh.*.m tcsh.*.cat
+
+depend:: config.h ed.defns.h sh.err.h tc.const.h $(SRCS) tc.defs.c
+
+tc.defs.${SUF}: tc.defs.c sh.h
+
+tc.defs.c: gethost host.defs
+ @rm -f $@
+ @echo "/* Do not edit this file, make creates it */" > $@
+ ./gethost host.defs >> $@
+
+ALIB=$(HESLIB) $(AFSLIB) $(SYSLIBS)
+AINC=ed.defns.h sh.err.h tc.const.h sh.h
+
+NormalProgramTarget(tcsh, $(OBJS), $(AINC), $(LOCALLIBS), $(ALIB))
+NormalProgramTarget(gethost, gethost.${SUF}, $(AINC), $(LOCALLIBS), $(ALIB))
+
+InstallProgram(tcsh,$(TCSH_BINDIR))
+InstallManPage(tcsh,$(TCSH_MANDIR))
+DependTarget()
diff --git a/contrib/tcsh/MAKEDIFFS b/contrib/tcsh/MAKEDIFFS
new file mode 100755
index 000000000000..3b87683c5d5f
--- /dev/null
+++ b/contrib/tcsh/MAKEDIFFS
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# MAKEDIFFS.sh: Make context diffs for the csh sources
+#
+# $Id: MAKEDIFFS,v 3.0 1991/07/04 21:57:47 christos Exp $
+XINUDIR=/usr/share/src/mtXinu/bin/csh
+BSDDIR=/usr/share/src/mtXinu/BSD/bin/csh
+TAHOEDIR=/usr/share/src/mtXinu/TAHOE/bin/csh
+RENODIR=/usr/share/src/mtXinu/RENO/bin/csh
+TCSHDIR=`pwd`
+case "x$1" in
+xxinu)
+ CSHDIR=$XINUDIR;;
+xbsd)
+ CSHDIR=$BSDDIR;;
+xtahoe)
+ CSHDIR=$TAHOEDIR;;
+xreno)
+ CSHDIR=$RENODIR;;
+x*)
+ echo "Usage: `basename $0` [bsd|tahoe|xinu|reno]";exit 1;;
+esac
+DIFF1='sh.c sh.char.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.exp.c sh.file.c'
+DIFF2='sh.func.c sh.glob.c sh.hist.c sh.init.c sh.lex.c sh.misc.c sh.parse.c sh.print.c'
+DIFF3='sh.proc.c sh.sem.c sh.set.c sh.time.c sh.char.h sh.dir.h sh.h sh.local.h sh.proc.h'
+
+for i in $DIFF1
+do
+ diff -c $CSHDIR/$i $TCSHDIR/$i
+done > DIFFS.1
+
+for i in $DIFF2
+do
+ diff -c $CSHDIR/$i $TCSHDIR/$i
+done > DIFFS.2
+
+for i in $DIFF3
+do
+ diff -c $CSHDIR/$i $TCSHDIR/$i
+done > DIFFS.3
+exit 0
diff --git a/contrib/tcsh/MAKESHAR b/contrib/tcsh/MAKESHAR
new file mode 100755
index 000000000000..691690f081d1
--- /dev/null
+++ b/contrib/tcsh/MAKESHAR
@@ -0,0 +1,121 @@
+#!/bin/sh
+#
+# MAKESHAR.sh: Make a shar file for the sources
+#
+# $Id: MAKESHAR,v 3.1 1992/05/09 04:03:53 christos Exp $
+
+AWK=/usr/bin/nawk # Must be nawk or gawk cause of 2D arrays
+WC=/usr/ucb/wc
+GREP=/usr/bin/egrep
+SORT=/usr/bin/sort
+SH=/bin/sh
+
+dirs=
+name=kit
+files=
+verbose=0
+size=45000
+
+for i
+do
+ case $i in
+ -n)
+ name=;;
+ -v)
+ verbose=1;;
+ -d)
+ SH=/bin/cat;;
+ -s)
+ size=$1;;
+ *)
+ if [ -z "$name" ]
+ then
+ name=$i
+ elif [ -d $i ]
+ then
+ dirs="$dirs $i"
+ elif [ -f $i ]
+ then
+ files="$files $i"
+ else
+ echo "$0: File `$i' not found." 1>&2
+ exit 1
+ fi;;
+ esac
+done
+
+if [ \( -z "$files" \) -a \( -z "$dirs" \) ]
+then
+ echo "Usage: $0 [-n name] [-s size] [-vd] <files>." 1>&2
+ exit 1
+fi
+
+$WC $files | $GREP -v total | $SORT +2 | $AWK '
+ BEGIN {
+ i = 0;
+ seq = 1;
+ size = 0;
+ name = 1;
+ used = 2;
+ verbose='"$verbose"';
+ tty = "/dev/tty";
+ maxsize = '"$size"';
+ dirs = "'"$dirs"'";
+ };
+ {
+ a[i, size] = $3;
+ a[i, name] = $4;
+ a[i, used] = 0;
+ i++;
+ };
+ END {
+ for (maxi = i--; i >= 0; i--) {
+ idx = 0;
+ if (a[i, used] == 0) {
+ if (verbose && a[i, size] > maxsize)
+ printf("Warning: File %s is %d > %d\n",
+ a[i, name], a[i, size], maxsize) > tty;
+ s = a[i, size];
+ a[i, used] = 1;
+ kit[seq, idx++] = i;
+ j = 0;
+ while (j < maxi) {
+ # Find the greatest file we can add
+ j = maxi;
+ for (k = 0; k < maxi; k++)
+ if (a[k, used] == 0 && a[k, size] + s < maxsize)
+ j = k;
+ if (j < maxi) {
+ s += a[j, size];
+ a[j, used] = 1;
+ kit[seq, idx++] = j;
+ }
+ }
+ sizes[seq] = s;
+ kit[seq++, idx] = -1;
+ }
+ }
+ for (i = 1; i < seq; i++) {
+ printf("shar -n%d -e%d %s ", i, seq - 1, dirs);
+ if (verbose) {
+ printf("%3d of %3d: ", i, seq - 1) > tty;
+ len = 12;
+ }
+ for (j = 0; kit[i, j] != -1; j++) {
+ s = a[kit[i, j], name];
+ if (verbose) {
+ clen = length(s) + 1;
+ len += clen;
+ if (len > 70) {
+ printf("\n ") > tty;
+ len = 12 + clen;
+ }
+ printf("%s ", s) > tty;
+ }
+ printf("%s ", s);
+ }
+ printf("> '"$name"'-%d.shar;", i);
+ if (verbose)
+ printf("= %5d\n", sizes[i]) > tty;
+ }
+ }' | $SH
diff --git a/contrib/tcsh/Makefile.in b/contrib/tcsh/Makefile.in
new file mode 100644
index 000000000000..f7527637bc6b
--- /dev/null
+++ b/contrib/tcsh/Makefile.in
@@ -0,0 +1,628 @@
+# $Id: Makefile.in,v 3.12 1998/11/24 18:17:08 christos Exp $
+# Makefile.in 4.3 6/11/83
+#
+# C Shell with process control; VM/UNIX VAX Makefile
+# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
+#
+# With an input editor, command completion, etc. and ported to all sorts of
+# things; Paul Placeway, CIS Dept., Ohio State University
+#
+SHELL=/bin/sh
+VERSION=6.08
+BUILD=tcsh
+VPATH=@srcdir@
+srcdir=@srcdir@
+
+################################################################
+## CFLAGS. For various -D things, see config.h
+################################################################
+#
+# These are the default suffixes from .c to .o and -c to get there
+# but to use the global optimizer on the mips boxes, see below
+#
+SUF=o
+CF=-c
+
+CPPFLAGS=-I. -I$(srcdir)
+
+LFLAGS=
+#LFLAGS= -Zn10000 # hpux lint
+
+
+CFLAGS = @CFLAGS@ # This is set by autoconf.
+#CFLAGS= -g # debug
+#CFLAGS= -O # production
+#CFLAGS= # Broken optimizers....
+
+#CFLAGS= -g -pg -DPROF
+#CFLAGS= -O -pg -DPROF
+
+# gcc 1.00-1.37
+#CFLAGS= -O -finline-functions -fstrength-reduce
+
+# gcc 1.37-1.40
+#CFLAGS= -O -fcombine-regs -finline-functions -fstrength-reduce
+# add -msoft-float for 68881 machines.
+
+# gcc 2.0
+# On the sparc, don't use -O2; it breaks setjmp() and vfork()
+#CFLAGS= -O
+
+# gcc-2.1+
+#CFLAGS= -O2
+
+# lucid c on suns
+#CFLAGS= -O5
+
+# gcc 2.1 on linux
+#CFLAGS= -O6 -fomit-frame-pointer
+
+# HP/UX 8.0, 9.0
+#CFLAGS= +O3 -Aa
+
+# Ultrix 4.2a
+#CFLAGS= -O -Olimit 2000
+
+# Intel Paragon OSF/1 with PGI compilers
+#CFLAGS= -O -Mnodebug -Mnoperfmon
+
+# DEC Alpha OSF/1
+#CFLAGS= -O2 -Olimit 2000 ## Normal Optimization
+#CFLAGS= -O3 -Olimit 2000 ## Full Optimization - may not work
+#CF=-j
+#SUF=u
+#.SUFFIXES: .u
+
+# for silicon graphics (and other mips compilers) -- use the
+# global optimizer! (-O3).
+# On SGI 4.0+ you need to add -D__STDC__ too.
+#CFLAGS= -O3
+#CFLAGS= -O3 -Olimit 2000 ## Ultrix 4.2a
+#CF=-j
+#SUF=u
+#.SUFFIXES: .u ## Ultrix and gnu-make need that
+
+# mips systems
+# CFLAGS= -O -systype bsd43 -Wf,-XNd5000 -Wf,-XNp6000 -Olimit 2000
+
+# for at&t machines
+#CFLAGS= -O -Ksd
+
+# Stardent Titan
+#CFLAGS = -O -43
+
+# Stardent Stellar or sunos4 /bin/cc or Solaris2.1 /opt/SUNWspro/bin/cc
+#CFLAGS = -O4
+
+# Intergraph clipper CLIX 3.1
+#CFLAGS= -w -O2
+
+# Dnix 5.3
+#CFLAGS = -O -X7
+
+# Pyramid OS/x
+#CFLAGS = -OG
+
+# Multiflow (5M binary... if you choose -O5!)
+#CFLAGS = -O5 -sb_trace 0
+
+# DDE Supermax Unix SYSV Rel III.
+# CFLAGS= -O3
+
+# SINIX RMx00
+#CFLAGS= -O # -D_POSIX_SOURCE # -kansi
+
+# Apollo's with cc [apollo builtins don't work with gcc]
+# and apollo should not define __STDC__ if it does not have
+# the standard header files. RT's (aos4.3) need that too;
+# you might want to skip the -O on the rt's... Not very wise.
+# AIX/ESA needs -D_IBMESA on command line (this may disappear by GA)
+#DFLAGS=-U__STDC__
+#DFLAGS=-D_IBMESA
+# On aix2.2.1 we need more compiler space.
+#DFLAGS=-Nd4000 -Nn3000
+# AU/X 2.0 needs a flag for POSIX (read the config file)
+#DFLAGS=-Zp
+# Tektronix 4300 running UTek 4.0 (BSD 4.2) needs:
+#DFLAGS = -DUTek -DBSD
+# VMS_POSIX needs:
+#DFLAGS=-D_VMS_POSIX
+# Multiflow and PCC compilers don't like void typedefs.
+# You may also need -U__STDC__ if you use pcc (i.e. ibmrt aos4.3).
+#DFLAGS=-DMULTIFLOW
+#DFLAGS=-DPCC
+# DELL SVR4
+#DFLAGS=-DDELL
+#DFLAGS=
+#DFLAGS=-D_PATH_TCSHELL='"${DESTBIN}/tcsh"'
+## The following is set by autoconf.
+DFLAGS = -D_PATH_TCSHELL='"${DESTBIN}/tcsh"' @DFLAGS@ @CPPFLAGS@
+
+
+################################################################
+## LDFLAGS. Define something here if you need to
+################################################################
+LDFLAGS= @LDFLAGS@ ## This is set by autoconf.
+#LDFLAGS= ## The simplest, suitable for all.
+#LDFLAGS= -s ## Stripped. Takes less space on disk.
+#LDFLAGS= -s -n ## Pure executable. Spares paging over
+# ## the network for machines with local
+# ## swap but external /usr/local/bin .
+#LDFLAGS= -s -n -Bstatic ## Without dynamic linking. (SunOS/cc)
+#LDFLAGS= -s -n -static ## Without dynamic linking. (SunOS/gcc)
+#LDFLAGS= -Wl,-s,-n ## Stripped, shared text (Unicos)
+#LDFLAGS= -s -static ## Link statically. (linux)
+#LDFLAGS= -s -N ## Impure executable (linux)
+
+################################################################
+## LIBES. Pick one, or roll your own.
+################################################################
+LIBES= @LIBS@ ## This is set by autoconf.
+#LIBES= -ltermcap ## BSD style things
+#LIBES= -ltermcap ## SunOS, HP-UX, pyramid
+#LIBES= -ltermcap ## Linux
+#LIBES= -ltermcap -lshadow ## Linux with PW_SHADOW
+#LIBES= -ltermcap -lsec ## Tek XD88/10 (UTekV) with PW_SHADOW
+#LIBES= -ltermcap -lsec ## Motorola MPC (sysV88) with PW_SHADOW
+#LIBES= -ltermcap -lcs ## Mach
+#LIBES= -ltermcap -lbsd ## DEC osf1 on the alpha
+#LIBES= -ltermcap -lbsd ## Intel paragon
+#LIBES= -ltermcap -lbsd ## Clipper intergraph
+#LIBES= -ltermcap -lseq ## Sequent's Dynix
+#LIBES= -ltermcap -lauth ## Ultrix with Enhanced Security
+#LIBES= -ltermcap -ldir -lx ## Xenix 386 style things
+#LIBES= -ltermcap -lndir -lsocket -ljobs ## masscomp RTU6.0
+#LIBES= -lcurses ## AIX on the rt
+#LIBES= -lcurses ## TitanOS on the stellar
+#LIBES= -ltermlib -lsocket -lnsl ## SysV4 w/o BSDTIMES or Solaris 2
+#LIBES= -lcurses ## SysV3 w/o networking
+#LIBES= -lcurses -lnet ## SysV3 with networking
+#LIBES= -lcurses -ldir ## SysV2 w/o networking & dirlib
+#LIBES= -lcurses -ldir -lnet ## SysV2 with networking & dirlib
+#LIBES= -lcurses -lbsd ## AIX on the IBM 370 or rs6000 or ps2
+#LIBES= -lcurses -lbsd ## ETA10
+#LIBES= -lcurses -lbsd ## Irix3.1 on the SGI-IRIS4D
+#LIBES= -lcurses -lbsd -lc_s ## Irix3.3 on the SGI-IRIS4D w/o yp
+#LIBES= -lcurses -lsun -lbsd -lc_s ## Irix3.3 on the SGI-IRIS4D with yp
+#LIBES= -lcurses -lsocket -lbsd ## Amdahl UTS 2.1
+#LIBES= -lcurses -lsocket ## Intel's hypercube.
+#LIBES= -lcurses -lsocket ## ns32000 based Opus.
+#LIBES= -lcurses -lcposix ## ISC 2.2 without networking
+#LIBES= -lcposix -lc_s -lcurses -linet ## ISC 2.2 with networking
+#LIBES= -lcurses -lsec -lc_s ## ISC 2.0.2 without networking
+#LIBES= -lcurses -linet -lsec -lc_s ## ISC 2.0.2 with networking
+#LIBES= -lcurses -lintl -lcrypt ## SCO SysVR3.2v2.0
+#LIBES= -lcurses -lintl -lsocket -lcrypt ## SCO+ODT1.1
+#LIBES= -lposix -ltermcap ## A/UX 2.0
+#LIBES= -lposix -ltermcap -lc_s ## A/UX 3.0
+#LIBES= -ldirent -lcurses ## att3b1 cc w/o shared lib & dirlib
+#LIBES= -shlib -ldirent -lcurses ## att3b1 gcc with shared lib & dirlib
+#LIBES= -ltermlib -lsocket -lnsl -lc /usr/ucblib/libucb.a ## SysV4 with BSDTIMES
+#LIBES= -lcurses -lnsl -lsocket -lc /usr/ucblib/libucb.a ## Stardent Vistra
+#LIBES= -ltermc ## emx under OS/2
+#LIBES= ## Minix, VMS_POSIX
+#LIBES= -ltermcap -lcrypt ## Multiflow
+#LIBES= -ltermcap -lcrypt ## NetBSD
+#LIBES= -lcurses ## DDE Supermax
+
+################################################################
+## EXTRAFLAGS and EXTRALIBS
+################################################################
+# Compiling for AFS with kerberos authentication
+#AFSLIBDIR = /usr/afsws/lib
+#AFSDEF = -DAFS -I/usr/afsws/include
+#AFS33LIB = -laudit
+#
+#Solaris and HPUX require the BSD libraries with AFS.
+#We use -lc to use only what we require.
+#AFSAUXLIB = -lsocket -lnsl -lc -lucb # Solaris
+#AFSAUXLIB = -lc -lBSD # HPUX
+#
+#AFSLIB = -L$(AFSLIBDIR) -L$(AFSLIBDIR)/afs -lkauth -lprot -lubik\
+# -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err\
+# $(AFSLIBDIR)/afs/util.a $(AFS33LIB) $(AFSAUXLIB)
+#
+
+EXTRAFLAGS = @HESDEF@ $(AFSDEF)
+EXTRALIBS = @HESLIB@ $(AFSLIB)
+
+
+# The difficult choice of a c-compiler...
+# First, you should try your own c-compiler.
+# Gcc -traditional is also a safe choice.
+# If you think that you have good include files try gcc -Wall...
+# If you want to take out -traditional, make sure that your sys/ioctl.h
+# is fixed correctly, otherwise you'll be stopped for tty input, or you
+# will lose the editor and job control.
+
+# This is for setting your C preprocessor value.
+CPP = @CPP@ # This is set by autoconf.
+# The -B tells gcc to use /bin/ld. This is to avoid using the gnu ld, which
+# on the suns does not know how to make dynamically linked binaries.
+CC = @CC@ # This is set by autoconf.
+#CC= gcc -Wall -pipe -B/bin/ # -ansi -pedantic
+#CC= gcc -m486 -pipe -Wall # Generate code for Intel 486 (linux)
+#CC= shlicc # BSDI2.1 w/ shared libraries
+#CC= cc
+#CC= occ
+#CC= acc
+#CC= pcc
+#CC= hc -w
+#CC= c89 # For VMS/POSIX
+#CC= /bin/cc # For suns, w/o gcc and SVR4
+#CC= /usr/lib/sun.compile/cc # FPS 500 (+FPX) with Sun C compiler
+#CC= /opt/SUNWspro/bin/cc # Solaris 2.1
+#CC= scc # Alliant fx2800
+#CC= cc -h0,ansi,novector,float0 # for NEC SX-4
+#CC= lcc -wa
+ED= ed
+AS= as
+RM= rm
+CXREF= /usr/ucb/cxref
+VGRIND= csh /usr/ucb/vgrind
+CTAGS= /usr/ucb/ctags
+#XSTR= /usr/ucb/xstr
+SCCS= /usr/local/sccs
+PARALLEL=12 # Make the multi-max run fast.
+#P=& # Use Sequent's parallel make
+P=
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+bindir=@bindir@
+mandir=@mandir@
+MANSECT=1
+DESTBIN=${DESTDIR}${bindir}
+DESTMAN=${DESTDIR}${mandir}/man${MANSECT}
+# DESTMAN=${DESTDIR}/catman/man${MANSECT} # A/UX
+# DESTMAN=${DESTDIR}/usr/share/man/man${MANSECT} # Stardent Vistra (SysVR4)
+# DESTMAN=/usr/catman/1l # Amiga unix (SysVR4)
+FTPAREA=/usr/spool/ftp
+
+ASSRCS= sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.char.c \
+ sh.exp.c sh.file.c sh.func.c sh.glob.c sh.hist.c sh.init.c \
+ sh.lex.c sh.misc.c sh.parse.c sh.print.c sh.proc.c sh.sem.c \
+ sh.set.c sh.time.c sh.char.h sh.dir.h sh.proc.h sh.h \
+ tw.color.c
+PSSRCS= sh.decls.h glob.c glob.h mi.termios.c mi.wait.h mi.varargs.h ma.setp.c \
+ vms.termcap.c
+SHSRCS= ${ASSRCS} ${PSSRCS}
+SHOBJS= sh.${SUF} sh.dir.${SUF} sh.dol.${SUF} sh.err.${SUF} sh.exec.${SUF} \
+ sh.char.${SUF} sh.exp.${SUF} sh.func.${SUF} sh.glob.${SUF} \
+ sh.hist.${SUF} sh.init.${SUF} sh.lex.${SUF} sh.misc.${SUF} \
+ sh.parse.${SUF} sh.print.${SUF} sh.proc.${SUF} sh.sem.${SUF} \
+ sh.set.${SUF} sh.time.${SUF} glob.${SUF} mi.termios.${SUF} \
+ ma.setp.${SUF} vms.termcap.${SUF}
+
+TWSRCS= tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \
+ tw.comp.c tw.color.c
+TWOBJS= tw.help.${SUF} tw.init.${SUF} tw.parse.${SUF} tw.spell.${SUF} \
+ tw.comp.${SUF} tw.color.${SUF}
+
+EDSRCS= ed.chared.c ed.decls.h ed.defns.c ed.h ed.init.c ed.inputl.c \
+ ed.refresh.c ed.screen.c ed.xmap.c ed.term.c ed.term.h
+EDOBJS= ed.chared.${SUF} ed.refresh.${SUF} ed.screen.${SUF} ed.init.${SUF} \
+ ed.inputl.${SUF} ed.defns.${SUF} ed.xmap.${SUF} ed.term.${SUF}
+
+TCSRCS= tc.alloc.c tc.bind.c tc.const.c tc.decls.h tc.disc.c \
+ tc.func.c tc.os.c tc.os.h tc.printf.c tc.prompt.c \
+ tc.sched.c tc.sig.c tc.sig.h tc.str.c sh.types.h tc.vers.c tc.wait.h \
+ tc.who.c tc.h
+TCOBJS= tc.alloc.${SUF} tc.bind.${SUF} tc.const.${SUF} tc.defs.${SUF} \
+ tc.disc.${SUF} tc.func.${SUF} tc.os.${SUF} tc.printf.${SUF} \
+ tc.prompt.${SUF} tc.sched.${SUF} tc.sig.${SUF} tc.str.${SUF} \
+ tc.vers.${SUF} tc.who.${SUF}
+
+PVSRCS= Makefile.std Makefile.vms Makefile.in Makefile.win32
+AVSRCS= Fixes MAKEDIFFS MAKESHAR NewThings README FAQ \
+ WishList config_f.h eight-bit.me glob.3 patchlevel.h \
+ pathnames.h tcsh.man Ported src.desc Imakefile imake.config \
+ README.imake complete.tcsh vmsreadme.txt termcap.vms snames.h \
+ host.defs gethost.c tcsh.man2html configure.in configure config.h.in
+
+VHSRCS=${PVSRCS} ${AVSRCS}
+
+CONFSRCS=config/*
+
+ALLSRCS= ${SHSRCS} ${TWSRCS} ${EDSRCS} ${TCSRCS} ${VHSRCS}
+DISTSRCS= ${PSSRCS} ${TWSRCS} ${EDSRCS} ${TCSRCS} ${AVSRCS}
+
+
+OBJS= ${SHOBJS} ${TWOBJS} ${EDOBJS} ${TCOBJS}
+
+
+all: ${BUILD}
+
+tcsh:$(P) ${OBJS}
+ rm -f tcsh core
+ ${CC} -o tcsh ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} ${OBJS} ${LIBES} ${EXTRALIBS}
+
+# Purify
+pure:$(P) ${OBJS}
+ rm -f tcsh core
+ purify `echo ${CC} | sed -e s,-B/bin/,,` -o tcsh ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} ${OBJS} ${LIBES} ${EXTRALIBS}
+# OS/2
+tcsh.exe: tcsh
+ emxbind tcsh
+
+gethost: gethost.c sh.err.h tc.const.h sh.h
+ rm -f gethost
+ ${CC} -o gethost ${LDFLAGS} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} $(srcdir)/gethost.c ${LIBES} ${EXTRALIBS}
+
+tc.defs.c: gethost host.defs
+ @rm -f $@
+ @echo "/* Do not edit this file, make creates it */" > $@
+ ./gethost $(srcdir)/host.defs >> $@
+
+tcsh.ps: tcsh.man
+ rm -f tcsh.ps
+ -ptroff -t -man $(srcdir)/tcsh.man > tcsh.ps
+
+
+.c.${SUF}:
+ ${CC} ${CF} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ${EXTRAFLAGS} $<
+
+# _VMS_POSIX #module addition
+#.c.${SUF}:
+# @(echo '#module '`echo $< | sed -e 's/\./_/g'`; cat $<) > $*..c
+# @echo ${CC} ${CF} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ${EXTRAFLAGS} $*.c
+# @${CC} ${CF} ${CFLAGS} ${CPPFLAGS} ${DFLAGS} ${EXTRAFLAGS} $*..c
+# @mv $*..o $*.o
+# @rm -f $*..c
+
+
+# Don't do any special massaging of C files for sharing of strings!!
+# it causes weird segmentation faults on some systems.
+#.c.o:
+# ${CPP} ${CFLAGS} ${CPPFLAGS} $*.c | ${XSTR} -c -
+# ${CC} ${CF} ${CFLAGS} ${CPPFLAGS} x.c
+# mv -f x.o $*.o
+# rm -f x.c
+
+#ed.init.o: ed.init.c
+# ${CPP} ${CFLAGS} ${CPPFLAGS} $*.c | ${XSTR} -c -
+# ${CC} -R ${CF} ${CFLAGS} ${CPPFLAGS} x.c
+# mv -f x.o $*.o
+# rm -f x.c
+
+#strings.o: strings
+# ${XSTR}
+# ${CC} -c -R xs.c
+# mv -f xs.o strings.o
+# rm -f xs.c
+
+##.DEFAULT:
+## ${SCCS} get $<
+
+##.DEFAULT:
+## co $<
+
+ed.defns.h: ed.defns.c
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '#ifndef _h_ed_defns' >> $@
+ @echo '#define _h_ed_defns' >> $@
+ grep '[FV]_' $(srcdir)/ed.defns.c | grep '^#define' >> $@
+ @echo '#endif /* _h_ed_defns */' >> $@
+
+sh.err.h: sh.err.c
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '#ifndef _h_sh_err' >> $@
+ @echo '#define _h_sh_err' >> $@
+ grep 'ERR_' $(srcdir)/sh.err.c | grep '^#define' >> $@
+ @echo '#endif /* _h_sh_err */' >> $@
+
+tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '#ifndef _h_tc_const' >> $@
+ @echo '#define _h_tc_const' >> $@
+ ${CPP} $(CPPFLAGS) ${DFLAGS} ${EXTRAFLAGS} -D_h_tc_const\
+ $(srcdir)/tc.const.c | grep 'Char STR' | \
+ sed -e 's/Char \([a-zA-Z0-9_]*\)\[\].*/extern Char \1[];/' | \
+ sort >> $@
+ @echo '#endif /* _h_tc_const */' >> $@
+
+csh.prof: ${OBJS} sh.prof.${SUF} mcrt0.${SUF}
+ rm -f csh.prof
+ ld -X mcrt0.${SUF} ${OBJS} -o csh.prof ${LIBES} -lc
+
+sh.prof.${SUF}:
+ cp sh.c sh.prof.c
+ ${CC} ${CF} ${CFLAGS} ${CPPFLAGS} -DPROF sh.prof.c
+
+lint: tc.const.h ed.defns.h
+ lint ${DFLAGS} ${CPPFLAGS} ${LFLAGS} sh*.c tw*.c ed*.c tc.*.c ${LIBES}
+
+alint: tc.const.h ed.defns.h
+ alint ${DFLAGS} ${CPPFLAGS} ${LFLAGS} sh*.c tw*.c ed*.c tc.*.c ${LIBES}
+
+print:
+ @pr READ_ME
+ @pr makefile makefile.*
+ @(size -l a.out; size *.${SUF}) | pr -h SIZES
+ @${CXREF} sh*.c | pr -h XREF
+ @ls -l | pr
+ @pr sh*.h [a-rt-z]*.h sh*.c alloc.c
+
+vprint:
+ @pr -l84 READ_ME TODO
+ @pr -l84 makefile makefile.*
+ @(size -l a.out; size *.${SUF}) | pr -l84 -h SIZES
+ @${CXREF} sh*.c | pr -l84 -h XREF
+ @ls -l | pr -l84
+ @${CXREF} sh*.c | pr -l84 -h XREF
+ @pr -l84 sh*.h [a-rt-z]*.h sh*.c alloc.c
+
+vgrind:
+ @cp /dev/null index
+ @for i in *.h; do vgrind -t -h "C Shell" $$i >/crp/bill/csh/$$i.t; done
+ @for i in *.c; do vgrind -t -h "C Shell" $$i >/crp/bill/csh/$$i.t; done
+ @vgrind -t -x -h Index index >/crp/bill/csh/index.t
+
+install-strip: install
+
+install: tcsh
+ mkdir -p ${DESTBIN}
+ -mv -f ${DESTBIN}/tcsh ${DESTBIN}/tcsh.old
+ cp tcsh ${DESTBIN}/tcsh
+ -strip ${DESTBIN}/tcsh
+ chmod 555 ${DESTBIN}/tcsh
+
+install.man: tcsh.man
+ mkdir -p ${DESTMAN}
+ -rm -f ${DESTMAN}/tcsh.${MANSECT}
+ cp $(srcdir)/tcsh.man ${DESTMAN}/tcsh.${MANSECT}
+ chmod 444 ${DESTMAN}/tcsh.${MANSECT}
+
+# Amiga Unix
+#install.man: tcsh.man
+# compress tcsh.man
+# cp tcsh.man.Z ${DESTMAN}/tcsh.Z
+# chmod 444 ${DESTMAN}/tcsh.Z
+
+# Apple A/UX
+#install.man: tcsh.man
+# -rm -f ${DESTMAN}/tcsh.${MANSECT}.Z
+# nroff -man tcsh.man | compress > ${DESTMAN}/tcsh.${MANSECT}.Z
+# chmod 444 ${DESTMAN}/tcsh.${MANSECT}.Z
+
+clean:
+ ${RM} -f a.out strings x.c xs.c tcsh tcsh.a _MAKE_LOG core gethost
+ ${RM} -f *.${SUF} sh.prof.c ed.defns.h tc.const.h sh.err.h tc.defs.c
+ ${RM} -f tcsh.*.m tcsh.*.cat
+
+veryclean: clean
+ ${RM} -f config.h config.status config.cache config.log Makefile tcsh.ps
+ ${RM} -f *~ #*
+
+distclean: veryclean
+
+tags: /tmp
+ ${CTAGS} sh*.c
+
+tar.Z:
+ rm -f tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | compress > tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+
+tar.gz:
+ rm -f tcsh-${VERSION}.tar.gz
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | gzip > tcsh-${VERSION}.tar.gz
+ rm -rf tcsh-${VERSION}
+
+shar:
+ rm -f tcsh-*.shar
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ MAKESHAR -v -n tcsh-${VERSION} tcsh-${VERSION} \
+ tcsh-${VERSION}/?* tcsh-${VERSION}/config/?* \
+ tcsh-${VERSION}/?*/set?*
+ rm -rf tcsh-${VERSION}
+
+catalogs:
+ @(cd nls; make catalogs)
+
+tcsh-${VERSION}.tar.Z:
+ rm -rf tcsh-${VERSION}
+ rm -f tcsh-${VERSION}.tar tcsh-${VERSION}.tar.Z DIFFS.[123]
+ mkdir tcsh-${VERSION}
+ ./MAKEDIFFS bsd
+ mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh-${VERSION}
+ cp ${DISTSRCS} tcsh-${VERSION}
+ mkdir tcsh-${VERSION}/config
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ cp Makefile tcsh-${VERSION}/Makefile.new
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | compress > tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+
+tcsh.tahoe-${VERSION}.tar.Z:
+ rm -rf tcsh.tahoe-${VERSION}
+ rm -f tcsh.tahoe-${VERSION}.tar tcsh.tahoe-${VERSION}.tar.Z DIFFS.[123]
+ mkdir tcsh.tahoe-${VERSION}
+ ./MAKEDIFFS tahoe
+ mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh.tahoe-${VERSION}
+ cp ${DISTSRCS} tcsh.tahoe-${VERSION}
+ mkdir tcsh.tahoe-${VERSION}/config
+ cp ${CONFSRCS} tcsh.tahoe-${VERSION}/config
+ cp Makefile tcsh.tahoe-${VERSION}/Makefile.new
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh.tahoe-${VERSION} | compress > tcsh.tahoe-${VERSION}.tar.Z
+ rm -rf tcsh.tahoe-${VERSION}
+
+tcsh.reno-${VERSION}.tar.Z:
+ rm -rf tcsh.reno-${VERSION}
+ rm -f tcsh.reno-${VERSION}.tar tcsh.reno-${VERSION}.tar.Z DIFFS.[123]
+ mkdir tcsh.reno-${VERSION}
+ ./MAKEDIFFS reno
+ mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh.reno-${VERSION}
+ cp ${DISTSRCS} tcsh.reno-${VERSION}
+ mkdir tcsh.reno-${VERSION}/config
+ cp ${CONFSRCS} tcsh.reno-${VERSION}/config
+ cp Makefile tcsh.reno-${VERSION}/Makefile.new
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh.reno-${VERSION} | compress > tcsh.reno-${VERSION}.tar.Z
+ rm -rf tcsh.reno-${VERSION}
+
+ftp: tcsh-${VERSION}.tar.Z tcsh.tahoe-${VERSION}.tar.Z
+ cp tcsh-${VERSION}.tar.Z tcsh.tahoe-${VERSION}.tar.Z ${FTPAREA}
+ cp tcsh.man ${FTPAREA}
+
+autoconfigure: $(srcdir)/configure $(srcdir)/config.h.in
+
+$(srcdir)/configure: $(srcdir)/configure.in
+ cd $(srcdir) && autoconf
+
+$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
+$(srcdir)/stamp-h.in: $(srcdir)/configure.in
+ cd $(srcdir) && autoheader
+ @echo timestamp > $(srcdir)/stamp-h.in
+
+#
+# Dependencies
+#
+config.h: config_f.h
+
+TCH=tc.h tc.const.h tc.decls.h tc.os.h tc.sig.h
+SHH=sh.h sh.types.h sh.char.h sh.err.h sh.dir.h sh.proc.h pathnames.h \
+ sh.decls.h ${TCH}
+TWH=tw.h tw.decls.h
+EDH=ed.h ed.decls.h
+
+# EDH
+EDINC=sh.${SUF} sh.func.${SUF} sh.lex.${SUF} sh.print.${SUF} sh.proc.${SUF} \
+ sh.set.${SUF} tc.bind.${SUF} tc.os.${SUF} tc.prompt.${SUF} \
+ tc.sched.${SUF} tw.parse.${SUF} tw.color.${SUF}
+${EDOBJS} ${EDINC} : ${EDH}
+
+# SHH
+${OBJS}: config.h ${SHH}
+
+# TWH
+TWINC=ed.chared.${SUF} ed.inputl.${SUF} sh.exec.${SUF} sh.func.${SUF} \
+ sh.set.${SUF} tc.func.${SUF} tw.color.${SUF}
+${TWOBJS} ${TWINC}: ${TWH}
+
+# glob.h
+glob.${SUF} sh.glob.${SUF}: glob.h
+
+# ed.defns.h
+EDDINC=tc.bind.${SUF} tc.func.${SUF} tc.os.${SUF}
+${EDOBJS} ${EDDINC}: ed.defns.h
+
+# tc.defs.o
+tc.defs.${SUF}: tc.defs.c sh.h
diff --git a/contrib/tcsh/Makefile.std b/contrib/tcsh/Makefile.std
new file mode 100644
index 000000000000..2e676be14ea0
--- /dev/null
+++ b/contrib/tcsh/Makefile.std
@@ -0,0 +1,625 @@
+# $Id: Makefile.std,v 1.88 1998/10/02 10:56:47 christos Exp $
+# Makefile.std 4.3 6/11/83
+#
+# C Shell with process control; VM/UNIX VAX Makefile
+# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
+#
+# With an input editor, command completion, etc. and ported to all sorts of
+# things; Paul Placeway, CIS Dept., Ohio State University
+#
+SHELL=/bin/sh
+VERSION=6.08
+BUILD=tcsh
+srcdir=.
+
+################################################################
+## CFLAGS. For various -D things, see config.h
+################################################################
+#
+# These are the default suffixes from .c to .o and -c to get there
+# but to use the global optimizer on the mips boxes, see below
+#
+SUF=o
+CF=-c
+
+INCLUDES=-I. -I$(srcdir)
+
+LFLAGS=$(INCLUDES)
+#LFLAGS=$(INCLUDES) -Zn10000 # hpux lint
+
+
+#CFLAGS= $(INCLUDES) -g # debug
+#CFLAGS= $(INCLUDES) -O # production
+#CFLAGS= $(INCLUDES) # Broken optimizers....
+
+#CFLAGS= -g -pg $(INCLUDES) -DPROF
+#CFLAGS= -O -pg $(INCLUDES) -DPROF
+
+# gcc 1.00-1.37
+#CFLAGS=-O $(INCLUDES) -finline-functions -fstrength-reduce
+
+# gcc 1.37-1.40
+#CFLAGS=-O $(INCLUDES) -fcombine-regs -finline-functions -fstrength-reduce
+# add -msoft-float for 68881 machines.
+
+# gcc 2.0
+# On the sparc, don't use -O2; it breaks setjmp() and vfork()
+#CFLAGS=-O $(INCLUDES)
+
+# gcc-2.1+
+CFLAGS=-O2 $(INCLUDES)
+
+# lucid c on suns
+#CFLAGS=-O5 $(INCLUDES)
+
+# gcc 2.1 on linux
+#CFLAGS=-O6 -fomit-frame-pointer $(INCLUDES)
+
+# HP/UX 8.0, 9.0
+#CFLAGS= $(INCLUDES) +O3 -Aa
+
+# Ultrix 4.2a
+#CFLAGS= $(INCLUDES) -O -Olimit 2000
+
+# Intel Paragon OSF/1 with PGI compilers
+#CFLAGS=-O -Mnodebug -Mnoperfmon $(INCLUDES)
+
+# DEC Alpha OSF/1
+#CFLAGS= -O2 $(INCLUDES) -Olimit 2000 ## Normal Optimization
+#CFLAGS= -O3 $(INCLUDES) -Olimit 2000 ## Full Optimization - may not work
+#CF=-j
+#SUF=u
+#.SUFFIXES: .u
+
+# for silicon graphics (and other mips compilers) -- use the
+# global optimizer! (-O3).
+# On SGI 4.0+ you need to add -D__STDC__ too.
+#CFLAGS= -O3 $(INCLUDES)
+#CFLAGS= -O3 $(INCLUDES) -Olimit 2000 ## Ultrix 4.2a
+#CF=-j
+#SUF=u
+#.SUFFIXES: .u ## Ultrix and gnu-make need that
+
+# mips systems
+# CFLAGS= $(INCLUDES) -O -systype bsd43 -Wf,-XNd5000 -Wf,-XNp6000 -Olimit 2000
+
+# for at&t machines
+#CFLAGS= -O -Ksd $(INCLUDES)
+
+# Stardent Titan
+#CFLAGS = $(INCLUDES) -O -43
+
+# Stardent Stellar or sunos4 /bin/cc or Solaris2.1 /opt/SUNWspro/bin/cc
+#CFLAGS = $(INCLUDES) -O4
+
+# Intergraph clipper CLIX 3.1
+#CFLAGS= -w -O2 $(INCLUDES)
+
+# Dnix 5.3
+#CFLAGS = -O -X7
+
+# Pyramid OS/x
+#CFLAGS = -OG
+
+# Multiflow (5M binary... if you choose -O5!)
+#CFLAGS = -O5 -sb_trace 0
+
+# DDE Supermax Unix SYSV Rel III.
+# CFLAGS= -O3
+
+# SINIX RMx00
+#CFLAGS= -O # -D_POSIX_SOURCE # -kansi
+
+# Apollo's with cc [apollo builtins don't work with gcc]
+# and apollo should not define __STDC__ if it does not have
+# the standard header files. RT's (aos4.3) need that too;
+# you might want to skip the -O on the rt's... Not very wise.
+# AIX/ESA needs -D_IBMESA on command line (this may disappear by GA)
+#DFLAGS=-U__STDC__
+#DFLAGS=-D_IBMESA
+# On aix2.2.1 we need more compiler space.
+#DFLAGS=-Nd4000 -Nn3000
+# AU/X 2.0 needs a flag for POSIX (read the config file)
+#DFLAGS=-Zp
+# Tektronix 4300 running UTek 4.0 (BSD 4.2) needs:
+#DFLAGS = -DUTek -DBSD
+# VMS_POSIX needs:
+#DFLAGS=-D_VMS_POSIX
+# Multiflow and PCC compilers don't like void typedefs.
+# You may also need -U__STDC__ if you use pcc (i.e. ibmrt aos4.3).
+#DFLAGS=-DMULTIFLOW
+#DFLAGS=-DPCC
+# DELL SVR4
+#DFLAGS=-DDELL
+# SCO_SV
+#DFLAGS=-D_SPEED_T -DSCO
+DFLAGS=
+#DFLAGS=-D_PATH_TCSHELL='"${DESTBIN}/tcsh"'
+
+
+################################################################
+## LDFLAGS. Define something here if you need to
+################################################################
+LDFLAGS= ## The simplest, suitable for all.
+#LDFLAGS= -s ## Stripped. Takes less space on disk.
+#LDFLAGS= -s -n ## Pure executable. Spares paging over
+# ## the network for machines with local
+# ## swap but external /usr/local/bin .
+#LDFLAGS= -s -n -Bstatic ## Without dynamic linking. (SunOS/cc)
+#LDFLAGS= -s -n -static ## Without dynamic linking. (SunOS/gcc)
+#LDFLAGS= -Wl,-s,-n ## Stripped, shared text (Unicos)
+#LDFLAGS= -s -static ## Link statically. (linux)
+#LDFLAGS= -s -N ## Impure executable (linux)
+#LDFLAGS= -Bdynamic -dy ## SCO_SV
+
+################################################################
+## LIBES. Pick one, or roll your own.
+################################################################
+LIBES= -ltermcap ## BSD style things
+#LIBES= -ltermcap ## SunOS, HP-UX, pyramid
+#LIBES= -ltermcap ## Linux
+#LIBES= -ltermcap -lshadow ## Linux with PW_SHADOW
+#LIBES= -ltermcap -lsec ## Tek XD88/10 (UTekV) with PW_SHADOW
+#LIBES= -ltermcap -lsec ## Motorola MPC (sysV88) with PW_SHADOW
+#LIBES= -ltermcap -lcs ## Mach
+#LIBES= -ltermcap -lbsd ## DEC osf1 on the alpha
+#LIBES= -ltermcap -lbsd ## Intel paragon
+#LIBES= -ltermcap -lbsd ## Clipper intergraph
+#LIBES= -ltermcap -lseq ## Sequent's Dynix
+#LIBES= -ltermcap -lauth ## Ultrix with Enhanced Security
+#LIBES= -ltermcap -ldir -lx ## Xenix 386 style things
+#LIBES= -ltermcap -lndir -lsocket -ljobs ## masscomp RTU6.0
+#LIBES= -lcurses ## AIX on the rt
+#LIBES= -lcurses ## TitanOS on the stellar
+#LIBES= -ltermlib -lsocket -lnsl ## SysV4 w/o BSDTIMES or Solaris 2
+#LIBES= -lcurses ## SysV3 w/o networking
+#LIBES= -lcurses -lnet ## SysV3 with networking
+#LIBES= -lcurses -ldir ## SysV2 w/o networking & dirlib
+#LIBES= -lcurses -ldir -lnet ## SysV2 with networking & dirlib
+#LIBES= -lcurses -lbsd ## AIX on the IBM 370 or rs6000 or ps2
+#LIBES= -lcurses -lbsd ## ETA10
+#LIBES= -lcurses -lbsd ## Irix3.1 on the SGI-IRIS4D
+#LIBES= -lcurses -lbsd -lc_s ## Irix3.3 on the SGI-IRIS4D w/o yp
+#LIBES= -lcurses -lsun -lbsd -lc_s ## Irix3.3 on the SGI-IRIS4D with yp
+#LIBES= -lcurses -lsocket -lbsd ## Amdahl UTS 2.1
+#LIBES= -lcurses -lsocket ## Intel's hypercube.
+#LIBES= -lcurses -lsocket ## ns32000 based Opus.
+#LIBES= -lcurses -lcposix ## ISC 2.2 without networking
+#LIBES= -lcposix -lc_s -lcurses -linet ## ISC 2.2 with networking
+#LIBES= -lcurses -lsec -lc_s ## ISC 2.0.2 without networking
+#LIBES= -lcurses -linet -lsec -lc_s ## ISC 2.0.2 with networking
+#LIBES= -lcurses -lintl -lcrypt ## SCO SysVR3.2v2.0
+#LIBES= -lcurses -lintl -lsocket -lcrypt ## SCO+ODT1.1
+#LIBES= -lcurses -lsocket -lcrypt ## SCO_SV
+#LIBES= -lposix -ltermcap ## A/UX 2.0
+#LIBES= -lposix -ltermcap -lc_s ## A/UX 3.0
+#LIBES= -ldirent -lcurses ## att3b1 cc w/o shared lib & dirlib
+#LIBES= -shlib -ldirent -lcurses ## att3b1 gcc with shared lib & dirlib
+#LIBES= -ltermlib -lsocket -lnsl -lc /usr/ucblib/libucb.a ## SysV4 with BSDTIMES
+#LIBES= -lcurses -lnsl -lsocket -lc /usr/ucblib/libucb.a ## Stardent Vistra
+#LIBES= -ltermc ## emx under OS/2
+#LIBES= ## Minix, VMS_POSIX
+#LIBES= -ltermcap -lcrypt ## Multiflow
+#LIBES= -ltermcap -lcrypt ## NetBSD
+#LIBES= -lcurses ## DDE Supermax
+
+################################################################
+## EXTRAFLAGS and EXTRALIBS
+################################################################
+# Compiling for HESIOD
+#HESDEF = -DHESIOD -I/usr/athena/include
+#HESLIB = -L/usr/athena/lib -lhesiod
+#
+# Compiling for AFS with kerberos authentication
+#AFSLIBDIR = /usr/afsws/lib
+#AFSDEF = -DAFS -I/usr/afsws/include
+#AFS33LIB = -laudit
+#
+#Solaris and HPUX require the BSD libraries with AFS.
+#We use -lc to use only what we require.
+#AFSAUXLIB = -lsocket -lnsl -lc -lucb # Solaris
+#AFSAUXLIB = -lc -lBSD # HPUX
+#
+#AFSLIB = -L$(AFSLIBDIR) -L$(AFSLIBDIR)/afs -lkauth -lprot -lubik\
+# -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err\
+# $(AFSLIBDIR)/afs/util.a $(AFS33LIB) $(AFSAUXLIB)
+#
+
+EXTRAFLAGS = $(HESDEF) $(AFSDEF)
+EXTRALIBS = $(HESLIB) $(AFSLIB)
+
+
+# The difficult choice of a c-compiler...
+# First, you should try your own c-compiler.
+# Gcc -traditional is also a safe choice.
+# If you think that you have good include files try gcc -Wall...
+# If you want to take out -traditional, make sure that your sys/ioctl.h
+# is fixed correctly, otherwise you'll be stopped for tty input, or you
+# will lose the editor and job control.
+
+# This is for setting your C preprocessor value.
+CPP = ${CC} -E
+# The -B tells gcc to use /bin/ld. This is to avoid using the gnu ld, which
+# on the suns does not know how to make dynamically linked binaries.
+CC= gcc -Wall -pipe -B/bin/ # -ansi -pedantic
+#CC= gcc -m486 -pipe -Wall # Generate code for Intel 486 (linux)
+#CC= shlicc # BSDI2.1 w/ shared libraries
+#CC= cc
+#CC= occ
+#CC= acc
+#CC= pcc
+#CC= hc -w
+#CC= c89 # For VMS/POSIX
+#CC= /bin/cc # For suns, w/o gcc and SVR4
+#CC= /usr/lib/sun.compile/cc # FPS 500 (+FPX) with Sun C compiler
+#CC= /opt/SUNWspro/bin/cc # Solaris 2.1
+#CC= scc # Alliant fx2800
+#CC= lcc -wa
+#CC= cc -b elf -Kpic # SCO_SV
+ED= ed
+AS= as
+RM= rm
+CXREF= /usr/ucb/cxref
+#CXREF= /bin/cxref # SCO_SV
+VGRIND= csh /usr/ucb/vgrind
+CTAGS= /usr/ucb/ctags
+#CTAGS= /usr/bin/ctags # SCO_SV
+#XSTR= /usr/ucb/xstr
+#XSTR= /usr/bin/xstr # SCO_SV
+SCCS= /usr/local/sccs
+PARALLEL=12 # Make the multi-max run fast.
+#P=& # Use Sequent's parallel make
+P=
+DESTDIR=/usr/local
+#DESTDIR=/usr/contrib
+MANSECT=1
+DESTBIN=${DESTDIR}/bin
+DESTMAN=${DESTDIR}/man/man${MANSECT}
+# DESTMAN=${DESTDIR}/catman/man${MANSECT} # A/UX
+# DESTMAN=${DESTDIR}/usr/share/man/man${MANSECT} # Stardent Vistra (SysVR4)
+# DESTMAN=/usr/catman/1l # Amiga unix (SysVR4)
+FTPAREA=/usr/spool/ftp
+
+ASSRCS= sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.char.c \
+ sh.exp.c sh.file.c sh.func.c sh.glob.c sh.hist.c sh.init.c \
+ sh.lex.c sh.misc.c sh.parse.c sh.print.c sh.proc.c sh.sem.c \
+ sh.set.c sh.time.c sh.char.h sh.dir.h sh.proc.h sh.h
+PSSRCS= sh.decls.h glob.c glob.h mi.termios.c mi.wait.h mi.varargs.h ma.setp.c \
+ vms.termcap.c
+SHSRCS= ${ASSRCS} ${PSSRCS}
+SHOBJS= sh.${SUF} sh.dir.${SUF} sh.dol.${SUF} sh.err.${SUF} sh.exec.${SUF} \
+ sh.char.${SUF} sh.exp.${SUF} sh.func.${SUF} sh.glob.${SUF} \
+ sh.hist.${SUF} sh.init.${SUF} sh.lex.${SUF} sh.misc.${SUF} \
+ sh.parse.${SUF} sh.print.${SUF} sh.proc.${SUF} sh.sem.${SUF} \
+ sh.set.${SUF} sh.time.${SUF} glob.${SUF} mi.termios.${SUF} \
+ ma.setp.${SUF} vms.termcap.${SUF}
+
+TWSRCS= tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \
+ tw.comp.c tw.color.c
+TWOBJS= tw.help.${SUF} tw.init.${SUF} tw.parse.${SUF} tw.spell.${SUF} \
+ tw.comp.${SUF} tw.color.${SUF}
+
+EDSRCS= ed.chared.c ed.decls.h ed.defns.c ed.h ed.init.c ed.inputl.c \
+ ed.refresh.c ed.screen.c ed.xmap.c ed.term.c ed.term.h
+EDOBJS= ed.chared.${SUF} ed.refresh.${SUF} ed.screen.${SUF} ed.init.${SUF} \
+ ed.inputl.${SUF} ed.defns.${SUF} ed.xmap.${SUF} ed.term.${SUF}
+
+TCSRCS= tc.alloc.c tc.bind.c tc.const.c tc.decls.h tc.disc.c \
+ tc.func.c tc.os.c tc.os.h tc.printf.c tc.prompt.c \
+ tc.sched.c tc.sig.c tc.sig.h tc.str.c sh.types.h tc.vers.c tc.wait.h \
+ tc.who.c tc.h
+TCOBJS= tc.alloc.${SUF} tc.bind.${SUF} tc.const.${SUF} tc.defs.${SUF} \
+ tc.disc.${SUF} tc.func.${SUF} tc.os.${SUF} tc.printf.${SUF} \
+ tc.prompt.${SUF} tc.sched.${SUF} tc.sig.${SUF} tc.str.${SUF} \
+ tc.vers.${SUF} tc.who.${SUF}
+
+PVSRCS= Makefile.std Makefile.vms Makefile.in Makefile.win32
+AVSRCS= Fixes MAKEDIFFS MAKESHAR NewThings README FAQ \
+ WishList config_f.h eight-bit.me glob.3 patchlevel.h \
+ pathnames.h tcsh.man Ported src.desc Imakefile imake.config \
+ README.imake complete.tcsh vmsreadme.txt termcap.vms snames.h \
+ host.defs gethost.c tcsh.man2html configure.in configure config.h.in
+
+VHSRCS=${PVSRCS} ${AVSRCS}
+
+CONFSRCS=config/*
+
+ALLSRCS= ${SHSRCS} ${TWSRCS} ${EDSRCS} ${TCSRCS} ${VHSRCS}
+DISTSRCS= ${PSSRCS} ${TWSRCS} ${EDSRCS} ${TCSRCS} ${AVSRCS}
+
+
+OBJS= ${SHOBJS} ${TWOBJS} ${EDOBJS} ${TCOBJS}
+
+
+all: ${BUILD}
+
+tcsh:$(P) ${OBJS}
+ rm -f tcsh core
+ ${CC} -o tcsh ${LDFLAGS} ${CFLAGS} ${OBJS} ${LIBES} ${EXTRALIBS}
+
+# Purify
+pure:$(P) ${OBJS}
+ rm -f tcsh core
+ purify `echo ${CC} | sed -e s,-B/bin/,,` -o tcsh ${LDFLAGS} ${CFLAGS} ${OBJS} ${LIBES} ${EXTRALIBS}
+# OS/2
+tcsh.exe: tcsh
+ emxbind tcsh
+
+gethost: gethost.c sh.err.h tc.const.h sh.h
+ rm -f gethost
+ ${CC} -o gethost ${LDFLAGS} ${CFLAGS} ${DFLAGS} $(srcdir)/gethost.c ${LIBES} ${EXTRALIBS}
+
+tc.defs.c: gethost host.defs
+ @rm -f $@
+ @echo "/* Do not edit this file, make creates it */" > $@
+ ./gethost $(srcdir)/host.defs >> $@
+
+tcsh.ps: tcsh.man
+ rm -f tcsh.ps
+ -ptroff -t -man $(srcdir)/tcsh.man > tcsh.ps
+
+
+.c.${SUF}:
+ ${CC} ${CF} ${CFLAGS} ${DFLAGS} ${EXTRAFLAGS} $<
+
+# _VMS_POSIX #module addition
+#.c.${SUF}:
+# @(echo '#module '`echo $< | sed -e 's/\./_/g'`; cat $<) > $*..c
+# @echo ${CC} ${CF} ${CFLAGS} ${DFLAGS} ${EXTRAFLAGS} $*.c
+# @${CC} ${CF} ${CFLAGS} ${DFLAGS} ${EXTRAFLAGS} $*..c
+# @mv $*..o $*.o
+# @rm -f $*..c
+
+
+# Don't do any special massaging of C files for sharing of strings!!
+# it causes weird segmentation faults on some systems.
+#.c.o:
+# ${CPP} ${CFLAGS} $*.c | ${XSTR} -c -
+# ${CC} ${CF} ${CFLAGS} x.c
+# mv -f x.o $*.o
+# rm -f x.c
+
+#ed.init.o: ed.init.c
+# ${CPP} ${CFLAGS} $*.c | ${XSTR} -c -
+# ${CC} -R ${CF} ${CF} x.c
+# mv -f x.o $*.o
+# rm -f x.c
+
+#strings.o: strings
+# ${XSTR}
+# ${CC} -c -R xs.c
+# mv -f xs.o strings.o
+# rm -f xs.c
+
+##.DEFAULT:
+## ${SCCS} get $<
+
+##.DEFAULT:
+## co $<
+
+ed.defns.h: ed.defns.c
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '#ifndef _h_ed_defns' >> $@
+ @echo '#define _h_ed_defns' >> $@
+ grep '[FV]_' $(srcdir)/ed.defns.c | grep '^#define' >> $@
+ @echo '#endif /* _h_ed_defns */' >> $@
+
+sh.err.h: sh.err.c
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '#ifndef _h_sh_err' >> $@
+ @echo '#define _h_sh_err' >> $@
+ grep 'ERR_' $(srcdir)/sh.err.c | grep '^#define' >> $@
+ @echo '#endif /* _h_sh_err */' >> $@
+
+tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '#ifndef _h_tc_const' >> $@
+ @echo '#define _h_tc_const' >> $@
+ ${CPP} $(INCLUDES) ${DFLAGS} ${EXTRAFLAGS} -D_h_tc_const\
+ $(srcdir)/tc.const.c | grep 'Char STR' | \
+ sed -e 's/Char \([a-zA-Z0-9_]*\)\[\].*/extern Char \1[];/' | \
+ sort >> $@
+ @echo '#endif /* _h_tc_const */' >> $@
+
+csh.prof: ${OBJS} sh.prof.${SUF} mcrt0.${SUF}
+ rm -f csh.prof
+ ld -X mcrt0.${SUF} ${OBJS} -o csh.prof ${LIBES} -lc
+
+sh.prof.${SUF}:
+ cp sh.c sh.prof.c
+ ${CC} ${CF} ${CFLAGS} -DPROF sh.prof.c
+
+lint: tc.const.h ed.defns.h
+ lint ${DFLAGS} ${LFLAGS} sh*.c tw*.c ed*.c tc.*.c ${LIBES}
+
+alint: tc.const.h ed.defns.h
+ alint ${DFLAGS} ${LFLAGS} sh*.c tw*.c ed*.c tc.*.c ${LIBES}
+
+print:
+ @pr READ_ME
+ @pr makefile makefile.*
+ @(size -l a.out; size *.${SUF}) | pr -h SIZES
+ @${CXREF} sh*.c | pr -h XREF
+ @ls -l | pr
+ @pr sh*.h [a-rt-z]*.h sh*.c alloc.c
+
+vprint:
+ @pr -l84 READ_ME TODO
+ @pr -l84 makefile makefile.*
+ @(size -l a.out; size *.${SUF}) | pr -l84 -h SIZES
+ @${CXREF} sh*.c | pr -l84 -h XREF
+ @ls -l | pr -l84
+ @${CXREF} sh*.c | pr -l84 -h XREF
+ @pr -l84 sh*.h [a-rt-z]*.h sh*.c alloc.c
+
+vgrind:
+ @cp /dev/null index
+ @for i in *.h; do vgrind -t -h "C Shell" $$i >/crp/bill/csh/$$i.t; done
+ @for i in *.c; do vgrind -t -h "C Shell" $$i >/crp/bill/csh/$$i.t; done
+ @vgrind -t -x -h Index index >/crp/bill/csh/index.t
+
+install: tcsh
+ -mv -f ${DESTBIN}/tcsh ${DESTBIN}/tcsh.old
+ cp tcsh ${DESTBIN}/tcsh
+ -strip ${DESTBIN}/tcsh
+ chmod 555 ${DESTBIN}/tcsh
+
+install.man: tcsh.man
+ -rm -f ${DESTMAN}/tcsh.${MANSECT}
+ cp $(srcdir)/tcsh.man ${DESTMAN}/tcsh.${MANSECT}
+ chmod 444 ${DESTMAN}/tcsh.${MANSECT}
+
+# Amiga Unix
+#install.man: tcsh.man
+# compress tcsh.man
+# cp tcsh.man.Z ${DESTMAN}/tcsh.Z
+# chmod 444 ${DESTMAN}/tcsh.Z
+
+# Apple A/UX
+#install.man: tcsh.man
+# -rm -f ${DESTMAN}/tcsh.${MANSECT}.Z
+# nroff -man tcsh.man | compress > ${DESTMAN}/tcsh.${MANSECT}.Z
+# chmod 444 ${DESTMAN}/tcsh.${MANSECT}.Z
+
+clean:
+ ${RM} -f a.out strings x.c xs.c tcsh tcsh.a _MAKE_LOG core gethost
+ ${RM} -f *.${SUF} sh.prof.c ed.defns.h tc.const.h sh.err.h tc.defs.c
+ ${RM} -f tcsh.*.m tcsh.*.cat
+
+veryclean: clean
+ ${RM} -f config.h config.status config.cache config.log Makefile tcsh.ps
+ ${RM} -f *~ #*
+
+distclean: veryclean
+
+tags: /tmp
+ ${CTAGS} sh*.c
+
+tar.Z:
+ rm -f tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | compress > tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+
+tar.gz:
+ rm -f tcsh-${VERSION}.tar.gz
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | gzip > tcsh-${VERSION}.tar.gz
+ rm -rf tcsh-${VERSION}
+
+shar:
+ rm -f tcsh-*.shar
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ MAKESHAR -v -n tcsh-${VERSION} tcsh-${VERSION} \
+ tcsh-${VERSION}/?* tcsh-${VERSION}/config/?* \
+ tcsh-${VERSION}/?*/set?*
+ rm -rf tcsh-${VERSION}
+
+catalogs:
+ @(cd nls; make catalogs)
+
+tcsh-${VERSION}.tar.Z:
+ rm -rf tcsh-${VERSION}
+ rm -f tcsh-${VERSION}.tar tcsh-${VERSION}.tar.Z DIFFS.[123]
+ mkdir tcsh-${VERSION}
+ ./MAKEDIFFS bsd
+ mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh-${VERSION}
+ cp ${DISTSRCS} tcsh-${VERSION}
+ mkdir tcsh-${VERSION}/config
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ cp Makefile tcsh-${VERSION}/Makefile.new
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | compress > tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+
+tcsh.tahoe-${VERSION}.tar.Z:
+ rm -rf tcsh.tahoe-${VERSION}
+ rm -f tcsh.tahoe-${VERSION}.tar tcsh.tahoe-${VERSION}.tar.Z DIFFS.[123]
+ mkdir tcsh.tahoe-${VERSION}
+ ./MAKEDIFFS tahoe
+ mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh.tahoe-${VERSION}
+ cp ${DISTSRCS} tcsh.tahoe-${VERSION}
+ mkdir tcsh.tahoe-${VERSION}/config
+ cp ${CONFSRCS} tcsh.tahoe-${VERSION}/config
+ cp Makefile tcsh.tahoe-${VERSION}/Makefile.new
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh.tahoe-${VERSION} | compress > tcsh.tahoe-${VERSION}.tar.Z
+ rm -rf tcsh.tahoe-${VERSION}
+
+tcsh.reno-${VERSION}.tar.Z:
+ rm -rf tcsh.reno-${VERSION}
+ rm -f tcsh.reno-${VERSION}.tar tcsh.reno-${VERSION}.tar.Z DIFFS.[123]
+ mkdir tcsh.reno-${VERSION}
+ ./MAKEDIFFS reno
+ mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh.reno-${VERSION}
+ cp ${DISTSRCS} tcsh.reno-${VERSION}
+ mkdir tcsh.reno-${VERSION}/config
+ cp ${CONFSRCS} tcsh.reno-${VERSION}/config
+ cp Makefile tcsh.reno-${VERSION}/Makefile.new
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh.reno-${VERSION} | compress > tcsh.reno-${VERSION}.tar.Z
+ rm -rf tcsh.reno-${VERSION}
+
+ftp: tcsh-${VERSION}.tar.Z tcsh.tahoe-${VERSION}.tar.Z
+ cp tcsh-${VERSION}.tar.Z tcsh.tahoe-${VERSION}.tar.Z ${FTPAREA}
+ cp tcsh.man ${FTPAREA}
+
+autoconfigure: $(srcdir)/configure $(srcdir)/config.h.in
+
+$(srcdir)/configure: $(srcdir)/configure.in
+ cd $(srcdir) && autoconf
+
+$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
+$(srcdir)/stamp-h.in: $(srcdir)/configure.in
+ cd $(srcdir) && autoheader
+ @echo timestamp > $(srcdir)/stamp-h.in
+
+#
+# Dependencies
+#
+config.h: config_f.h
+
+TCH=tc.h tc.const.h tc.decls.h tc.os.h tc.sig.h
+SHH=sh.h sh.types.h sh.char.h sh.err.h sh.dir.h sh.proc.h pathnames.h \
+ sh.decls.h ${TCH}
+TWH=tw.h tw.decls.h
+EDH=ed.h ed.decls.h
+
+# EDH
+EDINC=sh.${SUF} sh.func.${SUF} sh.lex.${SUF} sh.print.${SUF} sh.proc.${SUF} \
+ sh.set.${SUF} tc.bind.${SUF} tc.os.${SUF} tc.prompt.${SUF} \
+ tc.sched.${SUF} tw.parse.${SUF} tw.color.${SUF}
+${EDOBJS} ${EDINC} : ${EDH}
+
+# SHH
+${OBJS}: config.h ${SHH}
+
+# TWH
+TWINC=ed.chared.${SUF} ed.inputl.${SUF} sh.exec.${SUF} sh.func.${SUF} \
+ sh.set.${SUF} tc.func.${SUF} tw.color.${SUF}
+${TWOBJS} ${TWINC}: ${TWH}
+
+# glob.h
+glob.${SUF} sh.glob.${SUF}: glob.h
+
+# ed.defns.h
+EDDINC=tc.bind.${SUF} tc.func.${SUF} tc.os.${SUF}
+${EDOBJS} ${EDDINC}: ed.defns.h
+
+# tc.defs.o
+tc.defs.${SUF}: tc.defs.c sh.h
diff --git a/contrib/tcsh/Makefile.vms b/contrib/tcsh/Makefile.vms
new file mode 100644
index 000000000000..e225ee8b3b64
--- /dev/null
+++ b/contrib/tcsh/Makefile.vms
@@ -0,0 +1,594 @@
+# $Id: Makefile.vms,v 1.32 1998/10/02 10:56:49 christos Exp $
+# Makefile.vms 4.3 6/11/83
+#
+# C Shell with process control; VM/UNIX VAX Makefile
+# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
+#
+# With an input editor, command completion, etc. and ported to all sorts of
+# things; Paul Placeway, CIS Dept., Ohio State University
+#
+SHELL=/bin/sh
+VERSION=6.08
+BUILD=tcsh
+
+################################################################
+## CFLAGS. For various -D things, see config.h
+################################################################
+#
+# These are the default suffixes from .c to .o and -c to get there
+# but to use the global optimizer on the mips boxes, see below
+#
+SUF=o
+CF=-c
+
+INCLUDES=-I. -I..
+
+LFLAGS=$(INCLUDES)
+#LFLAGS=$(INCLUDES) -Zn10000 # hpux lint
+
+
+#CFLAGS= $(INCLUDES) -g # debug
+#CFLAGS= $(INCLUDES) -O # production
+#CFLAGS= $(INCLUDES) # Broken optimizers....
+
+#CFLAGS= -g -pg $(INCLUDES) -DPROF
+#CFLAGS= -O -pg $(INCLUDES) -DPROF
+
+# gcc 1.00-1.37
+#CFLAGS=-O $(INCLUDES) -finline-functions -fstrength-reduce
+
+# gcc 1.37-1.40
+#CFLAGS=-O $(INCLUDES) -fcombine-regs -finline-functions -fstrength-reduce
+# add -msoft-float for 68881 machines.
+
+# gcc 2.0
+# On the sparc, don't use -O2; it breaks setjmp() and vfork()
+#CFLAGS=-O $(INCLUDES)
+
+# gcc-2.1+
+#CFLAGS=-O2 $(INCLUDES)
+
+# lucid c on suns
+#CFLAGS=-O5 $(INCLUDES)
+
+# gcc 2.1 on linux
+#CFLAGS=-O6 -fomit-frame-pointer $(INCLUDES)
+
+# HP/UX 8.0, 9.0
+#CFLAGS= $(INCLUDES) +O3 -Aa
+
+# Ultrix 4.2a
+#CFLAGS= $(INCLUDES) -O -Olimit 2000
+
+# Intel Paragon OSF/1 with PGI compilers
+#CFLAGS=-O -Mnodebug -Mnoperfmon $(INCLUDES)
+
+# DEC Alpha OSF/1
+#CFLAGS= -O2 $(INCLUDES) -Olimit 2000 ## Normal Optimization
+#CFLAGS= -O3 $(INCLUDES) -Olimit 2000 ## Full Optimization - may not work
+#CF=-j
+#SUF=u
+#.SUFFIXES: .u
+
+# for silicon graphics (and other mips compilers) -- use the
+# global optimizer! (-O3).
+# On SGI 4.0+ you need to add -D__STDC__ too.
+#CFLAGS= -O3 $(INCLUDES)
+#CFLAGS= -O3 $(INCLUDES) -Olimit 2000 ## Ultrix 4.2a
+#CF=-j
+#SUF=u
+#.SUFFIXES: .u ## Ultrix and gnu-make need that
+
+# mips systems
+# CFLAGS= $(INCLUDES) -O -systype bsd43 -Wf,-XNd5000 -Wf,-XNp6000 -Olimit 2000
+
+# for at&t machines
+#CFLAGS= -O -Ksd $(INCLUDES)
+
+# Stardent Titan
+#CFLAGS = $(INCLUDES) -O -43
+
+# Stardent Stellar or sunos4 /bin/cc or Solaris2.1 /opt/SUNWspro/bin/cc
+#CFLAGS = $(INCLUDES) -O4
+
+# Intergraph clipper CLIX 3.1
+#CFLAGS= -w -O2 $(INCLUDES)
+
+# Dnix 5.3
+#CFLAGS = -O -X7
+
+# Pyramid OS/x
+#CFLAGS = -OG
+
+# Multiflow (5M binary... if you choose -O5!)
+#CFLAGS = -O5 -sb_trace 0
+
+# DDE Supermax Unix SYSV Rel III.
+# CFLAGS= -O3
+
+# Apollo's with cc [apollo builtins don't work with gcc]
+# and apollo should not define __STDC__ if it does not have
+# the standard header files. RT's (aos4.3) need that too;
+# you might want to skip the -O on the rt's... Not very wise.
+# AIX/ESA needs -D_IBMESA on command line (this may disappear by GA)
+#DFLAGS=-U__STDC__
+#DFLAGS=-D_IBMESA
+# On aix2.2.1 we need more compiler space.
+#DFLAGS=-Nd4000 -Nn3000
+# AU/X 2.0 needs a flag for POSIX (read the config file)
+#DFLAGS=-Zp
+# Tektronix 4300 running UTek 4.0 (BSD 4.2) needs:
+#DFLAGS = -DUTek -DBSD
+# VMS_POSIX needs:
+#DFLAGS=-D_VMS_POSIX
+# Multiflow
+#DFLAGS=-DMULTIFLOW
+# DELL SVR4
+#DFLAGS=-DDELL
+DFLAGS=
+#DFLAGS=-D_PATH_TCSHELL='"${DESTBIN}/tcsh"'
+
+
+################################################################
+## LDFLAGS. Define something here if you need to
+################################################################
+LDFLAGS= ## The simplest, suitable for all.
+#LDFLAGS= -s ## Stripped. Takes less space on disk.
+#LDFLAGS= -s -n ## Pure executable. Spares paging over
+# ## the network for machines with local
+# ## swap but external /usr/local/bin .
+#LDFLAGS= -s -n -Bstatic ## Without dynamic links. (SunOS)
+#LDFLAGS= -Wl,-s,-n ## Stripped, shared text (Unicos)
+#LDFLAGS= -s -static ## Link statically. (linux)
+#LDFLAGS= -s -N ## Impure executable (linux)
+
+################################################################
+## LIBES. Pick one, or roll your own.
+################################################################
+#LIBES= -ltermcap ## BSD style things
+#LIBES= -ltermcap ## SunOS, HP-UX, pyramid
+#LIBES= -ltermcap ## Linux
+#LIBES= -ltermcap -lshadow ## Linux with PW_SHADOW
+#LIBES= -ltermcap -lsec ## Tek XD88/10 (UTekV) with PW_SHADOW
+#LIBES= -ltermcap -lsec ## Motorola MPC (sysV88) with PW_SHADOW
+#LIBES= -ltermcap -lcs ## Mach
+#LIBES= -ltermcap -lbsd ## DEC osf1 on the alpha
+#LIBES= -ltermcap -lbsd ## Intel paragon
+#LIBES= -ltermcap -lbsd ## Clipper intergraph
+#LIBES= -ltermcap -lseq ## Sequent's Dynix
+#LIBES= -ltermcap -lauth ## Ultrix with Enhanced Security
+#LIBES= -ltermcap -ldir -lx ## Xenix 386 style things
+#LIBES= -ltermcap -lndir -lsocket -ljobs ## masscomp RTU6.0
+#LIBES= -lcurses ## AIX on the rt
+#LIBES= -lcurses ## TitanOS on the stellar
+#LIBES= -ltermlib -lsocket -lnsl ## SysV4 w/o BSDTIMES or Solaris 2
+#LIBES= -lcurses ## SysV3 w/o networking
+#LIBES= -lcurses -lnet ## SysV3 with networking
+#LIBES= -lcurses -ldir ## SysV2 w/o networking & dirlib
+#LIBES= -lcurses -ldir -lnet ## SysV2 with networking & dirlib
+#LIBES= -lcurses -lbsd ## AIX on the IBM 370 or rs6000 or ps2
+#LIBES= -lcurses -lbsd ## ETA10
+#LIBES= -lcurses -lbsd ## Irix3.1 on the SGI-IRIS4D
+#LIBES= -lcurses -lbsd -lc_s ## Irix3.3 on the SGI-IRIS4D w/o yp
+#LIBES= -lcurses -lsun -lbsd -lc_s ## Irix3.3 on the SGI-IRIS4D with yp
+#LIBES= -lcurses -lsocket -lbsd ## Amdahl UTS 2.1
+#LIBES= -lcurses -lsocket ## Intel's hypercube.
+#LIBES= -lcurses -lsocket ## ns32000 based Opus.
+#LIBES= -lcurses -lcposix ## ISC 2.2 without networking
+#LIBES= -lcposix -lc_s -lcurses -linet ## ISC 2.2 with networking
+#LIBES= -lcurses -lsec -lc_s ## ISC 2.0.2 without networking
+#LIBES= -lcurses -linet -lsec -lc_s ## ISC 2.0.2 with networking
+#LIBES= -lcurses -lintl -lcrypt ## SCO SysVR3.2v2.0
+#LIBES= -lcurses -lintl -lsocket -lcrypt ## SCO+ODT1.1
+#LIBES= -lposix -ltermcap ## A/UX 2.0
+#LIBES= -lposix -ltermcap -lc_s ## A/UX 3.0
+#LIBES= -ldirent -lcurses ## att3b1 cc w/o shared lib & dirlib
+#LIBES= -shlib -ldirent -lcurses ## att3b1 gcc with shared lib & dirlib
+#LIBES= -ltermlib -lsocket -lnsl -lc /usr/ucblib/libucb.a ## SysV4 with BSDTIMES
+#LIBES= -lcurses -lnsl -lsocket -lc /usr/ucblib/libucb.a ## Stardent Vistra
+#LIBES= -ltermc ## emx under OS/2
+LIBES= ## Minix, VMS_POSIX
+#LIBES= -ltermcap -lcrypt ## Multiflow
+#LIBES= -ltermcap -lcrypt ## NetBSD
+#LIBES= -lcurses ## DDE Supermax
+
+################################################################
+## EXTRAFLAGS and EXTRALIBS
+################################################################
+# Compiling for HESIOD
+#HESDEF = -DHESIOD -I/usr/athena/include
+#HESLIB = -L/usr/athena/lib -lhesiod
+#
+# Compiling for AFS with kerberos authentication
+#AFSLIBDIR = /usr/afsws/lib
+#AFSDEF = -DAFS -I/usr/afsws/include
+#AFS33LIB = -laudit
+#
+#Solaris and HPUX require the BSD libraries with AFS.
+#We use -lc to use only what we require.
+#AFSAUXLIB = -lsocket -lnsl -lc -lucb # Solaris
+#AFSAUXLIB = -lc -lBSD # HPUX
+#
+#AFSLIB = -L$(AFSLIBDIR) -L$(AFSLIBDIR)/afs -lkauth -lprot -lubik\
+# -lauth -lrxkad -lsys -ldes -lrx -llwp -lcom_err\
+# $(AFSLIBDIR)/afs/util.a $(AFS33LIB) $(AFSAUXLIB)
+#
+
+EXTRAFLAGS = $(HESDEF) $(AFSDEF)
+EXTRALIBS = $(HESLIB) $(AFSLIB)
+
+
+# The difficult choice of a c-compiler...
+# First, you should try your own c-compiler.
+# Gcc -traditional is also a safe choice.
+# If you think that you have good include files try gcc -Wall...
+# If you want to take out -traditional, make sure that your sys/ioctl.h
+# is fixed correctly, otherwise you'll be stopped for tty input, or you
+# will lose the editor and job control.
+
+# The -B tells gcc to use /bin/ld. This is to avoid using the gnu ld, which
+# on the suns does not know how to make dynamically linked binaries.
+#CC= gcc -Wall -pipe -B/bin/ # -ansi -pedantic
+#CC= gcc -m486 -pipe -Wall # Generate code for Intel 486 (linux)
+#CC= cc
+#CC= occ
+#CC= acc
+#CC= pcc
+#CC= hc -w
+CC= c89 # For VMS/POSIX
+#CC= /bin/cc # For suns, w/o gcc and SVR4
+#CC= /usr/lib/sun.compile/cc # FPS 500 (+FPX) with Sun C compiler
+#CC= /opt/SUNWspro/bin/cc # Solaris 2.1
+#CC= scc # Alliant fx2800
+#CC= lcc -wa
+ED= ed
+AS= as
+RM= rm
+CXREF= /usr/ucb/cxref
+VGRIND= csh /usr/ucb/vgrind
+CTAGS= /usr/ucb/ctags
+#XSTR= /usr/ucb/xstr
+SCCS= /usr/local/sccs
+PARALLEL=12 # Make the multi-max run fast.
+#P=& # Use Sequent's parallel make
+P=
+DESTDIR=/usr/local
+MANSECT=1
+DESTBIN=${DESTDIR}/bin
+DESTMAN=${DESTDIR}/man/man${MANSECT}
+# DESTMAN=${DESTDIR}/catman/man${MANSECT} # A/UX
+# DESTMAN=${DESTDIR}/usr/share/man/man${MANSECT} # Stardent Vistra (SysVR4)
+# DESTMAN=/usr/catman/1l # Amiga unix (SysVR4)
+FTPAREA=/usr/spool/ftp
+
+ASSRCS= sh.c sh.dir.c sh.dol.c sh.err.c sh.exec.c sh.char.c \
+ sh.exp.c sh.file.c sh.func.c sh.glob.c sh.hist.c sh.init.c \
+ sh.lex.c sh.misc.c sh.parse.c sh.print.c sh.proc.c sh.sem.c \
+ sh.set.c sh.time.c sh.char.h sh.dir.h sh.proc.h sh.h
+PSSRCS= sh.decls.h glob.c glob.h mi.termios.c mi.wait.h mi.varargs.h ma.setp.c \
+ vms.termcap.c
+SHSRCS= ${ASSRCS} ${PSSRCS}
+SHOBJS= sh.${SUF} sh.dir.${SUF} sh.dol.${SUF} sh.err.${SUF} sh.exec.${SUF} \
+ sh.char.${SUF} sh.exp.${SUF} sh.func.${SUF} sh.glob.${SUF} \
+ sh.hist.${SUF} sh.init.${SUF} sh.lex.${SUF} sh.misc.${SUF} \
+ sh.parse.${SUF} sh.print.${SUF} sh.proc.${SUF} sh.sem.${SUF} \
+ sh.set.${SUF} sh.time.${SUF} glob.${SUF} mi.termios.${SUF} \
+ ma.setp.${SUF} vms.termcap.${SUF}
+
+TWSRCS= tw.decls.h tw.h tw.help.c tw.init.c tw.parse.c tw.spell.c \
+ tw.comp.c tw.color.c
+TWOBJS= tw.help.${SUF} tw.init.${SUF} tw.parse.${SUF} tw.spell.${SUF} \
+ tw.comp.${SUF} tw.color.${SUF}
+
+EDSRCS= ed.chared.c ed.decls.h ed.defns.c ed.h ed.init.c ed.inputl.c \
+ ed.refresh.c ed.screen.c ed.xmap.c ed.term.c ed.term.h
+EDOBJS= ed.chared.${SUF} ed.refresh.${SUF} ed.screen.${SUF} ed.init.${SUF} \
+ ed.inputl.${SUF} ed.defns.${SUF} ed.xmap.${SUF} ed.term.${SUF}
+
+TCSRCS= tc.alloc.c tc.bind.c tc.const.c tc.decls.h tc.disc.c \
+ tc.func.c tc.os.c tc.os.h tc.printf.c tc.prompt.c \
+ tc.sched.c tc.sig.c tc.sig.h tc.str.c sh.types.h tc.vers.c tc.wait.h \
+ tc.who.c tc.h
+TCOBJS= tc.alloc.${SUF} tc.bind.${SUF} tc.const.${SUF} tc.defs.${SUF} \
+ tc.disc.${SUF} tc.func.${SUF} tc.os.${SUF} tc.printf.${SUF} \
+ tc.prompt.${SUF} tc.sched.${SUF} tc.sig.${SUF} tc.str.${SUF} \
+ tc.vers.${SUF} tc.who.${SUF}
+
+PVSRCS= Makefile.std Makefile.vms Makefile.in Makefile.win32
+AVSRCS= Fixes MAKEDIFFS MAKESHAR NewThings README FAQ \
+ WishList config_f.h eight-bit.me glob.3 patchlevel.h \
+ pathnames.h tcsh.man Ported src.desc Imakefile imake.config \
+ README.imake complete.tcsh vmsreadme.txt termcap.vms snames.h \
+ host.defs gethost.c tcsh.man2html configure.in
+
+VHSRCS=${PVSRCS} ${AVSRCS}
+
+CONFSRCS=config/*
+
+ALLSRCS= ${SHSRCS} ${TWSRCS} ${EDSRCS} ${TCSRCS} ${VHSRCS}
+DISTSRCS= ${PSSRCS} ${TWSRCS} ${EDSRCS} ${TCSRCS} ${AVSRCS}
+
+
+OBJS= ${SHOBJS} ${TWOBJS} ${EDOBJS} ${TCOBJS}
+
+
+all: ${BUILD}
+
+tcsh:$(P) ${OBJS}
+ rm -f tcsh core
+ ${CC} -o tcsh ${LDFLAGS} ${CFLAGS} ${OBJS} ${LIBES} ${EXTRALIBS}
+
+# Purify
+pure:$(P) ${OBJS}
+ rm -f tcsh core
+ purify `echo ${CC} | sed -e s,-B/bin/,,` -o tcsh ${LDFLAGS} ${CFLAGS} ${OBJS} ${LIBES} ${EXTRALIBS}
+# OS/2
+tcsh.exe: tcsh
+ emxbind tcsh
+
+gethost: gethost.c sh.err.h tc.const.h sh.h
+ rm -f gethost
+ ${CC} -o gethost ${LDFLAGS} ${CFLAGS} ${DFLAGS} gethost.c ${LIBES} ${EXTRALIBS}
+
+tc.defs.c: gethost host.defs
+ @rm -f $@
+ @echo "/* Do not edit this file, make creates it */" > $@
+ ./gethost host.defs >> $@
+
+tcsh.ps: tcsh.man
+ rm -f tcsh.ps
+ -ptroff -man tcsh.man > tcsh.ps
+
+
+#.c.${SUF}:
+# ${CC} ${CF} ${CFLAGS} ${DFLAGS} ${EXTRAFLAGS} $<
+
+# _VMS_POSIX #module addition
+.c.${SUF}:
+ @(echo '\#module '`echo $< | sed -e 's/\./_/g'`; cat $<) > $*..c
+ @echo ${CC} ${CF} ${CFLAGS} ${DFLAGS} ${EXTRAFLAGS} $*.c
+ @${CC} ${CF} ${CFLAGS} ${DFLAGS} ${EXTRAFLAGS} $*..c
+ @mv $*..o $*.o
+ @rm -f $*..c
+
+
+# Don't do any special massaging of C files for sharing of strings!!
+# it causes weird segmentation faults on some systems.
+#.c.o:
+# ${CC} -E ${CFLAGS} $*.c | ${XSTR} -c -
+# ${CC} ${CF} ${CFLAGS} x.c
+# mv -f x.o $*.o
+# rm -f x.c
+
+#ed.init.o: ed.init.c
+# ${CC} -E ${CFLAGS} $*.c | ${XSTR} -c -
+# ${CC} -R ${CF} ${CF} x.c
+# mv -f x.o $*.o
+# rm -f x.c
+
+#strings.o: strings
+# ${XSTR}
+# ${CC} -c -R xs.c
+# mv -f xs.o strings.o
+# rm -f xs.c
+
+##.DEFAULT:
+## ${SCCS} get $<
+
+##.DEFAULT:
+## co $<
+
+ed.defns.h: ed.defns.c
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '\#ifndef _h_ed_defns' >> $@
+ @echo '\#define _h_ed_defns' >> $@
+ grep '[FV]_' ed.defns.c | grep '^\#define' >> $@
+ @echo '\#endif /* _h_ed_defns */' >> $@
+
+sh.err.h: sh.err.c
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '\#ifndef _h_sh_err' >> $@
+ @echo '\#define _h_sh_err' >> $@
+ grep 'ERR_' sh.err.c | grep '^#define' >> $@
+ @echo '\#endif /* _h_sh_err */' >> $@
+
+tc.const.h: tc.const.c sh.char.h config.h config_f.h sh.types.h sh.err.h
+ @rm -f $@
+ @echo '/* Do not edit this file, make creates it. */' > $@
+ @echo '\#ifndef _h_tc_const' >> $@
+ @echo '\#define _h_tc_const' >> $@
+ ${CC} -E $(INCLUDES) ${DFLAGS} -D_h_tc_const tc.const.c | \
+ grep 'Char STR' | \
+ sed -e 's/Char \([a-zA-Z0-9_]*\)\[\].*/extern Char \1[];/' | \
+ sort >> $@
+ @echo '\#endif /* _h_tc_const */' >> $@
+
+csh.prof: ${OBJS} sh.prof.${SUF} mcrt0.${SUF}
+ rm -f csh.prof
+ ld -X mcrt0.${SUF} ${OBJS} -o csh.prof ${LIBES} -lc
+
+sh.prof.${SUF}:
+ cp sh.c sh.prof.c
+ ${CC} ${CF} ${CFLAGS} -DPROF sh.prof.c
+
+lint: tc.const.h ed.defns.h
+ lint ${DFLAGS} ${LFLAGS} sh*.c tw*.c ed*.c tc.*.c ${LIBES}
+
+alint: tc.const.h ed.defns.h
+ alint ${DFLAGS} ${LFLAGS} sh*.c tw*.c ed*.c tc.*.c ${LIBES}
+
+print:
+ @pr READ_ME
+ @pr makefile makefile.*
+ @(size -l a.out; size *.${SUF}) | pr -h SIZES
+ @${CXREF} sh*.c | pr -h XREF
+ @ls -l | pr
+ @pr sh*.h [a-rt-z]*.h sh*.c alloc.c
+
+vprint:
+ @pr -l84 READ_ME TODO
+ @pr -l84 makefile makefile.*
+ @(size -l a.out; size *.${SUF}) | pr -l84 -h SIZES
+ @${CXREF} sh*.c | pr -l84 -h XREF
+ @ls -l | pr -l84
+ @${CXREF} sh*.c | pr -l84 -h XREF
+ @pr -l84 sh*.h [a-rt-z]*.h sh*.c alloc.c
+
+vgrind:
+ @cp /dev/null index
+ @for i in *.h; do vgrind -t -h "C Shell" $$i >/crp/bill/csh/$$i.t; done
+ @for i in *.c; do vgrind -t -h "C Shell" $$i >/crp/bill/csh/$$i.t; done
+ @vgrind -t -x -h Index index >/crp/bill/csh/index.t
+
+install: tcsh
+ -mv -f ${DESTBIN}/tcsh ${DESTBIN}/tcsh.old
+ cp tcsh ${DESTBIN}/tcsh
+ -strip ${DESTBIN}/tcsh
+ chmod 555 ${DESTBIN}/tcsh
+
+install.man: tcsh.man
+ -rm -f ${DESTMAN}/tcsh.${MANSECT}
+ cp tcsh.man ${DESTMAN}/tcsh.${MANSECT}
+ chmod 444 ${DESTMAN}/tcsh.${MANSECT}
+
+# Amiga Unix
+#install.man: tcsh.man
+# compress tcsh.man
+# cp tcsh.man.Z ${DESTMAN}/tcsh.Z
+# chmod 444 ${DESTMAN}/tcsh.Z
+
+# Apple A/UX
+#install.man: tcsh.man
+# -rm -f ${DESTMAN}/tcsh.${MANSECT}.Z
+# nroff -man tcsh.man | compress > ${DESTMAN}/tcsh.${MANSECT}.Z
+# chmod 444 ${DESTMAN}/tcsh.${MANSECT}.Z
+
+clean:
+ ${RM} -f a.out strings x.c xs.c tcsh tcsh.a _MAKE_LOG core gethost
+ ${RM} -f *.${SUF} sh.prof.c ed.defns.h tc.const.h sh.err.h tc.defs.c
+ ${RM} -f tcsh.*.m tcsh.*.cat
+
+veryclean: clean
+ ${RM} -f config.h
+ ${RM} -f *~ #*
+
+tags: /tmp
+ ${CTAGS} sh*.c
+
+tar.Z:
+ rm -f tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | compress > tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+
+tar.gz:
+ rm -f tcsh-${VERSION}.tar.gz
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | gzip > tcsh-${VERSION}.tar.gz
+ rm -rf tcsh-${VERSION}
+
+shar:
+ rm -f tcsh-*.shar
+ rm -rf tcsh-${VERSION}
+ mkdir tcsh-${VERSION} tcsh-${VERSION}/config
+ cp ${ALLSRCS} tcsh-${VERSION}
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ MAKESHAR -v -n tcsh-${VERSION} tcsh-${VERSION} \
+ tcsh-${VERSION}/?* tcsh-${VERSION}/config/?* \
+ tcsh-${VERSION}/?*/set?*
+ rm -rf tcsh-${VERSION}
+
+catalogs:
+ @(cd nls; make catalogs)
+
+tcsh-${VERSION}.tar.Z:
+ rm -rf tcsh-${VERSION}
+ rm -f tcsh-${VERSION}.tar tcsh-${VERSION}.tar.Z DIFFS.[123]
+ mkdir tcsh-${VERSION}
+ ./MAKEDIFFS bsd
+ mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh-${VERSION}
+ cp ${DISTSRCS} tcsh-${VERSION}
+ mkdir tcsh-${VERSION}/config
+ cp ${CONFSRCS} tcsh-${VERSION}/config
+ cp Makefile tcsh-${VERSION}/Makefile.new
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh-${VERSION} | compress > tcsh-${VERSION}.tar.Z
+ rm -rf tcsh-${VERSION}
+
+tcsh.tahoe-${VERSION}.tar.Z:
+ rm -rf tcsh.tahoe-${VERSION}
+ rm -f tcsh.tahoe-${VERSION}.tar tcsh.tahoe-${VERSION}.tar.Z DIFFS.[123]
+ mkdir tcsh.tahoe-${VERSION}
+ ./MAKEDIFFS tahoe
+ mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh.tahoe-${VERSION}
+ cp ${DISTSRCS} tcsh.tahoe-${VERSION}
+ mkdir tcsh.tahoe-${VERSION}/config
+ cp ${CONFSRCS} tcsh.tahoe-${VERSION}/config
+ cp Makefile tcsh.tahoe-${VERSION}/Makefile.new
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh.tahoe-${VERSION} | compress > tcsh.tahoe-${VERSION}.tar.Z
+ rm -rf tcsh.tahoe-${VERSION}
+
+tcsh.reno-${VERSION}.tar.Z:
+ rm -rf tcsh.reno-${VERSION}
+ rm -f tcsh.reno-${VERSION}.tar tcsh.reno-${VERSION}.tar.Z DIFFS.[123]
+ mkdir tcsh.reno-${VERSION}
+ ./MAKEDIFFS reno
+ mv DIFFS.1 DIFFS.2 DIFFS.3 tcsh.reno-${VERSION}
+ cp ${DISTSRCS} tcsh.reno-${VERSION}
+ mkdir tcsh.reno-${VERSION}/config
+ cp ${CONFSRCS} tcsh.reno-${VERSION}/config
+ cp Makefile tcsh.reno-${VERSION}/Makefile.new
+ tar cf - nls/Makefile nls/?*/set?* | (cd tcsh-${VERSION}; tar xpf -)
+ tar cvf - tcsh.reno-${VERSION} | compress > tcsh.reno-${VERSION}.tar.Z
+ rm -rf tcsh.reno-${VERSION}
+
+ftp: tcsh-${VERSION}.tar.Z tcsh.tahoe-${VERSION}.tar.Z
+ cp tcsh-${VERSION}.tar.Z tcsh.tahoe-${VERSION}.tar.Z ${FTPAREA}
+ cp tcsh.man ${FTPAREA}
+
+#
+# Dependencies
+#
+config.h: config_f.h
+
+TCH=tc.h tc.const.h tc.decls.h tc.os.h tc.sig.h
+SHH=sh.h sh.types.h sh.char.h sh.err.h sh.dir.h sh.proc.h pathnames.h \
+ sh.decls.h ${TCH}
+TWH=tw.h tw.decls.h
+EDH=ed.h ed.decls.h
+
+# EDH
+EDINC=sh.${SUF} sh.func.${SUF} sh.lex.${SUF} sh.print.${SUF} sh.proc.${SUF} \
+ sh.set.${SUF} tc.bind.${SUF} tc.os.${SUF} tc.prompt.${SUF} \
+ tc.sched.${SUF} tw.parse.${SUF}
+${EDOBJS} ${EDINC} : ${EDH}
+
+# SHH
+${OBJS}: config.h ${SHH}
+
+# TWH
+TWINC=ed.chared.${SUF} ed.inputl.${SUF} sh.exec.${SUF} sh.func.${SUF} \
+ sh.set.${SUF} tc.func.${SUF}
+${TWOBJS} ${TWINC}: ${TWH}
+
+# glob.h
+glob.${SUF} sh.glob.${SUF}: glob.h
+
+# ed.defns.h
+EDDINC=tc.bind.${SUF} tc.func.${SUF} tc.os.${SUF}
+${EDOBJS} ${EDDINC}: ed.defns.h
+
+# tc.defs.o
+tc.defs.${SUF}: tc.defs.c sh.h
diff --git a/contrib/tcsh/NewThings b/contrib/tcsh/NewThings
new file mode 100644
index 000000000000..a372fbb22805
--- /dev/null
+++ b/contrib/tcsh/NewThings
@@ -0,0 +1,169 @@
+This file contains visible (incompatible) changes to the users.
+This version of tcsh has the following new things:
+
+6.08
+* %$variables are now expanded in the prompt.
+* print_by_columns prints in a single column if the output is not a tty.
+* REMOTEHOST contains only the IP address, not the host name of the machine.
+* names in .cshdirs are quoted.
+* exit value from 0..255 not -128..127 as posix mandates.
+
+6.07
+* Implicit cd when the variable implicitcd is set or set to verbose
+
+6.06
+* NLS Message Catalog support.
+
+6.05
+* The bind, aliases, linedit builtins are not used anymore; they are
+ #ifdef'ed OBSOLETE and will be really removed in the next version
+* new filetest builtin
+* new hup builtin
+* =x obeys nonomatch
+* tcsh.man2html nroff to HTML converter for the tcsh manpage
+* prompt is now %# by default.
+* $REMOTEHOST contains the name of the remote host (optional)
+* $HOSTTYPE is going away. New variables $OSTYPE, $MACHTYPE, $VENDOR similar
+ to the gnu ones.
+* $< can be interrupted and takes modifiers. Does not quote args by default
+ like csh.
+
+6.04
+* Variable modifiers do not stop processing after the first one fails
+ > set i=aabbcc
+ > echo $i:s/a/A/:s/b/B/
+ AaBbcc
+ > echo $i:s/x/A/:s/b/B/
+ aabbcc
+* set -r makes variables readonly
+* set nonomatch, echo ~notaser returns ~notauser instead of an error
+* file operators: Changed -s == !-z and -S == socket
+* $?0 returns false now on interactive shells for csh compatibility.
+* %p%P include seconds in prompt strings.
+
+6.03
+* $%var contains the number of characters in $var.
+* Shell -w -x are now POSIX compliant on POSIX machines.
+* Imported environment variables are not globbed.
+* $dirstack can be used to set and examine the directory stack.
+* $? == $status and $# == $#argv like in the bourne shell.
+* expand variables expands arrays too (but not array elements yet).
+* $0 contains argv[0] on interactive shells.
+* new -b -c etc file operators from SGI csh.
+* nostat takes a list of shell patterns.
+* symbolic names for arrow key bindings [left, right, up, down]
+* shift, left operators update variables correctly.
+* builtins builtin.
+* history and dirs accept now -LSc flags.
+* $history accepts an optional second argument, that can change the
+ history builtin output similar to the $time format.
+* History timestamps preserved in .history. The history file contains
+ now the timestamps as csh comments.
+
+
+6.02
+* ignore_symlinks and chase_symlinks are replaced with symlinks=ignore
+ and symlinks=chase; symlinks=expand addition
+* complete and uncomplete builtins; user-programmable completion additions.
+* Tcsh now uses the rightmost column of the terminal, allowing cut-and-paste
+ operations in terminal emulators that work [xterm R5 not R4]
+* echo_style controls now the behaviour of the builtin echo; the default
+ should match the builtin echo of /bin/csh; if your system does not
+ come with csh, then the default echo should match /bin/echo.
+* cd -; changes to the previous directory.
+* setting dunique variable pushes only unique directories on the directory
+ stack.
+* source builtin allows additional arguments that get passed in $argv in
+ the sourced script.
+* tcsh now mirrors correctly all exported csh variables [term=TERM,path=PATH
+ etc.]
+* showdots=-A makes listing behave like ls -A.
+* directory stack access =<num> allows for entries > 9.
+* $a:u uppercase the first character in $a, $a:l downcases the first
+ character in $a.
+* Shorthand for file tests in 'if' expressions ( -dx file ) is the
+ same as ( -d file && -x file )
+
+6.01
+* Nothing new.
+
+6.00 PL3
+* %d in the prompt is the week-day and no longer $cwd; use %/ instead.
+* changes in the prompt format. Date changes to accomodate people from
+ down under.
+* vi insert mode to command mode transition does not move the cursor.
+
+6.00 PL2
+* setty builtin
+ This is used to specify what tcsh modes can be altered using stty,
+ Modes that should be set are specified as +<mode>, modes that should
+ be cleared are specified as -<mode>, and the ones that should be
+ untouched are specified as <mode>. setty with no arguments prints
+ the modes that are affected by tcsh, and setty -a prints all modes.
+* multiple : modifiers in variables and ! escapes. Things like:
+ > set prompt="$host:r:$cwd>"
+ don't work any more, they should be replaced with
+ > set prompt="${host:r}:$cwd>"
+ or
+ > set prompt="$host:r"":$cwd>"
+ the reason is that now you can
+ > set foo=/usr/local/a.b.c
+ > echo $foo:t:r:e
+ b
+ If for some reason you don't like this change you can disable it with
+ -DCOMPAT. -DCOMPAT may go away in future tcsh versions and the way tcsh
+ works now is the way the 4.4BSD csh works.
+
+6.00 PL1
+* There is no more config.iris4d, use config.sgi instead
+
+6.00
+* History searching searches using shell patterns too.
+* The autolist values that controlled beeping are not supported any more;
+ used matchbeep instead.
+* /etc/Login and /etc/Logout were renamed to /etc/csh.login /etc/csh.logout
+ and /etc/csh.cshrc was added
+* prompt2 and prompt3 can have prompt escapes.
+* eval pipes work
+* ignore_symlinks works
+
+5.20 PL2
+* %{..%} escapes in prompt
+
+5.20 PL0
+* bindkey -r
+* history -t
+* shell variables in paths expand correctly.
+* variable expansion
+* quoted expansions now work.
+* new version and tcsh variable format
+
+5.19 PL2
+* NLS support
+* New bindkey and echotc builtins
+* Underline and Bold in the prompt; additions and changes to the prompt and
+ who syntax (%u is now %n, so that %u can be used to turn undeline off,
+ and %n is now \n).
+* rmstar needs to be set to protect from accidental removal
+* Fixed editor, and spell line.
+* Glob-expand, on arguments.
+* Added process migration builtins for aix370
+
+5.19 PL1
+* Maintainance release for mainly the rs6000
+
+5.19 PL0
+* 8 bit clean code, by using 16 bit strings.
+* Mostly shared strings (a side-effect)
+* Highlights everywhere (and in ls-F) filenames that contain characters
+ with the eighth bit set (or passes them unchanged depending on the
+ variable 'nometa')
+* Newline in the prompt via %n.
+* dirs takes also a -v flag for `vertical display'
+* There is a new variable `listjobs' which controls if and how jobs
+ are displayed when a new job is suspended. [Idea from the mtXinu
+ code, very useful for novice users who hit control-Z 10 times on
+ the same job!]
+ set listjobs=long, jobs -l is executed every time a job is suspended.
+ set listjobs=short, jobs is executed every time a job is suspended.
+* Passes lint... At least on a sun.
diff --git a/contrib/tcsh/Ported b/contrib/tcsh/Ported
new file mode 100644
index 000000000000..769f4073392f
--- /dev/null
+++ b/contrib/tcsh/Ported
@@ -0,0 +1,1016 @@
+
+Hello,
+
+This file contains a list of machines used, libraries compiler etc. If you
+find it out-of-date, or you have additions or changes, please let me know.
+
+christos
+
+
+VENDOR : sun
+MODELS : sun3, sun4, sun386i
+COMPILER: cc, gcc, acc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : sunos 3.5, 4.0, 4.1, 4.1.1, 4.1.2, 4.1.3, 4.1.4
+CONFIG : sunos*
+ENVIRON : n/a
+NOTES : Don't compile with /usr/5bin/cc
+VERSION : 6.08
+
+VENDOR : sun
+MODELS : sun4, ultra
+COMPILER: cc, gcc
+CFLAGS : normal
+LIBES : -lcurses -lsocket -lnsl
+OS : solaris 2.1, 2.2, 2.3, 2.4, 2.5, 2.5.1
+CONFIG : sol*
+ENVIRON : n/a
+NOTES : The sunpro compiler cannot compile tcsh with -O, it crashes
+ : on some files. In any case do not use -O with any of the
+ : tcsh files, because the optimized code assumes that the
+ : floating point is already initialized and does not do the
+ : necessary initializations. This results in weird floating
+ : point failures of programs exec'ed from tcsh.
+VERSION : 6.08
+
+VENDOR : sun
+MODELS : ultra
+COMPILER: WorkShop cc
+CFLAGS : normal
+LIBES : -lcurses -lsocket -lnsl
+OS : solaris 2.6
+CONFIG : sol26
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.08
+
+VENDOR : sun
+MODELS : i386
+COMPILER: cc, gcc
+CFLAGS : -D__STDC__=0
+LIBES : -lcurses -lsocket -lnsl
+OS : solaris 2.1
+CONFIG : sol2
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.04.13
+
+VENDOR : sun
+MODELS : sun4
+COMPILER: gcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : linux 2.0.x, 2.1.x
+CONFIG : linux
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.07.03
+
+VENDOR : hp
+MODELS : apollo
+COMPILER: cc
+CFLAGS : -U__STDC__ -I. -O
+LIBES : -ltermcap
+OS : domain 10.4.3
+CONFIG : bsd
+ENVIRON : bsd4.3
+NOTES : Don't use gcc; breaks tc.os.c
+VERSION : 6.01.00
+
+VENDOR : hp
+MODELS : hp9000s300, hp9000s700, hp9000s800
+COMPILER: cc, gcc
+CFLAGS : normal (-Aa -O3 hpux 8.0, 8.07, 9.05)
+LIBES : -ltermcap
+OS : hpux 6.5, 7.0.x, 8.0, 9.05
+CONFIG : hpux{7,8}
+ENVIRON : n/a
+NOTES : Don't use -lBSD; breaks getpgrp(). Config.hp-3.2 obsolete?
+ : Some versions of the compiler are broken with -O3. Try 'ls *'
+ : If it does not work, lower the optimization level...
+VERSION : 6.05.06
+
+VENDOR : hp
+MODELS : hp9000s700
+COMPILER: cc, c89, gcc
+CFLAGS : +O3 -Aa (cc), +O3 (c89), normal (gcc)
+LIBES : -ltermcap
+OS : hpux 10.00, 10.01
+CONFIG : hpux8
+ENVIRON : n/a
+NOTES : Carl-Olof Almbladh (coa@teorfys.lu.se)
+ : To make a statically linked version: in config_f.h, #undef NLS
+ : and use these LDFLAGS in the Makefile: LDFLAGS= -Wl,-a,archive
+ : [orban@kato.den.csci.csc.com (Tom Orban)
+VERSION : 6.08
+
+VENDOR : hp
+MODELS : SPP-1200 SPP-1600 S-2X00 X-2X00
+COMPILER: cc
+CFLAGS : -Ae
+LIBES : -ltermcap
+OS : SPP-UX 5.X
+CONFIG : hpux8
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.07.02
+
+VENDOR : hp
+MODELS : hp9000s500
+COMPILER: cc
+CFLAGS : -I. -O
+LIBES : -ltermcap
+OS : hpux 5.2
+CONFIG : hp-5.2
+ENVIRON : n/a
+NOTES : very slow in executing commands (I think the reason is
+NOTES : a very slow fork)
+VERSION : 6.00.01
+
+VENDOR : digital
+MODELS : vax
+COMPILER: cc, gcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : bsd4.3, bsd4.4
+CONFIG : bsd*
+ENVIRON : n/a
+NOTES : cc broken: typedef void sigret_t; typedef void pret_t;
+VERSION : 6.00.03
+
+VENDOR : digital
+MODELS : vax
+COMPILER: cc, gcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : mtXinu 4.3
+CONFIG : mtxinu
+ENVIRON : n/a
+NOTES : cc broken: typedef void sigret_t; typedef void pret_t;
+VERSION : 6.03.09
+
+VENDOR : digital
+MODELS : vax, DECstation
+COMPILER: cc, gcc
+CFLAGS : -O -Olimit 2000 (cc), normal (gcc)
+LIBES : -ltermcap
+OS : ultrix 3.0 (vax), 4.0, 4.1, 4.2, 4.3, 4.4
+CONFIG : ultrix
+ENVIRON : n/a
+NOTES : pcc broken: typedef void sigret_t (vax);
+NOTES : mips compiler on ultrix 3.5 needs -Dvoid=int
+NOTES : vax compiler on ultrix 3.0 needs -Dvoid=int
+NOTES : Does Ultrix 4.x still need YPBUGS?
+NOTES : Ultrix4.2 may need NAMEI_BUG
+VERSION : 6.07.11
+
+VENDOR : apple
+MODELS : macII
+COMPILER: cc
+CFLAGS : normal (-ZP)
+LIBES : -ltermcap (-lposix -ltermcap)
+OS : aux 2.0
+CONFIG : mac2 (-DPOSIX -DPOSIXJOBS)
+ENVIRON : n/a
+NOTES : Tcsh can compile both in non POSIX and POSIX mode. The
+NOTES : default configuration is non POSIX. The flags in parentheses
+NOTES : are the changes that are needed to compile in POSIX mode
+VERSION : 6.00.01
+
+VENDOR : ibm
+MODELS : ps/2, rs6000, ibm370, ibmESA
+COMPILER: cc
+CFLAGS : normal
+LIBES : -lcurses -lbsd [No -lbsd for 4.1]
+OS : aix 3.1,3.2,4.1 (rs6000) aix 1.1 (ps/2) aix G9.9 (ibm370)
+ : aix (ibmESA)
+CONFIG : aix
+ENVIRON : n/a
+NOTES : aix G9.9 sfname() frees bad pointers. Use TCF with care!
+NOTES : aix 3.2 may need NAMEI_BUG
+NOTES : aix 3.2 may need _BSD_INCLUDES defined in h
+NOTES : aix 4.1 does not need -lbsd anymore.
+VERSION : 6.06.00 (rs6000)
+
+VENDOR : ibm
+MODELS : rt
+COMPILER: hc, gcc
+CFLAGS : -I. -U__STDC__
+LIBES : -ltermcap
+OS : aos 4.3
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : Old versions of the compiler break with -O. No ansi include
+NOTES : files so we have to undef __STDC__
+VERSION : 6.05.06
+
+VENDOR : ibm
+MODELS : rt
+COMPILER: pcc
+CFLAGS : -I. -U__STDC__ -DPCC
+LIBES : -ltermcap
+OS : aos 4.3
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : Old versions of the compiler break with -O. No ansi include
+NOTES : files so we have to undef __STDC__
+NOTES : pcc broken: typedef void sigret_t; typedef void pret_t;
+VERSION : 6.05.06
+
+VENDOR : ibm
+MODELS : rt
+COMPILER: cc
+CFLAGS : -I. -Nd4000 -Nn3000
+LIBES : -lcurses
+OS : aix 2.2.1
+CONFIG : aix
+ENVIRON : n/a
+NOTES : Stacksize limit is 1K off?
+VERSION : 6.00.03
+
+VENDOR : sequent
+MODELS : balance, symmetry
+COMPILER: cc
+CFLAGS : normal
+LIBES : -ltermcap -lseq
+OS : Dynix 3.1, 3.2, ptx 1.2
+CONFIG : sequent
+ENVIRON : universe on Dynix 3.1, 3.2: ucb
+NOTES : none
+VERSION : 6.04.00
+
+VENDOR : sequent
+MODELS : symmetry
+COMPILER: gcc 2.6.2
+CFLAGS : -m486
+LIBES : -ltermcap -lseq -lsocket -linet -lnsl
+OS : DYNIX/ptx 2.1.0, 4.1.3
+CONFIG : sequent
+ENVIRON :
+NOTES : Didn't work for me with Sequent's /bin/cc
+NOTES : 4.1.3 does not need libinet anymore.
+VERSION : 6.05.00
+
+VENDOR : encore
+MODELS : multimax
+COMPILER: gcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : umax 4.2
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.00.00
+
+VENDOR : sony
+MODELS : news 1850, 1750
+COMPILER: gcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : bsd 4.3, news-os 3.3,4.1C
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.05.06
+
+VENDOR : ibm + compatibles
+MODELS : i386,i286
+COMPILER: cc
+CFLAGS : normal
+LIBES : -ltermcap -ldir -lx
+OS : xenix
+CONFIG : xenix
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.00.01
+
+VENDOR : hp
+MODELS : hp300
+COMPILER: cc, gcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : MORE/bsd 4.3+
+CONFIG : mtxinu
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.05.06
+
+VENDOR : hp, motorola
+MODELS : hp300, m68k
+COMPILER: gcc
+CFLAGS : normal
+LIBES : -ltermcap -lcrypt
+OS : NetBSD 1.0A
+CONFIG : bsd4.4
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.05.06
+
+VENDOR : digital
+MODELS : vax
+COMPILER: gcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : bsd 4.3reno
+CONFIG : bsdreno
+NOTES : ttyname() is buggy. calls closedir() twice. See README
+ENVIRON : n/a
+VERSION : 6.00.04
+
+VENDOR : Cray Research
+MODELS : Y-MP
+COMPILER: cc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : Unicos 6.0
+CONFIG : cray
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.00.01
+
+VENDOR : Cray Research
+MODELS : C90
+COMPILER: cc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : Unicos 9.0.2.1
+CONFIG : cray
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.08
+
+VENDOR : pyramid
+MODELS : MIS4/2T
+COMPILER: cc
+CFLAGS : -OG
+LIBES : -ltermcap
+OS : OSx5.1,6.4
+CONFIG : pyr
+ENVIRON : n/a
+NOTES : If there are problems with the global optimizer, use -OP
+NOTES : If you only have the AT&T universe, use the pyratt config
+NOTES : file and define -D_PID_T -Dpyr.
+VERSION : 6.06.00
+
+VENDOR : next
+MODELS : any
+COMPILER: gcc or cc -arch m68k -arch i386
+CFLAGS : -O2 -g
+LIBES : -ltermcap # [-lcs 2.0]
+OS : next os 2.x, 3.x
+CONFIG : mach
+ENVIRON : n/a
+NOTES : NeXTSTeP 3.3 on intel defines speed_t so compile with -D_SPEED_T
+NOTES : NeXT's cc -E adds spaces before and after array brackets!
+NOTES : You'll need to change the sed expression in the Makefile to
+NOTES : something like:
+NOTES : 's/Char \([a-zA-Z0-9_]*\) *\[ *\].*/extern Char \1[];/'
+VERSION : 6.04.00
+
+VENDOR : Apple
+MODELS : any
+COMPILER: cc
+CFLAGS : -O3 -pipe -g -arch ppc -arch i386 -UNeXT
+OS : Rhapsody 5
+CONFIG : rhapsody
+ENVIRON : n/a
+NOTES : CFLAGS="-O3 -pipe -g -arch ppc -arch i386 -UNeXT" configure && make
+VERSION : 6.08.00
+
+VENDOR : Heurikon
+MODELS : HK68
+COMPILER: gcc (Green Hills C-68000)
+CFLAGS : -ga -X138 -X25 -I.
+LDFLAGS : -n
+LIBES : -lcurses -ltermcap -ldirent
+OS : UniPlus+ 5.0
+CONFIG : hk68
+ENVIRON : n/a
+NOTES : Need Doug Gwyn's POSIX directory library (libdirent.a)
+VERSION : 6.00.01
+
+VENDOR : Amdahl
+MODELS : n/a
+COMPILER: cc/gcc
+CFLAGS : normal
+LIBES : -lcurses -lsocket -lbsd
+CONFIG : amdahl
+ENVIRON : n/a
+VERSION : 6.00.01
+
+VENDOR : prime
+MODELS : exl 300 series
+COMPILER: cc
+CFLAGS : -O -s -I.
+LIBES : -lcurses -lstcp
+OS : system v.3.1.2
+CONFIG : sysv
+ENVIRON : sysv
+NOTES : Is libstcp.a on all exl 300s?
+VERSION : 6.00.01
+
+VENDOR : convex
+MODELS : c220
+COMPILER: cc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : 9.0.6 (bsd 4.3)
+CONFIG : convex
+ENVIRON : n/a
+NOTES : Dont use the -pcc flag.
+ : Use setty to fix the default tty settings.
+VERSION : 6.00.01
+
+VENDOR : Norsk Data
+MODELS : nd5000
+COMPILER: cc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : Ndix Version C
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : The -O option makes the compiler run for ages!
+VERSION : 6.00.03
+
+VENDOR : SGI
+MODELS : 4D, 3000
+COMPILER: cc
+CFLAGS : -D__STDC__
+LIBES : -lcurses -lsun -lbsd -lc_s
+OS : IRIX (3.?) 3.2 3.3 4.0
+CONFIG : sgi
+ENVIRON : n/a
+NOTES : AUTOLOGOUT is probably best undef'ed
+NOTES : For 4.0, the NLS define in h can be enabled.
+NOTES : 4.0.5a cc does not have -O3 anymore.
+NOTES : If you don't like -lbsd, you can define POSIXJOBS in
+NOTES : config.h and omit it.
+VERSION : 6.06.00
+
+VENDOR : SGI
+MODELS : R8000 PowerIndigo2
+COMPILER: cc -n32
+CFLAGS : -D__STDC__
+LIBES : -lcurses -lsun -lbsd -lc_s
+OS : IRIX 6.2
+CONFIG : sgi
+ENVIRON : n/a
+NOTES : CCOPTIONS=-OPT:fold_arith_limit=4000
+NOTES : SHLIBDIR=/usr/lib32
+NOTES : LDPOSTLIB = -nostdlib -L$(ROOT)$(SHLIBDIR)/mips3 \
+NOTES : -L$(ROOT)$(SHLIBDIR)
+NOTES : In config.h #undef NLS and #undef NLS_CATALOGS
+VERSION : 6.06.00
+
+VENDOR : SGI
+MODELS : Onyx R10000
+COMPILER: gcc-2.7.2.1 configured for mips-sgi-irix5.3
+CFLAGS : none
+LIBES : -ltermcap -lbsd
+OS : IRIX 6.2
+CONFIG : sgi
+ENVIRON : n/a
+VERSION : 6.07.02
+
+VENDOR : ibm + compatibles
+MODELS : i386,i486
+COMPILER: /bin/cc
+CFLAGS : normal
+LIBES : -ltermlib -lsocket -lnsl (without BSDTIMES)
+LIBES : -ltermlib -lsocket -lnsl -lc /usr/ucblib/libucb.a (BSDTIMES)
+OS : SVR4 (DELL, ESIX, ISC, UHC)
+CONFIG : sysv4
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.05.06
+
+VENDOR : ibm + compatibles
+MODELS : i386,i486
+COMPILER: gcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : linux 0.8x, 0.9x, 1.x
+CONFIG : linux
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.05.06
+
+VENDOR : ibm + compatibles
+MODELS : i386,i486
+COMPILER: gcc
+CFLAGS : normal
+LIBES : -lcurses -lc_s [for crypt]
+OS : SVR3.2.2 [SCO]
+CONFIG : sco32v2
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.03.00
+
+VENDOR : stardent
+MODELS : gs2600
+COMPILER: /bin/cc
+CFLAGS : -O
+LIBES : -lcurses
+OS : stellix
+CONFIG : stellar
+ENVIRON : n/a
+NOTES : works but not worth compiling with -O4...
+NOTES : setpgrp() and SIGCHLD work the BSD way, not the way documented.
+NOTES : we need to define BACKPIPE
+VERSION : 6.00.04
+
+VENDOR : stardent
+MODELS : titan 3000 series
+COMPILER: /bin/cc
+CFLAGS : -O -43
+LIBES : -ltermcap
+OS : OS 3.0.3
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : Kernel bug with SIGTTIN, Try vi, ^Z, bg, fg....
+VERSION : 6.01.01
+
+VENDOR : stardent
+MODELS : titan 1500 series
+COMPILER: cc
+CFLAGS : -O -43
+LIBES : -ltermcap
+OS : OS 2.5
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : Kernel bug with SIGTTIN, Try vi, ^Z, bg, fg....
+NOTES : You can add -w to the CFLAGS to suppress the warnings.
+VERSION : 6.02.07
+
+VENDOR : SGI
+MODELS : INDIGO
+COMPILER: cc
+CFLAGS : -D__STDC__
+LIBES : -lcurses -lsun -lbsd -lc_s
+OS : IRIX (3.?) 3.2 3.3 4.0
+CONFIG : sgi
+ENVIRON : n/a
+NOTES : AUTOLOGOUT is probably best undef'ed
+NOTES : For 4.0, the NLS define in h can be enabled.
+VERSION : 6.01
+
+VENDOR : SGI
+MODELS : INDY
+COMPILER: cc
+CFLAGS :
+LIBES : -lcurses -lbsd
+OS : IRIX 5.1
+CONFIG : sgi
+ENVIRON : n/a
+NOTES : it will build without -lbsd but then job control
+NOTES : won't actually work.
+VERSION : 6.04.00
+
+VENDOR : alliant
+MODELS : FX/2800 series
+COMPILER: scc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : Alliant Concentrix 2800 2.2.00
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : For a newer version of the operating system try defining
+ : NEW_OS in alliant [or better find a way to tell
+ : them apart.
+VERSION : 6.03.00
+
+VENDOR : stardent
+MODELS : Vistra 800
+COMPILER: /bin/cc
+CFLAGS : -O
+LIBES : -lcurses -lnsl -lsocket -lc /usr/ucblib/libucb.a
+OS : SYSVR4
+CONFIG : sysv4
+ENVIRON : n/a
+NOTES : Works like a charm
+VERSION : 6.01
+
+VENDOR : Evans & Sutherland
+MODELS : ESV
+COMPILER: cc
+CFLAGS : mips systems
+LIBES : -ltermcap
+OS : ES/os 2.2 (UMIPS mips ATT_V3_0)
+CONFIG : mips
+ENVIRON : bsd4.3
+NOTES : would it be preferable to have HOSTTYPE of
+NOTES : "esv" instead of "mips"?
+VERSION : 6.01.00
+
+VENDOR : masscomp
+MODELS : Masscomp 6000
+COMPILER: cc
+CFLAGS : production
+LIBES : -ltermcap
+OS : RTU 5.0
+CONFIG : masscomp
+ENVIRON : Link in the "bsd" universe as opposed to "att".
+NOTES : For pre RTU 6.0, remember to remove the #define RTU6 in the
+NOTES : masscomp file.
+NOTES : As of tcsh v6.02.07, try putting "bindkey ^t stuff-char"
+NOTES : in your /etc/csh.cshrc for masscomp kernel (ctrl-t) status.
+VERSION : 6.02.07
+
+VENDOR : masscomp
+MODELS : Masscomp 5400
+COMPILER: cc
+CFLAGS : normal
+LIBES : -ltermcap -lndir -lsocket -ljobs
+OS : RTU 6.0
+CONFIG : masscomp
+ENVIRON : Link in the "bsd" universe as opposed to "att".
+NOTES : n/a
+VERSION : 6.01.00
+
+VENDOR : Cray Computer
+MODELS : CRAY-2 & CRAY-3
+COMPILER: cc
+CFLAGS : normal
+LIBES : -lcurses -lnet
+OS : CSOS 1.0
+CONFIG : csos
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.02
+
+VENDOR : Motorola
+MODELS : Delta 3000/Delta 4000
+COMPILER: cc
+CFLAGS : normal
+LIBES : -lcurses
+OS : System V/68 R3V6.2, R3V7
+CONFIG : sysV68
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.01.00, 6.02.00
+
+VENDOR : Motorola
+MODELS : MPC 3062
+COMPILER: cc
+CFLAGS : Broken optimizers...
+LIBES : -lcurses -lsec
+OS : System V/88 R32V2
+CONFIG : sysV88
+ENVIRON : n/a
+NOTES : If you're using the bundled Greenhills compiler, don't use -O.
+NOTES : One error -O causes is failure to exec scripts with /bin/sh
+NOTES : if they don't have a #! header on top.
+VERSION : 6.02.07
+
+VENDOR : alliant
+MODELS : FX/8X series
+COMPILER: pcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : Concentrix 6.0.00 beta
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : Needs to define DIRENT in h
+VERSION : 6.02.00
+
+VENDOR : alliant
+MODELS : FX/8X series
+COMPILER: pcc
+CFLAGS : normal
+LIBES : -ltermcap
+OS : Concentrix 5.7.00
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.00.01
+
+VENDOR : gould (encore)
+MODELS : NP1
+COMPILER: cc
+CFLAGS : production
+LIBES : -ltermcap
+OS : UTX/32 3.1A
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.02.00
+
+VENDOR : gould (encore)
+MODELS : 9050
+COMPILER: cc
+CFLAGS : production
+LIBES : -ltermcap
+OS : UTX/32 2.1A
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.02.00
+
+VENDOR : ibm & compatible
+MODELS : i386
+COMPILER: cc
+CFLAGS : production
+LIBES : -lcurses -lcposix
+OS : 3.2
+CONFIG : isc
+ENVIRON : ISC386
+NOTES : n/a
+VERSION : 6.02.00
+
+VENDOR : att
+MODELS : 3b2-600GR (RISC)
+COMPILER: cc
+CFLAGS : production
+LIBES : -lcurses
+OS : SystemV R4.0
+CONFIG : sysv4
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.02.00
+
+VENDOR : att
+MODELS : 3b2-600G
+COMPILER: cc
+CFLAGS : production
+LIBES : -lcurses
+OS : SystemV R3.2.3
+CONFIG : sysv3
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.02.00
+
+VENDOR : tektronix
+MODELS : XD88/10
+COMPILER: cc
+CFLAGS : Broken optimizers...
+LIBES : -ltermcap -lsec
+OS : UTekV 3.2e
+CONFIG : tekXD88
+ENVIRON : n/a
+NOTES : If you're using the bundled Greenhills compiler, don't use -O.
+NOTES : One error -O causes is failure to exec scripts with /bin/sh
+NOTES : if they don't have a #! header on top.
+VERSION : 6.02.07
+
+VENDOR : tektronix
+MODELS : 4300
+COMPILER: cc
+CFLAGS : production
+LIBES : -ltermcap
+OS : UTek 4.0 (BSD 4.2)
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : set DFLAGS = -DUTek -DBSD in the Makefile
+VERSION : 6.02.07
+
+VENDOR : BBN
+MODELS : butterfly gp1000
+COMPILER: cc
+CFLAGS : production
+LIBES : -ltermcap
+OS : Mach 1000 version 2.5
+CONFIG : mach
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.02.07
+
+VENDOR : sony
+MODELS : news 3700
+COMPILER: cc
+CFLAGS : -O -Wf,-XNp15000,-XNd15000,-XNh15000
+LIBES : -lcurses -lc /usr/ucblib/libucb.a
+OS : sysvr4, news-os 5.02
+CONFIG : sysv4
+ENVIRON : n/a
+NOTES : Use /usr/bin/cc, not /usr/ucb/cc.
+VERSION : 6.00.03
+
+VENDOR : ibm & compatible
+MODELS : i386, i486
+COMPILER: cc
+CFLAGS : production
+LIBES : -lterm
+OS : Coherent 4.0
+CONFIG : coh3
+ENVIRON : gnu tools (see below)
+NOTES : The standard make, /bin/sh and sed that come with Coherent are
+NOTES : not quite up to the makefile. Either use gnu make or change
+NOTES : occurances of '# to '\# since Coherent's make takes all '#'s to
+NOTES : be a comment, even when quoted, except when escaped by '\'.
+NOTES : Coherent's /bin/sh does not allow you to set VERSION, etc.
+NOTES : since they are hard-wired internal variables. Either use
+NOTES : /usr/bin/ksh, another sh or change the name of the offending
+NOTES : variables. Coherent's sed, unfortunately, is broken beyond a
+NOTES : workaround. Either get gnu sed or run that portion of the
+NOTES : makefile on a machine with a full sed and import the output.
+VERSION : 6.02.08
+
+VENDOR : Control Data Systems
+MODELS : CD4680
+COMPILER: cc, cc2.20 (mips)
+CFLAGS : mips systems, DFLAGS=-DCDC
+LIBES : -ltermcap
+OS : EP/IX 1.4.3 (RiscOS based)
+CONFIG : mips
+ENVIRON : bsd4.3 (if sysv, need "set path=(/usr/bsd43/bin $path)" )
+NOTES : n/a
+VERSION : 6.02.00
+
+VENDOR : alliant
+MODELS : FX/8X series
+COMPILER: pcc
+CFLAGS : normal
+LIBES : -ltermcap -lresolv
+OS : Concentrix 6.0.00 beta
+CONFIG : alliant (see NOTES)
+ENVIRON : n/a
+NOTES : Needs to define DIRENT and BSDLIMIT in h. The
+NOTES : beta release of the Concentrix 6.0.00 has some errors
+NOTES : in the system header files, namely, /usr/include/sys/dir.h.
+VERSION : 6.03.00
+
+VENDOR : hp
+MODELS : hp9000s700
+COMPILER: cc
+CFLAGS : No -O here!!! Breaks quoting! Try echo 'foo | bar'...
+LIBES : -ltermcap
+OS : HP OSF/1 1.0
+CONFIG : hposf1
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.03.00
+
+VENDOR : digital
+MODELS : DEC 3000/400 (alpha)
+COMPILER: cc
+CFLAGS : -call_shared -I. -I.. -O -Olimit 2000 -std1
+LIBES : -lcurses
+OS : OSF1 1.2
+CONFIG : decosf1
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.03
+
+VENDOR : digital
+MODELS : DEC 3000/400 (alpha)
+COMPILER: cc
+CFLAGS : -O2 -I. -I.. -Olimit 2000
+LIBES : -lcurses
+OS : OSF1 (Digital Unix) 1.3, 2.0, 3.0, 3.2, 4.0
+CONFIG : decosf1
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.07.11
+
+VENDOR : Intel
+MODELS : Paragon
+COMPILER: icc
+CFLAGS : -O2
+LIBES : -ltermcap
+OS : Paragon OSF/1 Release 1.0.1 Server 1.0 R1.0
+CONFIG : parosf1
+ENVIRON : n/a
+NOTES : I have gotten two different config files that both seem to
+ : work!
+VERSION : 6.03.00
+
+VENDOR : Data General
+MODELS : AViiON mc88000
+COMPILER: cc
+CFLAGS : -O2
+LIBES : -lcurses
+OS : DGUX 5.4R2.01
+CONFIG : dgux5.4
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.04.00
+
+VENDOR : Data General
+MODELS : Aviion
+COMPILER: gcc 2.5.8
+CFLAGS : -g -O2 -msvr4
+LIBES : -ltermcap
+OS : DGUX 5.4.1
+CONFIG : dgux5.4
+ENVIRON : sde m88kdguxelf
+VERSION : 6.05.00
+
+VENDOR : Harris
+MODELS : Tahoe
+COMPILER: cc, gcc 1.42
+CFLAGS : -O
+LIBES : -ltermcap
+OS : CX/UX 5.1 CX/UX 7.1
+CONFIG : hcx
+ENVIRON : universe bsd
+NOTES : n/a
+VERSION : 6.06.01
+
+VENDOR : Multiflow
+MODELS : multiflow
+COMPILER: cc
+CFLAGS : -O5 -sb_trace 0 -DMULTIFLOW
+LIBES : -ltermcap -lcrypt
+OS : 4.3 BSD TRACE/UNIX
+CONFIG : bsd
+ENVIRON : n/a
+NOTES : Lower the optimization or you'll get a 5M binary!
+NOTES : cc broken: typedef void sigret_t; typedef void pret_t;
+VERSION : 6.04.00
+
+VENDOR : Unixware
+MODELS : all
+COMPILER: cc
+CFLAGS : normal
+LIBES : -lcrypt -ltermlib -lsocket -lnsl -lgen
+OS : Unixware 2.03 (4.2MP)
+CONFIG : svr4
+ENVIRON : n/a
+NOTES : Remove PW_SHADOW from config file, or add -lgen for getspnam
+VERSION : 6.07.00
+
+VENDOR : Intergraph
+MODELS : clipper
+COMPILER: cc
+CFLAGS : n/a
+LIBES : -ltermcap -lbsd
+OS : clix 7.1.3
+CONFIG : clipper
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.05.00
+
+VENDOR : SNI (Siemens Nixdorf Information Systems)
+MODELS : rm400 (R4000 mips)
+COMPILER: /usr/bin/cc
+CFLAGS : -kansi; xmkmf (=> -DSVR4 -DSNI -DSMSINFO -DR3000)
+LIBES : -ltermcap -lc -L/usr/ucblib -lucb
+OS : SINIX 5.42
+CONFIG : sysv4
+ENVIRON :
+NOTES : This is a POSIX (XPG-4) system.
+NOTES : Make sure that -lucb is included _last_ (even after -lc)
+NOTES : so use: -ltermcap -lc -L/usr/ucblib -lucb
+NOTES : In config.h, set HAVEUTMPX und unset BSDSIGS and BSDTIMES
+NOTES :
+VERSION : 6.06.03
+
+VENDOR : U/WIN
+MODELS : i386
+COMPILER: cc
+CFLAGS : -O
+LIBES : -lcurses
+OS : Windows NT with U/WIN
+CONFIG : uwin
+ENVIRON :
+NOTES : Needs POSIX.DLL from U/WIN version later than 1.6
+NOTES : Did not function correctly when using #define SYSMALLOC
+VERSION : 6.07.02
+
+VENDOR : SNI (Siemens Nixdorf Information Systems)
+MODELS : rm600 (R4000 mips)
+COMPILER: /usr/bin/cc
+CFLAGS : -kansi -DSVR4 -DSNI -DSMSINFO -DR3000
+LIBES : -ltermcap -lsocket -lxnet -lc -L/usr/ucblib -lucb
+OS : SINIX 5.43
+CONFIG : sysv4
+ENVIRON :
+NOTES : In config.h, set HAVEUTMPX und unset BSDSIGS,
+NOTES : BSDTIMES, and BSDLIMIT, since otherwise resource.h
+NOTES : is falsely searched in /usr/ucbinclude/sys/
+NOTES :
+VERSION : 6.07.02
+
+VENDOR : FUJITSU
+MODELS : ds90
+COMPILER: cc
+CFLAGS : -O -I. -DSVR4 -DANSICPP
+LIBES : -lsocket -lnsl -ltermcap
+OS : UXP/DS V20L10(SVR4.2)
+CONFIG : sysv4
+ENVIRON : n/a
+NOTES : n/a
+VERSION : 6.07.02
+
+VENDOR : Fujitsu ICL
+MODELS : SuperServer Intel based
+COMPILER: gcc 2.7.2
+CFLAGS : normal for gcc 2.1+ .... -O2 $(INCLUDES)
+LIBES : -ltermlib -lsocket -lnsl -lcrypt -lgen
+OS : SCO UnixWare 2.1 SysVR4.2 i386 x86at
+CONFIG : sysv4
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.06.00
+
+VENDOR : NEC
+MODELS : SX-4, SX-5
+COMPILER: cc
+CFLAGS : -h0,ansi,novector,float0 # for NEC SX-4
+LIBES : -Gsmall
+OS : NEC's
+CONFIG : superux8
+ENVIRON : n/a
+NOTES : none
+VERSION : 6.08.01
diff --git a/contrib/tcsh/README b/contrib/tcsh/README
new file mode 100644
index 000000000000..fb17faf67f41
--- /dev/null
+++ b/contrib/tcsh/README
@@ -0,0 +1,207 @@
+This is tcsh version 6.08. Tcsh is a version of the Berkeley
+C-Shell, with the addition of: a command line editor, command and file
+name completion, listing, etc. and a bunch of small additions to the
+shell itself.
+
+Tcsh has been ported to most unix variants, and can be tinkered to work
+in unix systems that it has not ported yet. See the Ported file for
+a more complete list of ported systems and in the config directory for
+a configuration file that matches your system.
+Tcsh also runs under VMS/POSIX and OS/2+emx; the OS/2 port is not
+complete yet.
+
+Feel free to use it. These changes to csh may only be included in a
+commercial product if the inclusion or exclusion does not change the
+purchase price, level of support, etc. Please respect the individual
+authors by giving credit where credit is due (in other words, don't
+claim that you wrote portions that you haven't, and don't delete the
+names of the authors from the source code or documentation).
+
+To install tcsh:
+
+0) Try running "configure". If that works, goto step 6.
+ If you are using imake, try xmkmf and goto step 3.
+ If imake does not work, copy Makefile.std to Makefile.
+
+1) Look at the Makefile and make sure that you are using the right
+ compilation flags.
+
+2) Copy the appropriate for your machine and OS config file from the
+ config subdirectory into config.h. Consult the file "Ported" for
+ settings known to work on various machines. If you are trying to
+ compile tcsh on a machine for which there is no config file yet,
+ you will need to create a config file using as a template one of
+ the supplied ones. If you get tcsh working on a new machine, I'd
+ appreciate a copy of the config file plus additional information
+ about the architecture/OS. If you are creating a new config file,
+ look very hard at BSDJOBS, BSDSIGS, and BSDTIMES if you are running
+ a non-BSD machine. For vanila SysV, these would all be #undef-ed,
+ but others may vary (such as A/UX or HPUX). On a pyramid, compile
+ in the UCB universe even if you are running under the ATT universe
+ usually; it will work anyway, and you get job control for free.
+
+3) Look at config_f.h, and enable or disable any features you want.
+ It is configured the way I like it, but you may disagree.
+ If you do not have NLS, then locale.h will not be found. Undefine it
+ and things should work ok. On the other hand, if you have NLS you
+ might as well use it...
+
+4) Look at host.defs to make sure that you have the right defines to set
+ the environment variables "HOSTTYPE", "MACHTYPE", "OSTYPE" and
+ "VENDOR" correctly. If you need to make changes, PLEASE SEND THEM
+ BACK TO ME.
+
+5) You may want to adjust the TCSH_BINDIR and TCSH_MANDIR entries in
+ the Makefile. These are the directories that tcsh, and the tcsh.1
+ man entry will be placed in when you do a "make install" and "make
+ install.man" respectively. If you decide to install tcsh somewhere
+ other than in /usr/local/bin/tcsh, you should #define _PATH_TCSHELL
+ "/your/installation/directory/tcsh" in pathnames.h.
+
+6) make
+
+7) Read the documentation while you are waiting. The file tcsh.man
+ is in standard [nt]roff -man format. If you like, you can run the
+ tcsh.man2html script (requires Perl) to generate an HTML version of
+ the manpage which you can read with Mosaic, lynx or other HTML browser.
+
+8) Test tcsh by typing ./tcsh to see that it has compiled correctly.
+ The history command should give a time stamp on every entry.
+ Typing normal characters should echo each exactly once. Control-A
+ should put the cursor at the beginning of the input line, but after
+ the prompt. Typing characters after that should insert them into
+ the line. If you have job control make sure that stopping and
+ restarting jobs works. Make sure you can ^C in the middle of the
+ input line. Also make sure that pipelines work correctly and there
+ are no races. Try 'echo | cat | cat | cat | cat | more' a couple of
+ times. If you have job control, try this command in the background
+ and bring it in the foreground when it stops for tty output. Also
+ make sure that the ioctl() modes are preserved. Get into vi, enter
+ and exit input mode and suspend it, background it and foreground it
+ again. After all that, lastly make sure that the tty process group
+ manipulation is happening correctly. Try ftp to some host. If your
+ passwd appears on the screen, you have lost /dev/tty. Otherwise
+ everything is fine.
+
+9) Once satisfied that tcsh is working correctly, complete the installation
+ by typing "make install" to install the binary, and "make install.man" to
+ install the documentation. Don't forget to look at complete.tcsh for
+ useful completions...
+
+10) Enjoy.
+
+11) PLEASE send any bug reports (and fixes), code for new features,
+ comments, questions, etc. (even flames) to:
+
+ The tcsh mailing list
+ tcsh@mx.gw.com
+
+Various:
+
+***************************************************************************
+
+On sysv versions < 3.0 (not hpux) Doug Gwyn's public domain directory
+manipulation library has to be installed. This library is available
+for anonymous ftp from prep.ai.mit.edu:/pub/gnu/dirent.tar.Z
+If the network is not installed, then there is a gethostname()
+routine is tc.os.c, enabled by defining NEEDgethostname
+
+***************************************************************************
+
+On BSDreno, in ttyname() closedir() is called twice and so the same
+pointer gets free'd twice. tcsh's malloc is picky and it prints an
+error message to that effect. If you don't like the message:
+
+1. Apply the following patch:
+
+*** /usr/src/lib/libc/gen/ttyname.c.orig Fri Jun 1 17:17:15 1990
+--- /usr/src/lib/libc/gen/ttyname.c Tue Oct 29 16:33:12 1991
+***************
+*** 51,57 ****
+ if (stat(buf, &sb2) < 0 || sb1.st_dev != sb2.st_dev ||
+ sb1.st_ino != sb2.st_ino)
+ continue;
+- closedir(dp);
+ rval = buf;
+ break;
+ }
+--- 51,56 ----
+
+Or: Comment the error printing out in tc.alloc.c
+Or: Compile -DSYSMALLOC
+
+
+***************************************************************************
+
+From: Scott Krotz <krotz@honey.rtsg.mot.com>
+
+Tcsh has been ported to minix by Scott Krotz (krotz@honey.rtsg.mot.com).
+Unfortunately the minix sed is broken, so you'll have to find a way to
+make tc.const.h, sh.err.h, ed.defns.h which are automatically generated.
+The easiest way to create them is to make a copy from unix, copying
+minix to config.h, and then 'make sh.err.h tc.const.h ed.defns.h'
+
+The OS/dependent files are in mi.termios.h, mi.wait.h, mi.varargs.h
+
+You will get some warnings, but dont worry about them, just ignore
+them. After tcsh has compiled and the gcc binary is converted to a
+minix binary, remember to chmem it to give it more memory - it will
+need it! How much you need depends on how many aliases you have, etc..
+Add at least 50000 to it.
+
+One last thing. You might have to make some links for include files so
+that they are in the directories that tcsh is expecting while compiling.
+I forget if I had to do this or not, but it should be fairly easy to sort
+out. If it cant find any include files this is probably the reason.
+
+If you have any problems, please tell me. I can be contacted through
+e-mail at:
+
+krotz@honey.rtsg.mot.com
+
+I also read comp.os.minix on a regular basis, so a note there will get
+my attention also.
+
+Have fun!
+
+ps. The termios functions are provided by Magnus Doell and Bruce Evans.
+ Thanks, guys!
+
+
+From: Bob Byrnes <byrnes@ee.cornell.edu>
+
+This is for minix 1.5 (straight out of the box from P-H) plus the i386
+patches from Bruce Evans.
+
+I cross-compiled on a Sun using gcc 2.1 with a target of i386-bsd
+(using the minix include files instead of the bsd versions), and then
+linked the resulting object files with similarly compiled crtso.o and
+libc.a on vax (little endian) using a hacked version of ld which I put
+together to generate minix executables instead of bsd a.out format.
+What a kludge ...
+
+I compiled with -O2 -Wall ... So far I haven't noticed any problems
+with the optimizer.
+
+In case anyone is contemplating compiling tcsh with bcc (Bruce Evan's
+i386 compiler that comes with the minix386 upgrade package), don't bother.
+It is some serious bugs that kill tcsh when compiled for 16-bit characters.
+I can provide more details of bugs that I noticed for brave souls who want
+to try, but it would be hard (and why bother if you can get gcc?).
+
+I can make the binary available to anyone who wants it (for example people
+who can't get access to a cross-compiling environment, and who don't yet
+have gcc running under minix).
+
+
+***************************************************************************
+
+If your compiler cannot handle long symbol names, add
+
+#include "snames.h"
+
+to your config.h file
+
+ -- Christos Zoulas
+ christos@zoulas.com
+
diff --git a/contrib/tcsh/README.imake b/contrib/tcsh/README.imake
new file mode 100644
index 000000000000..dfe2e2fdc095
--- /dev/null
+++ b/contrib/tcsh/README.imake
@@ -0,0 +1,9 @@
+
+If you have imake running on your machine, you may skip steps 1 and 2
+described in the README file and try instead the process described here.
+Note that imake is not supported for all the platforms yet, so this
+might not work on your machine. If that is the case please let us know.
+If you can send a patch that fixes the problem we would appreciate it.
+
+1. edit imake.config and modify the configurable parameters to your liking.
+2. 'xmkmf; make depend; make'
diff --git a/contrib/tcsh/WishList b/contrib/tcsh/WishList
new file mode 100644
index 000000000000..a849b188449d
--- /dev/null
+++ b/contrib/tcsh/WishList
@@ -0,0 +1,40 @@
+* Fix memory leak related to aliasrun(). Precmd, Cwdcmd etc. leak memory.
+
+* Fix migrate -site $$... Seems to hang... (aix370)
+
+* Fix history in loops.
+
+* New idea.
+ Lots of people seem to like the idea to be able to do sed type
+ operations on shell variables. Maybe we can extend the syntax
+ of the variable editing to understand string operations.
+ So I would like to be able to use:
+ > set a="this is a STRING"
+ > echo $a:[3-]
+ is is a STRING
+ > echo $a:[#]
+ 16
+ > echo $a:[6-7]
+ is
+ > echo $a:[-2]
+ ng
+ > echo $a:[-20]
+ Subscript out of bounds.
+ > echo $a:[2-20]
+ Subscript out of bounds.
+ > echo $a:[1-1]:u$a:[2-].
+ This is a string.
+
+* Fix pipelines that contain builtins so that they behave correctly.
+ I tried to fix that (most of the code is in sh.sem.c, but it works
+ only for non POSIX machines cause otherwise the setpgid() I added
+ fails).
+
+* Fix the correct code... How to do that involves A.I....
+
+* Rewrite the whole thing. It has taken to much beating over the years...
+
+* Add another hook like precmd to be executed after the prompt but before the
+ command.
+
+* Add instructions for using configure in the README file.
diff --git a/contrib/tcsh/Y2K b/contrib/tcsh/Y2K
new file mode 100644
index 000000000000..daf6cd099393
--- /dev/null
+++ b/contrib/tcsh/Y2K
@@ -0,0 +1,10 @@
+The tcsh code has been tested on a solaris-2.6 machine and a
+NetBSD-1.3H machine running before, and after the year 2000. The
+code has been also visually inspected for Y2K compliance problems.
+Tcsh does not use time functions for anything but display purposes,
+so its operation should not be affected assuming that the time
+related functions of the c library work properly.
+
+Note: Since the last audit, tcsh-6.08.00 has been found to have
+a minor problem with %y in the prompt (it will print 10 instead
+of 00 in y2k). This has been fixed in tcsh-6.09.00.
diff --git a/contrib/tcsh/complete.tcsh b/contrib/tcsh/complete.tcsh
new file mode 100644
index 000000000000..f8e0ab9805b2
--- /dev/null
+++ b/contrib/tcsh/complete.tcsh
@@ -0,0 +1,708 @@
+#
+# $Id: complete.tcsh,v 1.32 1999/06/09 19:09:12 christos Exp $
+# example file using the new completion code
+#
+
+onintr -
+if (! $?prompt) goto end
+
+if ($?tcsh) then
+ if ($tcsh != 1) then
+ set rev=$tcsh:r
+ set rel=$rev:e
+ set pat=$tcsh:e
+ set rev=$rev:r
+ endif
+ if ($rev > 5 && $rel > 1) then
+ set complete=1
+ endif
+ unset rev rel pat
+endif
+
+if ($?complete) then
+ set noglob
+ set hosts
+ foreach f ($HOME/.hosts /usr/local/etc/csh.hosts $HOME/.rhosts /etc/hosts.equiv)
+ if ( -r $f ) then
+ set hosts = ($hosts `grep -v "+" $f | tr -s " " " " | cut -f 1`)
+ endif
+ end
+ if ( -r $HOME/.netrc ) then
+ set f=`awk '/machine/ { print $2 }' < $HOME/.netrc` >& /dev/null
+ set hosts=($hosts $f)
+ endif
+ unset f
+ if ( ! $?hosts ) then
+ set hosts=(hyperion.ee.cornell.edu phaeton.ee.cornell.edu \
+ guillemin.ee.cornell.edu vangogh.cs.berkeley.edu \
+ ftp.uu.net prep.ai.mit.edu export.lcs.mit.edu \
+ labrea.stanford.edu sumex-aim.stanford.edu \
+ tut.cis.ohio-state.edu)
+ endif
+
+ complete ywho n/*/\$hosts/ # argument from list in $hosts
+ complete rsh p/1/\$hosts/ c/-/"(l n)"/ n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/
+ complete ssh p/1/\$hosts/ c/-/"(l n)"/ n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/
+ complete xrsh p/1/\$hosts/ c/-/"(l 8 e)"/ n/-l/u/ N/-l/c/ n/-/c/ p/2/c/ p/*/f/
+ complete rlogin p/1/\$hosts/ c/-/"(l 8 e)"/ n/-l/u/
+ complete telnet p/1/\$hosts/ p/2/x:'<port>'/ n/*/n/
+
+ complete cd p/1/d/ # Directories only
+ complete chdir p/1/d/
+ complete pushd p/1/d/
+ complete popd p/1/d/
+ complete pu p/1/d/
+ complete po p/1/d/
+ complete complete p/1/X/ # Completions only
+ complete uncomplete n/*/X/
+ complete exec p/1/c/ # Commands only
+ complete trace p/1/c/
+ complete strace p/1/c/
+ complete which n/*/c/
+ complete where n/*/c/
+ complete skill p/1/c/
+ complete dde p/1/c/
+ complete adb c/-I/d/ n/-/c/ N/-/"(core)"/ p/1/c/ p/2/"(core)"/
+ complete sdb p/1/c/
+ complete dbx c/-I/d/ n/-/c/ N/-/"(core)"/ p/1/c/ p/2/"(core)"/
+ complete xdb p/1/c/
+ complete gdb n/-d/d/ n/*/c/
+ complete ups p/1/c/
+ complete set 'c/*=/f/' 'p/1/s/=' 'n/=/f/'
+ complete unset n/*/s/
+ complete alias p/1/a/ # only aliases are valid
+ complete unalias n/*/a/
+ complete xdvi n/*/f:*.dvi/ # Only files that match *.dvi
+ complete dvips n/*/f:*.dvi/
+ complete tex n/*/f:*.tex/ # Only files that match *.tex
+ complete latex n/*/f:*.{tex,ltx}/
+ complete su c/--/"(login fast preserve-environment command shell \
+ help version)"/ c/-/"(f l m p c s -)"/ \
+ n/{-c,--command}/c/ \
+ n@{-s,--shell}@'`cat /etc/shells`'@ n/*/u/
+ complete cc c/-[IL]/d/ \
+ c@-l@'`\ls -1 /usr/lib/lib*.a | sed s%^.\*/lib%%\;s%\\.a\$%%`'@ \
+ c/-/"(o l c g L I D U)"/ n/*/f:*.[coasi]/
+ complete acc c/-[IL]/d/ \
+ c@-l@'`\ls -1 /usr/lang/SC1.0/lib*.a | sed s%^.\*/lib%%\;s%\\.a\$%%`'@ \
+ c/-/"(o l c g L I D U)"/ n/*/f:*.[coasi]/
+ complete gcc c/-[IL]/d/ \
+ c/-f/"(caller-saves cse-follow-jumps delayed-branch \
+ elide-constructors expensive-optimizations \
+ float-store force-addr force-mem inline \
+ inline-functions keep-inline-functions \
+ memoize-lookups no-default-inline \
+ no-defer-pop no-function-cse omit-frame-pointer \
+ rerun-cse-after-loop schedule-insns \
+ schedule-insns2 strength-reduce \
+ thread-jumps unroll-all-loops \
+ unroll-loops syntax-only all-virtual \
+ cond-mismatch dollars-in-identifiers \
+ enum-int-equiv no-asm no-builtin \
+ no-strict-prototype signed-bitfields \
+ signed-char this-is-variable unsigned-bitfields \
+ unsigned-char writable-strings call-saved-reg \
+ call-used-reg fixed-reg no-common \
+ no-gnu-binutils nonnull-objects \
+ pcc-struct-return pic PIC shared-data \
+ short-enums short-double volatile)"/ \
+ c/-W/"(all aggregate-return cast-align cast-qual \
+ comment conversion enum-clash error format \
+ id-clash-len implicit missing-prototypes \
+ no-parentheses pointer-arith return-type shadow \
+ strict-prototypes switch uninitialized unused \
+ write-strings)"/ \
+ c/-m/"(68000 68020 68881 bitfield fpa nobitfield rtd \
+ short c68000 c68020 soft-float g gnu unix fpu \
+ no-epilogue)"/ \
+ c/-d/"(D M N)"/ \
+ c/-/"(f W vspec v vpath ansi traditional \
+ traditional-cpp trigraphs pedantic x o l c g L \
+ I D U O O2 C E H B b V M MD MM i dynamic \
+ nodtdlib static nostdinc undef)"/ \
+ c/-l/f:*.a/ \
+ n/*/f:*.{c,C,cc,o,a,s,i}/
+ complete g++ n/*/f:*.{C,cc,o,s,i}/
+ complete CC n/*/f:*.{C,cc,o,s,i}/
+ complete rm c/--/"(directory force interactive verbose \
+ recursive help version)"/ c/-/"(d f i v r R -)"/ \
+ n/*/f:^*.{c,cc,C,h,in}/ # Protect precious files
+ complete vi n/*/f:^*.[oa]/
+ complete bindkey N/-a/b/ N/-c/c/ n/-[ascr]/'x:<key-sequence>'/ \
+ n/-[svedlr]/n/ c/-[vedl]/n/ c/-/"(a s k c v e d l r)"/\
+ n/-k/"(left right up down)"/ p/2-/b/ \
+ p/1/'x:<key-sequence or option>'/
+
+ complete find n/-fstype/"(nfs 4.2)"/ n/-name/f/ \
+ n/-type/"(c b d f p l s)"/ n/-user/u/ n/-group/g/ \
+ n/-exec/c/ n/-ok/c/ n/-cpio/f/ n/-ncpio/f/ n/-newer/f/ \
+ c/-/"(fstype name perm prune type user nouser \
+ group nogroup size inum atime mtime ctime exec \
+ ok print ls cpio ncpio newer xdev depth \
+ daystart follow maxdepth mindepth noleaf version \
+ anewer cnewer amin cmin mmin true false uid gid \
+ ilname iname ipath iregex links lname empty path \
+ regex used xtype fprint fprint0 fprintf \
+ print0 printf not a and o or)"/ \
+ n/*/d/
+
+ complete -%* c/%/j/ # fill in the jobs builtin
+ complete {fg,bg,stop} c/%/j/ p/1/"(%)"//
+
+ complete limit c/-/"(h)"/ n/*/l/
+ complete unlimit c/-/"(h)"/ n/*/l/
+
+ complete -co* p/0/"(compress)"/ # make compress completion
+ # not ambiguous
+ complete zcat n/*/f:*.Z/
+ complete nm n/*/f:^*.{h,C,c,cc}/
+
+ complete finger c/*@/\$hosts/ n/*/u/@
+ complete ping p/1/\$hosts/
+ complete traceroute p/1/\$hosts/
+
+ complete {talk,ntalk,phone} p/1/'`users | tr " " "\012" | uniq`'/ \
+ n/*/\`who\ \|\ grep\ \$:1\ \|\ awk\ \'\{\ print\ \$2\ \}\'\`/
+
+ complete ftp c/-/"(d i g n v)"/ n/-/\$hosts/ p/1/\$hosts/ n/*/n/
+
+ # this one is simple...
+ #complete rcp c/*:/f/ C@[./\$~]*@f@ n/*/\$hosts/:
+ # From Michael Schroeder <mlschroe@immd4.informatik.uni-erlangen.de>
+ # This one will rsh to the file to fetch the list of files!
+ complete rcp 'c%*@*:%`set q=$:-0;set q="$q:s/@/ /";set q="$q:s/:/ /";set q=($q " ");rsh $q[2] -l $q[1] ls -dp $q[3]\*`%' 'c%*:%`set q=$:-0;set q="$q:s/:/ /";set q=($q " ");rsh $q[1] ls -dp $q[2]\*`%' 'c%*@%$hosts%:' 'C@[./$~]*@f@' 'n/*/$hosts/:'
+
+ complete dd c/--/"(help version)"/ c/[io]f=/f/ \
+ c/conv=*,/"(ascii ebcdic ibm block unblock \
+ lcase notrunc ucase swab noerror sync)"/,\
+ c/conv=/"(ascii ebcdic ibm block unblock \
+ lcase notrunc ucase swab noerror sync)"/,\
+ c/*=/x:'<number>'/ \
+ n/*/"(if of conv ibs obs bs cbs files skip file seek count)"/=
+
+ complete nslookup p/1/x:'<host>'/ p/2/\$hosts/
+
+ complete ar c/[dmpqrtx]/"(c l o u v a b i)"/ p/1/"(d m p q r t x)"// \
+ p/2/f:*.a/ p/*/f:*.o/
+
+ # these should be merged with the MH completion hacks below - jgotts
+ complete {sprev,snext} \
+ c@+@F:$HOME/Mail/@
+
+ # these and interrupt handling from Jaap Vermeulen <jaap@sequent.com>
+ complete {rexec,rxexec,rxterm,rmterm} \
+ 'p/1/$hosts/' 'c/-/(l L E)/' 'n/-l/u/' 'n/-L/f/' \
+ 'n/-E/e/' 'n/*/c/'
+ complete kill 'c/-/S/' 'c/%/j/' \
+ 'n/*/`ps -u $LOGNAME | awk '"'"'{print $1}'"'"'`/'
+
+ # these from Marc Horowitz <marc@cam.ov.com>
+ complete attach 'n/-mountpoint/d/' 'n/-m/d/' 'n/-type/(afs nfs rvd ufs)/' \
+ 'n/-t/(afs nfs rvd ufs)/' 'n/-user/u/' 'n/-U/u/' \
+ 'c/-/(verbose quiet force printpath lookup debug map \
+ nomap remap zephyr nozephyr readonly write \
+ mountpoint noexplicit explicit type mountoptions \
+ nosetuid setuid override skipfsck lock user host)/' \
+ 'n/-e/f/' 'n/*/()/'
+ complete hesinfo 'p/1/u/' \
+ 'p/2/(passwd group uid grplist pcap pobox cluster \
+ filsys sloc service)/'
+
+ # these from E. Jay Berkenbilt <ejb@ERA.COM>
+ # = isn't always followed by a filename or a path anymore - jgotts
+ complete ./configure 'c/--*=/f/' 'c/--{cache-file,prefix,exec-prefix,\
+ bindir,sbindir,libexecdir,datadir,\
+ sysconfdir,sharedstatedir,localstatedir,\
+ libdir,includedir,oldincludedir,infodir,\
+ mandir,srcdir}/(=)//' \
+ 'c/--/(cache-file verbose prefix exec-prefix bindir \
+ sbindir libexecdir datadir sysconfdir \
+ sharedstatedir localstatedir libdir \
+ includedir oldincludedir infodir mandir \
+ srcdir)//'
+ complete gs 'c/-sDEVICE=/(x11 cdjmono cdj550 epson eps9high epsonc \
+ dfaxhigh dfaxlow laserjet ljet4 sparc pbm \
+ pbmraw pgm pgmraw ppm ppmraw bit)/' \
+ 'c/-sOutputFile=/f/' 'c/-s/(DEVICE OutputFile)/=' \
+ 'c/-d/(NODISPLAY NOPLATFONTS NOPAUSE)/' 'n/*/f/'
+ complete perl 'n/-S/c/'
+ complete printenv 'n/*/e/'
+ complete sccs p/1/"(admin cdc check clean comb deledit delget \
+ delta diffs edit enter fix get help info \
+ print prs prt rmdel sccsdiff tell unedit \
+ unget val what)"/
+ complete setenv 'p/1/e/' 'c/*:/f/'
+
+ # these and method of setting hosts from Kimmo Suominen <kim@tac.nyc.ny.us>
+ if ( -f $HOME/.mh_profile && -x "`which folders`" ) then
+
+ if ( ! $?FOLDERS ) setenv FOLDERS "`folders -fast -recurse`"
+ if ( ! $?MHA ) setenv MHA "`ali | sed -e '/^ /d' -e 's/:.*//'`"
+
+ set folders = ( $FOLDERS )
+ set mha = ( $MHA )
+
+ complete ali \
+ 'c/-/(alias nolist list nonormalize normalize nouser user help)/' \
+ 'n,-alias,f,'
+
+ complete anno \
+ 'c/-/(component noinplace inplace nodate date text help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete burst \
+ 'c/-/(noinplace inplace noquiet quiet noverbose verbose help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete comp \
+ 'c/-/(draftfolder draftmessage nodraftfolder editor noedit file form nouse use whatnowproc nowhatnowproc help)/' \
+ 'c,+,$folders,' \
+ 'n,-whatnowproc,c,' \
+ 'n,-file,f,'\
+ 'n,-form,f,'\
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete dist \
+ 'c/-/(noannotate annotate draftfolder draftmessage nodraftfolder editor noedit form noinplace inplace whatnowproc nowhatnowproc help)/' \
+ 'c,+,$folders,' \
+ 'n,-whatnowproc,c,' \
+ 'n,-form,f,'\
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete folder \
+ 'c/-/(all nofast fast noheader header nopack pack noverbose verbose norecurse recurse nototal total noprint print nolist list push pop help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete folders \
+ 'c/-/(all nofast fast noheader header nopack pack noverbose verbose norecurse recurse nototal total noprint print nolist list push pop help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete forw \
+ 'c/-/(noannotate annotate draftfolder draftmessage nodraftfolder editor noedit filter form noformat format noinplace inplace digest issue volume whatnowproc nowhatnowproc help)/' \
+ 'c,+,$folders,' \
+ 'n,-whatnowproc,c,' \
+ 'n,-filter,f,'\
+ 'n,-form,f,'\
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete inc \
+ 'c/-/(audit file noaudit nochangecur changecur file form format nosilent silent notruncate truncate width help)/' \
+ 'c,+,$folders,' \
+ 'n,-audit,f,'\
+ 'n,-form,f,'
+
+ complete mark \
+ 'c/-/(add delete list sequence nopublic public nozero zero help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete mhmail \
+ 'c/-/(body cc from subject help)/' \
+ 'n,-cc,$mha,' \
+ 'n,-from,$mha,' \
+ 'n/*/$mha/'
+
+ complete mhpath \
+ 'c/-/(help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete msgchk \
+ 'c/-/(nodate date nonotify notify help)/'
+
+ complete msh \
+ 'c/-/(prompt noscan scan notopcur topcur help)/'
+
+ complete next \
+ 'c/-/(draft form moreproc nomoreproc length width showproc noshowproc header noheader help)/' \
+ 'c,+,$folders,' \
+ 'n,-moreproc,c,' \
+ 'n,-showproc,c,' \
+ 'n,-form,f,'
+
+ complete packf \
+ 'c/-/(file help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete pick \
+ 'c/-/(and or not lbrace rbrace cc date from search subject to othercomponent after before datefield sequence nopublic public nozero zero nolist list help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete prev \
+ 'c/-/(draft form moreproc nomoreproc length width showproc noshowproc header noheader help)/' \
+ 'c,+,$folders,' \
+ 'n,-moreproc,c,' \
+ 'n,-showproc,c,' \
+ 'n,-form,f,'
+
+ complete prompter \
+ 'c/-/(erase kill noprepend prepend norapid rapid nodoteof doteof help)/'
+
+ complete refile \
+ 'c/-/(draft nolink link nopreserve preserve src file help)/' \
+ 'c,+,$folders,' \
+ 'n,-file,f,'\
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete rmf \
+ 'c/-/(nointeractive interactive help)/' \
+ 'c,+,$folders,'
+
+ complete rmm \
+ 'c/-/(help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete scan \
+ 'c/-/(noclear clear form format noheader header width noreverse reverse file help)/' \
+ 'c,+,$folders,' \
+ 'n,-form,f,'\
+ 'n,-file,f,'\
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete send \
+ 'c/-/(alias draft draftfolder draftmessage nodraftfolder filter nofilter noformat format noforward forward nomsgid msgid nopush push noverbose verbose nowatch watch width help)/' \
+ 'n,-alias,f,'\
+ 'n,-filter,f,'
+
+ complete show \
+ 'c/-/(draft form moreproc nomoreproc length width showproc noshowproc header noheader help)/' \
+ 'c,+,$folders,' \
+ 'n,-moreproc,c,' \
+ 'n,-showproc,c,' \
+ 'n,-form,f,'\
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete sortm \
+ 'c/-/(datefield textfield notextfield limit nolimit noverbose verbose help)/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete vmh \
+ 'c/-/(prompt vmhproc novmhproc help)/' \
+ 'n,-vmhproc,c,'
+
+ complete whatnow \
+ 'c/-/(draftfolder draftmessage nodraftfolder editor noedit prompt help)/'
+
+ complete whom \
+ 'c/-/(alias nocheck check draft draftfolder draftmessage nodraftfolder help)/' \
+ 'n,-alias,f,'
+
+ complete plum \
+ 'c/-/()/' \
+ 'c,+,$folders,' \
+ 'n,*,`(mark | sed "s/:.*//";echo next cur prev first last)|tr " " "\12" | sort -u`,'
+
+ complete mail \
+ 'c/-/()/' \
+ 'n/*/$mha/'
+
+ endif
+
+ #from Dan Nicolaescu <dann@ics.uci.edu>
+ if ( $?MODULESHOME ) then
+
+ alias Compl_module ' set q = "$MODULEPATH:as/:/ /" ; find $q -name .version -o -name .modulea\* -prune -o -print | sed `echo "-e s@"$MODULEPATH:as%:%/\*@@g -e s@%"/\*@@g"`'
+
+ complete module 'p%1%(add load unload switch display avail use unuse update purge list clear help initadd initrm initswitch initlist initclear)%' \
+ 'n%unload%`echo "$LOADEDMODULES:as/:/ /"`%' \
+ 'n%{lo*,sw*,di*,he*,inita*,initr*,inits*}%`eval Compl_module`%' \
+ 'N%{sw*,initsw*}%`eval Compl_module`%' 'C%-%(-append)%' 'n%{use,unu*,av*}%d%' 'n%-append%d%' \
+ 'C%[^-]*%`eval Compl_module`%'
+ endif
+
+ # these from Tom Warzeka <waz@quahog.npt.nuwc.navy.mil>
+ # you may need to set the following variables for your host
+ set _elispdir = /usr/local/share/emacs/20.2/lisp # GNU Emacs lisp directory
+ set _maildir = /var/spool/mail # Post Office: /var/spool/mail or /usr/mail
+ set _ypdir = /var/yp # directory where NIS (YP) maps are kept
+ set _domain = "`domainname`"
+
+ # this one works but is slow and doesn't descend into subdirectories
+ # complete cd C@[./\$~]*@d@ \
+ # p@1@'`\ls -1F . $cdpath | grep /\$ | sort -u`'@ n@*@n@
+
+ if ( -r /etc/shells ) then
+ complete setenv p@1@e@ n@DISPLAY@\$hosts@: n@SHELL@'`cat /etc/shells`'@
+ else
+ complete setenv p@1@e@ n@DISPLAY@\$hosts@:
+ endif
+ complete unsetenv n/*/e/
+
+ if (-r $HOME/.mailrc) then
+ complete mail c/-/"(e i f n s u v)"/ c/*@/\$hosts/ \
+ c@+@F:$HOME/Mail@ C@[./\$~]@f@ n/-s/x:'<subject>'/ \
+ n@-u@T:$_maildir@ n/-f/f/ \
+ n@*@'`sed -n s/alias//p $HOME/.mailrc | tr -s " " " " | cut -f 2`'@
+ else
+ complete mail c/-/"(e i f n s u v)"/ c/*@/\$hosts/ \
+ c@+@F:$HOME/Mail@ C@[./\$~]@f@ n/-s/x:'<subject>'/ \
+ n@-u@T:$_maildir@ n/-f/f/ n/*/u/
+ endif
+
+ complete man n@1@'`\ls -1 /usr/man/man1 | sed s%\\.1.\*\$%%`'@ \
+ n@2@'`\ls -1 /usr/man/man2 | sed s%\\.2.\*\$%%`'@ \
+ n@3@'`\ls -1 /usr/man/man3 | sed s%\\.3.\*\$%%`'@ \
+ n@4@'`\ls -1 /usr/man/man4 | sed s%\\.4.\*\$%%`'@ \
+ n@5@'`\ls -1 /usr/man/man5 | sed s%\\.5.\*\$%%`'@ \
+ n@6@'`\ls -1 /usr/man/man6 | sed s%\\.6.\*\$%%`'@ \
+ n@7@'`\ls -1 /usr/man/man7 | sed s%\\.7.\*\$%%`'@ \
+ n@8@'`\ls -1 /usr/man/man8 | sed s%\\.8.\*\$%%`'@ \
+ n@9@'`[ -r /usr/man/man9 ] && \ls -1 /usr/man/man9 | sed s%\\.9.\*\$%%`'@ \
+ n@0@'`[ -r /usr/man/man0 ] && \ls -1 /usr/man/man0 | sed s%\\.0.\*\$%%`'@ \
+ n@new@'`[ -r /usr/man/mann ] && \ls -1 /usr/man/mann | sed s%\\.n.\*\$%%`'@ \
+ n@old@'`[ -r /usr/man/mano ] && \ls -1 /usr/man/mano | sed s%\\.o.\*\$%%`'@ \
+n@local@'`[ -r /usr/man/manl ] && \ls -1 /usr/man/manl | sed s%\\.l.\*\$%%`'@ \
+n@public@'`[ -r /usr/man/manp ]&& \ls -1 /usr/man/manp | sed s%\\.p.\*\$%%`'@ \
+ c/-/"(- f k M P s t)"/ n/-f/c/ n/-k/x:'<keyword>'/ n/-[MP]/d/ \
+ N@-[MP]@'`\ls -1 $:-1/man? | sed s%\\..\*\$%%`'@ n/*/c/
+
+ complete ps c/-t/x:'<tty>'/ c/-/"(a c C e g k l S t u v w x)"/ \
+ n/-k/x:'<kernel>'/ N/-k/x:'<core_file>'/ n/*/x:'<PID>'/
+ complete compress c/-/"(c f v b)"/ n/-b/x:'<max_bits>'/ n/*/f:^*.Z/
+ complete uncompress c/-/"(c f v)"/ n/*/f:*.Z/
+
+ complete xhost c/[+-]/\$hosts/ n/*/\$hosts/
+
+ # these conform to the latest GNU versions available at press time ...
+ # updates by John Gotts <jgotts@engin.umich.edu>
+
+ complete emacs c/-/"(batch d f funcall i insert kill l load \
+ no-init-file nw q t u user)"/ c/+/x:'<line_number>'/ \
+ n/-d/x:'<display>'/ n/-f/x:'<lisp_function>'/ n/-i/f/ \
+ n@-l@F:$_elispdir@ n/-t/x:'<terminal>'/ \
+ n/-u/u/ n/*/f:^*[\#~]/
+
+ complete gzcat c/--/"(force help license quiet version)"/ \
+ c/-/"(f h L q V -)"/ n/*/f:*.{gz,Z,z,zip}/
+ complete gzip c/--/"(stdout to-stdout decompress uncompress \
+ force help list license no-name quiet recurse \
+ suffix test verbose version fast best)"/ \
+ c/-/"(c d f h l L n q r S t v V 1 2 3 4 5 6 7 8 9 -)"/\
+ n/{-S,--suffix}/x:'<file_name_suffix>'/ \
+ n/{-d,--{de,un}compress}/f:*.{gz,Z,z,zip,taz,tgz}/ \
+ N/{-d,--{de,un}compress}/f:*.{gz,Z,z,zip,taz,tgz}/ \
+ n/*/f:^*.{gz,Z,z,zip,taz,tgz}/
+ complete {gunzip,ungzip} c/--/"(stdout to-stdout force help list license \
+ no-name quiet recurse suffix test verbose version)"/ \
+ c/-/"(c f h l L n q r S t v V -)"/ \
+ n/{-S,--suffix}/x:'<file_name_suffix>'/ \
+ n/*/f:*.{gz,Z,z,zip,taz,tgz}/
+ complete zgrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
+ c/-/"(A b B c C e f h i l n s v V w x)"/ \
+ p/1/x:'<limited_regular_expression>'/ N/-*e/f/ \
+ n/-*e/x:'<limited_regular_expression>'/ n/-*f/f/ n/*/f/
+ complete zegrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
+ c/-/"(A b B c C e f h i l n s v V w x)"/ \
+ p/1/x:'<full_regular_expression>'/ N/-*e/f/ \
+ n/-*e/x:'<full_regular_expression>'/ n/-*f/f/ n/*/f/
+ complete zfgrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
+ c/-/"(A b B c C e f h i l n s v V w x)"/ \
+ p/1/x:'<fixed_string>'/ N/-*e/f/ \
+ n/-*e/x:'<fixed_string>'/ n/-*f/f/ n/*/f/
+ complete znew c/-/"(f t v 9 P K)"/ n/*/f:*.Z/
+ complete zmore n/*/f:*.{gz,Z,z,zip}/
+ complete zfile n/*/f:*.{gz,Z,z,zip,taz,tgz}/
+ complete ztouch n/*/f:*.{gz,Z,z,zip,taz,tgz}/
+ complete zforce n/*/f:^*.{gz,tgz}/
+
+ complete grep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
+ c/--/"(extended-regexp fixed-regexp basic-regexp \
+ regexp file ignore-case word-regexp line-regexp \
+ no-messages revert-match version help byte-offset \
+ line-number with-filename no-filename quiet silent \
+ text directories recursive files-without-match \
+ files-with-matches count before-context after-context \
+ context binary unix-byte-offsets)"/ \
+ c/-/"(A a B b C c d E e F f G H h i L l n q r s U u V \
+ v w x)"/ \
+ p/1/x:'<limited_regular_expression>'/ N/-*e/f/ \
+ n/-*e/x:'<limited_regular_expression>'/ n/-*f/f/ n/*/f/
+ complete egrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
+ c/--/"(extended-regexp fixed-regexp basic-regexp \
+ regexp file ignore-case word-regexp line-regexp \
+ no-messages revert-match version help byte-offset \
+ line-number with-filename no-filename quiet silent \
+ text directories recursive files-without-match \
+ files-with-matches count before-context after-context \
+ context binary unix-byte-offsets)"/ \
+ c/-/"(A a B b C c d E e F f G H h i L l n q r s U u V \
+ v w x)"/ \
+ p/1/x:'<full_regular_expression>'/ N/-*e/f/ \
+ n/-*e/x:'<full_regular_expression>'/ n/-*f/f/ n/*/f/
+ complete fgrep c/-*A/x:'<#_lines_after>'/ c/-*B/x:'<#_lines_before>'/\
+ c/--/"(extended-regexp fixed-regexp basic-regexp \
+ regexp file ignore-case word-regexp line-regexp \
+ no-messages revert-match version help byte-offset \
+ line-number with-filename no-filename quiet silent \
+ text directories recursive files-without-match \
+ files-with-matches count before-context after-context \
+ context binary unix-byte-offsets)"/ \
+ c/-/"(A a B b C c d E e F f G H h i L l n q r s U u V \
+ v w x)"/ \
+ p/1/x:'<fixed_string>'/ N/-*e/f/ \
+ n/-*e/x:'<fixed_string>'/ n/-*f/f/ n/*/f/
+
+ complete users c/--/"(help version)"/ p/1/x:'<accounting_file>'/
+ complete who c/--/"(heading idle count mesg message writable help \
+ version)"/ c/-/"(H i m q s T w u -)"/ \
+ p/1/x:'<accounting_file>'/ n/am/"(i)"/ n/are/"(you)"/
+
+ complete chown c/--/"(changes dereference no-dereference silent \
+ quiet reference recursive verbose help version)"/ \
+ c/-/"(c f h R v -)"/ C@[./\$~]@f@ c/*[.:]/g/ \
+ n/-/u/. p/1/u/. n/*/f/
+ complete chgrp c/--/"(changes no-dereference silent quiet reference \
+ recursive verbose help version)"/ \
+ c/-/"(c f h R v -)"/ n/-/g/ p/1/g/ n/*/f/
+ complete chmod c/--/"(changes silent quiet verbose reference \
+ recursive help version)"/ c/-/"(c f R v)"/
+ complete df c/--/"(all block-size human-readable si inodes \
+ kilobytes local megabytes no-sync portability sync \
+ type print-type exclude-type help version)"/ \
+ c/-/"(a H h i k l m P T t v x)"/
+ complete du c/--/"(all block-size bytes total dereference-args \
+ human-readable si kilobytes count-links dereference \
+ megabytes separate-dirs summarize one-file-system \
+ exclude-from exclude max-depth help version"/ \
+ c/-/"(a b c D H h k L l m S s X x)"/
+
+ complete cat c/--/"(number-nonblank number squeeze-blank show-all \
+ show-nonprinting show-ends show-tabs help version)"/ \
+ c/-/"(A b E e n s T t u v -)"/ n/*/f/
+ complete mv c/--/"(backup force interactive update verbose suffix \
+ version-control help version)"/ \
+ c/-/"(b f i S u V v -)"/ \
+ n/{-S,--suffix}/x:'<suffix>'/ \
+ n/{-V,--version-control}/"(t numbered nil existing \
+ never simple)"/ n/-/f/ N/-/d/ p/1/f/ p/2/d/ n/*/f/
+ complete cp c/--/"(archive backup no-dereference force \
+ interactive link preserve parents sparse recursive \
+ symbolic-link suffix update verbose version-control \
+ one-file-system help version)"/ \
+ c/-/"(a b d f i l P p R r S s u V v x -)"/ \
+ n/-*r/d/ n/{-S,--suffix}/x:'<suffix>'/ \
+ n/{-V,--version-control}/"(t numbered nil existing \
+ never simple)"/ n/-/f/ N/-/d/ p/1/f/ p/2/d/ n/*/f/
+ complete ln c/--/"(backup directory force no-dereference \
+ interactive symbolic suffix verbose version-control \
+ help version)"/ \
+ c/-/"(b d F f i n S s V v -)"/ \
+ n/{-S,--suffix}/x:'<suffix>'/ \
+ n/{-V,--version-control}/"(t numbered nil existing \
+ never simple)"/ n/-/f/ N/-/x:'<link_name>'/ \
+ p/1/f/ p/2/x:'<link_name>'/
+ complete touch c/--/"(date reference time help version)"/ \
+ c/-/"(a c d f m r t -)"/ \
+ n/{-d,--date}/x:'<date_string>'/ \
+ c/--time/"(access atime mtime modify use)"/ \
+ n/{-r,--file}/f/ n/-t/x:'<time_stamp>'/ n/*/f/
+ complete mkdir c/--/"(mode parents verbose help version)"/ \
+ c/-/"(p m -)"/ \
+ n/{-m,--mode}/x:'<mode>'/ n/*/d/
+ complete rmdir c/--/"(ignore-fail-on-non-empty parents verbose help \
+ version)"/ c/-/"(p -)"/ n/*/d/
+
+ complete tar c/-[Acru]*/"(b B C f F g G h i l L M N o P \
+ R S T v V w W X z Z)"/ \
+ c/-[dtx]*/"( B C f F g G i k K m M O p P \
+ R s S T v w x X z Z)"/ \
+ p/1/"(A c d r t u x -A -c -d -r -t -u -x \
+ --catenate --concatenate --create --diff --compare \
+ --delete --append --list --update --extract --get \
+ --help --version)"/ \
+ c/--/"(catenate concatenate create diff compare \
+ delete append list update extract get atime-preserve \
+ block-size read-full-blocks directory checkpoint file \
+ force-local info-script new-volume-script incremental \
+ listed-incremental dereference ignore-zeros \
+ ignore-failed-read keep-old-files starting-file \
+ one-file-system tape-length modification-time \
+ multi-volume after-date newer old-archive portability \
+ to-stdout same-permissions preserve-permissions \
+ absolute-paths preserve record-number remove-files \
+ same-order preserve-order same-owner sparse \
+ files-from null totals verbose label version \
+ interactive confirmation verify exclude exclude-from \
+ compress uncompress gzip ungzip use-compress-program \
+ block-compress help version)"/ \
+ c/-/"(b B C f F g G h i k K l L m M N o O p P R s S \
+ T v V w W X z Z 0 1 2 3 4 5 6 7 -)"/ \
+ n/-c*f/x:'<new_tar_file, device_file, or "-">'/ \
+ n/{-[Adrtux]*f,--file}/f:*.tar/ \
+ N/{-x*f,--file}/'`tar -tf $:-1`'/ \
+ n/--use-compress-program/c/ \
+ n/{-b,--block-size}/x:'<block_size>'/ \
+ n/{-V,--label}/x:'<volume_label>'/ \
+ n/{-N,--{after-date,newer}}/x:'<date>'/ \
+ n/{-L,--tape-length}/x:'<tape_length_in_kB>'/ \
+ n/{-C,--directory}/d/ \
+ N/{-C,--directory}/'`\ls $:-1`'/ \
+ n/-[0-7]/"(l m h)"/
+
+ # SVR4 filesystems
+ #complete mount c/-/"(a F m o O p r v V)"/ n/-p/n/ n/-v/n/ \
+ # n/-o/x:'<FSType_options>'/ \
+ # n@-F@'`\ls -1 /usr/lib/fs`'@ \
+ # n@*@'`grep -v "^#" /etc/vfstab | tr -s " " " " | cut -f 3`'@
+ #complete umount c/-/"(a o V)"/ n/-o/x:'<FSType_options>'/ \
+ # n/*/'`mount | cut -d " " -f 1`'/
+ #complete mountall c/-/"(F l r)"/ n@-F@'`\ls -1 /usr/lib/fs`'@
+ #complete umountall c/-/"(F h k l r s)"/ n@-F@'`\ls -1 /usr/lib/fs`'@ \
+ # n/-h/'`df -k | cut -s -d ":" -f 1 | sort -u`'/
+ # BSD 4.3 filesystems
+ complete mount c/-/"(a r t v)"/ n/-t/"(4.2 nfs)"/ \
+ n@*@'`grep -v "^#" /etc/fstab | tr -s " " " " | cut -f 2`'@
+ complete umount c/-/"(a h t v)"/ n/-t/"(4.2 nfs)"/ \
+ n/-h/'`df | cut -s -d ":" -f 1 | sort -u`'/ \
+ n/*/'`mount | cut -d " " -f 3`'/
+ # BSD 4.2 filesystems
+ #complete mount c/-/"(a r t v)"/ n/-t/"(ufs nfs)"/ \
+ # n@*@'`cut -d ":" -f 2 /etc/fstab`'@
+ #complete umount c/-/"(a h t v)"/ n/-t/"(ufs nfs)"/ \
+ # n/-h/'`df | cut -s -d ":" -f 1 | sort -u`'/ \
+ # n/*/'`mount | cut -d " " -f 3`'/
+
+ # these deal with NIS (formerly YP); if it's not running you don't need 'em
+ complete domainname p@1@D:$_ypdir@" " n@*@n@
+ complete ypcat c@-@"(d k t x)"@ n@-x@n@ n@-d@D:$_ypdir@" " \
+ N@-d@\`\\ls\ -1\ $_ypdir/\$:-1\ \|\ sed\ -n\ s%\\\\.pag\\\$%%p\`@ \
+ n@*@\`\\ls\ -1\ $_ypdir/$_domain\ \|\ sed\ -n\ s%\\\\.pag\\\$%%p\`@
+ complete ypmatch c@-@"(d k t x)"@ n@-x@n@ n@-d@D:$_ypdir@" " \
+ N@-d@x:'<key ...>'@ n@-@x:'<key ...>'@ p@1@x:'<key ...>'@ \
+ n@*@\`\\ls\ -1\ $_ypdir/$_domain\ \|\ sed\ -n\ s%\\\\.pag\\\$%%p\`@
+ complete ypwhich c@-@"(d m t x V1 V2)"@ n@-x@n@ n@-d@D:$_ypdir@" " \
+ n@-m@\`\\ls\ -1\ $_ypdir/$_domain\ \|\ sed\ -n\ s%\\\\.pag\\\$%%p\`@ \
+ N@-m@n@ n@*@\$hosts@
+
+ # there's no need to clutter the user's shell with these
+ unset _elispdir _maildir _ypdir _domain
+
+ complete make \
+ 'n/-f/f/' \
+ 'c/*=/f/' \
+ 'n@*@`cat -s GNUmakefile Makefile makefile |& sed -n -e "/No such file/d" -e "/^[^ #].*:/s/:.*//p"`@'
+
+ if ( -f /etc/printcap ) then
+ set printers=(`sed -n -e "/^[^ #].*:/s/:.*//p" /etc/printcap`)
+
+ complete lpr 'c/-P/$printers/'
+ complete lpq 'c/-P/$printers/'
+ complete lprm 'c/-P/$printers/'
+ complete lpquota 'p/1/(-Qprlogger)/' 'c/-P/$printers/'
+ complete dvips 'c/-P/$printers/' 'n/-o/f:*.{ps,PS}/' 'n/*/f:*.dvi/'
+ endif
+
+ unset noglob
+ unset complete
+endif
+
+end:
+ onintr
diff --git a/contrib/tcsh/config.h.in b/contrib/tcsh/config.h.in
new file mode 100644
index 000000000000..61025bcef7b5
--- /dev/null
+++ b/contrib/tcsh/config.h.in
@@ -0,0 +1 @@
+/* config.h.in. Generated automatically from configure.in by autoheader. */
diff --git a/contrib/tcsh/config_f.h b/contrib/tcsh/config_f.h
new file mode 100644
index 000000000000..4a8401ce52fa
--- /dev/null
+++ b/contrib/tcsh/config_f.h
@@ -0,0 +1,193 @@
+/* $Header: /src/pub/tcsh/config_f.h,v 3.22 1999/05/11 13:07:42 christos Exp $ */
+/*
+ * config_f.h -- configure various defines for tcsh
+ *
+ * This is included by config.h.
+ *
+ * Edit this to match your particular feelings; this is set up to the
+ * way I like it.
+ */
+/*-
+ * Copyright (c) 1980, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _h_config_f
+#define _h_config_f
+
+/*
+ * SHORT_STRINGS Use 16 bit characters instead of 8 bit chars
+ * This fixes up quoting problems and eases implementation
+ * of nls...
+ *
+ */
+#define SHORT_STRINGS
+
+/*
+ * NLS: Use Native Language System
+ * Routines like setlocale() are needed
+ * if you don't have <locale.h>, you don't want
+ * to define this.
+ */
+#define NLS
+
+/*
+ * NLS_CATALOGS:Use Native Language System catalogs for
+ * international messages.
+ * Routines like catopen() are needed
+ * if you don't have <nl_types.h>, you don't want
+ * to define this.
+ */
+#undef NLS_CATALOGS
+
+/*
+ * LOGINFIRST Source ~/.login before ~/.cshrc
+ */
+#undef LOGINFIRST
+
+/*
+ * VIDEFAULT Make the VI mode editor the default
+ */
+#undef VIDEFAULT
+
+/*
+ * KAI use "bye" command and rename "log" to "watchlog"
+ */
+#undef KAI
+
+/*
+ * TESLA drops DTR on logout. Historical note:
+ * tesla.ee.cornell.edu was a vax11/780 with a develcon
+ * switch that sometimes would not hang up.
+ */
+#undef TESLA
+
+/*
+ * DOTLAST put "." last in the default path, for security reasons
+ */
+#define DOTLAST
+
+/*
+ * NODOT Don't put "." in the default path, for security reasons
+ */
+#undef NODOT
+
+/*
+ * AUTOLOGOUT tries to determine if it should set autologout depending
+ * on the name of the tty, and environment.
+ * Does not make sense in the modern window systems!
+ */
+#define AUTOLOGOUT
+
+/*
+ * SUSPENDED Newer shells say 'Suspended' instead of 'Stopped'.
+ * Define to get the same type of messages.
+ */
+#define SUSPENDED
+
+/*
+ * KANJI Ignore meta-next, and the ISO character set. Should
+ * be used with SHORT_STRINGS
+ *
+ */
+#undef KANJI
+
+/*
+ * DSPMBYTE add variable "dspmbyte" and display multi-byte string at
+ * only output, when "dspmbyte" is set. Should be used with
+ * KANJI
+ */
+#undef DSPMBYTE
+
+/*
+ * MBYTEDEBUG when "dspmbyte" is changed, set multi-byte checktable to
+ * variable "mbytemap".
+ * (use for multi-byte table check)
+ */
+#undef MBYTEDEBUG
+
+/*
+ * NEWGRP Provide a newgrp builtin.
+ */
+#undef NEWGRP
+
+/*
+ * SYSMALLOC Use the system provided version of malloc and friends.
+ * This can be much slower and no memory statistics will be
+ * provided.
+ */
+#if defined(__MACHTEN__) || defined(PURIFY) || defined(MALLOC_TRACE) || defined(_OSD_POSIX)
+# define SYSMALLOC
+#else
+# undef SYSMALLOC
+#endif
+
+/*
+ * USE_ACCESS Use access(2) rather than stat(2) when POSIX is defined.
+ * POSIX says to use stat, but stat(2) is less accurate
+ * than access(2) for determining file access.
+ */
+#undef USE_ACCESS
+
+/*
+ * REMOTEHOST Try to determine the remote host that we logged in from
+ * using first getpeername, and then the utmp file. If
+ * successful, set $REMOTEHOST to the name or address of the
+ * host
+ */
+#define REMOTEHOST
+
+/*
+ * COLOR_LS_F Do you want to use builtin color ls-F ?
+ *
+ */
+#define COLOR_LS_F
+
+/*
+ * COLORCAT Do you want to colorful message ?
+ *
+ */
+#undef COLORCAT
+
+/*
+ * RCSID This defines if we want rcs strings in the binary or not
+ *
+ */
+#if !defined(lint) && !defined(SABER) && !defined(__CLCC__)
+# ifndef __GNUC__
+# define RCSID(id) static char *rcsid = (id);
+# else
+# define RCSID(id) static char *rcsid(const char *a) { return rcsid(a = id); }
+# endif /* !__GNUC__ */
+#else
+# define RCSID(id) /* Nothing */
+#endif /* !lint && !SABER */
+
+#endif /* _h_config_f */
diff --git a/contrib/tcsh/csh-mode.el b/contrib/tcsh/csh-mode.el
new file mode 100644
index 000000000000..20fee71287fc
--- /dev/null
+++ b/contrib/tcsh/csh-mode.el
@@ -0,0 +1,935 @@
+;; csh-mode.el --- csh (and tcsh) script editing mode for Emacs.
+;;
+;; Version: 1.2
+;; Date: April 2, 1999
+;; Maintainer: Dan Harkless <dan@wave.eng.uci.edu>
+;;
+;; Description:
+;; csh and tcsh script editing mode for Emacs.
+;;
+;; Installation:
+;; Put csh-mode.el in some directory in your load-path and load it.
+;;
+;; Usage:
+;; This major mode assists shell script writers with indentation
+;; control and control structure construct matching in much the same
+;; fashion as other programming language modes. Invoke describe-mode
+;; for more information.
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;
+;; Author key:
+;; DH - Dan Harkless <dan@wave.eng.uci.edu>
+;; CM - Carlo Migliorini <migliorini@sodalia.it>
+;; JR - Jack Repenning <jackr@sgi.com>
+;; GE - Gary Ellison <Gary.F.Ellison@att.com>
+;;
+;; *** REVISION HISTORY ***
+;;
+;; DATE MOD. BY REASON FOR MODIFICATION
+;; --------- -- --------------------------------------------------------------
+;; 2 Apr 99 DH 1.2: Noticed an out-of-date comment referencing .bashrc etc.
+;; 11 Dec 96 DH 1.1: ksh-mode just indented continuation lines by 1 space.
+;; csh-mode looks at the first line and indents properly to line
+;; up under the open-paren, quote, or command.
+;; 11 Dec 96 DH Added fontification for history substitutions.
+;; 10 Dec 96 DH Added indentation and fontification for labels. Added
+;; fontification for variables and backquoted strings.
+;; 9 Dec 96 DH 1.0: Brought csh-mode up to the level of functionality of
+;; the original ksh-mode.
+;; 7 Oct 96 CM 0.1: Hacked ksh-mode.el into minimally functional csh-mode.el
+;; by doing search-and-replace and some keyword changes.
+;; 8 Aug 96 JR (Last modification to ksh-mode 2.6.)
+;; [...]
+;; 19 Jun 92 GE (Conception of ksh-mode.)
+;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+
+(defconst csh-mode-version "1.2"
+ "*Version number of this version of csh-mode")
+
+(defvar csh-mode-hook
+ '(lambda ()
+ (auto-fill-mode 1))
+ "Hook to run each time csh-mode is entered.")
+
+
+;;
+;; -------------------------------------------> Variables controlling completion
+;;
+(defvar csh-completion-list '())
+(make-variable-buffer-local 'csh-completion-list)
+(set-default 'csh-completion-list '())
+;;
+;; -type- : type number, 0:misc, 1:variable, 2:function
+;; -regexp-: regexp used to parse the script
+;; -match- : used by match-beginning/end to pickup target
+;;
+(defvar csh-completion-type-misc 0)
+(defvar csh-completion-regexp-var "\\([A-Za-z_0-9]+\\)=")
+(defvar csh-completion-type-var 1)
+(defvar csh-completion-match-var 1)
+(defvar csh-completion-regexp-var2 "\\$\\({\\|{#\\)?\\([A-Za-z_0-9]+\\)[#%:}]?")
+(defvar csh-completion-match-var2 2)
+(defvar csh-completion-regexp-function
+ "\\(function\\)?[ \t]*\\([A-Za-z_0-9]+\\)[ \t]*([ \t]*)")
+(defvar csh-completion-type-function 2)
+(defvar csh-completion-match-function 2)
+
+
+;;
+;; ------------------------------------> Variables controlling indentation style
+;;
+(defvar csh-indent 4
+ "*Indentation of csh statements with respect to containing block. A value
+of nil indicates compound list keyword \(\"do\" and \"then\"\) alignment.")
+
+(defvar csh-case-item-offset csh-indent
+ "*Additional indentation for case items within a case statement.")
+(defvar csh-case-indent nil
+ "*Additional indentation for statements under case items.")
+(defvar csh-comment-regexp "^\\s *#"
+ "*Regular expression used to recognize comments. Customize to support
+csh-like languages.")
+(defvar csh-match-and-tell t
+ "*If non-nil echo in the minibuffer the matching compound command
+for the \"breaksw\", \"end\", or \"endif\".")
+(defvar csh-tab-always-indent t
+ "*Controls the operation of the TAB key. If t (the default), always
+reindent the current line. If nil, indent the current line only if
+point is at the left margin or in the line's indentation; otherwise
+insert a tab.")
+
+
+;;
+;; ----------------------------------------> Constants containing syntax regexps
+;;
+(defconst csh-case-default-re
+ "^\\s *\\(case\\|default\\)\\b"
+ "Regexp used to locate grouping keywords case and default" )
+
+(defconst csh-case-item-re "^\\s *\\(case .*\\|default\\):"
+ "Regexp used to match case-items")
+
+(defconst csh-end-re "^\\s *end\\b"
+ "Regexp used to match keyword: end")
+
+(defconst csh-endif-re "^\\s *endif\\b"
+ "Regexp used to match keyword: endif")
+
+(defconst csh-endsw-re "^\\s *endsw\\b"
+ "Regexp used to match keyword: endsw")
+
+(defconst csh-else-re "^\\s *\\belse\\(\\b\\|$\\)"
+ "Regexp used to match keyword: else")
+
+(defconst csh-else-if-re "^\\s *\\belse if\\(\\b\\|$\\)"
+ "Regexp used to match keyword pair: else if")
+
+(defconst csh-if-re "^\\s *if\\b.+\\(\\\\\\|\\bthen\\b\\)"
+ "Regexp used to match non-one-line if statements")
+
+(defconst csh-iteration-keywords-re "^[^#\n]*\\s\"*\\b\\(while\\|foreach\\)\\b"
+ "Match one of the keywords: while, foreach")
+
+(defconst csh-keywords-re
+ "^\\s *\\(else\\b\\|foreach\\b\\|if\\b.+\\(\\\\\\|\\bthen\\b\\)\\|switch\\b\\|while\\b\\)"
+ "Regexp used to detect compound command keywords: else, if, foreach, while")
+
+(defconst csh-label-re "^\\s *[^!#$\n ]+:"
+ "Regexp used to match flow-control labels")
+
+(defconst csh-multiline-re "^.*\\\\$"
+ "Regexp used to match a line with a statement using more lines.")
+
+(defconst csh-switch-re "^\\s *switch\\b"
+ "Regexp used to match keyword: switch")
+
+
+;;
+;; ----------------------------------------> Variables controlling fontification
+;;
+(defvar csh-keywords '("@" "alias" "bg" "break" "breaksw" "case" "cd" "chdir"
+ "continue" "default" "dirs" "echo" "else" "end" "endif"
+ "endsw" "eval" "exec" "exit" "fg" "foreach" "glob" "goto"
+ "hashstat" "history" "if" "jobs" "kill" "limit" "login"
+ "logout" "limit" "notify" "onintr" "popd" "printenv"
+ "pushd" "rehash" "repeat" "set" "setenv" "shift" "source"
+ "stop" "suspend" "switch" "then" "time" "umask" "unalias"
+ "unhash" "unlimit" "unset" "unsetenv" "wait" "while"
+ ;; tcsh-keywords
+ "alloc" "bindkey" "builtins" "complete" "echotc"
+ "filetest" "hup" "log" "ls-F" "nice" "nohup" "sched"
+ "settc" "setty" "telltc" "uncomplete" "where" "which"))
+
+(require 'font-lock) ; need to do this before referring to font-lock-* below
+
+(defconst csh-font-lock-keywords
+ ;; NOTE: The order of some of the items in this list is significant. Do not
+ ;; alphabetize or otherwise blindly rearrange.
+ (list
+ ;; Comments on line 1, which are missed by syntactic fontification.
+ '("^#.*" 0 font-lock-comment-face)
+
+ ;; Label definitions (1 means first parenthesized exp in regexp).
+ '("^\\s *\\([^!#$\n ]+\\):" 1 font-lock-function-name-face)
+
+ ;; Label references.
+ '("\\b\\(goto\\|onintr\\)\\b\\s +\\([^!#$ \n\t]+\\)"
+ 2 font-lock-function-name-face)
+
+ ;; Variable settings.
+ '("\\(@\\|set\\|setenv\\)\\s +\\([0-9A-Za-z_]+\\b\\)"
+ 2 font-lock-variable-name-face)
+
+ ;; Variable references not inside of strings.
+ '("\\$[][0-9A-Za-z_#:?]+" 0 font-lock-variable-name-face)
+
+ ;; Backquoted strings. 'keep' means to just fontify non-fontified text.
+ '("`\\(.*\\)`" 1 font-lock-reference-face keep)
+
+ ;; NOTE: The following variables need to be anchored to the beginning of
+ ;; line to prevent re-fontifying text in comments. Due to this, we
+ ;; can only catch a finite number of occurrences. More can be added.
+ ;; The 't' means to override previous fontification.
+ ;;
+ ;; Variable references inside of " strings.
+ '("^[^#\n]*\".*\\(\\$[][0-9A-Za-z_#:?]+\\).*\""
+ 1 font-lock-variable-name-face t) ; 1
+ '("^[^#\n]*\".*\\(\\$[][0-9A-Za-z_#:?]+\\).*\\$[][0-9A-Za-z_#:?]+.*\""
+ 1 font-lock-variable-name-face t) ; 2
+ (cons (concat "^[^#\n]*\".*\\(\\$[][0-9A-Za-z_#:?]+\\).*"
+ "\\$[][0-9A-Za-z_#:?]+.*\\$[][0-9A-Za-z_#:?]+.*\"")
+ (list 1 font-lock-variable-name-face t)) ; 3
+ ;;
+ ;; History substitutions.
+ '("^![^~= \n\t]+" 0 font-lock-reference-face t) ; BOL
+ '("^[^#\n]*[^#\\\n]\\(![^~= \n\t]+\\)" 1 font-lock-reference-face t) ; 1
+ '("^[^#\n]*[^#\\\n]\\(![^~= \n\t]+\\).*![^~= \n\t]+"
+ 1 font-lock-reference-face t) ; 2
+
+ ;; Keywords.
+ (cons (concat
+ "\\(\\<"
+ (mapconcat 'identity csh-keywords "\\>\\|\\<")
+ "\\>\\)")
+ 1)
+ ))
+
+(put 'csh-mode 'font-lock-keywords 'csh-font-lock-keywords)
+
+
+;;
+;; -------------------------------------------------------> Mode-specific tables
+;;
+(defvar csh-mode-abbrev-table nil
+ "Abbrev table used while in csh mode.")
+(define-abbrev-table 'csh-mode-abbrev-table ())
+
+(defvar csh-mode-map nil
+ "Keymap used in csh mode")
+(if csh-mode-map
+ ()
+ (setq csh-mode-map (make-sparse-keymap))
+;;(define-key csh-mode-map "\177" 'backward-delete-char-untabify)
+ (define-key csh-mode-map "\C-c\t" 'csh-completion-init-and-pickup)
+ (define-key csh-mode-map "\C-j" 'reindent-then-newline-and-indent)
+ (define-key csh-mode-map "\e\t" 'csh-complete-symbol)
+ (define-key csh-mode-map "\n" 'reindent-then-newline-and-indent)
+ (define-key csh-mode-map '[return] 'reindent-then-newline-and-indent)
+ (define-key csh-mode-map "\t" 'csh-indent-command)
+;;(define-key csh-mode-map "\t" 'csh-indent-line)
+ )
+
+(defvar csh-mode-syntax-table nil
+ "Syntax table used while in csh mode.")
+(if csh-mode-syntax-table
+ ;; If it's already set up, don't change it.
+ ()
+ ;; Else, create it from the standard table and modify entries that need to be.
+ (setq csh-mode-syntax-table (make-syntax-table))
+ (modify-syntax-entry ?& "." csh-mode-syntax-table) ; & -punctuation
+ (modify-syntax-entry ?* "." csh-mode-syntax-table) ; * -punctuation
+ (modify-syntax-entry ?- "." csh-mode-syntax-table) ; - -punctuation
+ (modify-syntax-entry ?= "." csh-mode-syntax-table) ; = -punctuation
+ (modify-syntax-entry ?+ "." csh-mode-syntax-table) ; + -punctuation
+ (modify-syntax-entry ?| "." csh-mode-syntax-table) ; | -punctuation
+ (modify-syntax-entry ?< "." csh-mode-syntax-table) ; < -punctuation
+ (modify-syntax-entry ?> "." csh-mode-syntax-table) ; > -punctuation
+ (modify-syntax-entry ?/ "." csh-mode-syntax-table) ; / -punctuation
+ (modify-syntax-entry ?\' "\"" csh-mode-syntax-table) ; ' -string quote
+ (modify-syntax-entry ?. "w" csh-mode-syntax-table) ; . -word constituent
+ (modify-syntax-entry ?? "w" csh-mode-syntax-table) ; ? -word constituent
+
+ ;; \n - comment ender, first character of 2-char comment sequence
+ (modify-syntax-entry ?\n "> 1" csh-mode-syntax-table) ; # -word constituent
+
+ ;; - whitespace, first character of 2-char comment sequence
+ (modify-syntax-entry ? " 1" csh-mode-syntax-table) ;
+
+ ;; \t - whitespace, first character of 2-char comment sequence
+ (modify-syntax-entry ?\t " 1" csh-mode-syntax-table) ; # -word constituent
+
+ ;; # - word constituent, second character of 2-char comment sequence
+ (modify-syntax-entry ?# "w 2" csh-mode-syntax-table) ; # -word constituent
+ )
+
+
+;;
+;; ------------------------------------------------------------------> Functions
+;;
+(defun csh-current-line ()
+ "Return the vertical position of point in the buffer.
+Top line is 1."
+ (+ (count-lines (point-min) (point))
+ (if (= (current-column) 0) 1 0))
+ )
+
+(defun csh-get-compound-level
+ (begin-re end-re anchor-point &optional balance-list)
+ "Determine how much to indent this structure. Return a list (level line)
+of the matching compound command or nil if no match found."
+ (let*
+ (;; Locate the next compound begin keyword bounded by point-min
+ (match-point (if (re-search-backward begin-re (point-min) t)
+ (match-beginning 0) 0))
+ (nest-column (if (zerop match-point)
+ 1
+ (progn
+ (goto-char match-point)
+ (current-indentation))))
+ (nest-list (cons 0 0)) ;; sentinel cons since cdr is >= 1
+ )
+ (if (zerop match-point)
+ nil ;; graceful exit from recursion
+ (progn
+ (if (nlistp balance-list)
+ (setq balance-list (list)))
+ ;; Now search forward from matching start keyword for end keyword
+ (while (and (consp nest-list) (zerop (cdr nest-list))
+ (re-search-forward end-re anchor-point t))
+ (if (not (memq (point) balance-list))
+ (progn
+ (setq balance-list (cons (point) balance-list))
+ (goto-char match-point) ;; beginning of compound cmd
+ (setq nest-list
+ (csh-get-compound-level begin-re end-re
+ anchor-point balance-list))
+ )))
+
+ (cond ((consp nest-list)
+ (if (zerop (cdr nest-list))
+ (progn
+ (goto-char match-point)
+ (cons nest-column (csh-current-line)))
+ nest-list))
+ (t nil)
+ )
+ )
+ )
+ )
+ )
+
+(defun csh-get-nest-level ()
+ "Return a 2 element list (nest-level nest-line) describing where the
+current line should nest."
+ (let ((case-fold-search)
+ (level))
+ (save-excursion
+ (forward-line -1)
+ (while (and (not (bobp))
+ (null level))
+ (if (and (not (looking-at "^\\s *$"))
+ (not (save-excursion
+ (forward-line -1)
+ (beginning-of-line)
+ (looking-at csh-multiline-re)))
+ (not (looking-at csh-comment-regexp)))
+ (setq level (cons (current-indentation)
+ (csh-current-line)))
+ (forward-line -1)
+ );; if
+ );; while
+ (if (null level)
+ (cons (current-indentation) (csh-current-line))
+ level)
+ )
+ )
+ )
+
+(defun csh-get-nester-column (nest-line)
+ "Return the column to indent to with respect to nest-line taking
+into consideration keywords and other nesting constructs."
+ (save-excursion
+ (let ((fence-post)
+ (case-fold-search)
+ (start-line (csh-current-line)))
+ ;;
+ ;; Handle case item indentation constructs for this line
+ (cond ((looking-at csh-case-item-re)
+ ;; This line is a case item...
+ (save-excursion
+ (goto-line nest-line)
+ (let ((fence-post (save-excursion (end-of-line) (point))))
+ (cond ((re-search-forward csh-switch-re fence-post t)
+ ;; If this is the first case under the switch, indent.
+ (goto-char (match-beginning 0))
+ (+ (current-indentation) csh-case-item-offset))
+
+ ((re-search-forward csh-case-item-re fence-post t)
+ ;; If this is another case right under a previous case
+ ;; without intervening code, stay at the same
+ ;; indentation.
+ (goto-char (match-beginning 0))
+ (current-indentation))
+
+ (t
+ ;; Else, this is a new case. Outdent.
+ (- (current-indentation) csh-case-item-offset))
+ )
+ )))
+ (t;; Not a case-item. What to do relative to the nest-line?
+ (save-excursion
+ (goto-line nest-line)
+ (setq fence-post (save-excursion (end-of-line) (point)))
+ (save-excursion
+ (cond
+ ;;
+ ;; Check if we are in a continued statement
+ ((and (looking-at csh-multiline-re)
+ (save-excursion
+ (goto-line (1- start-line))
+ (looking-at csh-multiline-re)))
+ (if (looking-at ".*[\'\"]\\\\")
+ ;; If this is a continued string, indent under
+ ;; opening quote.
+ (progn
+ (re-search-forward "[\'\"]")
+ (forward-char -1))
+ (if (looking-at ".*([^\)\n]*\\\\")
+ ;; Else if this is a continued parenthesized
+ ;; list, indent after paren.
+ (re-search-forward "(" fence-post t)
+ ;; Else, indent after whitespace after first word.
+ (re-search-forward "[^ \t]+[ \t]+" fence-post t)))
+ (current-column))
+
+ ;; In order to locate the column of the keyword,
+ ;; which might be embedded within a case-item,
+ ;; it is necessary to use re-search-forward.
+ ;; Search by literal case, since shell is
+ ;; case-sensitive.
+ ((re-search-forward csh-keywords-re fence-post t)
+ (goto-char (match-beginning 1))
+ (if (looking-at csh-switch-re)
+ (+ (current-indentation) csh-case-item-offset)
+ (+ (current-indentation)
+ (if (null csh-indent)
+ 2 csh-indent)
+ )))
+
+ ((re-search-forward csh-case-default-re fence-post t)
+ (if (null csh-indent)
+ (progn
+ (goto-char (match-end 1))
+ (+ (current-indentation) 1))
+ (progn
+ (goto-char (match-beginning 1))
+ (+ (current-indentation) csh-indent))
+ ))
+
+ ;;
+ ;; Now detect first statement under a case item
+ ((looking-at csh-case-item-re)
+ (if (null csh-case-indent)
+ (progn
+ (re-search-forward csh-case-item-re fence-post t)
+ (goto-char (match-end 1))
+ (+ (current-column) 1))
+ (+ (current-indentation) csh-case-indent)))
+
+ ;;
+ ;; If this is the first statement under a control-flow
+ ;; label, indent one level.
+ ((csh-looking-at-label)
+ (+ (current-indentation) csh-indent))
+
+ ;; This is hosed when using current-column
+ ;; and there is a multi-command expression as the
+ ;; nester.
+ (t (current-indentation)))
+ )
+ ));; excursion over
+ );; Not a case-item
+ );;let
+ );; excursion
+ );; defun
+
+(defun csh-indent-command ()
+ "Indent current line relative to containing block and allow for
+csh-tab-always-indent customization"
+ (interactive)
+ (let (case-fold-search)
+ (cond ((save-excursion
+ (skip-chars-backward " \t")
+ (bolp))
+ (csh-indent-line))
+ (csh-tab-always-indent
+ (save-excursion
+ (csh-indent-line)))
+ (t (insert-tab))
+ ))
+ )
+
+(defun csh-indent-line ()
+ "Indent current line as far as it should go according
+to the syntax/context"
+ (interactive)
+ (let (case-fold-search)
+ (save-excursion
+ (beginning-of-line)
+ (if (bobp)
+ nil
+ ;;
+ ;; Align this line to current nesting level
+ (let*
+ (
+ (level-list (csh-get-nest-level)) ; Where to nest against
+ ;; (last-line-level (car level-list))
+ (this-line-level (current-indentation))
+ (nester-column (csh-get-nester-column (cdr level-list)))
+ (struct-match (csh-match-structure-and-reindent))
+ )
+ (if struct-match
+ (setq nester-column struct-match))
+ (if (eq nester-column this-line-level)
+ nil
+ (beginning-of-line)
+ (let ((beg (point)))
+ (back-to-indentation)
+ (delete-region beg (point)))
+ (indent-to nester-column))
+ );; let*
+ );; if
+ );; excursion
+ ;;
+ ;; Position point on this line
+ (let*
+ (
+ (this-line-level (current-indentation))
+ (this-bol (save-excursion
+ (beginning-of-line)
+ (point)))
+ (this-point (- (point) this-bol))
+ )
+ (cond ((> this-line-level this-point);; point in initial white space
+ (back-to-indentation))
+ (t nil)
+ );; cond
+ );; let*
+ );; let
+ );; defun
+
+(defun csh-indent-region (start end)
+ "From start to end, indent each line."
+ ;; The algorithm is just moving through the region line by line with
+ ;; the match noise turned off. Only modifies nonempty lines.
+ (save-excursion
+ (let (csh-match-and-tell
+ (endmark (copy-marker end)))
+
+ (goto-char start)
+ (beginning-of-line)
+ (setq start (point))
+ (while (> (marker-position endmark) start)
+ (if (not (and (bolp) (eolp)))
+ (csh-indent-line))
+ (forward-line 1)
+ (setq start (point)))
+
+ (set-marker endmark nil)
+ )
+ )
+ )
+
+(defun csh-line-to-string ()
+ "From point, construct a string from all characters on
+current line"
+ (skip-chars-forward " \t") ;; skip tabs as well as spaces
+ (buffer-substring (point)
+ (progn
+ (end-of-line 1)
+ (point))))
+
+(defun csh-looking-at-label ()
+ "Return true if current line is a label (not the default: case label)."
+ (and
+ (looking-at csh-label-re)
+ (not (looking-at "^\\s *default:"))))
+
+(defun csh-match-indent-level (begin-re end-re)
+ "Match the compound command and indent. Return nil on no match,
+indentation to use for this line otherwise."
+ (interactive)
+ (let* ((case-fold-search)
+ (nest-list
+ (save-excursion
+ (csh-get-compound-level begin-re end-re (point))
+ ))
+ ) ;; bindings
+ (if (null nest-list)
+ (progn
+ (if csh-match-and-tell
+ (message "No matching compound command"))
+ nil) ;; Propagate a miss.
+ (let* (
+ (nest-level (car nest-list))
+ (match-line (cdr nest-list))
+ ) ;; bindings
+ (if csh-match-and-tell
+ (save-excursion
+ (goto-line match-line)
+ (message "Matched ... %s" (csh-line-to-string))
+ ) ;; excursion
+ ) ;; if csh-match-and-tell
+ nest-level ;;Propagate a hit.
+ ) ;; let*
+ ) ;; if
+ ) ;; let*
+ ) ;; defun csh-match-indent-level
+
+(defun csh-match-structure-and-reindent ()
+ "If the current line matches one of the indenting keywords
+or one of the control structure ending keywords then reindent. Also
+if csh-match-and-tell is non-nil the matching structure will echo in
+the minibuffer"
+ (interactive)
+ (let (case-fold-search)
+ (save-excursion
+ (beginning-of-line)
+ (cond ((looking-at csh-else-re)
+ (csh-match-indent-level csh-if-re csh-endif-re))
+ ((looking-at csh-else-if-re)
+ (csh-match-indent-level csh-if-re csh-endif-re))
+ ((looking-at csh-endif-re)
+ (csh-match-indent-level csh-if-re csh-endif-re))
+ ((looking-at csh-end-re)
+ (csh-match-indent-level csh-iteration-keywords-re csh-end-re))
+ ((looking-at csh-endsw-re)
+ (csh-match-indent-level csh-switch-re csh-endsw-re))
+ ((csh-looking-at-label)
+ ;; Flush control-flow labels left since they don't nest.
+ 0)
+ ;;
+ (t nil)
+ );; cond
+ )
+ ))
+
+;;;###autoload
+(defun csh-mode ()
+ "csh-mode 2.0 - Major mode for editing csh and tcsh scripts.
+Special key bindings and commands:
+\\{csh-mode-map}
+Variables controlling indentation style:
+csh-indent
+ Indentation of csh statements with respect to containing block.
+ Default value is 4.
+csh-case-indent
+ Additional indentation for statements under case items.
+ Default value is nil which will align the statements one position
+ past the \")\" of the pattern.
+csh-case-item-offset
+ Additional indentation for case items within a case statement.
+ Default value is 2.
+csh-tab-always-indent
+ Controls the operation of the TAB key. If t (the default), always
+ reindent the current line. If nil, indent the current line only if
+ point is at the left margin or in the line's indentation; otherwise
+ insert a tab.
+csh-match-and-tell
+ If non-nil echo in the minibuffer the matching compound command
+ for the \"done\", \"}\", \"fi\", or \"endsw\". Default value is t.
+
+csh-comment-regexp
+ Regular expression used to recognize comments. Customize to support
+ csh-like languages. Default value is \"\^\\\\s *#\".
+
+Style Guide.
+ By setting
+ (setq csh-indent default-tab-width)
+
+ The following style is obtained:
+
+ if [ -z $foo ]
+ then
+ bar # <-- csh-group-offset is additive to csh-indent
+ foo
+ fi
+
+ By setting
+ (setq csh-indent default-tab-width)
+ (setq csh-group-offset (- 0 csh-indent))
+
+ The following style is obtained:
+
+ if [ -z $foo ]
+ then
+ bar
+ foo
+ fi
+
+ By setting
+ (setq csh-case-item-offset 1)
+ (setq csh-case-indent nil)
+
+ The following style is obtained:
+
+ case x in *
+ foo) bar # <-- csh-case-item-offset
+ baz;; # <-- csh-case-indent aligns with \")\"
+ foobar) foo
+ bar;;
+ endsw
+
+ By setting
+ (setq csh-case-item-offset 1)
+ (setq csh-case-indent 6)
+
+ The following style is obtained:
+
+ case x in *
+ foo) bar # <-- csh-case-item-offset
+ baz;; # <-- csh-case-indent
+ foobar) foo
+ bar;;
+ endsw
+
+
+Installation:
+ Put csh-mode.el in some directory in your load-path.
+ Put the following forms in your .emacs file.
+
+ (setq auto-mode-alist
+ (append auto-mode-alist
+ (list
+ '(\"\\\\.csh$\" . csh-mode)
+ '(\"\\\\.login\" . csh-mode))))
+
+ (setq csh-mode-hook
+ (function (lambda ()
+ (font-lock-mode 1) ;; font-lock the buffer
+ (setq csh-indent 8)
+ (setq csh-tab-always-indent t)
+ (setq csh-match-and-tell t)
+ (setq csh-align-to-keyword t) ;; Turn on keyword alignment
+ )))"
+ (interactive)
+ (kill-all-local-variables)
+ (use-local-map csh-mode-map)
+ (setq major-mode 'csh-mode)
+ (setq mode-name "Csh")
+ (setq local-abbrev-table csh-mode-abbrev-table)
+ (set-syntax-table csh-mode-syntax-table)
+ (make-local-variable 'indent-line-function)
+ (setq indent-line-function 'csh-indent-line)
+ (make-local-variable 'indent-region-function)
+ (setq indent-region-function 'csh-indent-region)
+ (make-local-variable 'comment-start)
+ (setq comment-start "# ")
+ (make-local-variable 'comment-end)
+ (setq comment-end "")
+ (make-local-variable 'comment-column)
+ (setq comment-column 32)
+ (make-local-variable 'comment-start-skip)
+ (setq comment-start-skip "#+ *")
+ ;;
+ ;; config font-lock mode
+ (make-local-variable 'font-lock-keywords)
+ (setq font-lock-keywords csh-font-lock-keywords)
+ ;;
+ ;; Let the user customize
+ (run-hooks 'csh-mode-hook)
+ ) ;; defun
+
+;;
+;; Completion code supplied by Haavard Rue <hrue@imf.unit.no>.
+;;
+;;
+;; add a completion with a given type to the list
+;;
+(defun csh-addto-alist (completion type)
+ (setq csh-completion-list
+ (append csh-completion-list
+ (list (cons completion type)))))
+
+(defun csh-bol-point ()
+ (save-excursion
+ (beginning-of-line)
+ (point)))
+
+(defun csh-complete-symbol ()
+ "Perform completion."
+ (interactive)
+ (let* ((case-fold-search)
+ (end (point))
+ (beg (unwind-protect
+ (save-excursion
+ (backward-sexp 1)
+ (while (= (char-syntax (following-char)) ?\')
+ (forward-char 1))
+ (point))))
+ (pattern (buffer-substring beg end))
+ (predicate
+ ;;
+ ;; ` or $( mark a function
+ ;;
+ (save-excursion
+ (goto-char beg)
+ (if (or
+ (save-excursion
+ (backward-char 1)
+ (looking-at "`"))
+ (save-excursion
+ (backward-char 2)
+ (looking-at "\\$(")))
+ (function (lambda (sym)
+ (equal (cdr sym) csh-completion-type-function)))
+ ;;
+ ;; a $, ${ or ${# mark a variable
+ ;;
+ (if (or
+ (save-excursion
+ (backward-char 1)
+ (looking-at "\\$"))
+ (save-excursion
+ (backward-char 2)
+ (looking-at "\\${"))
+ (save-excursion
+ (backward-char 3)
+ (looking-at "\\${#")))
+ (function (lambda (sym)
+ (equal (cdr sym)
+ csh-completion-type-var)))
+ ;;
+ ;; don't know. use 'em all
+ ;;
+ (function (lambda (sym) t))))))
+ ;;
+ (completion (try-completion pattern csh-completion-list predicate)))
+ ;;
+ (cond ((eq completion t))
+ ;;
+ ;; oops, what is this ?
+ ;;
+ ((null completion)
+ (message "Can't find completion for \"%s\"" pattern))
+ ;;
+ ;; insert
+ ;;
+ ((not (string= pattern completion))
+ (delete-region beg end)
+ (insert completion))
+ ;;
+ ;; write possible completion in the minibuffer,
+ ;; use this instead of a seperate buffer (usual)
+ ;;
+ (t
+ (let ((list (all-completions pattern csh-completion-list predicate))
+ (string ""))
+ (while list
+ (progn
+ (setq string (concat string (format "%s " (car list))))
+ (setq list (cdr list))))
+ (message string))))))
+
+;;
+;; init the list and pickup all
+;;
+(defun csh-completion-init-and-pickup ()
+ (interactive)
+ (let (case-fold-search)
+ (csh-completion-list-init)
+ (csh-pickup-all)))
+
+;;
+;; init the list
+;;
+(defun csh-completion-list-init ()
+ (interactive)
+ (setq csh-completion-list
+ (list
+ (cons "break" csh-completion-type-misc)
+ (cons "breaksw" csh-completion-type-misc)
+ (cons "case" csh-completion-type-misc)
+ (cons "continue" csh-completion-type-misc)
+ (cons "endif" csh-completion-type-misc)
+ (cons "exit" csh-completion-type-misc)
+ (cons "foreach" csh-completion-type-misc)
+ (cons "if" csh-completion-type-misc)
+ (cons "while" csh-completion-type-misc))))
+
+(defun csh-eol-point ()
+ (save-excursion
+ (end-of-line)
+ (point)))
+
+(defun csh-pickup-all ()
+ "Pickup all completions in buffer."
+ (interactive)
+ (csh-pickup-completion-driver (point-min) (point-max) t))
+
+(defun csh-pickup-completion (regexp type match pmin pmax)
+ "Pickup completion in region and addit to the list, if not already
+there."
+ (let ((i 0) kw obj)
+ (save-excursion
+ (goto-char pmin)
+ (while (and
+ (re-search-forward regexp pmax t)
+ (match-beginning match)
+ (setq kw (buffer-substring
+ (match-beginning match)
+ (match-end match))))
+ (progn
+ (setq obj (assoc kw csh-completion-list))
+ (if (or (equal nil obj)
+ (and (not (equal nil obj))
+ (not (= type (cdr obj)))))
+ (progn
+ (setq i (1+ i))
+ (csh-addto-alist kw type))))))
+ i))
+
+(defun csh-pickup-completion-driver (pmin pmax message)
+ "Driver routine for csh-pickup-completion."
+ (if message
+ (message "pickup completion..."))
+ (let* (
+ (i1
+ (csh-pickup-completion csh-completion-regexp-var
+ csh-completion-type-var
+ csh-completion-match-var
+ pmin pmax))
+ (i2
+ (csh-pickup-completion csh-completion-regexp-var2
+ csh-completion-type-var
+ csh-completion-match-var2
+ pmin pmax))
+ (i3
+ (csh-pickup-completion csh-completion-regexp-function
+ csh-completion-type-function
+ csh-completion-match-function
+ pmin pmax)))
+ (if message
+ (message "pickup %d variables and %d functions." (+ i1 i2) i3))))
+
+(defun csh-pickup-this-line ()
+ "Pickup all completions in current line."
+ (interactive)
+ (csh-pickup-completion-driver (csh-bol-point) (csh-eol-point) nil))
+
+
+(provide 'csh-mode)
+;;; csh-mode.el ends here
diff --git a/contrib/tcsh/ed.chared.c b/contrib/tcsh/ed.chared.c
new file mode 100644
index 000000000000..7703bbe77fdf
--- /dev/null
+++ b/contrib/tcsh/ed.chared.c
@@ -0,0 +1,4005 @@
+/* $Header: /src/pub/tcsh/ed.chared.c,v 3.59 1999/08/13 16:34:57 christos Exp $ */
+/*
+ * ed.chared.c: Character editing functions.
+ */
+/*-
+ * Copyright (c) 1980, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+/*
+ Bjorn Knutsson @ Thu Jun 24 19:02:17 1999
+
+ e_dabbrev_expand() did not do proper completion if quoted spaces were present
+ in the string being completed. Exemple:
+
+ # echo hello\ world
+ hello world
+ # echo h<press key bound to dabbrev-expande>
+ # echo hello\<cursor>
+
+ Correct behavior is:
+ # echo h<press key bound to dabbrev-expande>
+ # echo hello\ world<cursor>
+
+ The same problem occured if spaces were present in a string withing quotation
+ marks. Example:
+
+ # echo "hello world"
+ hello world
+ # echo "h<press key bound to dabbrev-expande>
+ # echo "hello<cursor>
+
+ The former problem could be solved with minor modifications of c_preword()
+ and c_endword(). The latter, however, required a significant rewrite of
+ c_preword(), since quoted strings must be parsed from start to end to
+ determine if a given character is inside or outside the quotation marks.
+
+ Compare the following two strings:
+
+ # echo \"" 'foo \' bar\"
+ " 'foo \' bar\
+ # echo '\"" 'foo \' bar\"
+ \"" foo ' bar"
+
+ The only difference between the two echo lines is in the first character
+ after the echo command. The result is either one or three arguments.
+
+ */
+
+#include "sh.h"
+
+RCSID("$Id: ed.chared.c,v 3.59 1999/08/13 16:34:57 christos Exp $")
+
+#include "ed.h"
+#include "tw.h"
+#include "ed.defns.h"
+
+/* #define SDEBUG */
+
+#define TCSHOP_NOP 0x00
+#define TCSHOP_DELETE 0x01
+#define TCSHOP_INSERT 0x02
+#define TCSHOP_CHANGE 0x04
+
+#define CHAR_FWD 0
+#define CHAR_BACK 1
+
+/*
+ * vi word treatment
+ * from: Gert-Jan Vons <vons@cesar.crbca1.sinet.slb.com>
+ */
+#define C_CLASS_WHITE 1
+#define C_CLASS_ALNUM 2
+#define C_CLASS_OTHER 3
+
+static Char *InsertPos = InputBuf; /* Where insertion starts */
+static Char *ActionPos = 0; /* Where action begins */
+static int ActionFlag = TCSHOP_NOP; /* What delayed action to take */
+/*
+ * Word search state
+ */
+static int searchdir = F_UP_SEARCH_HIST; /* Direction of last search */
+static Char patbuf[INBUFSIZE]; /* Search target */
+static int patlen = 0;
+/*
+ * Char search state
+ */
+static int srch_dir = CHAR_FWD; /* Direction of last search */
+static Char srch_char = 0; /* Search target */
+
+/* all routines that start with c_ are private to this set of routines */
+static void c_alternativ_key_map __P((int));
+static void c_insert __P((int));
+static void c_delafter __P((int));
+static void c_delbefore __P((int));
+static int c_to_class __P((int));
+static Char *c_prev_word __P((Char *, Char *, int));
+static Char *c_next_word __P((Char *, Char *, int));
+static Char *c_number __P((Char *, int *, int));
+static Char *c_expand __P((Char *));
+static void c_excl __P((Char *));
+static void c_substitute __P((void));
+static void c_delfini __P((void));
+static int c_hmatch __P((Char *));
+static void c_hsetpat __P((void));
+#ifdef COMMENT
+static void c_get_word __P((Char **, Char **));
+#endif
+static Char *c_preword __P((Char *, Char *, int));
+static Char *c_nexword __P((Char *, Char *, int));
+static Char *c_endword __P((Char *, Char *, int));
+static Char *c_eword __P((Char *, Char *, int));
+static CCRETVAL c_get_histline __P((void));
+static CCRETVAL c_search_line __P((Char *, int));
+static CCRETVAL v_repeat_srch __P((int));
+static CCRETVAL e_inc_search __P((int));
+static CCRETVAL v_search __P((int));
+static CCRETVAL v_csearch_fwd __P((int, int, int));
+static CCRETVAL v_action __P((int));
+static CCRETVAL v_csearch_back __P((int, int, int));
+
+#if defined(DSPMBYTE)
+static void e_charfwd_mbyte __P((int));
+static void e_charback_mbyte __P((int));
+static int extdel;
+static int extins = 0;
+#endif
+
+static void
+c_alternativ_key_map(state)
+ int state;
+{
+ switch (state) {
+ case 0:
+ CurrentKeyMap = CcKeyMap;
+ break;
+ case 1:
+ CurrentKeyMap = CcAltMap;
+ break;
+ default:
+ return;
+ }
+
+ AltKeyMap = (Char) state;
+}
+
+static void
+c_insert(num)
+ register int num;
+{
+ register Char *cp;
+
+ if (LastChar + num >= InputLim)
+ return; /* can't go past end of buffer */
+
+ if (Cursor < LastChar) { /* if I must move chars */
+ for (cp = LastChar; cp >= Cursor; cp--)
+ cp[num] = *cp;
+ }
+ LastChar += num;
+}
+
+static void
+c_delafter(num)
+ register int num;
+{
+ register Char *cp, *kp = NULL;
+
+#if defined(DSPMBYTE)
+ Char *wkcp;
+
+ extdel = 0;
+#endif
+
+ if (num > LastChar - Cursor)
+ num = (int) (LastChar - Cursor); /* bounds check */
+
+ if (num > 0) { /* if I can delete anything */
+#if defined(DSPMBYTE)
+ /* check for code of deleted character */
+ if (_enable_mbdisp) {
+ for (wkcp = Cursor ; wkcp < Cursor + num; wkcp++) {
+ if (extdel == 0)
+ extdel = Ismbyte1(*wkcp); /* check to 1st. byte */
+ else
+ extdel = 0; /* if 2nd. byte, force set to 0 */
+ }
+ }
+#endif
+ if (VImode) {
+ kp = UndoBuf; /* Set Up for VI undo command */
+ UndoAction = TCSHOP_INSERT;
+ UndoSize = num;
+ UndoPtr = Cursor;
+ for (cp = Cursor; cp <= LastChar; cp++) {
+ *kp++ = *cp; /* Save deleted chars into undobuf */
+ *cp = cp[num];
+ }
+ }
+ else
+ for (cp = Cursor; cp <= LastChar; cp++)
+ *cp = cp[num];
+ LastChar -= num;
+#if defined(DSPMBYTE)
+ if (_enable_mbdisp && extdel && Ismbyte2(*Cursor)) {
+ if( VImode ) {
+ UndoSize++;
+ *kp++ = *Cursor; /* Save deleted chars into undobuf */
+ }
+ for (cp = Cursor; cp <= LastChar; cp++)
+ *cp = cp[1];
+ LastChar--;
+ e_redisp( 1 );
+ }
+ else
+ extdel = 0;
+#endif
+ }
+#ifdef notdef
+ else {
+ /*
+ * XXX: We don't want to do that. In emacs mode overwrite should be
+ * sticky. I am not sure how that affects vi mode
+ */
+ inputmode = MODE_INSERT;
+ }
+#endif /* notdef */
+}
+
+static void
+c_delbefore(num) /* delete before dot, with bounds checking */
+ register int num;
+{
+ register Char *cp, *kp = NULL;
+
+#if defined(DSPMBYTE)
+ Char *nowcur, *wkcp;
+ Char delc;
+
+ extdel = 0;
+#endif
+
+ if (num > Cursor - InputBuf)
+ num = (int) (Cursor - InputBuf); /* bounds check */
+
+ if (num > 0) { /* if I can delete anything */
+#if defined(DSPMBYTE)
+ nowcur = Cursor - num;
+ delc = *nowcur;
+#endif
+ if (VImode) {
+ kp = UndoBuf; /* Set Up for VI undo command */
+ UndoAction = TCSHOP_INSERT;
+ UndoSize = num;
+ UndoPtr = Cursor - num;
+ for (cp = Cursor - num; cp <= LastChar; cp++) {
+ *kp++ = *cp;
+ *cp = cp[num];
+ }
+ }
+ else
+ for (cp = Cursor - num; cp <= LastChar; cp++)
+ *cp = cp[num];
+ LastChar -= num;
+#if defined(DSPMBYTE)
+ if (_enable_mbdisp) {
+ for (wkcp = InputBuf; wkcp < nowcur; wkcp++) {
+ if(extdel == 0)
+ extdel = Ismbyte1(*wkcp); /* check to 1st. byte */
+ else
+ extdel = 0; /* if 2nd. byte, force set to 0 */
+ }
+ if (extdel && Ismbyte2(delc)) {
+ if( VImode ) {
+ UndoSize++;
+ UndoPtr--;
+ *kp++ = *(nowcur-1);
+ /* Save deleted chars into undobuf */
+ }
+ for (cp = nowcur - 1; cp <= LastChar; cp++)
+ *cp = cp[1];
+ LastChar--;
+ }
+ }
+ else
+ extdel = 0;
+#endif
+ }
+}
+
+static Char *
+c_preword(p, low, n)
+ register Char *p, *low;
+ register int n;
+{
+ while (n--) {
+ register Char *prev = low;
+ register Char *new;
+
+ while (prev < p) { /* Skip initial spaces */
+ if (!Isspace(*prev) || (Isspace(*prev) && *(prev-1) == (Char)'\\'))
+ break;
+ prev++;
+ }
+
+ new = prev;
+
+ while (new < p) {
+ prev = new;
+ new = c_endword(prev-1, p, 1); /* Skip to next space */
+ new++; /* Step away from end of word */
+ while (new <= p) { /* Skip trailing spaces */
+ if (!Isspace(*new) || (Isspace(*new) && *(new-1) == (Char)'\\'))
+ break;
+ new++;
+ }
+ }
+
+ p = prev; /* Set to previous word start */
+
+ }
+ if (p < low)
+ p = low;
+ return (p);
+}
+
+/*
+ * c_to_class() returns the class of the given character.
+ *
+ * This is used to make the c_prev_word() and c_next_word() functions
+ * work like vi's, which classify characters. A word is a sequence of
+ * characters belonging to the same class, classes being defined as
+ * follows:
+ *
+ * 1/ whitespace
+ * 2/ alphanumeric chars, + underscore
+ * 3/ others
+ */
+static int
+c_to_class(ch)
+register int ch;
+{
+ if (Isspace(ch))
+ return C_CLASS_WHITE;
+
+ if (Isdigit(ch) || Isalpha(ch) || ch == '_')
+ return C_CLASS_ALNUM;
+
+ return C_CLASS_OTHER;
+}
+
+static Char *
+c_prev_word(p, low, n)
+ register Char *p, *low;
+ register int n;
+{
+ p--;
+
+ if (!VImode) {
+ while (n--) {
+ while ((p >= low) && !isword(*p))
+ p--;
+ while ((p >= low) && isword(*p))
+ p--;
+ }
+
+ /* cp now points to one character before the word */
+ p++;
+ if (p < low)
+ p = low;
+ /* cp now points where we want it */
+ return(p);
+ }
+
+ while (n--) {
+ register int c_class;
+
+ if (p < low)
+ break;
+
+ /* scan until beginning of current word (may be all whitespace!) */
+ c_class = c_to_class(*p);
+ while ((p >= low) && c_class == c_to_class(*p))
+ p--;
+
+ /* if this was a non_whitespace word, we're ready */
+ if (c_class != C_CLASS_WHITE)
+ continue;
+
+ /* otherwise, move back to beginning of the word just found */
+ c_class = c_to_class(*p);
+ while ((p >= low) && c_class == c_to_class(*p))
+ p--;
+ }
+
+ p++; /* correct overshoot */
+
+ return (p);
+}
+
+static Char *
+c_next_word(p, high, n)
+ register Char *p, *high;
+ register int n;
+{
+ if (!VImode) {
+ while (n--) {
+ while ((p < high) && !isword(*p))
+ p++;
+ while ((p < high) && isword(*p))
+ p++;
+ }
+ if (p > high)
+ p = high;
+ /* p now points where we want it */
+ return(p);
+ }
+
+ while (n--) {
+ register int c_class;
+
+ if (p >= high)
+ break;
+
+ /* scan until end of current word (may be all whitespace!) */
+ c_class = c_to_class(*p);
+ while ((p < high) && c_class == c_to_class(*p))
+ p++;
+
+ /* if this was all whitespace, we're ready */
+ if (c_class == C_CLASS_WHITE)
+ continue;
+
+ /* if we've found white-space at the end of the word, skip it */
+ while ((p < high) && c_to_class(*p) == C_CLASS_WHITE)
+ p++;
+ }
+
+ p--; /* correct overshoot */
+
+ return (p);
+}
+
+static Char *
+c_nexword(p, high, n)
+ register Char *p, *high;
+ register int n;
+{
+ while (n--) {
+ while ((p < high) && !Isspace(*p))
+ p++;
+ while ((p < high) && Isspace(*p))
+ p++;
+ }
+
+ if (p > high)
+ p = high;
+ /* p now points where we want it */
+ return(p);
+}
+
+/*
+ * Expand-History (originally "Magic-Space") code added by
+ * Ray Moody <ray@gibbs.physics.purdue.edu>
+ * this is a neat, but odd, addition.
+ */
+
+/*
+ * c_number: Ignore character p points to, return number appearing after that.
+ * A '$' by itself means a big number; "$-" is for negative; '^' means 1.
+ * Return p pointing to last char used.
+ */
+
+/*
+ * dval is the number to subtract from for things like $-3
+ */
+
+static Char *
+c_number(p, num, dval)
+ register Char *p;
+ register int *num;
+ register int dval;
+{
+ register int i;
+ register int sign = 1;
+
+ if (*++p == '^') {
+ *num = 1;
+ return(p);
+ }
+ if (*p == '$') {
+ if (*++p != '-') {
+ *num = NCARGS; /* Handle $ */
+ return(--p);
+ }
+ sign = -1; /* Handle $- */
+ ++p;
+ }
+ for (i = 0; *p >= '0' && *p <= '9'; i = 10 * i + *p++ - '0')
+ continue;
+ *num = (sign < 0 ? dval - i : i);
+ return(--p);
+}
+
+/*
+ * excl_expand: There is an excl to be expanded to p -- do the right thing
+ * with it and return a version of p advanced over the expanded stuff. Also,
+ * update tsh_cur and related things as appropriate...
+ */
+
+static Char *
+c_expand(p)
+ register Char *p;
+{
+ register Char *q;
+ register struct Hist *h = Histlist.Hnext;
+ register struct wordent *l;
+ int i, from, to, dval;
+ bool all_dig;
+ bool been_once = 0;
+ Char *op = p;
+ Char buf[INBUFSIZE];
+ Char *bend = buf;
+ Char *modbuf, *omodbuf;
+
+ if (!h)
+ goto excl_err;
+excl_sw:
+ switch (*(q = p + 1)) {
+
+ case '^':
+ bend = expand_lex(buf, INBUFSIZE, &h->Hlex, 1, 1);
+ break;
+
+ case '$':
+ if ((l = (h->Hlex).prev) != 0)
+ bend = expand_lex(buf, INBUFSIZE, l->prev->prev, 0, 0);
+ break;
+
+ case '*':
+ bend = expand_lex(buf, INBUFSIZE, &h->Hlex, 1, NCARGS);
+ break;
+
+ default:
+ if (been_once) { /* unknown argument */
+ /* assume it's a modifier, e.g. !foo:h, and get whole cmd */
+ bend = expand_lex(buf, INBUFSIZE, &h->Hlex, 0, NCARGS);
+ q -= 2;
+ break;
+ }
+ been_once = 1;
+
+ if (*q == ':') /* short form: !:arg */
+ --q;
+
+ if (*q != HIST) {
+ /*
+ * Search for a space, tab, or colon. See if we have a number (as
+ * in !1234:xyz). Remember the number.
+ */
+ for (i = 0, all_dig = 1;
+ *q != ' ' && *q != '\t' && *q != ':' && q < Cursor; q++) {
+ /*
+ * PWP: !-4 is a valid history argument too, therefore the test
+ * is if not a digit, or not a - as the first character.
+ */
+ if ((*q < '0' || *q > '9') && (*q != '-' || q != p + 1))
+ all_dig = 0;
+ else if (*q == '-')
+ all_dig = 2;/* we are sneeky about this */
+ else
+ i = 10 * i + *q - '0';
+ }
+ --q;
+
+ /*
+ * If we have a number, search for event i. Otherwise, search for
+ * a named event (as in !foo). (In this case, I is the length of
+ * the named event).
+ */
+ if (all_dig) {
+ if (all_dig == 2)
+ i = -i; /* make it negitive */
+ if (i < 0) /* if !-4 (for example) */
+ i = eventno + 1 + i; /* remember: i is < 0 */
+ for (; h; h = h->Hnext) {
+ if (h->Hnum == i)
+ break;
+ }
+ }
+ else {
+ for (i = (int) (q - p); h; h = h->Hnext) {
+ if ((l = &h->Hlex) != 0) {
+ if (!Strncmp(p + 1, l->next->word, (size_t) i))
+ break;
+ }
+ }
+ }
+ }
+ if (!h)
+ goto excl_err;
+ if (q[1] == ':' || q[1] == '-' || q[1] == '*' ||
+ q[1] == '$' || q[1] == '^') { /* get some args */
+ p = q[1] == ':' ? ++q : q;
+ /*
+ * Go handle !foo:*
+ */
+ if ((q[1] < '0' || q[1] > '9') &&
+ q[1] != '-' && q[1] != '$' && q[1] != '^')
+ goto excl_sw;
+ /*
+ * Go handle !foo:$
+ */
+ if (q[1] == '$' && (q[2] != '-' || q[3] < '0' || q[3] > '9'))
+ goto excl_sw;
+ /*
+ * Count up the number of words in this event. Store it in dval.
+ * Dval will be fed to number.
+ */
+ dval = 0;
+ if ((l = h->Hlex.prev) != 0) {
+ for (l = l->prev; l != h->Hlex.next; l = l->prev, dval++)
+ continue;
+ }
+ if (!dval)
+ goto excl_err;
+ if (q[1] == '-')
+ from = 0;
+ else
+ q = c_number(q, &from, dval);
+ if (q[1] == '-') {
+ ++q;
+ if ((q[1] < '0' || q[1] > '9') && q[1] != '$')
+ to = dval - 1;
+ else
+ q = c_number(q, &to, dval);
+ }
+ else if (q[1] == '*') {
+ ++q;
+ to = NCARGS;
+ }
+ else {
+ to = from;
+ }
+ if (from < 0 || to < from)
+ goto excl_err;
+ bend = expand_lex(buf, INBUFSIZE, &h->Hlex, from, to);
+ }
+ else { /* get whole cmd */
+ bend = expand_lex(buf, INBUFSIZE, &h->Hlex, 0, NCARGS);
+ }
+ break;
+ }
+
+ /*
+ * Apply modifiers, if any.
+ */
+ if (q[1] == ':') {
+ *bend = '\0';
+ modbuf = omodbuf = buf;
+ while (q[1] == ':' && modbuf != NULL) {
+ switch (q[2]) {
+ case 'r':
+ case 'e':
+ case 'h':
+ case 't':
+ case 'q':
+ case 'x':
+ case 'u':
+ case 'l':
+ if ((modbuf = domod(omodbuf, (int) q[2])) != NULL) {
+ if (omodbuf != buf)
+ xfree((ptr_t) omodbuf);
+ omodbuf = modbuf;
+ }
+ ++q;
+ break;
+
+ case 'a':
+ case 'g':
+ /* Not implemented; this needs to be done before expanding
+ * lex. We don't have the words available to us anymore.
+ */
+ ++q;
+ break;
+
+ case 'p':
+ /* Ok */
+ ++q;
+ break;
+
+ case '\0':
+ break;
+
+ default:
+ ++q;
+ break;
+ }
+ if (q[1])
+ ++q;
+ }
+ if (omodbuf != buf) {
+ (void) Strcpy(buf, omodbuf);
+ xfree((ptr_t) omodbuf);
+ bend = Strend(buf);
+ }
+ }
+
+ /*
+ * Now replace the text from op to q inclusive with the text from buf to
+ * bend.
+ */
+ q++;
+
+ /*
+ * Now replace text non-inclusively like a real CS major!
+ */
+ if (LastChar + (bend - buf) - (q - op) >= InputLim)
+ goto excl_err;
+ (void) memmove((ptr_t) (q + (bend - buf) - (q - op)), (ptr_t) q,
+ (size_t) ((LastChar - q) * sizeof(Char)));
+ LastChar += (bend - buf) - (q - op);
+ Cursor += (bend - buf) - (q - op);
+ (void) memmove((ptr_t) op, (ptr_t) buf,
+ (size_t) ((bend - buf) * sizeof(Char)));
+ *LastChar = '\0';
+ return(op + (bend - buf));
+excl_err:
+ SoundBeep();
+ return(op + 1);
+}
+
+/*
+ * c_excl: An excl has been found at point p -- back up and find some white
+ * space (or the beginning of the buffer) and properly expand all the excl's
+ * from there up to the current cursor position. We also avoid (trying to)
+ * expanding '>!'
+ */
+
+static void
+c_excl(p)
+ register Char *p;
+{
+ register int i;
+ register Char *q;
+
+ /*
+ * if />[SPC TAB]*![SPC TAB]/, back up p to just after the >. otherwise,
+ * back p up to just before the current word.
+ */
+ if ((p[1] == ' ' || p[1] == '\t') &&
+ (p[-1] == ' ' || p[-1] == '\t' || p[-1] == '>')) {
+ for (q = p - 1; q > InputBuf && (*q == ' ' || *q == '\t'); --q)
+ continue;
+ if (*q == '>')
+ ++p;
+ }
+ else {
+ while (*p != ' ' && *p != '\t' && p > InputBuf)
+ --p;
+ }
+
+ /*
+ * Forever: Look for history char. (Stop looking when we find the cursor.)
+ * Count backslashes. Of odd, skip history char. Return if all done.
+ * Expand if even number of backslashes.
+ */
+ for (;;) {
+ while (*p != HIST && p < Cursor)
+ ++p;
+ for (i = 1; (p - i) >= InputBuf && p[-i] == '\\'; i++)
+ continue;
+ if (i % 2 == 0)
+ ++p;
+ if (p >= Cursor)
+ return;
+ if (i % 2 == 1)
+ p = c_expand(p);
+ }
+}
+
+
+static void
+c_substitute()
+{
+ register Char *p;
+
+ /*
+ * Start p out one character before the cursor. Move it backwards looking
+ * for white space, the beginning of the line, or a history character.
+ */
+ for (p = Cursor - 1;
+ p > InputBuf && *p != ' ' && *p != '\t' && *p != HIST; --p)
+ continue;
+
+ /*
+ * If we found a history character, go expand it.
+ */
+ if (*p == HIST)
+ c_excl(p);
+ Refresh();
+}
+
+static void
+c_delfini() /* Finish up delete action */
+{
+ register int Size;
+
+ if (ActionFlag & TCSHOP_INSERT)
+ c_alternativ_key_map(0);
+
+ ActionFlag = TCSHOP_NOP;
+
+ if (ActionPos == 0)
+ return;
+
+ UndoAction = TCSHOP_INSERT;
+
+ if (Cursor > ActionPos) {
+ Size = (int) (Cursor-ActionPos);
+ c_delbefore(Size);
+ Cursor = ActionPos;
+#if defined(DSPMBYTE)
+ if (_enable_mbdisp && extdel) {
+ Cursor--;
+ e_redisp(1);
+ }
+#endif
+ RefCursor();
+ }
+ else if (Cursor < ActionPos) {
+ Size = (int)(ActionPos-Cursor);
+ c_delafter(Size);
+ }
+ else {
+ Size = 1;
+ c_delafter(Size);
+ }
+ UndoPtr = Cursor;
+ UndoSize = Size;
+}
+
+static Char *
+c_endword(p, high, n)
+ register Char *p, *high;
+ register int n;
+{
+ register int inquote = 0;
+ p++;
+
+ while (n--) {
+ while (p < high) { /* Skip spaces */
+ if (!Isspace(*p) || (Isspace(*p) && *(p-1) == (Char)'\\'))
+ break;
+ p++;
+ }
+ while (p < high) { /* Skip string */
+ if ((*p == (Char)'\'' || *p == (Char)'"')) { /* Quotation marks? */
+ if ((!inquote && *(p-1) != (Char)'\\') || inquote) { /* Should it be honored? */
+ if (inquote == 0) inquote = *p;
+ else if (inquote == *p) inquote = 0;
+ }
+ }
+ if (!inquote && (Isspace(*p) && *(p-1) != (Char)'\\')) /* Break if unquoted space */
+ break;
+ p++;
+ }
+ }
+
+ p--;
+ return(p);
+}
+
+
+static Char *
+c_eword(p, high, n)
+ register Char *p, *high;
+ register int n;
+{
+ p++;
+
+ while (n--) {
+ while ((p < high) && Isspace(*p))
+ p++;
+
+ if (Isalnum(*p))
+ while ((p < high) && Isalnum(*p))
+ p++;
+ else
+ while ((p < high) && !(Isspace(*p) || Isalnum(*p)))
+ p++;
+ }
+
+ p--;
+ return(p);
+}
+
+static CCRETVAL
+c_get_histline()
+{
+ struct Hist *hp;
+ int h;
+
+ if (Hist_num == 0) { /* if really the current line */
+ copyn(InputBuf, HistBuf, INBUFSIZE);
+ LastChar = InputBuf + (LastHist - HistBuf);
+
+#ifdef KSHVI
+ if (VImode)
+ Cursor = InputBuf;
+ else
+#endif /* KSHVI */
+ Cursor = LastChar;
+
+ return(CC_REFRESH);
+ }
+
+ hp = Histlist.Hnext;
+ if (hp == NULL)
+ return(CC_ERROR);
+
+ for (h = 1; h < Hist_num; h++) {
+ if ((hp->Hnext) == NULL) {
+ Hist_num = h;
+ return(CC_ERROR);
+ }
+ hp = hp->Hnext;
+ }
+
+ if (HistLit && hp->histline) {
+ copyn(InputBuf, hp->histline, INBUFSIZE);
+ CurrentHistLit = 1;
+ }
+ else {
+ (void) sprlex(InputBuf, sizeof(InputBuf), &hp->Hlex);
+ CurrentHistLit = 0;
+ }
+ LastChar = InputBuf + Strlen(InputBuf);
+
+ if (LastChar > InputBuf) {
+ if (LastChar[-1] == '\n')
+ LastChar--;
+#if 0
+ if (LastChar[-1] == ' ')
+ LastChar--;
+#endif
+ if (LastChar < InputBuf)
+ LastChar = InputBuf;
+ }
+
+#ifdef KSHVI
+ if (VImode)
+ Cursor = InputBuf;
+ else
+#endif /* KSHVI */
+ Cursor = LastChar;
+
+ return(CC_REFRESH);
+}
+
+static CCRETVAL
+c_search_line(pattern, dir)
+Char *pattern;
+int dir;
+{
+ Char *cp;
+ int len;
+
+ len = (int) Strlen(pattern);
+
+ if (dir == F_UP_SEARCH_HIST) {
+ for (cp = Cursor; cp >= InputBuf; cp--)
+ if (Strncmp(cp, pattern, (size_t) len) == 0 ||
+ Gmatch(cp, pattern)) {
+ Cursor = cp;
+ return(CC_NORM);
+ }
+ return(CC_ERROR);
+ } else {
+ for (cp = Cursor; *cp != '\0' && cp < InputLim; cp++)
+ if (Strncmp(cp, pattern, (size_t) len) == 0 ||
+ Gmatch(cp, pattern)) {
+ Cursor = cp;
+ return(CC_NORM);
+ }
+ return(CC_ERROR);
+ }
+}
+
+static CCRETVAL
+e_inc_search(dir)
+ int dir;
+{
+ static Char STRfwd[] = { 'f', 'w', 'd', '\0' },
+ STRbck[] = { 'b', 'c', 'k', '\0' };
+ static Char pchar = ':'; /* ':' = normal, '?' = failed */
+ static Char endcmd[2];
+ Char ch, *cp,
+ *oldCursor = Cursor,
+ oldpchar = pchar;
+ CCRETVAL ret = CC_NORM;
+ int oldHist_num = Hist_num,
+ oldpatlen = patlen,
+ newdir = dir,
+ done, redo;
+
+ if (LastChar + sizeof(STRfwd)/sizeof(Char) + 2 + patlen >= InputLim)
+ return(CC_ERROR);
+
+ for (;;) {
+
+ if (patlen == 0) { /* first round */
+ pchar = ':';
+ patbuf[patlen++] = '*';
+ }
+ done = redo = 0;
+ *LastChar++ = '\n';
+ for (cp = newdir == F_UP_SEARCH_HIST ? STRbck : STRfwd;
+ *cp; *LastChar++ = *cp++)
+ continue;
+ *LastChar++ = pchar;
+ for (cp = &patbuf[1]; cp < &patbuf[patlen]; *LastChar++ = *cp++)
+ continue;
+ *LastChar = '\0';
+ Refresh();
+
+ if (GetNextChar(&ch) != 1)
+ return(e_send_eof(0));
+
+ switch (CurrentKeyMap[(unsigned char) ch]) {
+ case F_INSERT:
+ case F_DIGIT:
+ case F_MAGIC_SPACE:
+ if (patlen > INBUFSIZE - 3)
+ SoundBeep();
+ else {
+ patbuf[patlen++] = ch;
+ *LastChar++ = ch;
+ *LastChar = '\0';
+ Refresh();
+ }
+ break;
+
+ case F_INC_FWD:
+ newdir = F_DOWN_SEARCH_HIST;
+ redo++;
+ break;
+
+ case F_INC_BACK:
+ newdir = F_UP_SEARCH_HIST;
+ redo++;
+ break;
+
+ case F_DELPREV:
+ if (patlen > 1)
+ done++;
+ else
+ SoundBeep();
+ break;
+
+ default:
+ switch (ch) {
+ case 0007: /* ^G: Abort */
+ ret = CC_ERROR;
+ done++;
+ break;
+
+ case 0027: /* ^W: Append word */
+ /* No can do if globbing characters in pattern */
+ for (cp = &patbuf[1]; ; cp++)
+ if (cp >= &patbuf[patlen]) {
+ Cursor += patlen - 1;
+ cp = c_next_word(Cursor, LastChar, 1);
+ while (Cursor < cp && *Cursor != '\n') {
+ if (patlen > INBUFSIZE - 3) {
+ SoundBeep();
+ break;
+ }
+ patbuf[patlen++] = *Cursor;
+ *LastChar++ = *Cursor++;
+ }
+ Cursor = oldCursor;
+ *LastChar = '\0';
+ Refresh();
+ break;
+ } else if (isglob(*cp)) {
+ SoundBeep();
+ break;
+ }
+ break;
+
+ default: /* Terminate and execute cmd */
+ endcmd[0] = ch;
+ PushMacro(endcmd);
+ /*FALLTHROUGH*/
+
+ case 0033: /* ESC: Terminate */
+ ret = CC_REFRESH;
+ done++;
+ break;
+ }
+ break;
+ }
+
+ while (LastChar > InputBuf && *LastChar != '\n')
+ *LastChar-- = '\0';
+ *LastChar = '\0';
+
+ if (!done) {
+
+ /* Can't search if unmatched '[' */
+ for (cp = &patbuf[patlen - 1], ch = ']'; cp > patbuf; cp--)
+ if (*cp == '[' || *cp == ']') {
+ ch = *cp;
+ break;
+ }
+
+ if (patlen > 1 && ch != '[') {
+ if (redo && newdir == dir) {
+ if (pchar == '?') { /* wrap around */
+ Hist_num = newdir == F_UP_SEARCH_HIST ? 0 : 0x7fffffff;
+ if (c_get_histline() == CC_ERROR)
+ /* Hist_num was fixed by first call */
+ (void) c_get_histline();
+ Cursor = newdir == F_UP_SEARCH_HIST ?
+ LastChar : InputBuf;
+ } else
+ Cursor += newdir == F_UP_SEARCH_HIST ? -1 : 1;
+ }
+ patbuf[patlen++] = '*';
+ patbuf[patlen] = '\0';
+ if (Cursor < InputBuf || Cursor > LastChar ||
+ (ret = c_search_line(&patbuf[1], newdir)) == CC_ERROR) {
+ LastCmd = (KEYCMD) newdir; /* avoid c_hsetpat */
+ ret = newdir == F_UP_SEARCH_HIST ?
+ e_up_search_hist(0) : e_down_search_hist(0);
+ if (ret != CC_ERROR) {
+ Cursor = newdir == F_UP_SEARCH_HIST ?
+ LastChar : InputBuf;
+ (void) c_search_line(&patbuf[1], newdir);
+ }
+ }
+ patbuf[--patlen] = '\0';
+ if (ret == CC_ERROR) {
+ SoundBeep();
+ if (Hist_num != oldHist_num) {
+ Hist_num = oldHist_num;
+ if (c_get_histline() == CC_ERROR)
+ return(CC_ERROR);
+ }
+ Cursor = oldCursor;
+ pchar = '?';
+ } else {
+ pchar = ':';
+ }
+ }
+
+ ret = e_inc_search(newdir);
+
+ if (ret == CC_ERROR && pchar == '?' && oldpchar == ':') {
+ /* break abort of failed search at last non-failed */
+ ret = CC_NORM;
+ }
+
+ }
+
+ if (ret == CC_NORM || (ret == CC_ERROR && oldpatlen == 0)) {
+ /* restore on normal return or error exit */
+ pchar = oldpchar;
+ patlen = oldpatlen;
+ if (Hist_num != oldHist_num) {
+ Hist_num = oldHist_num;
+ if (c_get_histline() == CC_ERROR)
+ return(CC_ERROR);
+ }
+ Cursor = oldCursor;
+ if (ret == CC_ERROR)
+ Refresh();
+ }
+ if (done || ret != CC_NORM)
+ return(ret);
+
+ }
+
+}
+
+static CCRETVAL
+v_search(dir)
+ int dir;
+{
+ Char ch;
+ Char tmpbuf[INBUFSIZE];
+ Char oldbuf[INBUFSIZE];
+ Char *oldlc, *oldc;
+ int tmplen;
+
+ copyn(oldbuf, InputBuf, INBUFSIZE);
+ oldlc = LastChar;
+ oldc = Cursor;
+ tmplen = 0;
+ tmpbuf[tmplen++] = '*';
+
+ InputBuf[0] = '\0';
+ LastChar = InputBuf;
+ Cursor = InputBuf;
+ searchdir = dir;
+
+ c_insert(2); /* prompt + '\n' */
+ *Cursor++ = '\n';
+ *Cursor++ = dir == F_UP_SEARCH_HIST ? '?' : '/';
+ Refresh();
+ for (ch = 0;ch == 0;) {
+ if (GetNextChar(&ch) != 1)
+ return(e_send_eof(0));
+ switch (ASC(ch)) {
+ case 0010: /* Delete and backspace */
+ case 0177:
+ if (tmplen > 1) {
+ *Cursor-- = '\0';
+ LastChar = Cursor;
+ tmpbuf[tmplen--] = '\0';
+ }
+ else {
+ copyn(InputBuf, oldbuf, INBUFSIZE);
+ LastChar = oldlc;
+ Cursor = oldc;
+ return(CC_REFRESH);
+ }
+ Refresh();
+ ch = 0;
+ break;
+
+ case 0033: /* ESC */
+#ifndef _OSD_POSIX
+ case '\r': /* Newline */
+ case '\n':
+#else
+ case '\012': /* Newline */
+ case '\015': /* Return */
+#endif
+ break;
+
+ default:
+ if (tmplen >= INBUFSIZE)
+ SoundBeep();
+ else {
+ tmpbuf[tmplen++] = ch;
+ *Cursor++ = ch;
+ LastChar = Cursor;
+ }
+ Refresh();
+ ch = 0;
+ break;
+ }
+ }
+
+ if (tmplen == 1) {
+ /*
+ * Use the old pattern, but wild-card it.
+ */
+ if (patlen == 0) {
+ InputBuf[0] = '\0';
+ LastChar = InputBuf;
+ Cursor = InputBuf;
+ Refresh();
+ return(CC_ERROR);
+ }
+ if (patbuf[0] != '*') {
+ (void) Strcpy(tmpbuf, patbuf);
+ patbuf[0] = '*';
+ (void) Strcpy(&patbuf[1], tmpbuf);
+ patlen++;
+ patbuf[patlen++] = '*';
+ patbuf[patlen] = '\0';
+ }
+ }
+ else {
+ tmpbuf[tmplen++] = '*';
+ tmpbuf[tmplen] = '\0';
+ (void) Strcpy(patbuf, tmpbuf);
+ patlen = tmplen;
+ }
+ LastCmd = (KEYCMD) dir; /* avoid c_hsetpat */
+ Cursor = LastChar = InputBuf;
+ if ((dir == F_UP_SEARCH_HIST ? e_up_search_hist(0) :
+ e_down_search_hist(0)) == CC_ERROR) {
+ Refresh();
+ return(CC_ERROR);
+ }
+ else {
+ if (ch == 0033) {
+ Refresh();
+ *LastChar++ = '\n';
+ *LastChar = '\0';
+ PastBottom();
+ return(CC_NEWLINE);
+ }
+ else
+ return(CC_REFRESH);
+ }
+}
+
+/*
+ * semi-PUBLIC routines. Any routine that is of type CCRETVAL is an
+ * entry point, called from the CcKeyMap indirected into the
+ * CcFuncTbl array.
+ */
+
+/*ARGSUSED*/
+CCRETVAL
+v_cmd_mode(c)
+ int c;
+{
+ USE(c);
+ InsertPos = 0;
+ ActionFlag = TCSHOP_NOP; /* [Esc] cancels pending action */
+ ActionPos = 0;
+ DoingArg = 0;
+ if (UndoPtr > Cursor)
+ UndoSize = (int)(UndoPtr - Cursor);
+ else
+ UndoSize = (int)(Cursor - UndoPtr);
+
+ inputmode = MODE_INSERT;
+ c_alternativ_key_map(1);
+#ifdef notdef
+ /*
+ * We don't want to move the cursor, because all the editing
+ * commands don't include the character under the cursor.
+ */
+ if (Cursor > InputBuf)
+ Cursor--;
+#endif
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_unassigned(c)
+ int c;
+{ /* bound to keys that arn't really assigned */
+ USE(c);
+ SoundBeep();
+ flush();
+ return(CC_NORM);
+}
+
+CCRETVAL
+e_insert(c)
+ register int c;
+{
+ register int i;
+#if defined(DSPMBYTE)
+ CCRETVAL ret;
+ static Char savec;
+ static int exterr = 0;
+#endif
+#ifndef SHORT_STRINGS
+ c &= ASCII; /* no meta chars ever */
+#endif
+#if defined(DSPMBYTE)
+ ret = (CCRETVAL) CC_NORM;
+#endif
+
+ if (!c)
+ return(CC_ERROR); /* no NULs in the input ever!! */
+
+ if (LastChar + Argument >= InputLim)
+ return(CC_ERROR); /* end of buffer space */
+
+ if (Argument == 1) { /* How was this optimized ???? */
+
+#if defined(DSPMBYTE)
+ if(_enable_mbdisp && extins && exterr && Ismbyte2(c)) {
+ extins = 0;
+ exterr = 0;
+ return(CC_ERROR);
+ }
+#endif
+ if (inputmode != MODE_INSERT) {
+ UndoBuf[UndoSize++] = *Cursor;
+ UndoBuf[UndoSize] = '\0';
+ c_delafter(1); /* Do NOT use the saving ONE */
+ }
+
+ c_insert(1);
+
+#if defined(DSPMBYTE)
+ /* 1st. byte is store to special buffer, and replace space */
+ if(_enable_mbdisp && extins == 0 && Ismbyte1(c)) {
+ extins++;
+ savec = (Char) c;
+ *Cursor++ = (Char) ' ';
+ }
+ else if (_enable_mbdisp && extins && Ismbyte2(c)) {
+ *(Cursor-1) = savec;
+ *Cursor++ = (Char) c;
+ extins = 0;
+ e_redisp(1);
+ Refresh();
+ ret = CC_REFRESH;
+ }
+ else
+ *Cursor++ = (Char) c;
+ DoingArg = 0; /* just in case */
+ if (ret != CC_REFRESH)
+ RefPlusOne(); /* fast refresh for one char. */
+#else
+ *Cursor++ = (Char) c;
+ DoingArg = 0; /* just in case */
+ RefPlusOne(); /* fast refresh for one char. */
+#endif
+ }
+ else {
+#if defined(DSPMBYTE)
+ /* Cannot use ESC-(number) for multi-byte */
+ if (_enable_mbdisp && extins == 0 && Ismbyte1(c)) {
+ extins++;
+ exterr++;
+ return(CC_ERROR);
+ }
+ else if (_enable_mbdisp && extins && exterr && Ismbyte2(c))
+ {
+ extins = 0;
+ exterr = 0;
+ return(CC_ERROR);
+ }
+#endif
+ if (inputmode != MODE_INSERT) {
+
+ for(i=0;i<Argument;i++)
+ UndoBuf[UndoSize++] = *(Cursor+i);
+
+ UndoBuf[UndoSize] = '\0';
+ c_delafter(Argument); /* Do NOT use the saving ONE */
+ }
+
+ c_insert(Argument);
+
+ while (Argument--)
+ *Cursor++ = (Char) c;
+ Refresh();
+ }
+
+ if (inputmode == MODE_REPLACE_1)
+ (void) v_cmd_mode(0);
+
+#if defined(DSPMBYTE)
+ return(ret);
+#else
+ return(CC_NORM);
+#endif
+}
+
+int
+InsertStr(s) /* insert ASCIZ s at cursor (for complete) */
+ Char *s;
+{
+ register int len;
+
+ if ((len = (int) Strlen(s)) <= 0)
+ return -1;
+ if (LastChar + len >= InputLim)
+ return -1; /* end of buffer space */
+
+ c_insert(len);
+ while (len--)
+ *Cursor++ = *s++;
+ return 0;
+}
+
+void
+DeleteBack(n) /* delete the n characters before . */
+ int n;
+{
+ if (n <= 0)
+ return;
+ if (Cursor >= &InputBuf[n]) {
+ c_delbefore(n); /* delete before dot */
+ if (n > Cursor - InputBuf)
+ Cursor = InputBuf; /* bounds check */
+ else
+ Cursor -= n;
+#if defined(DSPMBYTE)
+ if(_enable_mbdisp && extdel && Cursor > InputBuf) {
+ Cursor--;
+ e_redisp(1);
+ }
+#endif
+ }
+}
+
+CCRETVAL
+e_digit(c) /* gray magic here */
+ register int c;
+{
+ if (!Isdigit(c))
+ return(CC_ERROR); /* no NULs in the input ever!! */
+
+ if (DoingArg) { /* if doing an arg, add this in... */
+ if (LastCmd == F_ARGFOUR) /* if last command was ^U */
+ Argument = c - '0';
+ else {
+ if (Argument > 1000000)
+ return CC_ERROR;
+ Argument = (Argument * 10) + (c - '0');
+ }
+ return(CC_ARGHACK);
+ }
+ else {
+ if (LastChar + 1 >= InputLim)
+ return CC_ERROR; /* end of buffer space */
+
+ if (inputmode != MODE_INSERT) {
+ UndoBuf[UndoSize++] = *Cursor;
+ UndoBuf[UndoSize] = '\0';
+ c_delafter(1); /* Do NOT use the saving ONE */
+ }
+ c_insert(1);
+ *Cursor++ = (Char) c;
+ DoingArg = 0; /* just in case */
+ RefPlusOne(); /* fast refresh for one char. */
+ }
+ return(CC_NORM);
+}
+
+CCRETVAL
+e_argdigit(c) /* for ESC-n */
+ register int c;
+{
+ c &= ASCII;
+
+ if (!Isdigit(c))
+ return(CC_ERROR); /* no NULs in the input ever!! */
+
+ if (DoingArg) { /* if doing an arg, add this in... */
+ if (Argument > 1000000)
+ return CC_ERROR;
+ Argument = (Argument * 10) + (c - '0');
+ }
+ else { /* else starting an argument */
+ Argument = c - '0';
+ DoingArg = 1;
+ }
+ return(CC_ARGHACK);
+}
+
+CCRETVAL
+v_zero(c) /* command mode 0 for vi */
+ register int c;
+{
+ if (DoingArg) { /* if doing an arg, add this in... */
+ if (Argument > 1000000)
+ return CC_ERROR;
+ Argument = (Argument * 10) + (c - '0');
+ return(CC_ARGHACK);
+ }
+ else { /* else starting an argument */
+ Cursor = InputBuf;
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+ RefCursor(); /* move the cursor */
+ return(CC_NORM);
+ }
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_newline(c)
+ int c;
+{ /* always ignore argument */
+ USE(c);
+ /* PastBottom(); NOW done in ed.inputl.c */
+ *LastChar++ = '\n'; /* for the benefit of CSH */
+ *LastChar = '\0'; /* just in case */
+ if (VImode)
+ InsertPos = InputBuf; /* Reset editing position */
+ return(CC_NEWLINE);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_send_eof(c)
+ int c;
+{ /* for when ^D is ONLY send-eof */
+ USE(c);
+ PastBottom();
+ *LastChar = '\0'; /* just in case */
+ return(CC_EOF);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_complete(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_COMPLETE);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_complete_back(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_COMPLETE_BACK);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_complete_fwd(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_COMPLETE_FWD);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_complete_all(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_COMPLETE_ALL);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_cm_complete(c)
+ int c;
+{
+ USE(c);
+ if (Cursor < LastChar)
+ Cursor++;
+ *LastChar = '\0'; /* just in case */
+ return(CC_COMPLETE);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_toggle_hist(c)
+ int c;
+{
+ struct Hist *hp;
+ int h;
+
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+
+ if (Hist_num <= 0) {
+ return CC_ERROR;
+ }
+
+ hp = Histlist.Hnext;
+ if (hp == NULL) { /* this is only if no history */
+ return(CC_ERROR);
+ }
+
+ for (h = 1; h < Hist_num; h++)
+ hp = hp->Hnext;
+
+ if (!CurrentHistLit) {
+ if (hp->histline) {
+ copyn(InputBuf, hp->histline, INBUFSIZE);
+ CurrentHistLit = 1;
+ }
+ else {
+ return CC_ERROR;
+ }
+ }
+ else {
+ (void) sprlex(InputBuf, sizeof(InputBuf), &hp->Hlex);
+ CurrentHistLit = 0;
+ }
+
+ LastChar = InputBuf + Strlen(InputBuf);
+ if (LastChar > InputBuf) {
+ if (LastChar[-1] == '\n')
+ LastChar--;
+ if (LastChar[-1] == ' ')
+ LastChar--;
+ if (LastChar < InputBuf)
+ LastChar = InputBuf;
+ }
+
+#ifdef KSHVI
+ if (VImode)
+ Cursor = InputBuf;
+ else
+#endif /* KSHVI */
+ Cursor = LastChar;
+
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_up_hist(c)
+ int c;
+{
+ Char beep = 0;
+
+ USE(c);
+ UndoAction = TCSHOP_NOP;
+ *LastChar = '\0'; /* just in case */
+
+ if (Hist_num == 0) { /* save the current buffer away */
+ copyn(HistBuf, InputBuf, INBUFSIZE);
+ LastHist = HistBuf + (LastChar - InputBuf);
+ }
+
+ Hist_num += Argument;
+
+ if (c_get_histline() == CC_ERROR) {
+ beep = 1;
+ (void) c_get_histline(); /* Hist_num was fixed by first call */
+ }
+
+ Refresh();
+ if (beep)
+ return(CC_ERROR);
+ else
+ return(CC_NORM); /* was CC_UP_HIST */
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_down_hist(c)
+ int c;
+{
+ USE(c);
+ UndoAction = TCSHOP_NOP;
+ *LastChar = '\0'; /* just in case */
+
+ Hist_num -= Argument;
+
+ if (Hist_num < 0) {
+ Hist_num = 0;
+ return(CC_ERROR); /* make it beep */
+ }
+
+ return(c_get_histline());
+}
+
+
+
+/*
+ * c_hmatch() return True if the pattern matches the prefix
+ */
+static int
+c_hmatch(str)
+Char *str;
+{
+ if (Strncmp(patbuf, str, (size_t) patlen) == 0)
+ return 1;
+ return Gmatch(str, patbuf);
+}
+
+/*
+ * c_hsetpat(): Set the history seatch pattern
+ */
+static void
+c_hsetpat()
+{
+ if (LastCmd != F_UP_SEARCH_HIST && LastCmd != F_DOWN_SEARCH_HIST) {
+ patlen = (int) (Cursor - InputBuf);
+ if (patlen >= INBUFSIZE) patlen = INBUFSIZE -1;
+ if (patlen >= 0) {
+ (void) Strncpy(patbuf, InputBuf, (size_t) patlen);
+ patbuf[patlen] = '\0';
+ }
+ else
+ patlen = (int) Strlen(patbuf);
+ }
+#ifdef SDEBUG
+ xprintf("\nHist_num = %d\n", Hist_num);
+ xprintf("patlen = %d\n", patlen);
+ xprintf("patbuf = \"%S\"\n", patbuf);
+ xprintf("Cursor %d LastChar %d\n", Cursor - InputBuf, LastChar - InputBuf);
+#endif
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_up_search_hist(c)
+ int c;
+{
+ struct Hist *hp;
+ int h;
+ bool found = 0;
+
+ USE(c);
+ ActionFlag = TCSHOP_NOP;
+ UndoAction = TCSHOP_NOP;
+ *LastChar = '\0'; /* just in case */
+ if (Hist_num < 0) {
+#ifdef DEBUG_EDIT
+ xprintf("%s: e_up_search_hist(): Hist_num < 0; resetting.\n", progname);
+#endif
+ Hist_num = 0;
+ return(CC_ERROR);
+ }
+
+ if (Hist_num == 0)
+ {
+ copyn(HistBuf, InputBuf, INBUFSIZE);
+ LastHist = HistBuf + (LastChar - InputBuf);
+ }
+
+
+ hp = Histlist.Hnext;
+ if (hp == NULL)
+ return(CC_ERROR);
+
+ c_hsetpat(); /* Set search pattern !! */
+
+ for (h = 1; h <= Hist_num; h++)
+ hp = hp->Hnext;
+
+ while (hp != NULL) {
+ Char sbuf[INBUFSIZE], *hl;
+ if (hp->histline == NULL) {
+ hp->histline = Strsave(sprlex(sbuf, sizeof(sbuf), &hp->Hlex));
+ }
+ hl = HistLit ? hp->histline : sprlex(sbuf, sizeof(sbuf), &hp->Hlex);
+#ifdef SDEBUG
+ xprintf("Comparing with \"%S\"\n", hl);
+#endif
+ if ((Strncmp(hl, InputBuf, (size_t) (LastChar - InputBuf)) ||
+ hl[LastChar-InputBuf]) && c_hmatch(hl)) {
+ found++;
+ break;
+ }
+ h++;
+ hp = hp->Hnext;
+ }
+
+ if (!found) {
+#ifdef SDEBUG
+ xprintf("not found\n");
+#endif
+ return(CC_ERROR);
+ }
+
+ Hist_num = h;
+
+ return(c_get_histline());
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_down_search_hist(c)
+ int c;
+{
+ struct Hist *hp;
+ int h;
+ bool found = 0;
+
+ USE(c);
+ ActionFlag = TCSHOP_NOP;
+ UndoAction = TCSHOP_NOP;
+ *LastChar = '\0'; /* just in case */
+
+ if (Hist_num == 0)
+ return(CC_ERROR);
+
+ hp = Histlist.Hnext;
+ if (hp == 0)
+ return(CC_ERROR);
+
+ c_hsetpat(); /* Set search pattern !! */
+
+ for (h = 1; h < Hist_num && hp; h++) {
+ Char sbuf[INBUFSIZE], *hl;
+ if (hp->histline == NULL) {
+ hp->histline = Strsave(sprlex(sbuf, sizeof(sbuf), &hp->Hlex));
+ }
+ hl = HistLit ? hp->histline : sprlex(sbuf, sizeof(sbuf), &hp->Hlex);
+#ifdef SDEBUG
+ xprintf("Comparing with \"%S\"\n", hl);
+#endif
+ if ((Strncmp(hl, InputBuf, (size_t) (LastChar - InputBuf)) ||
+ hl[LastChar-InputBuf]) && c_hmatch(hl))
+ found = h;
+ hp = hp->Hnext;
+ }
+
+ if (!found) { /* is it the current history number? */
+ if (!c_hmatch(HistBuf)) {
+#ifdef SDEBUG
+ xprintf("not found\n");
+#endif
+ return(CC_ERROR);
+ }
+ }
+
+ Hist_num = found;
+
+ return(c_get_histline());
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_helpme(c)
+ int c;
+{
+ USE(c);
+ PastBottom();
+ *LastChar = '\0'; /* just in case */
+ return(CC_HELPME);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_correct(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_CORRECT);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_correctl(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_CORRECT_L);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_run_fg_editor(c)
+ int c;
+{
+ register struct process *pp;
+ extern bool tellwhat;
+
+ USE(c);
+ if ((pp = find_stop_ed()) != NULL) {
+ /* save our editor state so we can restore it */
+ tellwhat = 1;
+ copyn(WhichBuf, InputBuf, INBUFSIZE);
+ LastWhich = WhichBuf + (LastChar - InputBuf);
+ CursWhich = WhichBuf + (Cursor - InputBuf);
+ HistWhich = Hist_num;
+ Hist_num = 0; /* for the history commands */
+
+ /* put the tty in a sane mode */
+ PastBottom();
+ (void) Cookedmode(); /* make sure the tty is set up correctly */
+
+ /* do it! */
+ fg_proc_entry(pp);
+
+ (void) Rawmode(); /* go on */
+ Refresh();
+ tellwhat = 0;
+ }
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_list_choices(c)
+ int c;
+{
+ USE(c);
+ PastBottom();
+ *LastChar = '\0'; /* just in case */
+ return(CC_LIST_CHOICES);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_list_all(c)
+ int c;
+{
+ USE(c);
+ PastBottom();
+ *LastChar = '\0'; /* just in case */
+ return(CC_LIST_ALL);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_list_glob(c)
+ int c;
+{
+ USE(c);
+ PastBottom();
+ *LastChar = '\0'; /* just in case */
+ return(CC_LIST_GLOB);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_expand_glob(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_EXPAND_GLOB);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_normalize_path(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_NORMALIZE_PATH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_normalize_command(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_NORMALIZE_COMMAND);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_expand_vars(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ return(CC_EXPAND_VARS);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_which(c)
+ int c;
+{ /* do a fast command line which(1) */
+ USE(c);
+ PastBottom();
+ *LastChar = '\0'; /* just in case */
+ return(CC_WHICH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_last_item(c)
+ int c;
+{ /* insert the last element of the prev. cmd */
+ register Char *cp;
+ register struct Hist *hp;
+ register struct wordent *wp, *firstp;
+ register int i;
+ Char buf[INBUFSIZE];
+
+ USE(c);
+ if (Argument <= 0)
+ return(CC_ERROR);
+
+ hp = Histlist.Hnext;
+ if (hp == NULL) { /* this is only if no history */
+ return(CC_ERROR);
+ }
+
+ wp = (hp->Hlex).prev;
+
+ if (wp->prev == (struct wordent *) NULL)
+ return(CC_ERROR); /* an empty history entry */
+
+ firstp = (hp->Hlex).next;
+
+ /* back up arg words in lex */
+ for (i = 0; i < Argument && wp != firstp; i++) {
+ wp = wp->prev;
+ }
+
+ cp = expand_lex(buf, INBUFSIZE, wp->prev, 0, i - 1);
+ *cp = '\0';
+ if (InsertStr(buf))
+ return(CC_ERROR);
+
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_dabbrev_expand(c)
+ int c;
+{ /* expand to preceding word matching prefix */
+ register Char *cp, *ncp, *bp;
+ register struct Hist *hp;
+ register int arg = 0, len = 0, i; /* len = 0 to shut up gcc -Wall */
+ register bool found = 0;
+ Char hbuf[INBUFSIZE];
+ static int oldevent, hist, word;
+ static Char *start, *oldcursor;
+
+ USE(c);
+ if (Argument <= 0)
+ return(CC_ERROR);
+
+ cp = c_preword(Cursor, InputBuf, 1);
+ if (cp == Cursor || Isspace(*cp))
+ return(CC_ERROR);
+
+ hp = Histlist.Hnext;
+ bp = InputBuf;
+ if (Argument == 1 && eventno == oldevent && cp == start &&
+ Cursor == oldcursor && patlen > 0 && Strncmp(patbuf, cp, patlen) == 0){
+ /* continue previous search - go to last match (hist/word) */
+ if (hist != 0) { /* need to move up history */
+ for (i = 1; i < hist && hp != NULL; i++)
+ hp = hp->Hnext;
+ if (hp == NULL) /* "can't happen" */
+ return(CC_ERROR);
+ cp = expand_lex(hbuf, INBUFSIZE, &hp->Hlex, 0, NCARGS);
+ *cp = '\0';
+ bp = hbuf;
+ hp = hp->Hnext;
+ }
+ cp = c_preword(cp, bp, word);
+ } else { /* starting new search */
+ oldevent = eventno;
+ start = cp;
+ patlen = (int) (Cursor - cp);
+ (void) Strncpy(patbuf, cp, patlen);
+ hist = 0;
+ word = 0;
+ }
+
+ while (!found) {
+ ncp = c_preword(cp, bp, 1);
+ if (ncp == cp || Isspace(*ncp)) { /* beginning of line */
+ hist++;
+ word = 0;
+ if (hp == NULL)
+ return(CC_ERROR);
+ cp = expand_lex(hbuf, INBUFSIZE, &hp->Hlex, 0, NCARGS);
+ *cp = '\0';
+ bp = hbuf;
+ hp = hp->Hnext;
+ continue;
+ } else {
+ word++;
+ len = (int) (c_endword(ncp-1, cp, 1) - ncp + 1);
+ cp = ncp;
+ }
+ if (len > patlen && Strncmp(cp, patbuf, patlen) == 0) {
+ /* We don't fully check distinct matches as Gnuemacs does: */
+ if (Argument > 1) { /* just count matches */
+ if (++arg >= Argument)
+ found++;
+ } else { /* match if distinct from previous */
+ if (len != Cursor - start || Strncmp(cp, start, len) != 0)
+ found++;
+ }
+ }
+ }
+
+ if (LastChar + len - (Cursor - start) >= InputLim)
+ return(CC_ERROR); /* no room */
+ DeleteBack(Cursor - start);
+ c_insert(len);
+ while (len--)
+ *Cursor++ = *cp++;
+ oldcursor = Cursor;
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_yank_kill(c)
+ int c;
+{ /* almost like GnuEmacs */
+ register Char *kp, *cp;
+
+ USE(c);
+ if (LastKill == KillBuf) /* if zero content */
+ return(CC_ERROR);
+
+ if (LastChar + (LastKill - KillBuf) >= InputLim)
+ return(CC_ERROR); /* end of buffer space */
+
+ /* else */
+ Mark = Cursor; /* set the mark */
+ cp = Cursor; /* for speed */
+
+ c_insert((int)(LastKill - KillBuf)); /* open the space, */
+ for (kp = KillBuf; kp < LastKill; kp++) /* copy the chars */
+ *cp++ = *kp;
+
+ if (Argument == 1) /* if an arg, cursor at beginning */
+ Cursor = cp; /* else cursor at end */
+
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_delprev(c) /* Backspace key in insert mode */
+ int c;
+{
+ int rc;
+
+ USE(c);
+ rc = CC_ERROR;
+
+ if (InsertPos != 0) {
+ if (Argument <= Cursor - InsertPos) {
+ c_delbefore(Argument); /* delete before */
+ Cursor -= Argument;
+#if defined(DSPMBYTE)
+ if (_enable_mbdisp && extdel) {
+ Cursor--;
+ e_redisp(c);
+ }
+#endif
+ rc = CC_REFRESH;
+ }
+ }
+ return(rc);
+} /* v_delprev */
+
+/*ARGSUSED*/
+CCRETVAL
+e_delprev(c)
+ int c;
+{
+ USE(c);
+ if (Cursor > InputBuf) {
+ c_delbefore(Argument); /* delete before dot */
+ if (Argument > Cursor - InputBuf)
+ Cursor = InputBuf; /* bounds check */
+ else
+ Cursor -= Argument;
+#if defined(DSPMBYTE)
+ if (_enable_mbdisp && extdel && Cursor > InputBuf) {
+ Cursor--;
+ e_redisp(c);
+ }
+#endif
+ return(CC_REFRESH);
+ }
+ else {
+ return(CC_ERROR);
+ }
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_delwordprev(c)
+ int c;
+{
+ register Char *cp, *p, *kp;
+
+ USE(c);
+ if (Cursor == InputBuf)
+ return(CC_ERROR);
+ /* else */
+
+ cp = c_prev_word(Cursor, InputBuf, Argument);
+
+ for (p = cp, kp = KillBuf; p < Cursor; p++) /* save the text */
+ *kp++ = *p;
+ LastKill = kp;
+
+ c_delbefore((int)(Cursor - cp)); /* delete before dot */
+ Cursor = cp;
+ if (Cursor < InputBuf)
+ Cursor = InputBuf; /* bounds check */
+ return(CC_REFRESH);
+}
+
+/* DCS <dcs@neutron.chem.yale.edu>, 9 Oct 93
+ *
+ * Changed the names of some of the ^D family of editor functions to
+ * correspond to what they actually do and created new e_delnext_list
+ * for completeness.
+ *
+ * Old names: New names:
+ *
+ * delete-char delete-char-or-eof
+ * F_DELNEXT F_DELNEXT_EOF
+ * e_delnext e_delnext_eof
+ * edelnxt edelnxteof
+ * delete-char-or-eof delete-char
+ * F_DELNEXT_EOF F_DELNEXT
+ * e_delnext_eof e_delnext
+ * edelnxteof edelnxt
+ * delete-char-or-list delete-char-or-list-or-eof
+ * F_LIST_DELNEXT F_DELNEXT_LIST_EOF
+ * e_list_delnext e_delnext_list_eof
+ * edellsteof
+ * (no old equivalent) delete-char-or-list
+ * F_DELNEXT_LIST
+ * e_delnext_list
+ * e_delnxtlst
+ */
+
+/* added by mtk@ari.ncl.omron.co.jp (920818) */
+/* rename e_delnext() -> e_delnext_eof() */
+/*ARGSUSED*/
+CCRETVAL
+e_delnext(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == LastChar) {/* if I'm at the end */
+ if (!VImode) {
+ return(CC_ERROR);
+ }
+ else {
+ if (Cursor != InputBuf)
+ Cursor--;
+ else
+ return(CC_ERROR);
+ }
+ }
+ c_delafter(Argument); /* delete after dot */
+ if (Cursor > LastChar)
+ Cursor = LastChar; /* bounds check */
+ return(CC_REFRESH);
+}
+
+
+/*ARGSUSED*/
+CCRETVAL
+e_delnext_eof(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == LastChar) {/* if I'm at the end */
+ if (!VImode) {
+ if (Cursor == InputBuf) {
+ /* if I'm also at the beginning */
+ so_write(STReof, 4);/* then do a EOF */
+ flush();
+ return(CC_EOF);
+ }
+ else
+ return(CC_ERROR);
+ }
+ else {
+ if (Cursor != InputBuf)
+ Cursor--;
+ else
+ return(CC_ERROR);
+ }
+ }
+ c_delafter(Argument); /* delete after dot */
+ if (Cursor > LastChar)
+ Cursor = LastChar; /* bounds check */
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_delnext_list(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == LastChar) { /* if I'm at the end */
+ PastBottom();
+ *LastChar = '\0'; /* just in case */
+ return(CC_LIST_CHOICES);
+ }
+ else {
+ c_delafter(Argument); /* delete after dot */
+ if (Cursor > LastChar)
+ Cursor = LastChar; /* bounds check */
+ return(CC_REFRESH);
+ }
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_delnext_list_eof(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == LastChar) { /* if I'm at the end */
+ if (Cursor == InputBuf) { /* if I'm also at the beginning */
+ so_write(STReof, 4);/* then do a EOF */
+ flush();
+ return(CC_EOF);
+ }
+ else {
+ PastBottom();
+ *LastChar = '\0'; /* just in case */
+ return(CC_LIST_CHOICES);
+ }
+ }
+ else {
+ c_delafter(Argument); /* delete after dot */
+ if (Cursor > LastChar)
+ Cursor = LastChar; /* bounds check */
+ return(CC_REFRESH);
+ }
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_list_eof(c)
+ int c;
+{
+ CCRETVAL rv;
+
+ USE(c);
+ if (Cursor == LastChar && Cursor == InputBuf) {
+ so_write(STReof, 4); /* then do a EOF */
+ flush();
+ rv = CC_EOF;
+ }
+ else {
+ PastBottom();
+ *LastChar = '\0'; /* just in case */
+ rv = CC_LIST_CHOICES;
+ }
+ return rv;
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_delwordnext(c)
+ int c;
+{
+ register Char *cp, *p, *kp;
+
+ USE(c);
+ if (Cursor == LastChar)
+ return(CC_ERROR);
+ /* else */
+
+ cp = c_next_word(Cursor, LastChar, Argument);
+
+ for (p = Cursor, kp = KillBuf; p < cp; p++) /* save the text */
+ *kp++ = *p;
+ LastKill = kp;
+
+ c_delafter((int)(cp - Cursor)); /* delete after dot */
+ if (Cursor > LastChar)
+ Cursor = LastChar; /* bounds check */
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_toend(c)
+ int c;
+{
+ USE(c);
+ Cursor = LastChar;
+ if (VImode)
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+ RefCursor(); /* move the cursor */
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_tobeg(c)
+ int c;
+{
+ USE(c);
+ Cursor = InputBuf;
+
+ if (VImode) {
+ while (Isspace(*Cursor)) /* We want FIRST non space character */
+ Cursor++;
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+ }
+
+ RefCursor(); /* move the cursor */
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_killend(c)
+ int c;
+{
+ register Char *kp, *cp;
+
+ USE(c);
+ cp = Cursor;
+ kp = KillBuf;
+ while (cp < LastChar)
+ *kp++ = *cp++; /* copy it */
+ LastKill = kp;
+ LastChar = Cursor; /* zap! -- delete to end */
+ return(CC_REFRESH);
+}
+
+
+/*ARGSUSED*/
+CCRETVAL
+e_killbeg(c)
+ int c;
+{
+ register Char *kp, *cp;
+
+ USE(c);
+ cp = InputBuf;
+ kp = KillBuf;
+ while (cp < Cursor)
+ *kp++ = *cp++; /* copy it */
+ LastKill = kp;
+ c_delbefore((int)(Cursor - InputBuf));
+ Cursor = InputBuf; /* zap! */
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_killall(c)
+ int c;
+{
+ register Char *kp, *cp;
+
+ USE(c);
+ cp = InputBuf;
+ kp = KillBuf;
+ while (cp < LastChar)
+ *kp++ = *cp++; /* copy it */
+ LastKill = kp;
+ LastChar = InputBuf; /* zap! -- delete all of it */
+ Cursor = InputBuf;
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_killregion(c)
+ int c;
+{
+ register Char *kp, *cp;
+
+ USE(c);
+ if (!Mark)
+ return(CC_ERROR);
+
+ if (Mark > Cursor) {
+ cp = Cursor;
+ kp = KillBuf;
+ while (cp < Mark)
+ *kp++ = *cp++; /* copy it */
+ LastKill = kp;
+ c_delafter((int)(cp - Cursor)); /* delete it - UNUSED BY VI mode */
+ }
+ else { /* mark is before cursor */
+ cp = Mark;
+ kp = KillBuf;
+ while (cp < Cursor)
+ *kp++ = *cp++; /* copy it */
+ LastKill = kp;
+ c_delbefore((int)(cp - Mark));
+ Cursor = Mark;
+ }
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_copyregion(c)
+ int c;
+{
+ register Char *kp, *cp;
+
+ USE(c);
+ if (!Mark)
+ return(CC_ERROR);
+
+ if (Mark > Cursor) {
+ cp = Cursor;
+ kp = KillBuf;
+ while (cp < Mark)
+ *kp++ = *cp++; /* copy it */
+ LastKill = kp;
+ }
+ else { /* mark is before cursor */
+ cp = Mark;
+ kp = KillBuf;
+ while (cp < Cursor)
+ *kp++ = *cp++; /* copy it */
+ LastKill = kp;
+ }
+ return(CC_NORM); /* don't even need to Refresh() */
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_charswitch(cc)
+ int cc;
+{
+ register Char c;
+
+ USE(cc);
+
+ /* do nothing if we are at beginning of line or have only one char */
+ if (Cursor == &InputBuf[0] || LastChar == &InputBuf[1]) {
+ return(CC_ERROR);
+ }
+
+ if (Cursor < LastChar) {
+ Cursor++;
+ }
+ c = Cursor[-2];
+ Cursor[-2] = Cursor[-1];
+ Cursor[-1] = c;
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_gcharswitch(cc)
+ int cc;
+{ /* gosmacs style ^T */
+ register Char c;
+
+ USE(cc);
+ if (Cursor > &InputBuf[1]) {/* must have at least two chars entered */
+ c = Cursor[-2];
+ Cursor[-2] = Cursor[-1];
+ Cursor[-1] = c;
+ return(CC_REFRESH);
+ }
+ else {
+ return(CC_ERROR);
+ }
+}
+
+#if defined(DSPMBYTE) /* BY TAGA Nayuta VERY THANKS */
+/*ARGSUSED*/
+static void
+e_charback_mbyte(argument)
+ int argument;
+{
+ if (!_enable_mbdisp) {
+ if (Argument > Cursor - InputBuf)
+ Cursor = InputBuf;
+ else
+ Cursor -= Argument;
+ }
+ else {
+ while (0 < argument && Cursor > InputBuf) {
+ if (Cursor - 1 != InputBuf &&
+ Ismbyte1(*(Cursor - 2)) && Ismbyte2(*(Cursor - 1))) {
+ Cursor--;
+ }
+ Cursor--;
+ argument--;
+ }
+ }
+}
+#endif
+
+/*ARGSUSED*/
+CCRETVAL
+e_charback(c)
+ int c;
+{
+ USE(c);
+ if (Cursor > InputBuf) {
+#if defined(DSPMBYTE) /* BY TAGA Nayuta VERY THANKS */
+ e_charback_mbyte(Argument);
+#else
+ if (Argument > Cursor - InputBuf)
+ Cursor = InputBuf;
+ else
+ Cursor -= Argument;
+#endif
+
+ if (VImode)
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+ }
+ else {
+ return(CC_ERROR);
+ }
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_wordback(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == InputBuf)
+ return(CC_ERROR);
+ /* else */
+
+ Cursor = c_preword(Cursor, InputBuf, Argument); /* bounds check */
+
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_wordback(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == InputBuf)
+ return(CC_ERROR);
+ /* else */
+
+ Cursor = c_prev_word(Cursor, InputBuf, Argument); /* bounds check */
+
+ if (VImode)
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+}
+
+#if defined(DSPMBYTE) /* BY TAGA Nayuta VERY THANKS */
+/*ARGSUSED*/
+static void
+e_charfwd_mbyte(argument)
+ int argument;
+{
+ if (!_enable_mbdisp)
+ Cursor += argument;
+ else
+ while (0 < argument && Cursor < LastChar) {
+ if (Cursor + 1 != LastChar &&
+ Ismbyte1(*Cursor) && Ismbyte2(*(Cursor + 1))) {
+ Cursor++;
+ }
+ Cursor++;
+ argument--;
+ }
+}
+#endif
+
+/*ARGSUSED*/
+CCRETVAL
+e_charfwd(c)
+ int c;
+{
+ USE(c);
+ if (Cursor < LastChar) {
+#if defined(DSPMBYTE) /* BY TAGA Nayuta VERY THANKS */
+ e_charfwd_mbyte(Argument);
+#else
+ Cursor += Argument;
+#endif
+ if (Cursor > LastChar)
+ Cursor = LastChar;
+
+ if (VImode)
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+ }
+ else {
+ return(CC_ERROR);
+ }
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_wordfwd(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == LastChar)
+ return(CC_ERROR);
+ /* else */
+
+ Cursor = c_next_word(Cursor, LastChar, Argument);
+
+ if (VImode)
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_wordfwd(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == LastChar)
+ return(CC_ERROR);
+ /* else */
+
+ Cursor = c_nexword(Cursor, LastChar, Argument);
+
+ if (VImode)
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_wordbegnext(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == LastChar)
+ return(CC_ERROR);
+ /* else */
+
+ Cursor = c_next_word(Cursor, LastChar, Argument);
+ if (Cursor < LastChar)
+ Cursor++;
+
+ if (VImode)
+ if (ActionFlag & TCSHOP_DELETE) {
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+static CCRETVAL
+v_repeat_srch(c)
+ int c;
+{
+ CCRETVAL rv = CC_ERROR;
+#ifdef SDEBUG
+ xprintf("dir %d patlen %d patbuf %S\n",
+ c, patlen, patbuf);
+#endif
+
+ LastCmd = (KEYCMD) c; /* Hack to stop c_hsetpat */
+ LastChar = InputBuf;
+ switch (c) {
+ case F_DOWN_SEARCH_HIST:
+ rv = e_down_search_hist(0);
+ break;
+ case F_UP_SEARCH_HIST:
+ rv = e_up_search_hist(0);
+ break;
+ default:
+ break;
+ }
+ return rv;
+}
+
+static CCRETVAL
+v_csearch_back(ch, count, tflag)
+ int ch, count, tflag;
+{
+ Char *cp;
+
+ cp = Cursor;
+ while (count--) {
+ if (*cp == ch)
+ cp--;
+ while (cp > InputBuf && *cp != ch)
+ cp--;
+ }
+
+ if (cp < InputBuf || (cp == InputBuf && *cp != ch))
+ return(CC_ERROR);
+
+ if (*cp == ch && tflag)
+ cp++;
+
+ Cursor = cp;
+
+ if (ActionFlag & TCSHOP_DELETE) {
+ Cursor++;
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+}
+
+static CCRETVAL
+v_csearch_fwd(ch, count, tflag)
+ int ch, count, tflag;
+{
+ Char *cp;
+
+ cp = Cursor;
+ while (count--) {
+ if(*cp == ch)
+ cp++;
+ while (cp < LastChar && *cp != ch)
+ cp++;
+ }
+
+ if (cp >= LastChar)
+ return(CC_ERROR);
+
+ if (*cp == ch && tflag)
+ cp--;
+
+ Cursor = cp;
+
+ if (ActionFlag & TCSHOP_DELETE) {
+ Cursor++;
+ c_delfini();
+ return(CC_REFRESH);
+ }
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+static CCRETVAL
+v_action(c)
+ int c;
+{
+ register Char *cp, *kp;
+
+ if (ActionFlag == TCSHOP_DELETE) {
+ ActionFlag = TCSHOP_NOP;
+ ActionPos = 0;
+
+ UndoSize = 0;
+ kp = UndoBuf;
+ for (cp = InputBuf; cp < LastChar; cp++) {
+ *kp++ = *cp;
+ UndoSize++;
+ }
+
+ UndoAction = TCSHOP_INSERT;
+ UndoPtr = InputBuf;
+ LastChar = InputBuf;
+ Cursor = InputBuf;
+ if (c & TCSHOP_INSERT)
+ c_alternativ_key_map(0);
+
+ return(CC_REFRESH);
+ }
+#ifdef notdef
+ else if (ActionFlag == TCSHOP_NOP) {
+#endif
+ ActionPos = Cursor;
+ ActionFlag = c;
+ return(CC_ARGHACK); /* Do NOT clear out argument */
+#ifdef notdef
+ }
+ else {
+ ActionFlag = 0;
+ ActionPos = 0;
+ return(CC_ERROR);
+ }
+#endif
+}
+
+#ifdef COMMENT
+/* by: Brian Allison <uiucdcs!convex!allison@RUTGERS.EDU> */
+static void
+c_get_word(begin, end)
+ Char **begin;
+ Char **end;
+{
+ Char *cp;
+
+ cp = &Cursor[0];
+ while (Argument--) {
+ while ((cp <= LastChar) && (isword(*cp)))
+ cp++;
+ *end = --cp;
+ while ((cp >= InputBuf) && (isword(*cp)))
+ cp--;
+ *begin = ++cp;
+ }
+}
+#endif /* COMMENT */
+
+/*ARGSUSED*/
+CCRETVAL
+e_uppercase(c)
+ int c;
+{
+ Char *cp, *end;
+
+ USE(c);
+ end = c_next_word(Cursor, LastChar, Argument);
+
+ for (cp = Cursor; cp < end; cp++) /* PWP: was cp=begin */
+ if (Islower(*cp))
+ *cp = Toupper(*cp);
+
+ Cursor = end;
+ if (Cursor > LastChar)
+ Cursor = LastChar;
+ return(CC_REFRESH);
+}
+
+
+/*ARGSUSED*/
+CCRETVAL
+e_capitolcase(c)
+ int c;
+{
+ Char *cp, *end;
+
+ USE(c);
+ end = c_next_word(Cursor, LastChar, Argument);
+
+ cp = Cursor;
+ for (; cp < end; cp++) {
+ if (Isalpha(*cp)) {
+ if (Islower(*cp))
+ *cp = Toupper(*cp);
+ cp++;
+ break;
+ }
+ }
+ for (; cp < end; cp++)
+ if (Isupper(*cp))
+ *cp = Tolower(*cp);
+
+ Cursor = end;
+ if (Cursor > LastChar)
+ Cursor = LastChar;
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_lowercase(c)
+ int c;
+{
+ Char *cp, *end;
+
+ USE(c);
+ end = c_next_word(Cursor, LastChar, Argument);
+
+ for (cp = Cursor; cp < end; cp++)
+ if (Isupper(*cp))
+ *cp = Tolower(*cp);
+
+ Cursor = end;
+ if (Cursor > LastChar)
+ Cursor = LastChar;
+ return(CC_REFRESH);
+}
+
+
+/*ARGSUSED*/
+CCRETVAL
+e_set_mark(c)
+ int c;
+{
+ USE(c);
+ Mark = Cursor;
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_exchange_mark(c)
+ int c;
+{
+ register Char *cp;
+
+ USE(c);
+ cp = Cursor;
+ Cursor = Mark;
+ Mark = cp;
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_argfour(c)
+ int c;
+{ /* multiply current argument by 4 */
+ USE(c);
+ if (Argument > 1000000)
+ return CC_ERROR;
+ DoingArg = 1;
+ Argument *= 4;
+ return(CC_ARGHACK);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_quote(c)
+ int c;
+{
+ Char ch;
+ int num;
+
+ USE(c);
+ QuoteModeOn();
+ num = GetNextChar(&ch);
+ QuoteModeOff();
+ if (num == 1)
+ return e_insert(ch);
+ else
+ return e_send_eof(0);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_metanext(c)
+ int c;
+{
+ USE(c);
+ MetaNext = 1;
+ return(CC_ARGHACK); /* preserve argument */
+}
+
+#ifdef notdef
+/*ARGSUSED*/
+CCRETVAL
+e_extendnext(c)
+ int c;
+{
+ CurrentKeyMap = CcAltMap;
+ return(CC_ARGHACK); /* preserve argument */
+}
+
+#endif
+
+/*ARGSUSED*/
+CCRETVAL
+v_insbeg(c)
+ int c;
+{ /* move to beginning of line and start vi
+ * insert mode */
+ USE(c);
+ Cursor = InputBuf;
+ InsertPos = Cursor;
+
+ UndoPtr = Cursor;
+ UndoAction = TCSHOP_DELETE;
+
+ RefCursor(); /* move the cursor */
+ c_alternativ_key_map(0);
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_replone(c)
+ int c;
+{ /* vi mode overwrite one character */
+ USE(c);
+ c_alternativ_key_map(0);
+ inputmode = MODE_REPLACE_1;
+ UndoAction = TCSHOP_CHANGE; /* Set Up for VI undo command */
+ UndoPtr = Cursor;
+ UndoSize = 0;
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_replmode(c)
+ int c;
+{ /* vi mode start overwriting */
+ USE(c);
+ c_alternativ_key_map(0);
+ inputmode = MODE_REPLACE;
+ UndoAction = TCSHOP_CHANGE; /* Set Up for VI undo command */
+ UndoPtr = Cursor;
+ UndoSize = 0;
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_substchar(c)
+ int c;
+{ /* vi mode substitute for one char */
+ USE(c);
+ c_delafter(Argument);
+ c_alternativ_key_map(0);
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_substline(c)
+ int c;
+{ /* vi mode replace whole line */
+ USE(c);
+ (void) e_killall(0);
+ c_alternativ_key_map(0);
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_chgtoend(c)
+ int c;
+{ /* vi mode change to end of line */
+ USE(c);
+ (void) e_killend(0);
+ c_alternativ_key_map(0);
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_insert(c)
+ int c;
+{ /* vi mode start inserting */
+ USE(c);
+ c_alternativ_key_map(0);
+
+ InsertPos = Cursor;
+ UndoPtr = Cursor;
+ UndoAction = TCSHOP_DELETE;
+
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_add(c)
+ int c;
+{ /* vi mode start adding */
+ USE(c);
+ c_alternativ_key_map(0);
+ if (Cursor < LastChar)
+ {
+ Cursor++;
+ if (Cursor > LastChar)
+ Cursor = LastChar;
+ RefCursor();
+ }
+
+ InsertPos = Cursor;
+ UndoPtr = Cursor;
+ UndoAction = TCSHOP_DELETE;
+
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_addend(c)
+ int c;
+{ /* vi mode to add at end of line */
+ USE(c);
+ c_alternativ_key_map(0);
+ Cursor = LastChar;
+
+ InsertPos = LastChar; /* Mark where insertion begins */
+ UndoPtr = LastChar;
+ UndoAction = TCSHOP_DELETE;
+
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_change_case(cc)
+ int cc;
+{
+ char c;
+
+ USE(cc);
+ if (Cursor < LastChar) {
+#ifndef WINNT
+ c = *Cursor;
+#else
+ c = CHAR & *Cursor;
+#endif /* WINNT */
+ if (Isupper(c))
+ *Cursor++ = Tolower(c);
+ else if (Islower(c))
+ *Cursor++ = Toupper(c);
+ else
+ Cursor++;
+ RefPlusOne(); /* fast refresh for one char */
+ return(CC_NORM);
+ }
+ return(CC_ERROR);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_expand(c)
+ int c;
+{
+ register Char *p;
+ extern bool justpr;
+
+ USE(c);
+ for (p = InputBuf; Isspace(*p); p++)
+ continue;
+ if (p == LastChar)
+ return(CC_ERROR);
+
+ justpr++;
+ Expand++;
+ return(e_newline(0));
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_startover(c)
+ int c;
+{ /* erase all of current line, start again */
+ USE(c);
+ ResetInLine(0); /* reset the input pointers */
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_redisp(c)
+ int c;
+{
+ USE(c);
+ ClearLines();
+ ClearDisp();
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_cleardisp(c)
+ int c;
+{
+ USE(c);
+ ClearScreen(); /* clear the whole real screen */
+ ClearDisp(); /* reset everything */
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_tty_int(c)
+ int c;
+{
+ USE(c);
+#if defined(_MINIX) || defined(WINNT)
+ /* SAK PATCH: erase all of current line, start again */
+ ResetInLine(0); /* reset the input pointers */
+ xputchar('\n');
+ ClearDisp();
+ return (CC_REFRESH);
+#else /* !_MINIX && !WINNT */
+ /* do no editing */
+ return (CC_NORM);
+#endif /* _MINIX || WINNT */
+}
+
+/*
+ * From: ghazi@cesl.rutgers.edu (Kaveh R. Ghazi)
+ * Function to send a character back to the input stream in cooked
+ * mode. Only works if we have TIOCSTI
+ */
+/*ARGSUSED*/
+CCRETVAL
+e_stuff_char(c)
+ int c;
+{
+#ifdef TIOCSTI
+ extern int Tty_raw_mode;
+ int was_raw = Tty_raw_mode;
+ char ch = (char) c;
+
+ if (was_raw)
+ (void) Cookedmode();
+
+ (void) write(SHIN, "\n", 1);
+ (void) ioctl(SHIN, TIOCSTI, (ioctl_t) &ch);
+
+ if (was_raw)
+ (void) Rawmode();
+ return(e_redisp(c));
+#else /* !TIOCSTI */
+ return(CC_ERROR);
+#endif /* !TIOCSTI */
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_insovr(c)
+ int c;
+{
+ USE(c);
+ inputmode = (inputmode == MODE_INSERT ? MODE_REPLACE : MODE_INSERT);
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_tty_dsusp(c)
+ int c;
+{
+ USE(c);
+ /* do no editing */
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_tty_flusho(c)
+ int c;
+{
+ USE(c);
+ /* do no editing */
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_tty_quit(c)
+ int c;
+{
+ USE(c);
+ /* do no editing */
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_tty_tsusp(c)
+ int c;
+{
+ USE(c);
+ /* do no editing */
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_tty_stopo(c)
+ int c;
+{
+ USE(c);
+ /* do no editing */
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_expand_history(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ c_substitute();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_magic_space(c)
+ int c;
+{
+ USE(c);
+ *LastChar = '\0'; /* just in case */
+ c_substitute();
+ return(e_insert(' '));
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_inc_fwd(c)
+ int c;
+{
+ USE(c);
+ patlen = 0;
+ return e_inc_search(F_DOWN_SEARCH_HIST);
+}
+
+
+/*ARGSUSED*/
+CCRETVAL
+e_inc_back(c)
+ int c;
+{
+ USE(c);
+ patlen = 0;
+ return e_inc_search(F_UP_SEARCH_HIST);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_copyprev(c)
+ int c;
+{
+ register Char *cp, *oldc, *dp;
+
+ USE(c);
+ if (Cursor == InputBuf)
+ return(CC_ERROR);
+ /* else */
+
+ oldc = Cursor;
+ /* does a bounds check */
+ cp = c_prev_word(Cursor, InputBuf, Argument);
+
+ c_insert((int)(oldc - cp));
+ for (dp = oldc; cp < oldc && dp < LastChar; cp++)
+ *dp++ = *cp;
+
+ Cursor = dp; /* put cursor at end */
+
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_tty_starto(c)
+ int c;
+{
+ USE(c);
+ /* do no editing */
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+e_load_average(c)
+ int c;
+{
+ USE(c);
+ PastBottom();
+#ifdef TIOCSTAT
+ /*
+ * Here we pass &c to the ioctl because some os's (NetBSD) expect it
+ * there even if they don't use it. (lukem@netbsd.org)
+ */
+ if (ioctl(SHIN, TIOCSTAT, (ioctl_t) &c) < 0)
+#endif
+ xprintf(CGETS(5, 1, "Load average unavailable\n"));
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_chgmeta(c)
+ int c;
+{
+ USE(c);
+ /*
+ * Delete with insert == change: first we delete and then we leave in
+ * insert mode.
+ */
+ return(v_action(TCSHOP_DELETE|TCSHOP_INSERT));
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_delmeta(c)
+ int c;
+{
+ USE(c);
+ return(v_action(TCSHOP_DELETE));
+}
+
+
+/*ARGSUSED*/
+CCRETVAL
+v_endword(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == LastChar)
+ return(CC_ERROR);
+ /* else */
+
+ Cursor = c_endword(Cursor, LastChar, Argument);
+
+ if (ActionFlag & TCSHOP_DELETE)
+ {
+ Cursor++;
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_eword(c)
+ int c;
+{
+ USE(c);
+ if (Cursor == LastChar)
+ return(CC_ERROR);
+ /* else */
+
+ Cursor = c_eword(Cursor, LastChar, Argument);
+
+ if (ActionFlag & TCSHOP_DELETE) {
+ Cursor++;
+ c_delfini();
+ return(CC_REFRESH);
+ }
+
+ RefCursor();
+ return(CC_NORM);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_char_fwd(c)
+ int c;
+{
+ Char ch;
+
+ USE(c);
+ if (GetNextChar(&ch) != 1)
+ return e_send_eof(0);
+
+ srch_dir = CHAR_FWD;
+ srch_char = ch;
+
+ return v_csearch_fwd(ch, Argument, 0);
+
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_char_back(c)
+ int c;
+{
+ Char ch;
+
+ USE(c);
+ if (GetNextChar(&ch) != 1)
+ return e_send_eof(0);
+
+ srch_dir = CHAR_BACK;
+ srch_char = ch;
+
+ return v_csearch_back(ch, Argument, 0);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_charto_fwd(c)
+ int c;
+{
+ Char ch;
+
+ USE(c);
+ if (GetNextChar(&ch) != 1)
+ return e_send_eof(0);
+
+ return v_csearch_fwd(ch, Argument, 1);
+
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_charto_back(c)
+ int c;
+{
+ Char ch;
+
+ USE(c);
+ if (GetNextChar(&ch) != 1)
+ return e_send_eof(0);
+
+ return v_csearch_back(ch, Argument, 1);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_rchar_fwd(c)
+ int c;
+{
+ USE(c);
+ if (srch_char == 0)
+ return CC_ERROR;
+
+ return srch_dir == CHAR_FWD ? v_csearch_fwd(srch_char, Argument, 0) :
+ v_csearch_back(srch_char, Argument, 0);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_rchar_back(c)
+ int c;
+{
+ USE(c);
+ if (srch_char == 0)
+ return CC_ERROR;
+
+ return srch_dir == CHAR_BACK ? v_csearch_fwd(srch_char, Argument, 0) :
+ v_csearch_back(srch_char, Argument, 0);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_undo(c)
+ int c;
+{
+ register int loop;
+ register Char *kp, *cp;
+ Char temp;
+ int size;
+
+ USE(c);
+ switch (UndoAction) {
+ case TCSHOP_DELETE|TCSHOP_INSERT:
+ case TCSHOP_DELETE:
+ if (UndoSize == 0) return(CC_NORM);
+ cp = UndoPtr;
+ kp = UndoBuf;
+ for (loop=0; loop < UndoSize; loop++) /* copy the chars */
+ *kp++ = *cp++; /* into UndoBuf */
+
+ for (cp = UndoPtr; cp <= LastChar; cp++)
+ *cp = cp[UndoSize];
+
+ LastChar -= UndoSize;
+ Cursor = UndoPtr;
+
+ UndoAction = TCSHOP_INSERT;
+ break;
+
+ case TCSHOP_INSERT:
+ if (UndoSize == 0) return(CC_NORM);
+ cp = UndoPtr;
+ Cursor = UndoPtr;
+ kp = UndoBuf;
+ c_insert(UndoSize); /* open the space, */
+ for (loop = 0; loop < UndoSize; loop++) /* copy the chars */
+ *cp++ = *kp++;
+
+ UndoAction = TCSHOP_DELETE;
+ break;
+
+ case TCSHOP_CHANGE:
+ if (UndoSize == 0) return(CC_NORM);
+ cp = UndoPtr;
+ Cursor = UndoPtr;
+ kp = UndoBuf;
+ size = (int)(Cursor-LastChar); /* NOT NSL independant */
+ if (size < UndoSize)
+ size = UndoSize;
+ for(loop = 0; loop < size; loop++) {
+ temp = *kp;
+ *kp++ = *cp;
+ *cp++ = temp;
+ }
+ break;
+
+ default:
+ return(CC_ERROR);
+ }
+
+ return(CC_REFRESH);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_ush_meta(c)
+ int c;
+{
+ USE(c);
+ return v_search(F_UP_SEARCH_HIST);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_dsh_meta(c)
+ int c;
+{
+ USE(c);
+ return v_search(F_DOWN_SEARCH_HIST);
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_rsrch_fwd(c)
+ int c;
+{
+ USE(c);
+ if (patlen == 0) return(CC_ERROR);
+ return(v_repeat_srch(searchdir));
+}
+
+/*ARGSUSED*/
+CCRETVAL
+v_rsrch_back(c)
+ int c;
+{
+ USE(c);
+ if (patlen == 0) return(CC_ERROR);
+ return(v_repeat_srch(searchdir == F_UP_SEARCH_HIST ?
+ F_DOWN_SEARCH_HIST : F_UP_SEARCH_HIST));
+}
+
+#ifndef WINNT
+/* Since ed.defns.h is generated from ed.defns.c, these empty
+ functions will keep the F_NUM_FNS consistent
+ */
+CCRETVAL
+e_copy_to_clipboard(c)
+ int c;
+{
+ USE(c);
+ return CC_ERROR;
+}
+
+CCRETVAL
+e_paste_from_clipboard(c)
+ int c;
+{
+ USE(c);
+ return (CC_ERROR);
+}
+
+CCRETVAL
+e_dosify_next(c)
+ int c;
+{
+ USE(c);
+ return (CC_ERROR);
+}
+CCRETVAL
+e_dosify_prev(c)
+ int c;
+{
+ USE(c);
+ return (CC_ERROR);
+}
+#else /* WINNT */
+/*ARGSUSED*/
+CCRETVAL
+e_dosify_next(c)
+ int c;
+{
+ register Char *cp, *p, *kp;
+
+ USE(c);
+ if (Cursor == LastChar)
+ return(CC_ERROR);
+ /* else */
+
+ cp = Cursor;
+ while( cp < LastChar) {
+ if ( (*cp & CHAR == ' ') && (cp[-1] & CHAR != '\\') )
+ break;
+ cp++;
+ }
+
+ for (p = Cursor, kp = KillBuf; p < cp; p++) {/* save the text */
+ if ( ( *p & CHAR ) == '/') {
+ *kp++ = '\\';
+ *kp++ = '\\';
+ }
+ else
+ *kp++ = *p;
+ }
+ LastKill = kp;
+
+ c_delafter((int)(cp - Cursor)); /* delete after dot */
+ if (Cursor > LastChar)
+ Cursor = LastChar; /* bounds check */
+ return (e_yank_kill(c));
+}
+/*ARGSUSED*/
+CCRETVAL
+e_dosify_prev(c)
+ int c;
+{
+ register Char *cp, *p, *kp;
+
+ USE(c);
+ if (Cursor == InputBuf)
+ return(CC_ERROR);
+ /* else */
+
+ cp = Cursor-1;
+ /* Skip trailing spaces */
+ while ((cp > InputBuf) && ( (*cp & CHAR) == ' '))
+ cp--;
+
+ while (cp > InputBuf) {
+ if ( ((*cp & CHAR) == ' ') && ((cp[-1] & CHAR) != '\\') )
+ break;
+ cp--;
+ }
+
+ for (p = cp, kp = KillBuf; p < Cursor; p++) {/* save the text */
+ if ( ( *p & CHAR ) == '/') {
+ *kp++ = '\\';
+ *kp++ = '\\';
+ }
+ else
+ *kp++ = *p;
+ }
+ LastKill = kp;
+
+ c_delbefore((int)(Cursor - cp)); /* delete before dot */
+ Cursor = cp;
+ if (Cursor < InputBuf)
+ Cursor = InputBuf; /* bounds check */
+ return(e_yank_kill(c));
+}
+#endif /* !WINNT */
+
+#ifdef notdef
+void
+MoveCursor(n) /* move cursor + right - left char */
+ int n;
+{
+ Cursor = Cursor + n;
+ if (Cursor < InputBuf)
+ Cursor = InputBuf;
+ if (Cursor > LastChar)
+ Cursor = LastChar;
+ return;
+}
+
+Char *
+GetCursor()
+{
+ return(Cursor);
+}
+
+int
+PutCursor(p)
+ Char *p;
+{
+ if (p < InputBuf || p > LastChar)
+ return 1; /* Error */
+ Cursor = p;
+ return 0;
+}
+#endif
diff --git a/contrib/tcsh/ed.decls.h b/contrib/tcsh/ed.decls.h
new file mode 100644
index 000000000000..4b96d6d05075
--- /dev/null
+++ b/contrib/tcsh/ed.decls.h
@@ -0,0 +1,274 @@
+/* $Header: /src/pub/tcsh/ed.decls.h,v 3.28 1998/09/04 21:16:38 christos Exp $ */
+/*
+ * ed.decls.h: Editor external definitions
+ */
+/*-
+ * Copyright (c) 1980, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _h_ed_decls
+#define _h_ed_decls
+
+/*
+ * ed.chared.c
+ */
+extern int InsertStr __P((Char *));
+extern void DeleteBack __P((int));
+
+/*
+ * ed.init.c
+ */
+#ifdef SIG_WINDOW
+extern void check_window_size __P((int));
+extern sigret_t window_change __P((int));
+#endif /* SIG_WINDOW */
+extern int ed_Setup __P((int));
+extern void ed_Init __P((void));
+extern int Cookedmode __P((void));
+extern int Rawmode __P((void));
+extern void ed_set_tty_eight_bit __P((void));
+
+extern void QuoteModeOn __P((void));
+extern void QuoteModeOff __P((void));
+extern void ResetInLine __P((int));
+extern int Load_input_line __P((void));
+
+/*
+ * ed.term.c:
+ */
+extern void dosetty __P((Char **, struct command *));
+extern int tty_getty __P((int, ttydata_t *));
+extern int tty_setty __P((int, ttydata_t *));
+extern void tty_getchar __P((ttydata_t *, unsigned char *));
+extern void tty_setchar __P((ttydata_t *, unsigned char *));
+extern speed_t tty_getspeed __P((ttydata_t *));
+extern int tty_gettabs __P((ttydata_t *));
+extern int tty_geteightbit __P((ttydata_t *));
+extern int tty_cooked_mode __P((ttydata_t *));
+#ifdef _IBMR2
+extern void tty_setdisc __P((int, int));
+#endif /* _IBMR2 */
+
+/*
+ * ed.screen.c
+ */
+extern void terminit __P((void));
+extern void SetAttributes __P((int));
+extern void so_write __P((Char *, int));
+extern void ClearScreen __P((void));
+extern void MoveToLine __P((int));
+extern void MoveToChar __P((int));
+extern void ClearEOL __P((int));
+extern void Insert_write __P((Char *, int));
+extern void DeleteChars __P((int));
+extern void TellTC __P((char *));
+extern void SetTC __P((char *, char *));
+extern void EchoTC __P((Char **));
+extern int SetArrowKeys __P((CStr *, XmapVal *, int));
+extern int IsArrowKey __P((Char *));
+extern void ResetArrowKeys __P((void));
+extern void DefaultArrowKeys __P((void));
+extern int ClearArrowKeys __P((CStr *));
+extern void PrintArrowKeys __P((CStr *));
+extern void BindArrowKeys __P((void));
+extern void SoundBeep __P((void));
+extern int CanWeTab __P((void));
+extern void ChangeSize __P((int, int));
+#ifdef SIG_WINDOW
+extern int GetSize __P((int *, int *));
+#endif /* SIG_WINDOW */
+extern void ClearToBottom __P((void));
+extern void GetTermCaps __P((void));
+
+/*
+ * ed.defns.c
+ */
+extern void editinit __P((void));
+extern void ed_InitNLSMaps __P((void));
+#ifdef DEBUG_EDIT
+extern void CheckMaps __P((void));
+#endif
+extern void ed_InitMaps __P((void));
+extern void ed_InitEmacsMaps __P((void));
+extern void ed_InitVIMaps __P((void));
+
+extern CCRETVAL e_unassigned __P((int));
+extern CCRETVAL e_insert __P((int));
+extern CCRETVAL e_newline __P((int));
+extern CCRETVAL e_delprev __P((int));
+extern CCRETVAL e_delnext __P((int));
+/* added by mtk@ari.ncl.omron.co.jp (920818) */
+extern CCRETVAL e_delnext_eof __P((int));
+extern CCRETVAL e_delnext_list __P((int));
+extern CCRETVAL e_delnext_list_eof __P((int)); /* for ^D */
+extern CCRETVAL e_toend __P((int));
+extern CCRETVAL e_tobeg __P((int));
+extern CCRETVAL e_charback __P((int));
+extern CCRETVAL e_charfwd __P((int));
+extern CCRETVAL e_quote __P((int));
+extern CCRETVAL e_startover __P((int));
+extern CCRETVAL e_redisp __P((int));
+extern CCRETVAL e_wordback __P((int));
+extern CCRETVAL e_wordfwd __P((int));
+extern CCRETVAL v_wordbegnext __P((int));
+extern CCRETVAL e_uppercase __P((int));
+extern CCRETVAL e_lowercase __P((int));
+extern CCRETVAL e_capitolcase __P((int));
+extern CCRETVAL e_cleardisp __P((int));
+extern CCRETVAL e_complete __P((int));
+extern CCRETVAL e_correct __P((int));
+extern CCRETVAL e_correctl __P((int));
+extern CCRETVAL e_up_hist __P((int));
+extern CCRETVAL e_down_hist __P((int));
+extern CCRETVAL e_up_search_hist __P((int));
+extern CCRETVAL e_down_search_hist __P((int));
+extern CCRETVAL e_helpme __P((int));
+extern CCRETVAL e_list_choices __P((int));
+extern CCRETVAL e_delwordprev __P((int));
+extern CCRETVAL e_delwordnext __P((int));
+extern CCRETVAL e_digit __P((int));
+extern CCRETVAL e_argdigit __P((int));
+extern CCRETVAL v_zero __P((int));
+extern CCRETVAL e_killend __P((int));
+extern CCRETVAL e_killbeg __P((int));
+extern CCRETVAL e_metanext __P((int));
+#ifdef notdef
+extern CCRETVAL e_extendnext __P((int));
+#endif
+extern CCRETVAL e_send_eof __P((int));
+extern CCRETVAL e_charswitch __P((int));
+extern CCRETVAL e_gcharswitch __P((int));
+extern CCRETVAL e_which __P((int));
+extern CCRETVAL e_yank_kill __P((int));
+extern CCRETVAL e_tty_dsusp __P((int));
+extern CCRETVAL e_tty_flusho __P((int));
+extern CCRETVAL e_tty_quit __P((int));
+extern CCRETVAL e_tty_tsusp __P((int));
+extern CCRETVAL e_tty_stopo __P((int));
+extern CCRETVAL e_tty_starto __P((int));
+extern CCRETVAL e_argfour __P((int));
+extern CCRETVAL e_set_mark __P((int));
+extern CCRETVAL e_exchange_mark __P((int));
+extern CCRETVAL e_last_item __P((int));
+extern CCRETVAL v_cmd_mode __P((int));
+extern CCRETVAL v_insert __P((int));
+extern CCRETVAL v_replmode __P((int));
+extern CCRETVAL v_replone __P((int));
+extern CCRETVAL v_substline __P((int));
+extern CCRETVAL v_substchar __P((int));
+extern CCRETVAL v_add __P((int));
+extern CCRETVAL v_addend __P((int));
+extern CCRETVAL v_insbeg __P((int));
+extern CCRETVAL v_chgtoend __P((int));
+extern CCRETVAL e_killregion __P((int));
+extern CCRETVAL e_killall __P((int));
+extern CCRETVAL e_copyregion __P((int));
+extern CCRETVAL e_tty_int __P((int));
+extern CCRETVAL e_run_fg_editor __P((int));
+extern CCRETVAL e_list_eof __P((int));
+extern CCRETVAL e_expand_history __P((int));
+extern CCRETVAL e_magic_space __P((int));
+extern CCRETVAL e_list_glob __P((int));
+extern CCRETVAL e_expand_glob __P((int));
+extern CCRETVAL e_insovr __P((int));
+extern CCRETVAL v_cm_complete __P((int));
+extern CCRETVAL e_copyprev __P((int));
+extern CCRETVAL v_change_case __P((int));
+extern CCRETVAL e_expand __P((int));
+extern CCRETVAL e_expand_vars __P((int));
+extern CCRETVAL e_toggle_hist __P((int));
+extern CCRETVAL e_load_average __P((int));
+extern CCRETVAL v_delprev __P((int));
+extern CCRETVAL v_delmeta __P((int));
+extern CCRETVAL v_wordfwd __P((int));
+extern CCRETVAL v_wordback __P((int));
+extern CCRETVAL v_endword __P((int));
+extern CCRETVAL v_eword __P((int));
+extern CCRETVAL v_undo __P((int));
+extern CCRETVAL v_ush_meta __P((int));
+extern CCRETVAL v_dsh_meta __P((int));
+extern CCRETVAL v_rsrch_fwd __P((int));
+extern CCRETVAL v_rsrch_back __P((int));
+extern CCRETVAL v_char_fwd __P((int));
+extern CCRETVAL v_char_back __P((int));
+extern CCRETVAL v_chgmeta __P((int));
+extern CCRETVAL e_inc_fwd __P((int));
+extern CCRETVAL e_inc_back __P((int));
+extern CCRETVAL v_rchar_fwd __P((int));
+extern CCRETVAL v_rchar_back __P((int));
+extern CCRETVAL v_charto_fwd __P((int));
+extern CCRETVAL v_charto_back __P((int));
+extern CCRETVAL e_normalize_path __P((int));
+extern CCRETVAL e_normalize_command __P((int));
+extern CCRETVAL e_stuff_char __P((int));
+extern CCRETVAL e_list_all __P((int));
+extern CCRETVAL e_complete_all __P((int));
+extern CCRETVAL e_complete_fwd __P((int));
+extern CCRETVAL e_complete_back __P((int));
+extern CCRETVAL e_dabbrev_expand __P((int));
+extern CCRETVAL e_copy_to_clipboard __P((int));
+extern CCRETVAL e_paste_from_clipboard __P((int));
+extern CCRETVAL e_dosify_next __P((int));
+extern CCRETVAL e_dosify_prev __P((int));
+
+/*
+ * ed.inputl.c
+ */
+extern int Inputl __P((void));
+extern int GetNextChar __P((Char *));
+extern void PushMacro __P((Char *));
+
+/*
+ * ed.refresh.c
+ */
+extern void ClearLines __P((void));
+extern void ClearDisp __P((void));
+extern void Refresh __P((void));
+extern void RefCursor __P((void));
+extern void RefPlusOne __P((void));
+extern void PastBottom __P((void));
+
+/*
+ * ed.xmap.c
+ */
+extern XmapVal *XmapStr __P((CStr *));
+extern XmapVal *XmapCmd __P((int));
+extern void AddXkey __P((CStr *, XmapVal *, int));
+extern void ClearXkey __P((KEYCMD *, CStr *));
+extern int GetXkey __P((CStr *, XmapVal *));
+extern void ResetXmap __P((void));
+extern int DeleteXkey __P((CStr *));
+extern void PrintXkey __P((CStr *));
+extern int printOne __P((CStr *, XmapVal *, int));
+extern int parseescape __P((const Char **));
+extern unsigned char *unparsestring __P((CStr *, unsigned char *, Char *));
+
+#endif /* _h_ed_decls */
diff --git a/contrib/tcsh/ed.defns.c b/contrib/tcsh/ed.defns.c
new file mode 100644
index 000000000000..41d79929202f
--- /dev/null
+++ b/contrib/tcsh/ed.defns.c
@@ -0,0 +1,1949 @@
+/* $Header: /src/pub/tcsh/ed.defns.c,v 3.33 1998/11/24 18:17:18 christos Exp $ */
+/*
+ * ed.defns.c: Editor function definitions and initialization
+ */
+/*-
+ * Copyright (c) 1980, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "sh.h"
+
+RCSID("$Id: ed.defns.c,v 3.33 1998/11/24 18:17:18 christos Exp $")
+
+#include "ed.h"
+
+static void ed_InitMetaBindings __P((void));
+
+PFCmd CcFuncTbl[] = { /* table of available commands */
+ e_unassigned,
+/* no #define here -- this is a dummy to detect initing of the key map */
+ e_unassigned,
+#define F_UNASSIGNED 1
+ e_insert,
+#define F_INSERT 2
+ e_newline,
+#define F_NEWLINE 3
+ e_delprev,
+#define F_DELPREV 4
+ e_delnext,
+#define F_DELNEXT 5
+ e_toend,
+#define F_TOEND 6
+ e_tobeg,
+#define F_TOBEG 7
+ e_charback,
+#define F_CHARBACK 8
+ e_charfwd,
+#define F_CHARFWD 9
+ e_quote,
+#define F_QUOTE 10
+ e_startover,
+#define F_STARTOVER 11
+ e_redisp,
+#define F_REDISP 12
+ e_tty_int,
+#define F_TTY_INT 13
+ e_wordback,
+#define F_WORDBACK 14
+ e_wordfwd,
+#define F_WORDFWD 15
+ e_cleardisp,
+#define F_CLEARDISP 16
+ e_complete,
+#define F_COMPLETE 17
+ e_correct,
+#define F_CORRECT 18
+ e_up_hist,
+#define F_UP_HIST 19
+ e_down_hist,
+#define F_DOWN_HIST 20
+ e_up_search_hist,
+#define F_UP_SEARCH_HIST 21
+ e_down_search_hist,
+#define F_DOWN_SEARCH_HIST 22
+ e_helpme,
+#define F_HELPME 23
+ e_list_choices,
+#define F_LIST_CHOICES 24
+ e_delwordprev,
+#define F_DELWORDPREV 25
+ e_delwordnext,
+#define F_DELWORDNEXT 26
+ e_digit,
+#define F_DIGIT 27
+ e_killend,
+#define F_KILLEND 28
+ e_killbeg,
+#define F_KILLBEG 29
+ e_metanext,
+#define F_METANEXT 30
+ e_send_eof,
+#define F_SEND_EOF 31
+ e_charswitch,
+#define F_CHARSWITCH 32
+ e_which,
+#define F_WHICH 33
+ e_yank_kill,
+#define F_YANK_KILL 34
+ e_tty_dsusp,
+#define F_TTY_DSUSP 35
+ e_tty_flusho,
+#define F_TTY_FLUSHO 36
+ e_tty_quit,
+#define F_TTY_QUIT 37
+ e_tty_tsusp,
+#define F_TTY_TSUSP 38
+ e_tty_stopo,
+#define F_TTY_STOPO 39
+ e_tty_starto,
+#define F_TTY_STARTO 40
+ e_argfour,
+#define F_ARGFOUR 41
+ e_set_mark,
+#define F_SET_MARK 42
+ e_exchange_mark,
+#define F_EXCHANGE_MARK 43
+ e_last_item,
+#define F_LAST_ITEM 44
+ e_delnext_list_eof,
+#define F_DELNEXT_LIST_EOF 45
+ v_cmd_mode,
+#define V_CMD_MODE 46
+ v_insert,
+#define V_INSERT 47
+ e_argdigit,
+#define F_ARGDIGIT 48
+ e_killregion,
+#define F_KILLREGION 49
+ e_copyregion,
+#define F_COPYREGION 50
+ e_gcharswitch,
+#define F_GCHARSWITCH 51
+ e_run_fg_editor,
+#define F_RUN_FG_EDITOR 52
+ e_unassigned, /* place holder for sequence lead in character */
+#define F_XKEY 53
+ e_uppercase,
+#define F_CASEUPPER 54
+ e_lowercase,
+#define F_CASELOWER 55
+ e_capitolcase,
+#define F_CASECAPITAL 56
+ v_zero,
+#define V_ZERO 57
+ v_add,
+#define V_ADD 58
+ v_addend,
+#define V_ADDEND 59
+ v_wordbegnext,
+#define V_WORDBEGNEXT 60
+ e_killall,
+#define F_KILLALL 61
+ e_unassigned,
+/* F_EXTENDNEXT removed */
+ v_insbeg,
+#define V_INSBEG 63
+ v_replmode,
+#define V_REPLMODE 64
+ v_replone,
+#define V_REPLONE 65
+ v_substline,
+#define V_SUBSTLINE 66
+ v_substchar,
+#define V_SUBSTCHAR 67
+ v_chgtoend,
+#define V_CHGTOEND 68
+ e_list_eof,
+#define F_LIST_EOF 69
+ e_list_glob,
+#define F_LIST_GLOB 70
+ e_expand_history,
+#define F_EXPAND_HISTORY 71
+ e_magic_space,
+#define F_MAGIC_SPACE 72
+ e_insovr,
+#define F_INSOVR 73
+ v_cm_complete,
+#define V_CM_COMPLETE 74
+ e_copyprev,
+#define F_COPYPREV 75
+ e_correctl,
+#define F_CORRECT_L 76
+ e_expand_glob,
+#define F_EXPAND_GLOB 77
+ e_expand_vars,
+#define F_EXPAND_VARS 78
+ e_toggle_hist,
+#define F_TOGGLE_HIST 79
+ v_change_case,
+#define V_CHGCASE 80
+ e_expand,
+#define F_EXPAND 81
+ e_load_average,
+#define F_LOAD_AVERAGE 82
+ v_delprev,
+#define V_DELPREV 83
+ v_delmeta,
+#define V_DELMETA 84
+ v_wordfwd,
+#define V_WORDFWD 85
+ v_wordback,
+#define V_WORDBACK 86
+ v_endword,
+#define V_ENDWORD 87
+ v_eword,
+#define V_EWORD 88
+ v_undo,
+#define V_UNDO 89
+ v_ush_meta,
+#define V_USH_META 90
+ v_dsh_meta,
+#define V_DSH_META 91
+ v_rsrch_fwd,
+#define V_RSRCH_FWD 92
+ v_rsrch_back,
+#define V_RSRCH_BACK 93
+ v_char_fwd,
+#define V_CHAR_FWD 94
+ v_char_back,
+#define V_CHAR_BACK 95
+ v_chgmeta,
+#define V_CHGMETA 96
+ e_inc_fwd,
+#define F_INC_FWD 97
+ e_inc_back,
+#define F_INC_BACK 98
+ v_rchar_fwd,
+#define V_RCHAR_FWD 99
+ v_rchar_back,
+#define V_RCHAR_BACK 100
+ v_charto_fwd,
+#define V_CHARTO_FWD 101
+ v_charto_back,
+#define V_CHARTO_BACK 102
+ e_normalize_path,
+#define F_PATH_NORM 103
+ e_delnext_eof, /* added by mtk@ari.ncl.omron.co.jp (920818) */
+#define F_DELNEXT_EOF 104
+ e_stuff_char,
+#define F_STUFF_CHAR 105
+ e_complete_all,
+#define F_COMPLETE_ALL 106
+ e_list_all,
+#define F_LIST_ALL 107
+ e_complete_fwd,
+#define F_COMPLETE_FWD 108
+ e_complete_back,
+#define F_COMPLETE_BACK 109
+ e_delnext_list,
+#define F_DELNEXT_LIST 110
+ e_normalize_command,
+#define F_COMMAND_NORM 111
+ e_dabbrev_expand,
+#define F_DABBREV_EXPAND 112
+ e_copy_to_clipboard,
+#define F_COPY_CLIP 113
+ e_paste_from_clipboard,
+#define F_PASTE_CLIP 114
+ e_dosify_next,
+#define F_DOSIFY_NEXT 115
+ e_dosify_prev,
+#define F_DOSIFY_PREV 116
+ 0 /* DUMMY VALUE */
+#define F_NUM_FNS 117
+
+};
+
+KEYCMD NumFuns = F_NUM_FNS;
+
+KEYCMD CcKeyMap[NT_NUM_KEYS]; /* the real key map */
+KEYCMD CcAltMap[NT_NUM_KEYS]; /* the alternative key map */
+#define F_NUM_FUNCNAMES (F_NUM_FNS + 2)
+struct KeyFuncs FuncNames[F_NUM_FUNCNAMES];
+
+#ifdef WINNT
+extern KEYCMD CcEmacsMap[];
+extern KEYCMD CcViMap[];
+extern KEYCMD CcViCmdMap[];
+#else /* !WINNT*/
+KEYCMD CcEmacsMap[] = {
+/* keymap table, each index into above tbl; should be 256*sizeof(KEYCMD)
+ bytes long */
+
+ F_SET_MARK, /* ^@ */
+ F_TOBEG, /* ^A */
+ F_CHARBACK, /* ^B */
+ F_TTY_INT, /* ^C */
+ F_DELNEXT_LIST_EOF, /* ^D */
+ F_TOEND, /* ^E */
+ F_CHARFWD, /* ^F */
+ F_UNASSIGNED, /* ^G */
+ F_DELPREV, /* ^H */
+ F_COMPLETE, /* ^I */
+ F_NEWLINE, /* ^J */
+ F_KILLEND, /* ^K */
+ F_CLEARDISP, /* ^L */
+ F_NEWLINE, /* ^M */
+ F_DOWN_HIST, /* ^N */
+ F_TTY_FLUSHO, /* ^O */
+ F_UP_HIST, /* ^P */
+ F_TTY_STARTO, /* ^Q */
+ F_REDISP, /* ^R */
+ F_TTY_STOPO, /* ^S */
+ F_CHARSWITCH, /* ^T */
+ F_KILLALL, /* ^U */
+ F_QUOTE, /* ^V */
+ F_KILLREGION, /* ^W */
+ F_XKEY, /* ^X */
+ F_YANK_KILL, /* ^Y */
+ F_TTY_TSUSP, /* ^Z */
+ F_METANEXT, /* ^[ */
+ F_TTY_QUIT, /* ^\ */
+ F_TTY_DSUSP, /* ^] */
+ F_UNASSIGNED, /* ^^ */
+ F_UNASSIGNED, /* ^_ */
+ F_INSERT, /* SPACE */
+ F_INSERT, /* ! */
+ F_INSERT, /* " */
+ F_INSERT, /* # */
+ F_INSERT, /* $ */
+ F_INSERT, /* % */
+ F_INSERT, /* & */
+ F_INSERT, /* ' */
+ F_INSERT, /* ( */
+ F_INSERT, /* ) */
+ F_INSERT, /* * */
+ F_INSERT, /* + */
+ F_INSERT, /* , */
+ F_INSERT, /* - */
+ F_INSERT, /* . */
+ F_INSERT, /* / */
+ F_DIGIT, /* 0 */
+ F_DIGIT, /* 1 */
+ F_DIGIT, /* 2 */
+ F_DIGIT, /* 3 */
+ F_DIGIT, /* 4 */
+ F_DIGIT, /* 5 */
+ F_DIGIT, /* 6 */
+ F_DIGIT, /* 7 */
+ F_DIGIT, /* 8 */
+ F_DIGIT, /* 9 */
+ F_INSERT, /* : */
+ F_INSERT, /* ; */
+ F_INSERT, /* < */
+ F_INSERT, /* = */
+ F_INSERT, /* > */
+ F_INSERT, /* ? */
+ F_INSERT, /* @ */
+ F_INSERT, /* A */
+ F_INSERT, /* B */
+ F_INSERT, /* C */
+ F_INSERT, /* D */
+ F_INSERT, /* E */
+ F_INSERT, /* F */
+ F_INSERT, /* G */
+ F_INSERT, /* H */
+ F_INSERT, /* I */
+ F_INSERT, /* J */
+ F_INSERT, /* K */
+ F_INSERT, /* L */
+ F_INSERT, /* M */
+ F_INSERT, /* N */
+ F_INSERT, /* O */
+ F_INSERT, /* P */
+ F_INSERT, /* Q */
+ F_INSERT, /* R */
+ F_INSERT, /* S */
+ F_INSERT, /* T */
+ F_INSERT, /* U */
+ F_INSERT, /* V */
+ F_INSERT, /* W */
+ F_INSERT, /* X */
+ F_INSERT, /* Y */
+ F_INSERT, /* Z */
+ F_INSERT, /* [ */
+ F_INSERT, /* \ */
+ F_INSERT, /* ] */
+ F_INSERT, /* ^ */
+ F_INSERT, /* _ */
+ F_INSERT, /* ` */
+ F_INSERT, /* a */
+ F_INSERT, /* b */
+ F_INSERT, /* c */
+ F_INSERT, /* d */
+ F_INSERT, /* e */
+ F_INSERT, /* f */
+ F_INSERT, /* g */
+ F_INSERT, /* h */
+ F_INSERT, /* i */
+ F_INSERT, /* j */
+ F_INSERT, /* k */
+ F_INSERT, /* l */
+ F_INSERT, /* m */
+ F_INSERT, /* n */
+ F_INSERT, /* o */
+ F_INSERT, /* p */
+ F_INSERT, /* q */
+ F_INSERT, /* r */
+ F_INSERT, /* s */
+ F_INSERT, /* t */
+ F_INSERT, /* u */
+ F_INSERT, /* v */
+ F_INSERT, /* w */
+ F_INSERT, /* x */
+ F_INSERT, /* y */
+ F_INSERT, /* z */
+ F_INSERT, /* { */
+ F_INSERT, /* | */
+ F_INSERT, /* } */
+ F_INSERT, /* ~ */
+ F_DELPREV, /* ^? */
+ F_UNASSIGNED, /* M-^@ */
+ F_UNASSIGNED, /* M-^A */
+ F_UNASSIGNED, /* M-^B */
+ F_UNASSIGNED, /* M-^C */
+ F_LIST_CHOICES, /* M-^D */
+ F_UNASSIGNED, /* M-^E */
+ F_UNASSIGNED, /* M-^F */
+ F_UNASSIGNED, /* M-^G */
+ F_DELWORDPREV, /* M-^H */
+ F_COMPLETE, /* M-^I */
+ F_UNASSIGNED, /* M-^J */
+ F_UNASSIGNED, /* M-^K */
+ F_CLEARDISP, /* M-^L */
+ F_UNASSIGNED, /* M-^M */
+ F_UNASSIGNED, /* M-^N */
+ F_UNASSIGNED, /* M-^O */
+ F_UNASSIGNED, /* M-^P */
+ F_UNASSIGNED, /* M-^Q */
+ F_UNASSIGNED, /* M-^R */
+ F_UNASSIGNED, /* M-^S */
+ F_UNASSIGNED, /* M-^T */
+ F_UNASSIGNED, /* M-^U */
+ F_UNASSIGNED, /* M-^V */
+ F_UNASSIGNED, /* M-^W */
+ F_UNASSIGNED, /* M-^X */
+ F_UNASSIGNED, /* M-^Y */
+ F_RUN_FG_EDITOR, /* M-^Z */
+ F_COMPLETE, /* M-^[ */
+ F_UNASSIGNED, /* M-^\ */
+ F_UNASSIGNED, /* M-^] */
+ F_UNASSIGNED, /* M-^^ */
+ F_COPYPREV, /* M-^_ */
+ F_EXPAND_HISTORY, /* M-SPACE */
+ F_EXPAND_HISTORY, /* M-! */
+ F_UNASSIGNED, /* M-" */
+ F_UNASSIGNED, /* M-# */
+ F_CORRECT_L, /* M-$ */
+ F_UNASSIGNED, /* M-% */
+ F_UNASSIGNED, /* M-& */
+ F_UNASSIGNED, /* M-' */
+ F_UNASSIGNED, /* M-( */
+ F_UNASSIGNED, /* M-) */
+ F_UNASSIGNED, /* M-* */
+ F_UNASSIGNED, /* M-+ */
+ F_UNASSIGNED, /* M-, */
+ F_UNASSIGNED, /* M-- */
+ F_UNASSIGNED, /* M-. */
+ F_DABBREV_EXPAND, /* M-/ */
+ F_ARGDIGIT, /* M-0 */
+ F_ARGDIGIT, /* M-1 */
+ F_ARGDIGIT, /* M-2 */
+ F_ARGDIGIT, /* M-3 */
+ F_ARGDIGIT, /* M-4 */
+ F_ARGDIGIT, /* M-5 */
+ F_ARGDIGIT, /* M-6 */
+ F_ARGDIGIT, /* M-7 */
+ F_ARGDIGIT, /* M-8 */
+ F_ARGDIGIT, /* M-9 */
+ F_UNASSIGNED, /* M-: */
+ F_UNASSIGNED, /* M-; */
+ F_UNASSIGNED, /* M-< */
+ F_UNASSIGNED, /* M-= */
+ F_UNASSIGNED, /* M-> */
+ F_WHICH, /* M-? */
+ F_UNASSIGNED, /* M-@ */
+ F_UNASSIGNED, /* M-A */
+ F_WORDBACK, /* M-B */
+ F_CASECAPITAL, /* M-C */
+ F_DELWORDNEXT, /* M-D */
+ F_UNASSIGNED, /* M-E */
+ F_WORDFWD, /* M-F */
+ F_UNASSIGNED, /* M-G */
+ F_HELPME, /* M-H */
+ F_UNASSIGNED, /* M-I */
+ F_UNASSIGNED, /* M-J */
+ F_UNASSIGNED, /* M-K */
+ F_CASELOWER, /* M-L */
+ F_UNASSIGNED, /* M-M */
+ F_DOWN_SEARCH_HIST, /* M-N */
+ F_XKEY, /* M-O *//* extended key esc PWP Mar 88 */
+ F_UP_SEARCH_HIST, /* M-P */
+ F_UNASSIGNED, /* M-Q */
+ F_TOGGLE_HIST, /* M-R */
+ F_CORRECT, /* M-S */
+ F_UNASSIGNED, /* M-T */
+ F_CASEUPPER, /* M-U */
+ F_UNASSIGNED, /* M-V */
+ F_COPYREGION, /* M-W */
+ F_UNASSIGNED, /* M-X */
+ F_UNASSIGNED, /* M-Y */
+ F_UNASSIGNED, /* M-Z */
+ F_XKEY, /* M-[ *//* extended key esc -mf Oct 87 */
+ F_UNASSIGNED, /* M-\ */
+ F_UNASSIGNED, /* M-] */
+ F_UNASSIGNED, /* M-^ */
+ F_LAST_ITEM, /* M-_ */
+ F_UNASSIGNED, /* M-` */
+ F_UNASSIGNED, /* M-a */
+ F_WORDBACK, /* M-b */
+ F_CASECAPITAL, /* M-c */
+ F_DELWORDNEXT, /* M-d */
+ F_UNASSIGNED, /* M-e */
+ F_WORDFWD, /* M-f */
+ F_UNASSIGNED, /* M-g */
+ F_HELPME, /* M-h */
+ F_UNASSIGNED, /* M-i */
+ F_UNASSIGNED, /* M-j */
+ F_UNASSIGNED, /* M-k */
+ F_CASELOWER, /* M-l */
+ F_UNASSIGNED, /* M-m */
+ F_DOWN_SEARCH_HIST, /* M-n */
+ F_UNASSIGNED, /* M-o */
+ F_UP_SEARCH_HIST, /* M-p */
+ F_UNASSIGNED, /* M-q */
+ F_TOGGLE_HIST, /* M-r */
+ F_CORRECT, /* M-s */
+ F_UNASSIGNED, /* M-t */
+ F_CASEUPPER, /* M-u */
+ F_UNASSIGNED, /* M-v */
+ F_COPYREGION, /* M-w */
+ F_UNASSIGNED, /* M-x */
+ F_UNASSIGNED, /* M-y */
+ F_UNASSIGNED, /* M-z */
+ F_UNASSIGNED, /* M-{ */
+ F_UNASSIGNED, /* M-| */
+ F_UNASSIGNED, /* M-} */
+ F_UNASSIGNED, /* M-~ */
+ F_DELWORDPREV /* M-^? */
+};
+
+/*
+ * keymap table for vi. Each index into above tbl; should be
+ * 256 entries long. Vi mode uses a sticky-extend to do command mode:
+ * insert mode characters are in the normal keymap, and command mode
+ * in the extended keymap.
+ */
+static KEYCMD CcViMap[] = {
+#ifdef KSHVI
+ F_UNASSIGNED, /* ^@ */
+ F_INSERT, /* ^A */
+ F_INSERT, /* ^B */
+ F_INSERT, /* ^C */
+ F_INSERT, /* ^D */
+ F_INSERT, /* ^E */
+ F_INSERT, /* ^F */
+ F_INSERT, /* ^G */
+ V_DELPREV, /* ^H */ /* BackSpace key */
+ F_COMPLETE, /* ^I */ /* Tab Key */
+ F_NEWLINE, /* ^J */
+ F_INSERT, /* ^K */
+ F_INSERT, /* ^L */
+ F_NEWLINE, /* ^M */
+ F_INSERT, /* ^N */
+ F_INSERT, /* ^O */
+ F_INSERT, /* ^P */
+ F_TTY_STARTO, /* ^Q */
+ F_INSERT, /* ^R */
+ F_INSERT, /* ^S */
+ F_INSERT, /* ^T */
+ F_INSERT, /* ^U */
+ F_QUOTE, /* ^V */
+ F_DELWORDPREV, /* ^W */ /* Only until start edit pos */
+ F_INSERT, /* ^X */
+ F_INSERT, /* ^Y */
+ F_INSERT, /* ^Z */
+ V_CMD_MODE, /* ^[ */ /* [ Esc ] key */
+ F_TTY_QUIT, /* ^\ */
+ F_INSERT, /* ^] */
+ F_INSERT, /* ^^ */
+ F_INSERT, /* ^_ */
+#else /* !KSHVI */
+ F_UNASSIGNED, /* ^@ */ /* NOTE: These mapping do NOT */
+ F_TOBEG, /* ^A */ /* Correspond well to the KSH */
+ F_CHARBACK, /* ^B */ /* VI editting assignments */
+ F_TTY_INT, /* ^C */ /* On the other hand they are */
+ F_LIST_EOF, /* ^D */ /* convenient any many people */
+ F_TOEND, /* ^E */ /* have gotten used to them */
+ F_CHARFWD, /* ^F */
+ F_LIST_GLOB, /* ^G */
+ F_DELPREV, /* ^H */ /* BackSpace key */
+ F_COMPLETE, /* ^I */ /* Tab Key */
+ F_NEWLINE, /* ^J */
+ F_KILLEND, /* ^K */
+ F_CLEARDISP, /* ^L */
+ F_NEWLINE, /* ^M */
+ F_DOWN_HIST, /* ^N */
+ F_TTY_FLUSHO, /* ^O */
+ F_UP_HIST, /* ^P */
+ F_TTY_STARTO, /* ^Q */
+ F_REDISP, /* ^R */
+ F_TTY_STOPO, /* ^S */
+ F_CHARSWITCH, /* ^T */
+ F_KILLBEG, /* ^U */
+ F_QUOTE, /* ^V */
+ F_DELWORDPREV, /* ^W */
+ F_EXPAND, /* ^X */
+ F_TTY_DSUSP, /* ^Y */
+ F_TTY_TSUSP, /* ^Z */
+ V_CMD_MODE, /* ^[ */
+ F_TTY_QUIT, /* ^\ */
+ F_UNASSIGNED, /* ^] */
+ F_UNASSIGNED, /* ^^ */
+ F_UNASSIGNED, /* ^_ */
+#endif /* KSHVI */
+ F_INSERT, /* SPACE */
+ F_INSERT, /* ! */
+ F_INSERT, /* " */
+ F_INSERT, /* # */
+ F_INSERT, /* $ */
+ F_INSERT, /* % */
+ F_INSERT, /* & */
+ F_INSERT, /* ' */
+ F_INSERT, /* ( */
+ F_INSERT, /* ) */
+ F_INSERT, /* * */
+ F_INSERT, /* + */
+ F_INSERT, /* , */
+ F_INSERT, /* - */
+ F_INSERT, /* . */
+ F_INSERT, /* / */
+ F_INSERT, /* 0 */
+ F_INSERT, /* 1 */
+ F_INSERT, /* 2 */
+ F_INSERT, /* 3 */
+ F_INSERT, /* 4 */
+ F_INSERT, /* 5 */
+ F_INSERT, /* 6 */
+ F_INSERT, /* 7 */
+ F_INSERT, /* 8 */
+ F_INSERT, /* 9 */
+ F_INSERT, /* : */
+ F_INSERT, /* ; */
+ F_INSERT, /* < */
+ F_INSERT, /* = */
+ F_INSERT, /* > */
+ F_INSERT, /* ? */
+ F_INSERT, /* @ */
+ F_INSERT, /* A */
+ F_INSERT, /* B */
+ F_INSERT, /* C */
+ F_INSERT, /* D */
+ F_INSERT, /* E */
+ F_INSERT, /* F */
+ F_INSERT, /* G */
+ F_INSERT, /* H */
+ F_INSERT, /* I */
+ F_INSERT, /* J */
+ F_INSERT, /* K */
+ F_INSERT, /* L */
+ F_INSERT, /* M */
+ F_INSERT, /* N */
+ F_INSERT, /* O */
+ F_INSERT, /* P */
+ F_INSERT, /* Q */
+ F_INSERT, /* R */
+ F_INSERT, /* S */
+ F_INSERT, /* T */
+ F_INSERT, /* U */
+ F_INSERT, /* V */
+ F_INSERT, /* W */
+ F_INSERT, /* X */
+ F_INSERT, /* Y */
+ F_INSERT, /* Z */
+ F_INSERT, /* [ */
+ F_INSERT, /* \ */
+ F_INSERT, /* ] */
+ F_INSERT, /* ^ */
+ F_INSERT, /* _ */
+ F_INSERT, /* ` */
+ F_INSERT, /* a */
+ F_INSERT, /* b */
+ F_INSERT, /* c */
+ F_INSERT, /* d */
+ F_INSERT, /* e */
+ F_INSERT, /* f */
+ F_INSERT, /* g */
+ F_INSERT, /* h */
+ F_INSERT, /* i */
+ F_INSERT, /* j */
+ F_INSERT, /* k */
+ F_INSERT, /* l */
+ F_INSERT, /* m */
+ F_INSERT, /* n */
+ F_INSERT, /* o */
+ F_INSERT, /* p */
+ F_INSERT, /* q */
+ F_INSERT, /* r */
+ F_INSERT, /* s */
+ F_INSERT, /* t */
+ F_INSERT, /* u */
+ F_INSERT, /* v */
+ F_INSERT, /* w */
+ F_INSERT, /* x */
+ F_INSERT, /* y */
+ F_INSERT, /* z */
+ F_INSERT, /* { */
+ F_INSERT, /* | */
+ F_INSERT, /* } */
+ F_INSERT, /* ~ */
+ F_DELPREV, /* ^? */
+ F_UNASSIGNED, /* M-^@ */
+ F_UNASSIGNED, /* M-^A */
+ F_UNASSIGNED, /* M-^B */
+ F_UNASSIGNED, /* M-^C */
+ F_UNASSIGNED, /* M-^D */
+ F_UNASSIGNED, /* M-^E */
+ F_UNASSIGNED, /* M-^F */
+ F_UNASSIGNED, /* M-^G */
+ F_UNASSIGNED, /* M-^H */
+ F_UNASSIGNED, /* M-^I */
+ F_UNASSIGNED, /* M-^J */
+ F_UNASSIGNED, /* M-^K */
+ F_UNASSIGNED, /* M-^L */
+ F_UNASSIGNED, /* M-^M */
+ F_UNASSIGNED, /* M-^N */
+ F_UNASSIGNED, /* M-^O */
+ F_UNASSIGNED, /* M-^P */
+ F_UNASSIGNED, /* M-^Q */
+ F_UNASSIGNED, /* M-^R */
+ F_UNASSIGNED, /* M-^S */
+ F_UNASSIGNED, /* M-^T */
+ F_UNASSIGNED, /* M-^U */
+ F_UNASSIGNED, /* M-^V */
+ F_UNASSIGNED, /* M-^W */
+ F_UNASSIGNED, /* M-^X */
+ F_UNASSIGNED, /* M-^Y */
+ F_UNASSIGNED, /* M-^Z */
+ F_UNASSIGNED, /* M-^[ */
+ F_UNASSIGNED, /* M-^\ */
+ F_UNASSIGNED, /* M-^] */
+ F_UNASSIGNED, /* M-^^ */
+ F_UNASSIGNED, /* M-^_ */
+ F_UNASSIGNED, /* M-SPACE */
+ F_UNASSIGNED, /* M-! */
+ F_UNASSIGNED, /* M-" */
+ F_UNASSIGNED, /* M-# */
+ F_UNASSIGNED, /* M-$ */
+ F_UNASSIGNED, /* M-% */
+ F_UNASSIGNED, /* M-& */
+ F_UNASSIGNED, /* M-' */
+ F_UNASSIGNED, /* M-( */
+ F_UNASSIGNED, /* M-) */
+ F_UNASSIGNED, /* M-* */
+ F_UNASSIGNED, /* M-+ */
+ F_UNASSIGNED, /* M-, */
+ F_UNASSIGNED, /* M-- */
+ F_UNASSIGNED, /* M-. */
+ F_UNASSIGNED, /* M-/ */
+ F_UNASSIGNED, /* M-0 */
+ F_UNASSIGNED, /* M-1 */
+ F_UNASSIGNED, /* M-2 */
+ F_UNASSIGNED, /* M-3 */
+ F_UNASSIGNED, /* M-4 */
+ F_UNASSIGNED, /* M-5 */
+ F_UNASSIGNED, /* M-6 */
+ F_UNASSIGNED, /* M-7 */
+ F_UNASSIGNED, /* M-8 */
+ F_UNASSIGNED, /* M-9 */
+ F_UNASSIGNED, /* M-: */
+ F_UNASSIGNED, /* M-; */
+ F_UNASSIGNED, /* M-< */
+ F_UNASSIGNED, /* M-= */
+ F_UNASSIGNED, /* M-> */
+ F_UNASSIGNED, /* M-? */
+ F_UNASSIGNED, /* M-@ */
+ F_UNASSIGNED, /* M-A */
+ F_UNASSIGNED, /* M-B */
+ F_UNASSIGNED, /* M-C */
+ F_UNASSIGNED, /* M-D */
+ F_UNASSIGNED, /* M-E */
+ F_UNASSIGNED, /* M-F */
+ F_UNASSIGNED, /* M-G */
+ F_UNASSIGNED, /* M-H */
+ F_UNASSIGNED, /* M-I */
+ F_UNASSIGNED, /* M-J */
+ F_UNASSIGNED, /* M-K */
+ F_UNASSIGNED, /* M-L */
+ F_UNASSIGNED, /* M-M */
+ F_UNASSIGNED, /* M-N */
+ F_UNASSIGNED, /* M-O */
+ F_UNASSIGNED, /* M-P */
+ F_UNASSIGNED, /* M-Q */
+ F_UNASSIGNED, /* M-R */
+ F_UNASSIGNED, /* M-S */
+ F_UNASSIGNED, /* M-T */
+ F_UNASSIGNED, /* M-U */
+ F_UNASSIGNED, /* M-V */
+ F_UNASSIGNED, /* M-W */
+ F_UNASSIGNED, /* M-X */
+ F_UNASSIGNED, /* M-Y */
+ F_UNASSIGNED, /* M-Z */
+ F_UNASSIGNED, /* M-[ */
+ F_UNASSIGNED, /* M-\ */
+ F_UNASSIGNED, /* M-] */
+ F_UNASSIGNED, /* M-^ */
+ F_UNASSIGNED, /* M-_ */
+ F_UNASSIGNED, /* M-` */
+ F_UNASSIGNED, /* M-a */
+ F_UNASSIGNED, /* M-b */
+ F_UNASSIGNED, /* M-c */
+ F_UNASSIGNED, /* M-d */
+ F_UNASSIGNED, /* M-e */
+ F_UNASSIGNED, /* M-f */
+ F_UNASSIGNED, /* M-g */
+ F_UNASSIGNED, /* M-h */
+ F_UNASSIGNED, /* M-i */
+ F_UNASSIGNED, /* M-j */
+ F_UNASSIGNED, /* M-k */
+ F_UNASSIGNED, /* M-l */
+ F_UNASSIGNED, /* M-m */
+ F_UNASSIGNED, /* M-n */
+ F_UNASSIGNED, /* M-o */
+ F_UNASSIGNED, /* M-p */
+ F_UNASSIGNED, /* M-q */
+ F_UNASSIGNED, /* M-r */
+ F_UNASSIGNED, /* M-s */
+ F_UNASSIGNED, /* M-t */
+ F_UNASSIGNED, /* M-u */
+ F_UNASSIGNED, /* M-v */
+ F_UNASSIGNED, /* M-w */
+ F_UNASSIGNED, /* M-x */
+ F_UNASSIGNED, /* M-y */
+ F_UNASSIGNED, /* M-z */
+ F_UNASSIGNED, /* M-{ */
+ F_UNASSIGNED, /* M-| */
+ F_UNASSIGNED, /* M-} */
+ F_UNASSIGNED, /* M-~ */
+ F_UNASSIGNED /* M-^? */
+};
+
+KEYCMD CcViCmdMap[] = {
+ F_UNASSIGNED, /* ^@ */
+ F_TOBEG, /* ^A */
+ F_UNASSIGNED, /* ^B */
+ F_TTY_INT, /* ^C */
+ F_LIST_CHOICES, /* ^D */
+ F_TOEND, /* ^E */
+ F_UNASSIGNED, /* ^F */
+ F_LIST_GLOB, /* ^G */
+ F_CHARBACK, /* ^H */
+ V_CM_COMPLETE, /* ^I */
+ F_NEWLINE, /* ^J */
+ F_KILLEND, /* ^K */
+ F_CLEARDISP, /* ^L */
+ F_NEWLINE, /* ^M */
+ F_DOWN_HIST, /* ^N */
+ F_TTY_FLUSHO, /* ^O */
+ F_UP_HIST, /* ^P */
+ F_TTY_STARTO, /* ^Q */
+ F_REDISP, /* ^R */
+ F_TTY_STOPO, /* ^S */
+ F_UNASSIGNED, /* ^T */
+ F_KILLBEG, /* ^U */
+ F_UNASSIGNED, /* ^V */
+ F_DELWORDPREV, /* ^W */
+ F_EXPAND, /* ^X */
+ F_UNASSIGNED, /* ^Y */
+ F_UNASSIGNED, /* ^Z */
+ F_METANEXT, /* ^[ */
+ F_TTY_QUIT, /* ^\ */
+ F_UNASSIGNED, /* ^] */
+ F_UNASSIGNED, /* ^^ */
+ F_UNASSIGNED, /* ^_ */
+ F_CHARFWD, /* SPACE */
+ F_EXPAND_HISTORY, /* ! */
+ F_UNASSIGNED, /* " */
+ F_UNASSIGNED, /* # */
+ F_TOEND, /* $ */
+ F_UNASSIGNED, /* % */
+ F_UNASSIGNED, /* & */
+ F_UNASSIGNED, /* ' */
+ F_UNASSIGNED, /* ( */
+ F_UNASSIGNED, /* ) */
+ F_EXPAND_GLOB, /* * */
+ F_DOWN_HIST, /* + */
+ V_RCHAR_BACK, /* , */
+ F_UP_HIST, /* - */
+ F_UNASSIGNED, /* . */
+ V_DSH_META, /* / */
+ V_ZERO, /* 0 */
+ F_ARGDIGIT, /* 1 */
+ F_ARGDIGIT, /* 2 */
+ F_ARGDIGIT, /* 3 */
+ F_ARGDIGIT, /* 4 */
+ F_ARGDIGIT, /* 5 */
+ F_ARGDIGIT, /* 6 */
+ F_ARGDIGIT, /* 7 */
+ F_ARGDIGIT, /* 8 */
+ F_ARGDIGIT, /* 9 */
+ F_UNASSIGNED, /* : */
+ V_RCHAR_FWD, /* ; */
+ F_UNASSIGNED, /* < */
+ F_UNASSIGNED, /* = */
+ F_UNASSIGNED, /* > */
+ V_USH_META, /* ? */
+ F_UNASSIGNED, /* @ */
+ V_ADDEND, /* A */
+ V_WORDBACK, /* B */
+ V_CHGTOEND, /* C */
+ F_KILLEND, /* D */
+ V_ENDWORD, /* E */
+ V_CHAR_BACK, /* F */
+ F_UNASSIGNED, /* G */
+ F_UNASSIGNED, /* H */
+ V_INSBEG, /* I */
+ F_DOWN_SEARCH_HIST, /* J */
+ F_UP_SEARCH_HIST, /* K */
+ F_UNASSIGNED, /* L */
+ F_UNASSIGNED, /* M */
+ V_RSRCH_BACK, /* N */
+ F_XKEY, /* O */
+ F_UNASSIGNED, /* P */
+ F_UNASSIGNED, /* Q */
+ V_REPLMODE, /* R */
+ V_SUBSTLINE, /* S */
+ V_CHARTO_BACK, /* T */
+ F_UNASSIGNED, /* U */
+ F_EXPAND_VARS, /* V */
+ V_WORDFWD, /* W */
+ F_DELPREV, /* X */
+ F_UNASSIGNED, /* Y */
+ F_UNASSIGNED, /* Z */
+ F_XKEY, /* [ */
+ F_UNASSIGNED, /* \ */
+ F_UNASSIGNED, /* ] */
+ F_TOBEG, /* ^ */
+ F_UNASSIGNED, /* _ */
+ F_UNASSIGNED, /* ` */
+ V_ADD, /* a */
+ F_WORDBACK, /* b */
+ V_CHGMETA, /* c */
+ V_DELMETA, /* d */
+ V_EWORD, /* e */
+ V_CHAR_FWD, /* f */
+ F_UNASSIGNED, /* g */
+ F_CHARBACK, /* h */
+ V_INSERT, /* i */
+ F_DOWN_HIST, /* j */
+ F_UP_HIST, /* k */
+ F_CHARFWD, /* l */
+ F_UNASSIGNED, /* m */
+ V_RSRCH_FWD, /* n */
+ F_UNASSIGNED, /* o */
+ F_UNASSIGNED, /* p */
+ F_UNASSIGNED, /* q */
+ V_REPLONE, /* r */
+ V_SUBSTCHAR, /* s */
+ V_CHARTO_FWD, /* t */
+ V_UNDO, /* u */
+ F_EXPAND_VARS, /* v */
+ V_WORDBEGNEXT, /* w */
+ F_DELNEXT_EOF, /* x */
+ F_UNASSIGNED, /* y */
+ F_UNASSIGNED, /* z */
+ F_UNASSIGNED, /* { */
+ F_UNASSIGNED, /* | */
+ F_UNASSIGNED, /* } */
+ V_CHGCASE, /* ~ */
+ F_DELPREV, /* ^? */
+ F_UNASSIGNED, /* M-^@ */
+ F_UNASSIGNED, /* M-^A */
+ F_UNASSIGNED, /* M-^B */
+ F_UNASSIGNED, /* M-^C */
+ F_UNASSIGNED, /* M-^D */
+ F_UNASSIGNED, /* M-^E */
+ F_UNASSIGNED, /* M-^F */
+ F_UNASSIGNED, /* M-^G */
+ F_UNASSIGNED, /* M-^H */
+ F_UNASSIGNED, /* M-^I */
+ F_UNASSIGNED, /* M-^J */
+ F_UNASSIGNED, /* M-^K */
+ F_UNASSIGNED, /* M-^L */
+ F_UNASSIGNED, /* M-^M */
+ F_UNASSIGNED, /* M-^N */
+ F_UNASSIGNED, /* M-^O */
+ F_UNASSIGNED, /* M-^P */
+ F_UNASSIGNED, /* M-^Q */
+ F_UNASSIGNED, /* M-^R */
+ F_UNASSIGNED, /* M-^S */
+ F_UNASSIGNED, /* M-^T */
+ F_UNASSIGNED, /* M-^U */
+ F_UNASSIGNED, /* M-^V */
+ F_UNASSIGNED, /* M-^W */
+ F_UNASSIGNED, /* M-^X */
+ F_UNASSIGNED, /* M-^Y */
+ F_UNASSIGNED, /* M-^Z */
+ F_UNASSIGNED, /* M-^[ */
+ F_UNASSIGNED, /* M-^\ */
+ F_UNASSIGNED, /* M-^] */
+ F_UNASSIGNED, /* M-^^ */
+ F_UNASSIGNED, /* M-^_ */
+ F_UNASSIGNED, /* M-SPACE */
+ F_UNASSIGNED, /* M-! */
+ F_UNASSIGNED, /* M-" */
+ F_UNASSIGNED, /* M-# */
+ F_UNASSIGNED, /* M-$ */
+ F_UNASSIGNED, /* M-% */
+ F_UNASSIGNED, /* M-& */
+ F_UNASSIGNED, /* M-' */
+ F_UNASSIGNED, /* M-( */
+ F_UNASSIGNED, /* M-) */
+ F_UNASSIGNED, /* M-* */
+ F_UNASSIGNED, /* M-+ */
+ F_UNASSIGNED, /* M-, */
+ F_UNASSIGNED, /* M-- */
+ F_UNASSIGNED, /* M-. */
+ F_UNASSIGNED, /* M-/ */
+ F_UNASSIGNED, /* M-0 */
+ F_UNASSIGNED, /* M-1 */
+ F_UNASSIGNED, /* M-2 */
+ F_UNASSIGNED, /* M-3 */
+ F_UNASSIGNED, /* M-4 */
+ F_UNASSIGNED, /* M-5 */
+ F_UNASSIGNED, /* M-6 */
+ F_UNASSIGNED, /* M-7 */
+ F_UNASSIGNED, /* M-8 */
+ F_UNASSIGNED, /* M-9 */
+ F_UNASSIGNED, /* M-: */
+ F_UNASSIGNED, /* M-; */
+ F_UNASSIGNED, /* M-< */
+ F_UNASSIGNED, /* M-= */
+ F_UNASSIGNED, /* M-> */
+ F_HELPME, /* M-? */
+ F_UNASSIGNED, /* M-@ */
+ F_UNASSIGNED, /* M-A */
+ F_UNASSIGNED, /* M-B */
+ F_UNASSIGNED, /* M-C */
+ F_UNASSIGNED, /* M-D */
+ F_UNASSIGNED, /* M-E */
+ F_UNASSIGNED, /* M-F */
+ F_UNASSIGNED, /* M-G */
+ F_UNASSIGNED, /* M-H */
+ F_UNASSIGNED, /* M-I */
+ F_UNASSIGNED, /* M-J */
+ F_UNASSIGNED, /* M-K */
+ F_UNASSIGNED, /* M-L */
+ F_UNASSIGNED, /* M-M */
+ F_UNASSIGNED, /* M-N */
+ F_XKEY, /* M-O *//* extended key esc PWP Mar 88 */
+ F_UNASSIGNED, /* M-P */
+ F_UNASSIGNED, /* M-Q */
+ F_UNASSIGNED, /* M-R */
+ F_UNASSIGNED, /* M-S */
+ F_UNASSIGNED, /* M-T */
+ F_UNASSIGNED, /* M-U */
+ F_UNASSIGNED, /* M-V */
+ F_UNASSIGNED, /* M-W */
+ F_UNASSIGNED, /* M-X */
+ F_UNASSIGNED, /* M-Y */
+ F_UNASSIGNED, /* M-Z */
+ F_XKEY, /* M-[ *//* extended key esc -mf Oct 87 */
+ F_UNASSIGNED, /* M-\ */
+ F_UNASSIGNED, /* M-] */
+ F_UNASSIGNED, /* M-^ */
+ F_UNASSIGNED, /* M-_ */
+ F_UNASSIGNED, /* M-` */
+ F_UNASSIGNED, /* M-a */
+ F_UNASSIGNED, /* M-b */
+ F_UNASSIGNED, /* M-c */
+ F_UNASSIGNED, /* M-d */
+ F_UNASSIGNED, /* M-e */
+ F_UNASSIGNED, /* M-f */
+ F_UNASSIGNED, /* M-g */
+ F_UNASSIGNED, /* M-h */
+ F_UNASSIGNED, /* M-i */
+ F_UNASSIGNED, /* M-j */
+ F_UNASSIGNED, /* M-k */
+ F_UNASSIGNED, /* M-l */
+ F_UNASSIGNED, /* M-m */
+ F_UNASSIGNED, /* M-n */
+ F_UNASSIGNED, /* M-o */
+ F_UNASSIGNED, /* M-p */
+ F_UNASSIGNED, /* M-q */
+ F_UNASSIGNED, /* M-r */
+ F_UNASSIGNED, /* M-s */
+ F_UNASSIGNED, /* M-t */
+ F_UNASSIGNED, /* M-u */
+ F_UNASSIGNED, /* M-v */
+ F_UNASSIGNED, /* M-w */
+ F_UNASSIGNED, /* M-x */
+ F_UNASSIGNED, /* M-y */
+ F_UNASSIGNED, /* M-z */
+ F_UNASSIGNED, /* M-{ */
+ F_UNASSIGNED, /* M-| */
+ F_UNASSIGNED, /* M-} */
+ F_UNASSIGNED, /* M-~ */
+ F_UNASSIGNED /* M-^? */
+};
+#endif /* WINNT */
+
+
+void
+editinit()
+{
+ struct KeyFuncs *f;
+
+#if defined(NLS_CATALOGS) || defined(WINNT)
+ int i;
+
+ for (i = 0; i < F_NUM_FUNCNAMES; i++)
+ xfree((ptr_t) FuncNames[i].desc);
+#endif
+
+ f = FuncNames;
+ f->name = "backward-char";
+ f->func = F_CHARBACK;
+ f->desc = CSAVS(3, 1, "Move back a character");
+
+ f++;
+ f->name = "backward-delete-char";
+ f->func = F_DELPREV;
+ f->desc = CSAVS(3, 2, "Delete the character behind cursor");
+
+ f++;
+ f->name = "backward-delete-word";
+ f->func = F_DELWORDPREV;
+ f->desc = CSAVS(3, 3,
+ "Cut from beginning of current word to cursor - saved in cut buffer");
+
+ f++;
+ f->name = "backward-kill-line";
+ f->func = F_KILLBEG;
+ f->desc = CSAVS(3, 4,
+ "Cut from beginning of line to cursor - save in cut buffer");
+
+ f++;
+ f->name = "backward-word";
+ f->func = F_WORDBACK;
+ f->desc = CSAVS(3, 5, "Move to beginning of current word");
+
+ f++;
+ f->name = "beginning-of-line";
+ f->func = F_TOBEG;
+ f->desc = CSAVS(3, 6, "Move to beginning of line");
+
+ f++;
+ f->name = "capitalize-word";
+ f->func = F_CASECAPITAL;
+ f->desc = CSAVS(3, 7,
+ "Capitalize the characters from cursor to end of current word");
+
+ f++;
+ f->name = "change-case";
+ f->func = V_CHGCASE;
+ f->desc = CSAVS(3, 8,
+ "Vi change case of character under cursor and advance one character");
+
+ f++;
+ f->name = "change-till-end-of-line";
+ f->func = V_CHGTOEND; /* backward compat. */
+ f->desc = CSAVS(3, 9, "Vi change to end of line");
+
+ f++;
+ f->name = "clear-screen";
+ f->func = F_CLEARDISP;
+ f->desc = CSAVS(3, 10, "Clear screen leaving current line on top");
+
+ f++;
+ f->name = "complete-word";
+ f->func = F_COMPLETE;
+ f->desc = CSAVS(3, 11, "Complete current word");
+
+ f++;
+ f->name = "complete-word-fwd";
+ f->func = F_COMPLETE_FWD;
+ f->desc = CSAVS(3, 12, "Tab forward through files");
+
+ f++;
+ f->name = "complete-word-back";
+ f->func = F_COMPLETE_BACK;
+ f->desc = CSAVS(3, 13, "Tab backward through files");
+
+ f++;
+ f->name = "complete-word-raw";
+ f->func = F_COMPLETE_ALL;
+ f->desc = CSAVS(3, 14,
+ "Complete current word ignoring programmable completions");
+
+ f++;
+ f->name = "copy-prev-word";
+ f->func = F_COPYPREV;
+ f->desc = CSAVS(3, 15, "Copy current word to cursor");
+
+ f++;
+ f->name = "copy-region-as-kill";
+ f->func = F_COPYREGION;
+ f->desc = CSAVS(3, 16, "Copy area between mark and cursor to cut buffer");
+
+ f++;
+ f->name = "dabbrev-expand";
+ f->func = F_DABBREV_EXPAND;
+ f->desc = CSAVS(3, 17,
+ "Expand to preceding word for which this is a prefix");
+
+ f++;
+ f->name = "delete-char";
+ f->func = F_DELNEXT;
+ f->desc = CSAVS(3, 18, "Delete character under cursor");
+
+ f++;
+ f->name = "delete-char-or-eof";
+ f->func = F_DELNEXT_EOF;
+ f->desc = CSAVS(3, 19,
+ "Delete character under cursor or signal end of file on an empty line");
+
+ f++;
+ f->name = "delete-char-or-list";
+ f->func = F_DELNEXT_LIST;
+ f->desc = CSAVS(3, 20,
+ "Delete character under cursor or list completions if at end of line");
+
+ f++;
+ f->name = "delete-char-or-list-or-eof";
+ f->func = F_DELNEXT_LIST_EOF;
+ f->desc = CSAVS(3, 21,
+ "Delete character under cursor, list completions or signal end of file");
+
+ f++;
+ f->name = "delete-word";
+ f->func = F_DELWORDNEXT;
+ f->desc = CSAVS(3, 22,
+ "Cut from cursor to end of current word - save in cut buffer");
+
+ f++;
+ f->name = "digit";
+ f->func = F_DIGIT;
+ f->desc = CSAVS(3, 23, "Adds to argument if started or enters digit");
+
+ f++;
+ f->name = "digit-argument";
+ f->func = F_ARGDIGIT;
+ f->desc = CSAVS(3, 24, "Digit that starts argument");
+
+ f++;
+ f->name = "down-history";
+ f->func = F_DOWN_HIST;
+ f->desc = CSAVS(3, 25, "Move to next history line");
+
+ f++;
+ f->name = "downcase-word";
+ f->func = F_CASELOWER;
+ f->desc = CSAVS(3, 26,
+ "Lowercase the characters from cursor to end of current word");
+
+ f++;
+ f->name = "end-of-file";
+ f->func = F_SEND_EOF;
+ f->desc = CSAVS(3, 27, "Indicate end of file");
+
+ f++;
+ f->name = "end-of-line";
+ f->func = F_TOEND;
+ f->desc = CSAVS(3, 28, "Move cursor to end of line");
+
+ f++;
+ f->name = "exchange-point-and-mark";
+ f->func = F_EXCHANGE_MARK;
+ f->desc = CSAVS(3, 29, "Exchange the cursor and mark");
+
+ f++;
+ f->name = "expand-glob";
+ f->func = F_EXPAND_GLOB;
+ f->desc = CSAVS(3, 30, "Expand file name wildcards");
+
+ f++;
+ f->name = "expand-history";
+ f->func = F_EXPAND_HISTORY;
+ f->desc = CSAVS(3, 31, "Expand history escapes");
+
+ f++;
+ f->name = "expand-line";
+ f->func = F_EXPAND;
+ f->desc = CSAVS(3, 32, "Expand the history escapes in a line");
+
+ f++;
+ f->name = "expand-variables";
+ f->func = F_EXPAND_VARS;
+ f->desc = CSAVS(3, 33, "Expand variables");
+
+ f++;
+ f->name = "forward-char";
+ f->func = F_CHARFWD;
+ f->desc = CSAVS(3, 34, "Move forward one character");
+
+ f++;
+ f->name = "forward-word";
+ f->func = F_WORDFWD;
+ f->desc = CSAVS(3, 35, "Move forward to end of current word");
+
+ f++;
+ f->name = "gosmacs-transpose-chars";
+ f->func = F_GCHARSWITCH;
+ f->desc = CSAVS(3, 36, "Exchange the two characters before the cursor");
+
+ f++;
+ f->name = "history-search-backward";
+ f->func = F_UP_SEARCH_HIST;
+ f->desc = CSAVS(3, 37,
+ "Search in history backward for line beginning as current");
+
+ f++;
+ f->name = "history-search-forward";
+ f->func = F_DOWN_SEARCH_HIST;
+ f->desc = CSAVS(3, 38,
+ "Search in history forward for line beginning as current");
+
+ f++;
+ f->name = "insert-last-word";
+ f->func = F_LAST_ITEM;
+ f->desc = CSAVS(3, 39, "Insert last item of previous command");
+
+ f++;
+ f->name = "i-search-fwd";
+ f->func = F_INC_FWD;
+ f->desc = CSAVS(3, 40, "Incremental search forward");
+
+ f++;
+ f->name = "i-search-back";
+ f->func = F_INC_BACK;
+ f->desc = CSAVS(3, 41, "Incremental search backward");
+
+ f++;
+ f->name = "keyboard-quit";
+ f->func = F_STARTOVER;
+ f->desc = CSAVS(3, 42, "Clear line");
+
+ f++;
+ f->name = "kill-line";
+ f->func = F_KILLEND;
+ f->desc = CSAVS(3, 43, "Cut to end of line and save in cut buffer");
+
+ f++;
+ f->name = "kill-region";
+ f->func = F_KILLREGION;
+ f->desc = CSAVS(3, 44,
+ "Cut area between mark and cursor and save in cut buffer");
+
+ f++;
+ f->name = "kill-whole-line";
+ f->func = F_KILLALL;
+ f->desc = CSAVS(3, 45, "Cut the entire line and save in cut buffer");
+
+ f++;
+ f->name = "list-choices";
+ f->func = F_LIST_CHOICES;
+ f->desc = CSAVS(3, 46, "List choices for completion");
+
+ f++;
+ f->name = "list-choices-raw";
+ f->func = F_LIST_ALL;
+ f->desc = CSAVS(3, 47,
+ "List choices for completion overriding programmable completion");
+
+ f++;
+ f->name = "list-glob";
+ f->func = F_LIST_GLOB;
+ f->desc = CSAVS(3, 48, "List file name wildcard matches");
+
+ f++;
+ f->name = "list-or-eof";
+ f->func = F_LIST_EOF;
+ f->desc = CSAVS(3, 49,
+ "List choices for completion or indicate end of file if empty line");
+
+ f++;
+ f->name = "load-average";
+ f->func = F_LOAD_AVERAGE;
+ f->desc = CSAVS(3, 50, "Display load average and current process status");
+
+ f++;
+ f->name = "magic-space";
+ f->func = F_MAGIC_SPACE;
+ f->desc = CSAVS(3, 51, "Expand history escapes and insert a space");
+
+ f++;
+ f->name = "newline";
+ f->func = F_NEWLINE;
+ f->desc = CSAVS(3, 52, "Execute command");
+
+ f++;
+ f->name = "normalize-path";
+ f->func = F_PATH_NORM;
+ f->desc = CSAVS(3, 53,
+ "Expand pathnames, eliminating leading .'s and ..'s");
+
+ f++;
+ f->name = "normalize-command";
+ f->func = F_COMMAND_NORM;
+ f->desc = CSAVS(3, 54,
+ "Expand commands to the resulting pathname or alias");
+
+ f++;
+ f->name = "overwrite-mode";
+ f->func = F_INSOVR;
+ f->desc = CSAVS(3, 55,
+ "Switch from insert to overwrite mode or vice versa");
+
+ f++;
+ f->name = "prefix-meta";
+ f->func = F_METANEXT;
+ f->desc = CSAVS(3, 56, "Add 8th bit to next character typed");
+
+ f++;
+ f->name = "quoted-insert";
+ f->func = F_QUOTE;
+ f->desc = CSAVS(3, 57, "Add the next character typed to the line verbatim");
+
+ f++;
+ f->name = "redisplay";
+ f->func = F_REDISP;
+ f->desc = CSAVS(3, 58, "Redisplay everything");
+
+ f++;
+ f->name = "run-fg-editor";
+ f->func = F_RUN_FG_EDITOR;
+ f->desc = CSAVS(3, 59, "Restart stopped editor");
+
+ f++;
+ f->name = "run-help";
+ f->func = F_HELPME;
+ f->desc = CSAVS(3, 60, "Look for help on current command");
+
+ f++;
+ f->name = "self-insert-command";
+ f->func = F_INSERT;
+ f->desc = CSAVS(3, 61, "This character is added to the line");
+
+ f++;
+ f->name = "sequence-lead-in";
+ f->func = F_XKEY;
+ f->desc = CSAVS(3, 62,
+ "This character is the first in a character sequence");
+
+ f++;
+ f->name = "set-mark-command";
+ f->func = F_SET_MARK;
+ f->desc = CSAVS(3, 63, "Set the mark at cursor");
+
+ f++;
+ f->name = "spell-word";
+ f->func = F_CORRECT;
+ f->desc = CSAVS(3, 64, "Correct the spelling of current word");
+
+ f++;
+ f->name = "spell-line";
+ f->func = F_CORRECT_L;
+ f->desc = CSAVS(3, 65, "Correct the spelling of entire line");
+
+ f++;
+ f->name = "stuff-char";
+ f->func = F_STUFF_CHAR;
+ f->desc = CSAVS(3, 66, "Send character to tty in cooked mode");
+
+ f++;
+ f->name = "toggle-literal-history";
+ f->func = F_TOGGLE_HIST;
+ f->desc = CSAVS(3, 67,
+ "Toggle between literal and lexical current history line");
+
+ f++;
+ f->name = "transpose-chars";
+ f->func = F_CHARSWITCH;
+ f->desc = CSAVS(3, 68,
+ "Exchange the character to the left of the cursor with the one under");
+
+ f++;
+ f->name = "transpose-gosling";
+ f->func = F_GCHARSWITCH;
+ f->desc = CSAVS(3, 69, "Exchange the two characters before the cursor");
+
+ f++;
+ f->name = "tty-dsusp";
+ f->func = F_TTY_DSUSP;
+ f->desc = CSAVS(3, 70, "Tty delayed suspend character");
+
+ f++;
+ f->name = "tty-flush-output";
+ f->func = F_TTY_FLUSHO;
+ f->desc = CSAVS(3, 71, "Tty flush output character");
+
+ f++;
+ f->name = "tty-sigintr";
+ f->func = F_TTY_INT;
+ f->desc = CSAVS(3, 72, "Tty interrupt character");
+
+ f++;
+ f->name = "tty-sigquit";
+ f->func = F_TTY_QUIT;
+ f->desc = CSAVS(3, 73, "Tty quit character");
+
+ f++;
+ f->name = "tty-sigtsusp";
+ f->func = F_TTY_TSUSP;
+ f->desc = CSAVS(3, 74, "Tty suspend character");
+
+ f++;
+ f->name = "tty-start-output";
+ f->func = F_TTY_STARTO;
+ f->desc = CSAVS(3, 75, "Tty allow output character");
+
+ f++;
+ f->name = "tty-stop-output";
+ f->func = F_TTY_STOPO;
+ f->desc = CSAVS(3, 76, "Tty disallow output character");
+
+ f++;
+ f->name = "undefined-key";
+ f->func = F_UNASSIGNED;
+ f->desc = CSAVS(3, 77, "Indicates unbound character");
+
+ f++;
+ f->name = "universal-argument";
+ f->func = F_ARGFOUR;
+ f->desc = CSAVS(3, 78, "Emacs universal argument (argument times 4)");
+
+ f++;
+ f->name = "up-history";
+ f->func = F_UP_HIST;
+ f->desc = CSAVS(3, 79, "Move to previous history line");
+
+ f++;
+ f->name = "upcase-word";
+ f->func = F_CASEUPPER;
+ f->desc = CSAVS(3, 80,
+ "Uppercase the characters from cursor to end of current word");
+
+ f++;
+ f->name = "vi-beginning-of-next-word";
+ f->func = V_WORDBEGNEXT;
+ f->desc = CSAVS(3, 81, "Vi goto the beginning of next word");
+
+ f++;
+ f->name = "vi-add";
+ f->func = V_ADD;
+ f->desc = CSAVS(3, 82, "Vi enter insert mode after the cursor");
+
+ f++;
+ f->name = "vi-add-at-eol";
+ f->func = V_ADDEND;
+ f->desc = CSAVS(3, 83, "Vi enter insert mode at end of line");
+
+ f++;
+ f->name = "vi-chg-case";
+ f->func = V_CHGCASE;
+ f->desc = CSAVS(3, 84,
+ "Vi change case of character under cursor and advance one character");
+
+ f++;
+ f->name = "vi-chg-meta";
+ f->func = V_CHGMETA;
+ f->desc = CSAVS(3, 85, "Vi change prefix command");
+
+ f++;
+ f->name = "vi-chg-to-eol";
+ f->func = V_CHGTOEND;
+ f->desc = CSAVS(3, 86, "Vi change to end of line");
+
+ f++;
+ f->name = "vi-cmd-mode";
+ f->func = V_CMD_MODE;
+ f->desc = CSAVS(3, 87,
+ "Enter vi command mode (use alternative key bindings)");
+
+ f++;
+ f->name = "vi-cmd-mode-complete";
+ f->func = V_CM_COMPLETE;
+ f->desc = CSAVS(3, 88, "Vi command mode complete current word");
+
+ f++;
+ f->name = "vi-delprev";
+ f->func = V_DELPREV;
+ f->desc = CSAVS(3, 89, "Vi move to previous character (backspace)");
+
+ f++;
+ f->name = "vi-delmeta";
+ f->func = V_DELMETA;
+ f->desc = CSAVS(3, 90, "Vi delete prefix command");
+
+ f++;
+ f->name = "vi-endword";
+ f->func = V_ENDWORD;
+ f->desc = CSAVS(3, 91,
+ "Vi move to the end of the current space delimited word");
+
+ f++;
+ f->name = "vi-eword";
+ f->func = V_EWORD;
+ f->desc = CSAVS(3, 92, "Vi move to the end of the current word");
+
+ f++;
+ f->name = "vi-char-back";
+ f->func = V_CHAR_BACK;
+ f->desc = CSAVS(3, 93, "Vi move to the character specified backward");
+
+ f++;
+ f->name = "vi-char-fwd";
+ f->func = V_CHAR_FWD;
+ f->desc = CSAVS(3, 94, "Vi move to the character specified forward");
+
+ f++;
+ f->name = "vi-charto-back";
+ f->func = V_CHARTO_BACK;
+ f->desc = CSAVS(3, 95, "Vi move up to the character specified backward");
+
+ f++;
+ f->name = "vi-charto-fwd";
+ f->func = V_CHARTO_FWD;
+ f->desc = CSAVS(3, 96, "Vi move up to the character specified forward");
+
+ f++;
+ f->name = "vi-insert";
+ f->func = V_INSERT;
+ f->desc = CSAVS(3, 97, "Enter vi insert mode");
+
+ f++;
+ f->name = "vi-insert-at-bol";
+ f->func = V_INSBEG;
+ f->desc = CSAVS(3, 98, "Enter vi insert mode at beginning of line");
+
+ f++;
+ f->name = "vi-repeat-char-fwd";
+ f->func = V_RCHAR_FWD;
+ f->desc = CSAVS(3, 99,
+ "Vi repeat current character search in the same search direction");
+
+ f++;
+ f->name = "vi-repeat-char-back";
+ f->func = V_RCHAR_BACK;
+ f->desc = CSAVS(3, 100,
+ "Vi repeat current character search in the opposite search direction");
+
+ f++;
+ f->name = "vi-repeat-search-fwd";
+ f->func = V_RSRCH_FWD;
+ f->desc = CSAVS(3, 101,
+ "Vi repeat current search in the same search direction");
+
+ f++;
+ f->name = "vi-repeat-search-back";
+ f->func = V_RSRCH_BACK;
+ f->desc = CSAVS(3, 102,
+ "Vi repeat current search in the opposite search direction");
+
+ f++;
+ f->name = "vi-replace-char";
+ f->func = V_REPLONE;
+ f->desc = CSAVS(3, 103,
+ "Vi replace character under the cursor with the next character typed");
+
+ f++;
+ f->name = "vi-replace-mode";
+ f->func = V_REPLMODE;
+ f->desc = CSAVS(3, 104, "Vi replace mode");
+
+ f++;
+ f->name = "vi-search-back";
+ f->func = V_USH_META;
+ f->desc = CSAVS(3, 105, "Vi search history backward");
+
+ f++;
+ f->name = "vi-search-fwd";
+ f->func = V_DSH_META;
+ f->desc = CSAVS(3, 106, "Vi search history forward");
+
+ f++;
+ f->name = "vi-substitute-char";
+ f->func = V_SUBSTCHAR;
+ f->desc = CSAVS(3, 107,
+ "Vi replace character under the cursor and enter insert mode");
+
+ f++;
+ f->name = "vi-substitute-line";
+ f->func = V_SUBSTLINE;
+ f->desc = CSAVS(3, 108, "Vi replace entire line");
+
+ f++;
+ f->name = "vi-word-back";
+ f->func = V_WORDBACK;
+ f->desc = CSAVS(3, 109, "Vi move to the previous word");
+
+ f++;
+ f->name = "vi-word-fwd";
+ f->func = V_WORDFWD;
+ f->desc = CSAVS(3, 110, "Vi move to the next word");
+
+ f++;
+ f->name = "vi-undo";
+ f->func = V_UNDO;
+ f->desc = CSAVS(3, 111, "Vi undo last change");
+
+ f++;
+ f->name = "vi-zero";
+ f->func = V_ZERO;
+ f->desc = CSAVS(3, 112, "Vi goto the beginning of line");
+
+ f++;
+ f->name = "which-command";
+ f->func = F_WHICH;
+ f->desc = CSAVS(3, 113, "Perform which of current command");
+
+ f++;
+ f->name = "yank";
+ f->func = F_YANK_KILL;
+ f->desc = CSAVS(3, 114, "Paste cut buffer at cursor position");
+
+ f++;
+ f->name = "e_copy_to_clipboard";
+ f->func = F_COPY_CLIP;
+ f->desc = CSAVS(3, 115, "(win32 only)Copy cut buffer to system clipboard");
+ f++;
+ f->name = "e_paste_from_clipboard";
+ f->func = F_PASTE_CLIP;
+ f->desc = CSAVS(3, 116, "(win32 only)Paste clipboard buffer at cursor position");
+ f++;
+ f->name = "e_dosify_next";
+ f->func = F_DOSIFY_NEXT;
+ f->desc = CSAVS(3, 117, "(win32 only)Convert each '/' in next word to '\\\\'");
+ f++;
+ f->name = "e_dosify_prev";
+ f->func = F_DOSIFY_PREV;
+ f->desc = CSAVS(3, 118, "(win32 only)Convert each '/' in previous word to '\\\\'");
+
+ f++;
+ f->name = NULL;
+ f->func = 0;
+ f->desc = NULL;
+
+ f++;
+ if (f - FuncNames != F_NUM_FUNCNAMES)
+ abort();
+}
+
+#ifdef DEBUG_EDIT
+void
+CheckMaps()
+{ /* check the size of the key maps */
+ int c1 = (NT_NUM_KEYS * sizeof(KEYCMD));
+
+ if ((sizeof(CcKeyMap)) != c1)
+ xprintf("CcKeyMap should be %d entries, but is %d.\r\n",
+ NT_NUM_KEYS, sizeof(CcKeyMap) / sizeof(KEYCMD)));
+
+ if ((sizeof(CcAltMap)) != c1)
+ xprintf("CcAltMap should be %d entries, but is %d.\r\n",
+ NT_NUM_KEYS, (sizeof(CcAltMap) / sizeof(KEYCMD)));
+
+ if ((sizeof(CcEmacsMap)) != c1)
+ xprintf("CcEmacsMap should be %d entries, but is %d.\r\n",
+ NT_NUM_KEYS, (sizeof(CcEmacsMap) / sizeof(KEYCMD)));
+
+ if ((sizeof(CcViMap)) != c1)
+ xprintf("CcViMap should be %d entries, but is %d.\r\n",
+ NT_NUM_KEYS, (sizeof(CcViMap) / sizeof(KEYCMD)));
+
+ if ((sizeof(CcViCmdMap)) != c1)
+ xprintf("CcViCmdMap should be %d entries, but is %d.\r\n",
+ NT_NUM_KEYS, (sizeof(CcViCmdMap) / sizeof(KEYCMD)));
+}
+
+#endif
+
+bool MapsAreInited = 0;
+bool NLSMapsAreInited = 0;
+bool NoNLSRebind;
+
+void
+ed_InitNLSMaps()
+{
+ register int i;
+
+ if (AsciiOnly)
+ return;
+ if (NoNLSRebind)
+ return;
+ for (i = 0200; i <= 0377; i++) {
+ if (Isprint(i)) {
+ CcKeyMap[i] = F_INSERT;
+ }
+ }
+ NLSMapsAreInited = 1;
+}
+
+static void
+ed_InitMetaBindings()
+{
+ Char buf[3];
+ int i;
+ CStr cstr;
+ KEYCMD *map;
+
+ map = CcKeyMap;
+ for (i = 0; i <= 0377 && CcKeyMap[i] != F_METANEXT; i++)
+ continue;
+ if (i > 0377) {
+ for (i = 0; i <= 0377 && CcAltMap[i] != F_METANEXT; i++)
+ continue;
+ if (i > 0377) {
+ i = CTL_ESC('\033');
+ if (VImode)
+ map = CcAltMap;
+ }
+ else {
+ map = CcAltMap;
+ }
+ }
+ buf[0] = (Char) i;
+ buf[2] = 0;
+ cstr.buf = buf;
+ cstr.len = 2;
+ for (i = 0200; i <= 0377; i++) {
+ if (map[i] != F_INSERT && map[i] != F_UNASSIGNED && map[i] != F_XKEY) {
+#ifndef _OSD_POSIX
+ buf[1] = i & ASCII;
+#else
+ buf[1] = _toebcdic[_toascii[i] & ASCII];
+#endif
+ AddXkey(&cstr, XmapCmd((int) map[i]), XK_CMD);
+ }
+ }
+ map[buf[0]] = F_XKEY;
+}
+
+void
+ed_InitVIMaps()
+{
+ register int i;
+
+ VImode = 1;
+ ResetXmap();
+ for (i = 0; i < NT_NUM_KEYS; i++) {
+ CcKeyMap[i] = CcViMap[i];
+ CcAltMap[i] = CcViCmdMap[i];
+ }
+ ed_InitMetaBindings();
+ ed_InitNLSMaps();
+ ResetArrowKeys();
+ BindArrowKeys();
+}
+
+void
+ed_InitEmacsMaps()
+{
+ int i;
+ Char buf[3];
+ CStr cstr;
+ cstr.buf = buf;
+ cstr.len = 2;
+
+ VImode = 0;
+ ResetXmap();
+ for (i = 0; i < NT_NUM_KEYS; i++) {
+ CcKeyMap[i] = CcEmacsMap[i];
+ CcAltMap[i] = F_UNASSIGNED;
+ }
+ ed_InitMetaBindings();
+ ed_InitNLSMaps();
+ buf[0] = CTL_ESC('\030');
+ buf[2] = 0;
+ buf[1] = CTL_ESC('\030');
+ AddXkey(&cstr, XmapCmd(F_EXCHANGE_MARK), XK_CMD);
+ buf[1] = '*';
+ AddXkey(&cstr, XmapCmd(F_EXPAND_GLOB), XK_CMD);
+ buf[1] = '$';
+ AddXkey(&cstr, XmapCmd(F_EXPAND_VARS), XK_CMD);
+ buf[1] = 'G';
+ AddXkey(&cstr, XmapCmd(F_LIST_GLOB), XK_CMD);
+ buf[1] = 'g';
+ AddXkey(&cstr, XmapCmd(F_LIST_GLOB), XK_CMD);
+ buf[1] = 'n';
+ AddXkey(&cstr, XmapCmd(F_PATH_NORM), XK_CMD);
+ buf[1] = 'N';
+ AddXkey(&cstr, XmapCmd(F_PATH_NORM), XK_CMD);
+ buf[1] = '?';
+ AddXkey(&cstr, XmapCmd(F_COMMAND_NORM), XK_CMD);
+ buf[1] = '\t';
+ AddXkey(&cstr, XmapCmd(F_COMPLETE_ALL), XK_CMD);
+ buf[1] = CTL_ESC('\004'); /* ^D */
+ AddXkey(&cstr, XmapCmd(F_LIST_ALL), XK_CMD);
+ ResetArrowKeys();
+ BindArrowKeys();
+}
+
+void
+ed_InitMaps()
+{
+ if (MapsAreInited)
+ return;
+#ifdef _OSD_POSIX
+ /* This machine has an EBCDIC charset. The assumptions made for the
+ * initialized keymaps therefore don't hold, since they are based on
+ * ASCII (or ISO8859-1).
+ * Here, we do a one-time transformation to EBCDIC environment
+ * for the key initializations.
+ */
+ {
+ KEYCMD temp[NT_NUM_KEYS];
+ static KEYCMD *const list[3] = { CcEmacsMap, CcViMap, CcViCmdMap };
+ register int i, table;
+
+ for (table=0; table<3; ++table)
+ {
+ /* copy ASCII ordered map to temp table */
+ for (i = 0; i < NT_NUM_KEYS; i++) {
+ temp[i] = list[table][i];
+ }
+ /* write back as EBCDIC ordered map */
+ for (i = 0; i < NT_NUM_KEYS; i++) {
+ list[table][_toebcdic[i]] = temp[i];
+ }
+ }
+ }
+#endif /* _OSD_POSIX */
+
+#ifdef VIDEFAULT
+ ed_InitVIMaps();
+#else
+ ed_InitEmacsMaps();
+#endif
+
+ MapsAreInited = 1;
+}
diff --git a/contrib/tcsh/ed.h b/contrib/tcsh/ed.h
new file mode 100644
index 000000000000..659a0a66aa5e
--- /dev/null
+++ b/contrib/tcsh/ed.h
@@ -0,0 +1,254 @@
+/* $Header: /src/pub/tcsh/ed.h,v 3.28 1998/11/24 18:17:21 christos Exp $ */
+/*
+ * ed.h: Editor declarations and globals
+ */
+/*-
+ * Copyright (c) 1980, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#ifndef _h_ed
+#define _h_ed
+
+#ifndef EXTERN
+# define EXTERN extern
+#endif
+
+#define TABSIZE 8 /* usually 8 spaces/tab */
+#define MAXMACROLEVELS 10 /* max number of nested kbd macros */
+
+#ifndef WINNT
+# define NT_NUM_KEYS 256
+#endif /* WINNT */
+
+extern int errno;
+
+/****************************************************************************/
+/* stuff for the different states returned by the character editor routines */
+/****************************************************************************/
+
+#define CCRETVAL char /* size needed for the different char editor */
+ /* return values */
+
+#define KEYCMD unsigned char /* size needed to index into CcFuncTbl */
+ /* Must be unsigned */
+
+typedef CCRETVAL(*PFCmd) __P((int)); /* pointer to function returning CCRETVAL */
+
+struct KeyFuncs { /* for the "bind" shell command */
+ char *name; /* function name for bind command */
+ int func; /* function numeric value */
+ char *desc; /* description of function */
+};
+
+extern PFCmd CcFuncTbl[]; /* table of available commands */
+extern KEYCMD CcKeyMap[]; /* keymap table, each index into above tbl */
+extern KEYCMD CcAltMap[]; /* Alt keymap table */
+extern KEYCMD CcEmacsMap[]; /* keymap table for Emacs default bindings */
+extern KEYCMD CcViCmdMap[]; /* for Vi command mode defaults */
+extern struct KeyFuncs FuncNames[]; /* string names vs. CcFuncTbl indices */
+
+extern KEYCMD NumFuns; /* number of KEYCMDs in above table */
+
+#define CC_ERROR 100 /* there should NOT be 100 different... */
+#define CC_FATAL 101 /* fatal error: inconsistant, must
+ * reset */
+#define CC_NORM 0
+#define CC_NEWLINE 1
+#define CC_EOF 2
+#define CC_COMPLETE 3
+#define CC_LIST_CHOICES 4
+#define CC_LIST_GLOB 5
+#define CC_EXPAND_GLOB 6
+#define CC_HELPME 9
+#define CC_CORRECT 10
+#define CC_WHICH 11
+#define CC_ARGHACK 12
+#define CC_CORRECT_L 13
+#define CC_REFRESH 14
+#define CC_EXPAND_VARS 15
+#define CC_NORMALIZE_PATH 16
+#define CC_LIST_ALL 17
+#define CC_COMPLETE_ALL 18
+#define CC_COMPLETE_FWD 19
+#define CC_COMPLETE_BACK 20
+#define CC_NORMALIZE_COMMAND 21
+
+typedef struct {
+ Char *buf;
+ int len;
+} CStr;
+
+typedef union Xmapval { /* value passed to the Xkey routines */
+ KEYCMD cmd;
+ CStr str;
+} XmapVal;
+
+#define XK_NOD -1 /* Internal tree node */
+#define XK_CMD 0 /* X-key was an editor command */
+#define XK_STR 1 /* X-key was a string macro */
+#define XK_EXE 2 /* X-key was a unix command */
+
+/****************************/
+/* Editor state and buffers */
+/****************************/
+
+EXTERN KEYCMD *CurrentKeyMap; /* current command key map */
+EXTERN int inputmode; /* insert, replace, replace1 mode */
+EXTERN Char GettingInput; /* true if getting an input line (mostly) */
+EXTERN Char NeedsRedraw; /* for editor and twenex error messages */
+EXTERN Char InputBuf[INBUFSIZE]; /* the real input data */
+EXTERN Char *LastChar, *Cursor; /* point to the next open space */
+EXTERN Char *InputLim; /* limit of size of InputBuf */
+EXTERN Char MetaNext; /* flags for ^V and ^[ functions */
+EXTERN Char AltKeyMap; /* Using alternative command map (for vi mode) */
+EXTERN Char VImode; /* true if running in vi mode (PWP 6-27-88) */
+EXTERN Char *Mark; /* the emacs "mark" (dot is Cursor) */
+EXTERN Char DoingArg; /* true if we have an argument */
+EXTERN int Argument; /* "universal" argument value */
+EXTERN KEYCMD LastCmd; /* previous command executed */
+EXTERN Char KillBuf[INBUFSIZE]; /* kill buffer */
+EXTERN Char *LastKill; /* points to end of kill buffer */
+
+EXTERN Char UndoBuf[INBUFSIZE];
+EXTERN Char *UndoPtr;
+EXTERN int UndoSize;
+EXTERN int UndoAction;
+
+EXTERN Char HistBuf[INBUFSIZE]; /* history buffer */
+EXTERN Char *LastHist; /* points to end of history buffer */
+EXTERN int Hist_num; /* what point up the history we are at now. */
+EXTERN Char WhichBuf[INBUFSIZE]; /* buffer for which command */
+EXTERN Char *LastWhich; /* points to end of which buffer */
+EXTERN Char *CursWhich; /* points to the cursor point in which buf */
+EXTERN int HistWhich; /* Hist_num is saved in this */
+EXTERN char Expand; /* true if we are expanding a line */
+extern Char HistLit; /* true if history lines are shown literal */
+EXTERN Char CurrentHistLit; /* Literal status of current show history line */
+
+/*
+ * These are truly extern
+ */
+extern int MacroLvl;
+
+EXTERN Char *KeyMacro[MAXMACROLEVELS];
+
+EXTERN Char **Display; /* display buffer seed vector */
+EXTERN int CursorV, /* real cursor vertical (line) */
+ CursorH, /* real cursor horisontal (column) */
+ TermV, /* number of real screen lines
+ * (sizeof(DisplayBuf) / width */
+ TermH; /* screen width */
+EXTERN Char **Vdisplay; /* new buffer */
+
+/* Variables that describe terminal ability */
+EXTERN int T_Lines, T_Cols; /* Rows and Cols of the terminal */
+EXTERN Char T_CanIns; /* true if I can insert characters */
+EXTERN Char T_CanDel; /* dito for delete characters */
+EXTERN Char T_Tabs; /* true if tty interface is passing tabs */
+EXTERN Char T_Margin;
+#define MARGIN_AUTO 1 /* term has auto margins */
+#define MARGIN_MAGIC 2 /* concept glitch */
+EXTERN speed_t T_Speed; /* Tty input Baud rate */
+EXTERN Char T_CanCEOL; /* true if we can clear to end of line */
+EXTERN Char T_CanUP; /* true if this term can do reverse linefeen */
+EXTERN Char T_HasMeta; /* true if we have a meta key */
+
+/* note the extra characters in the Strchr() call in this macro */
+#define isword(c) (Isalpha(c)||Isdigit(c)||Strchr(word_chars,c))
+#define min(x,y) (((x)<(y))?(x):(y))
+#define max(x,y) (((x)>(y))?(x):(y))
+
+/*
+ * Terminal dependend data structures
+ */
+typedef struct {
+#ifdef WINNT
+ int dummy;
+#else /* !WINNT */
+# if defined(POSIX) || defined(TERMIO)
+# ifdef POSIX
+ struct termios d_t;
+# else
+ struct termio d_t;
+# endif /* POSIX */
+# else /* SGTTY */
+# ifdef TIOCGETP
+ struct sgttyb d_t;
+# endif /* TIOCGETP */
+# ifdef TIOCGETC
+ struct tchars d_tc;
+# endif /* TIOCGETC */
+# ifdef TIOCGPAGE
+ struct ttypagestat d_pc;
+# endif /* TIOCGPAGE */
+# ifdef TIOCLGET
+ int d_lb;
+# endif /* TIOCLGET */
+# endif /* POSIX || TERMIO */
+# ifdef TIOCGLTC
+ struct ltchars d_ltc;
+# endif /* TIOCGLTC */
+#endif /* WINNT */
+} ttydata_t;
+
+#define MODE_INSERT 0
+#define MODE_REPLACE 1
+#define MODE_REPLACE_1 2
+
+#define EX_IO 0 /* while we are executing */
+#define ED_IO 1 /* while we are editing */
+#define TS_IO 2 /* new mode from terminal */
+#define QU_IO 2 /* used only for quoted chars */
+#define NN_IO 3 /* The number of entries */
+
+#if defined(POSIX) || defined(TERMIO)
+# define M_INPUT 0
+# define M_OUTPUT 1
+# define M_CONTROL 2
+# define M_LINED 3
+# define M_CHAR 4
+# define M_NN 5
+#else /* GSTTY */
+# define M_CONTROL 0
+# define M_LOCAL 1
+# define M_CHAR 2
+# define M_NN 3
+#endif /* TERMIO */
+typedef struct {
+ char *t_name;
+ int t_setmask;
+ int t_clrmask;
+} ttyperm_t[NN_IO][M_NN];
+
+extern ttyperm_t ttylist;
+#include "ed.decls.h"
+
+#endif /* _h_ed */
diff --git a/contrib/tcsh/ed.init.c b/contrib/tcsh/ed.init.c
new file mode 100644
index 000000000000..aa31987cbfa9
--- /dev/null
+++ b/contrib/tcsh/ed.init.c
@@ -0,0 +1,736 @@
+/* $Header: /src/pub/tcsh/ed.init.c,v 3.41 1999/02/06 15:01:16 christos Exp $ */
+/*
+ * ed.init.c: Editor initializations
+ */
+/*-
+ * Copyright (c) 1980, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTS_ION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "sh.h"
+
+RCSID("$Id: ed.init.c,v 3.41 1999/02/06 15:01:16 christos Exp $")
+
+#include "ed.h"
+#include "ed.term.h"
+#include "tc.h"
+#include "ed.defns.h"
+
+/* ed.init.c -- init routines for the line editor */
+/* #define DEBUG_TTY */
+
+int Tty_raw_mode = 0; /* Last tty change was to raw mode */
+int MacroLvl = -1; /* pointer to current macro nesting level; */
+ /* (-1 == none) */
+static int Tty_quote_mode = 0; /* Last tty change was to quote mode */
+static unsigned char vdisable; /* The value of _POSIX_VDISABLE from
+ * pathconf(2) */
+
+int Tty_eight_bit = -1; /* does the tty handle eight bits */
+
+extern bool GotTermCaps;
+
+static ttydata_t extty, edtty, tstty;
+#define qutty tstty
+
+extern int insource;
+#define SHTTY (insource ? OLDSTD : SHIN)
+
+#define uc unsigned char
+static unsigned char ttychars[NN_IO][C_NCC] = {
+ {
+ (uc)CINTR, (uc)CQUIT, (uc)CERASE, (uc)CKILL,
+ (uc)CEOF, (uc)CEOL, (uc)CEOL2, (uc)CSWTCH,
+ (uc)CDSWTCH, (uc)CERASE2, (uc)CSTART, (uc)CSTOP,
+ (uc)CWERASE, (uc)CSUSP, (uc)CDSUSP, (uc)CREPRINT,
+ (uc)CDISCARD, (uc)CLNEXT, (uc)CSTATUS, (uc)CPAGE,
+ (uc)CPGOFF, (uc)CKILL2, (uc)CBRK, (uc)CMIN,
+ (uc)CTIME
+ },
+ {
+ CINTR, CQUIT, CERASE, CKILL,
+ _POSIX_VDISABLE, _POSIX_VDISABLE, _POSIX_VDISABLE, _POSIX_VDISABLE,
+ _POSIX_VDISABLE, CERASE2, CSTART, CSTOP,
+ _POSIX_VDISABLE, _POSIX_VDISABLE, _POSIX_VDISABLE, _POSIX_VDISABLE,
+ CDISCARD, _POSIX_VDISABLE, _POSIX_VDISABLE, _POSIX_VDISABLE,
+ _POSIX_VDISABLE, _POSIX_VDISABLE, _POSIX_VDISABLE, 1,
+ 0
+ },
+ {
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0
+ }
+};
+
+#ifdef SIG_WINDOW
+void
+check_window_size(force)
+ int force;
+{
+#ifdef BSDSIGS
+ sigmask_t omask;
+#endif /* BSDSIGS */
+ int lins, cols;
+
+ /* don't want to confuse things here */
+#ifdef BSDSIGS
+ omask = sigblock(sigmask(SIG_WINDOW)) & ~sigmask(SIG_WINDOW);
+#else /* BSDSIGS */
+ (void) sighold(SIG_WINDOW);
+#endif /* BSDSIGS */
+ /*
+ * From: bret@shark.agps.lanl.gov (Bret Thaeler) Avoid sunview bug, where a
+ * partially hidden window gets a SIG_WINDOW every time the text is
+ * scrolled
+ */
+ if (GetSize(&lins, &cols) || force) {
+ if (GettingInput) {
+ ClearLines();
+ ClearDisp();
+ MoveToLine(0);
+ MoveToChar(0);
+ ChangeSize(lins, cols);
+ Refresh();
+ }
+ else
+ ChangeSize(lins, cols);
+ }
+#ifdef BSDSIGS
+ (void) sigsetmask(omask); /* can change it again */
+#else /* BSDSIGS */
+ (void) sigrelse(SIG_WINDOW);
+#endif /* BSDSIGS */
+}
+
+sigret_t
+/*ARGSUSED*/
+window_change(snum)
+int snum;
+{
+#ifdef UNRELSIGS
+ /* If we were called as a signal handler, restore it. */
+ if (snum > 0)
+ sigset(snum, window_change);
+#endif /* UNRELSIGS */
+ check_window_size(0);
+#ifndef SIGVOID
+ return (snum);
+#endif
+}
+
+#endif /* SIG_WINDOW */
+
+void
+ed_set_tty_eight_bit()
+{
+ if (tty_getty(SHTTY, &extty) == -1) {
+#ifdef DEBUG_TTY
+ xprintf("ed_set_tty_eight_bit: tty_getty: %s\n", strerror(errno));
+#endif /* DEBUG_TTY */
+ return;
+ }
+ Tty_eight_bit = tty_geteightbit(&extty);
+}
+
+
+int
+ed_Setup(rst)
+ int rst;
+{
+ static int havesetup = 0;
+ struct varent *imode;
+
+ if (havesetup) /* if we have never been called */
+ return(0);
+
+#if defined(POSIX) && defined(_PC_VDISABLE) && !defined(BSD4_4) && \
+ !defined(WINNT)
+ {
+ long pcret;
+
+ if ((pcret = fpathconf(SHTTY, _PC_VDISABLE)) == -1L)
+ vdisable = (unsigned char) _POSIX_VDISABLE;
+ else
+ vdisable = (unsigned char) pcret;
+ if (vdisable != (unsigned char) _POSIX_VDISABLE && rst != 0)
+ for (rst = 0; rst < C_NCC; rst++) {
+ if (ttychars[ED_IO][rst] == (unsigned char) _POSIX_VDISABLE)
+ ttychars[ED_IO][rst] = vdisable;
+ if (ttychars[EX_IO][rst] == (unsigned char) _POSIX_VDISABLE)
+ ttychars[EX_IO][rst] = vdisable;
+ }
+ }
+#else /* ! POSIX || !_PC_VDISABLE || BSD4_4 || WINNT */
+ vdisable = (unsigned char) _POSIX_VDISABLE;
+#endif /* POSIX && _PC_VDISABLE && !BSD4_4 && !WINNT */
+
+ if ((imode = adrof(STRinputmode)) != NULL) {
+ if (!Strcmp(*(imode->vec), STRinsert))
+ inputmode = MODE_INSERT;
+ else if (!Strcmp(*(imode->vec), STRoverwrite))
+ inputmode = MODE_REPLACE;
+ }
+ else
+ inputmode = MODE_INSERT;
+ ed_InitMaps();
+ Hist_num = 0;
+ Expand = 0;
+
+#ifndef WINNT
+ if (tty_getty(SHTTY, &extty) == -1) {
+# ifdef DEBUG_TTY
+ xprintf("ed_Setup: tty_getty: %s\n", strerror(errno));
+# endif /* DEBUG_TTY */
+ return(-1);
+ }
+
+ tstty = edtty = extty;
+
+ T_Speed = tty_getspeed(&extty);
+ T_Tabs = tty_gettabs(&extty);
+ Tty_eight_bit = tty_geteightbit(&extty);
+
+# if defined(POSIX) || defined(TERMIO)
+ extty.d_t.c_iflag &= ~ttylist[EX_IO][M_INPUT].t_clrmask;
+ extty.d_t.c_iflag |= ttylist[EX_IO][M_INPUT].t_setmask;
+
+ extty.d_t.c_oflag &= ~ttylist[EX_IO][M_OUTPUT].t_clrmask;
+ extty.d_t.c_oflag |= ttylist[EX_IO][M_OUTPUT].t_setmask;
+
+ extty.d_t.c_cflag &= ~ttylist[EX_IO][M_CONTROL].t_clrmask;
+ extty.d_t.c_cflag |= ttylist[EX_IO][M_CONTROL].t_setmask;
+
+ extty.d_t.c_lflag &= ~ttylist[EX_IO][M_LINED].t_clrmask;
+ extty.d_t.c_lflag |= ttylist[EX_IO][M_LINED].t_setmask;
+
+# if defined(IRIX3_3) && SYSVREL < 4
+ extty.d_t.c_line = NTTYDISC;
+# endif /* IRIX3_3 && SYSVREL < 4 */
+
+# else /* GSTTY */ /* V7, Berkeley style tty */
+
+ if (T_Tabs) { /* order of &= and |= is important to XTABS */
+ extty.d_t.sg_flags &= ~(ttylist[EX_IO][M_CONTROL].t_clrmask|XTABS);
+ extty.d_t.sg_flags |= ttylist[EX_IO][M_CONTROL].t_setmask;
+ }
+ else {
+ extty.d_t.sg_flags &= ~ttylist[EX_IO][M_CONTROL].t_clrmask;
+ extty.d_t.sg_flags |= (ttylist[EX_IO][M_CONTROL].t_setmask|XTABS);
+ }
+
+ extty.d_lb &= ~ttylist[EX_IO][M_LOCAL].t_clrmask;
+ extty.d_lb |= ttylist[EX_IO][M_LOCAL].t_setmask;
+
+# endif /* GSTTY */
+ /*
+ * Reset the tty chars to reasonable defaults
+ * If they are disabled, then enable them.
+ */
+ if (rst) {
+ if (tty_cooked_mode(&tstty)) {
+ tty_getchar(&tstty, ttychars[TS_IO]);
+ /*
+ * Don't affect CMIN and CTIME for the editor mode
+ */
+ for (rst = 0; rst < C_NCC - 2; rst++)
+ if (ttychars[TS_IO][rst] != vdisable &&
+ ttychars[ED_IO][rst] != vdisable)
+ ttychars[ED_IO][rst] = ttychars[TS_IO][rst];
+ for (rst = 0; rst < C_NCC; rst++)
+ if (ttychars[TS_IO][rst] != vdisable &&
+ ttychars[EX_IO][rst] != vdisable)
+ ttychars[EX_IO][rst] = ttychars[TS_IO][rst];
+ }
+ tty_setchar(&extty, ttychars[EX_IO]);
+ if (tty_setty(SHTTY, &extty) == -1) {
+# ifdef DEBUG_TTY
+ xprintf("ed_Setup: tty_setty: %s\n", strerror(errno));
+# endif /* DEBUG_TTY */
+ return(-1);
+ }
+ }
+ else
+ tty_setchar(&extty, ttychars[EX_IO]);
+
+# ifdef SIG_WINDOW
+ (void) sigset(SIG_WINDOW, window_change); /* for window systems */
+# endif
+#else /* WINNT */
+# ifdef DEBUG
+ if (rst)
+ xprintf("rst received in ed_Setup() %d\n", rst);
+# endif
+#endif /* WINNT */
+ havesetup = 1;
+ return(0);
+}
+
+void
+ed_Init()
+{
+ ResetInLine(1); /* reset the input pointers */
+ GettingInput = 0; /* just in case */
+ LastKill = KillBuf; /* no kill buffer */
+
+#ifdef DEBUG_EDIT
+ CheckMaps(); /* do a little error checking on key maps */
+#endif
+
+ if (ed_Setup(0) == -1)
+ return;
+
+ /*
+ * if we have been called before but GotTermCaps isn't set, our TERM has
+ * changed, so get new termcaps and try again
+ */
+
+ if (!GotTermCaps)
+ GetTermCaps(); /* does the obvious, but gets term type each
+ * time */
+
+#ifndef WINNT
+# if defined(TERMIO) || defined(POSIX)
+ edtty.d_t.c_iflag &= ~ttylist[ED_IO][M_INPUT].t_clrmask;
+ edtty.d_t.c_iflag |= ttylist[ED_IO][M_INPUT].t_setmask;
+
+ edtty.d_t.c_oflag &= ~ttylist[ED_IO][M_OUTPUT].t_clrmask;
+ edtty.d_t.c_oflag |= ttylist[ED_IO][M_OUTPUT].t_setmask;
+
+ edtty.d_t.c_cflag &= ~ttylist[ED_IO][M_CONTROL].t_clrmask;
+ edtty.d_t.c_cflag |= ttylist[ED_IO][M_CONTROL].t_setmask;
+
+ edtty.d_t.c_lflag &= ~ttylist[ED_IO][M_LINED].t_clrmask;
+ edtty.d_t.c_lflag |= ttylist[ED_IO][M_LINED].t_setmask;
+
+
+# if defined(IRIX3_3) && SYSVREL < 4
+ edtty.d_t.c_line = NTTYDISC;
+# endif /* IRIX3_3 && SYSVREL < 4 */
+
+# else /* GSTTY */
+
+ if (T_Tabs) { /* order of &= and |= is important to XTABS */
+ edtty.d_t.sg_flags &= ~(ttylist[ED_IO][M_CONTROL].t_clrmask | XTABS);
+ edtty.d_t.sg_flags |= ttylist[ED_IO][M_CONTROL].t_setmask;
+ }
+ else {
+ edtty.d_t.sg_flags &= ~ttylist[ED_IO][M_CONTROL].t_clrmask;
+ edtty.d_t.sg_flags |= (ttylist[ED_IO][M_CONTROL].t_setmask | XTABS);
+ }
+
+ edtty.d_lb &= ~ttylist[ED_IO][M_LOCAL].t_clrmask;
+ edtty.d_lb |= ttylist[ED_IO][M_LOCAL].t_setmask;
+# endif /* POSIX || TERMIO */
+
+ tty_setchar(&edtty, ttychars[ED_IO]);
+#endif /* WINNT */
+}
+
+/*
+ * Check and re-init the line. set the terminal into 1 char at a time mode.
+ */
+int
+Rawmode()
+{
+ if (Tty_raw_mode)
+ return (0);
+
+#ifdef WINNT
+ do_nt_raw_mode();
+#else /* !WINNT */
+# ifdef _IBMR2
+ tty_setdisc(SHTTY, ED_IO);
+# endif /* _IBMR2 */
+
+ if (tty_getty(SHTTY, &tstty) == -1) {
+# ifdef DEBUG_TTY
+ xprintf("Rawmode: tty_getty: %s\n", strerror(errno));
+# endif /* DEBUG_TTY */
+ return(-1);
+ }
+
+ /*
+ * We always keep up with the eight bit setting and the speed of the
+ * tty. But only we only believe changes that are made to cooked mode!
+ */
+# if defined(POSIX) || defined(TERMIO)
+ Tty_eight_bit = tty_geteightbit(&tstty);
+ T_Speed = tty_getspeed(&tstty);
+
+# ifdef POSIX
+ /*
+ * Fix from: Steven (Steve) B. Green <xrsbg@charney.gsfc.nasa.gov>
+ * Speed was not being set up correctly under POSIX.
+ */
+ if (tty_getspeed(&extty) != T_Speed || tty_getspeed(&edtty) != T_Speed) {
+ (void) cfsetispeed(&extty.d_t, T_Speed);
+ (void) cfsetospeed(&extty.d_t, T_Speed);
+ (void) cfsetispeed(&edtty.d_t, T_Speed);
+ (void) cfsetospeed(&edtty.d_t, T_Speed);
+ }
+# endif /* POSIX */
+# else /* GSTTY */
+
+ T_Speed = tty_getspeed(&tstty);
+ Tty_eight_bit = tty_geteightbit(&tstty);
+
+ if (extty.d_t.sg_ispeed != tstty.d_t.sg_ispeed) {
+ extty.d_t.sg_ispeed = tstty.d_t.sg_ispeed;
+ edtty.d_t.sg_ispeed = tstty.d_t.sg_ispeed;
+ }
+
+ if (extty.d_t.sg_ospeed != tstty.d_t.sg_ospeed) {
+ extty.d_t.sg_ospeed = tstty.d_t.sg_ospeed;
+ edtty.d_t.sg_ospeed = tstty.d_t.sg_ospeed;
+ }
+# endif /* POSIX || TERMIO */
+
+ if (tty_cooked_mode(&tstty)) {
+ /*
+ * re-test for some things here (like maybe the user typed
+ * "stty -tabs"
+ */
+ if (tty_gettabs(&tstty) == 0)
+ T_Tabs = 0;
+ else
+ T_Tabs = CanWeTab();
+
+# if defined(POSIX) || defined(TERMIO)
+ extty.d_t.c_cflag = tstty.d_t.c_cflag;
+ extty.d_t.c_cflag &= ~ttylist[EX_IO][M_CONTROL].t_clrmask;
+ extty.d_t.c_cflag |= ttylist[EX_IO][M_CONTROL].t_setmask;
+
+ edtty.d_t.c_cflag = tstty.d_t.c_cflag;
+ edtty.d_t.c_cflag &= ~ttylist[ED_IO][M_CONTROL].t_clrmask;
+ edtty.d_t.c_cflag |= ttylist[ED_IO][M_CONTROL].t_setmask;
+
+ extty.d_t.c_lflag = tstty.d_t.c_lflag;
+ extty.d_t.c_lflag &= ~ttylist[EX_IO][M_LINED].t_clrmask;
+ extty.d_t.c_lflag |= ttylist[EX_IO][M_LINED].t_setmask;
+
+ edtty.d_t.c_lflag = tstty.d_t.c_lflag;
+ edtty.d_t.c_lflag &= ~ttylist[ED_IO][M_LINED].t_clrmask;
+ edtty.d_t.c_lflag |= ttylist[ED_IO][M_LINED].t_setmask;
+
+ extty.d_t.c_iflag = tstty.d_t.c_iflag;
+ extty.d_t.c_iflag &= ~ttylist[EX_IO][M_INPUT].t_clrmask;
+ extty.d_t.c_iflag |= ttylist[EX_IO][M_INPUT].t_setmask;
+
+ edtty.d_t.c_iflag = tstty.d_t.c_iflag;
+ edtty.d_t.c_iflag &= ~ttylist[ED_IO][M_INPUT].t_clrmask;
+ edtty.d_t.c_iflag |= ttylist[ED_IO][M_INPUT].t_setmask;
+
+ extty.d_t.c_oflag = tstty.d_t.c_oflag;
+ extty.d_t.c_oflag &= ~ttylist[EX_IO][M_OUTPUT].t_clrmask;
+ extty.d_t.c_oflag |= ttylist[EX_IO][M_OUTPUT].t_setmask;
+
+ edtty.d_t.c_oflag = tstty.d_t.c_oflag;
+ edtty.d_t.c_oflag &= ~ttylist[ED_IO][M_OUTPUT].t_clrmask;
+ edtty.d_t.c_oflag |= ttylist[ED_IO][M_OUTPUT].t_setmask;
+
+# else /* GSTTY */
+
+ extty.d_t.sg_flags = tstty.d_t.sg_flags;
+
+ extty.d_t.sg_flags &= ~ttylist[EX_IO][M_CONTROL].t_clrmask;
+ extty.d_t.sg_flags |= ttylist[EX_IO][M_CONTROL].t_setmask;
+
+ if (T_Tabs) /* order of &= and |= is important to XTABS */
+ extty.d_t.sg_flags &= ~XTABS;
+ else
+ extty.d_t.sg_flags |= XTABS;
+
+ extty.d_lb = tstty.d_lb;
+ extty.d_lb &= ~ttylist[EX_IO][M_LOCAL].t_clrmask;
+ extty.d_lb |= ttylist[EX_IO][M_LOCAL].t_setmask;
+
+ edtty.d_t.sg_flags = extty.d_t.sg_flags;
+ if (T_Tabs) { /* order of &= and |= is important to XTABS */
+ edtty.d_t.sg_flags &=
+ ~(ttylist[ED_IO][M_CONTROL].t_clrmask|XTABS);
+ edtty.d_t.sg_flags |= ttylist[ED_IO][M_CONTROL].t_setmask;
+ }
+ else {
+ edtty.d_t.sg_flags &= ~ttylist[ED_IO][M_CONTROL].t_clrmask;
+ edtty.d_t.sg_flags |=
+ (ttylist[ED_IO][M_CONTROL].t_setmask|XTABS);
+ }
+
+ edtty.d_lb = tstty.d_lb;
+ edtty.d_lb &= ~ttylist[ED_IO][M_LOCAL].t_clrmask;
+ edtty.d_lb |= ttylist[ED_IO][M_LOCAL].t_setmask;
+
+# endif /* TERMIO || POSIX */
+
+ {
+ extern int didsetty;
+ int i;
+
+ tty_getchar(&tstty, ttychars[TS_IO]);
+ /*
+ * Check if the user made any changes.
+ * If he did, then propagate the changes to the
+ * edit and execute data structures.
+ */
+ for (i = 0; i < C_NCC; i++)
+ if (ttychars[TS_IO][i] != ttychars[EX_IO][i])
+ break;
+
+ if (i != C_NCC || didsetty) {
+ didsetty = 0;
+ /*
+ * Propagate changes only to the unprotected chars
+ * that have been modified just now.
+ */
+ for (i = 0; i < C_NCC; i++) {
+ if (!((ttylist[ED_IO][M_CHAR].t_setmask & C_SH(i))) &&
+ (ttychars[TS_IO][i] != ttychars[EX_IO][i]))
+ ttychars[ED_IO][i] = ttychars[TS_IO][i];
+ if (ttylist[ED_IO][M_CHAR].t_clrmask & C_SH(i))
+ ttychars[ED_IO][i] = vdisable;
+ }
+ tty_setchar(&edtty, ttychars[ED_IO]);
+
+ for (i = 0; i < C_NCC; i++) {
+ if (!((ttylist[EX_IO][M_CHAR].t_setmask & C_SH(i))) &&
+ (ttychars[TS_IO][i] != ttychars[EX_IO][i]))
+ ttychars[EX_IO][i] = ttychars[TS_IO][i];
+ if (ttylist[EX_IO][M_CHAR].t_clrmask & C_SH(i))
+ ttychars[EX_IO][i] = vdisable;
+ }
+ tty_setchar(&extty, ttychars[EX_IO]);
+ }
+
+ }
+ }
+ if (tty_setty(SHTTY, &edtty) == -1) {
+# ifdef DEBUG_TTY
+ xprintf("Rawmode: tty_setty: %s\n", strerror(errno));
+# endif /* DEBUG_TTY */
+ return(-1);
+ }
+#endif /* WINNT */
+ Tty_raw_mode = 1;
+ flush(); /* flush any buffered output */
+ return (0);
+}
+
+int
+Cookedmode()
+{ /* set tty in normal setup */
+#ifdef WINNT
+ do_nt_cooked_mode();
+#else
+ signalfun_t orig_intr;
+
+# ifdef _IBMR2
+ tty_setdisc(SHTTY, EX_IO);
+# endif /* _IBMR2 */
+
+ if (!Tty_raw_mode)
+ return (0);
+
+ /* hold this for reseting tty */
+# ifdef BSDSIGS
+ orig_intr = (signalfun_t) signal(SIGINT, SIG_IGN);
+# else
+# ifdef SIG_HOLD
+ /*
+ * sigset doesn't return the previous handler if the signal is held,
+ * it will return SIG_HOLD instead. So instead of restoring the
+ * the signal we would end up installing a blocked SIGINT with a
+ * SIG_IGN signal handler. This is what happened when Cookedmode
+ * was called from sched_run, disabling interrupt for the rest
+ * of your session.
+ *
+ * This is what we do:
+ * - if the signal is blocked, keep it that way
+ * - else set it to SIG_IGN
+ *
+ * Casper Dik (casper@fwi.uva.nl)
+ */
+ orig_intr = (signalfun_t) sigset(SIGINT, SIG_HOLD);
+ if (orig_intr != SIG_HOLD)
+ (void) sigset(SIGINT, SIG_IGN); /* returns SIG_HOLD */
+# else /* !SIG_HOLD */
+ /*
+ * No SIG_HOLD; probably no reliable signals as well.
+ */
+ orig_intr = (signalfun_t) sigset(SIGINT, SIG_IGN);
+# endif /* SIG_HOLD */
+# endif /* BSDSIGS */
+ if (tty_setty(SHTTY, &extty) == -1) {
+# ifdef DEBUG_TTY
+ xprintf("Cookedmode: tty_setty: %s\n", strerror(errno));
+# endif /* DEBUG_TTY */
+ return -1;
+ }
+# ifdef BSDSIGS
+ (void) signal(SIGINT, orig_intr); /* take these again */
+# else
+ (void) sigset(SIGINT, orig_intr); /* take these again */
+# endif /* BSDSIGS */
+#endif /* WINNT */
+
+ Tty_raw_mode = 0;
+ return (0);
+}
+
+void
+ResetInLine(macro)
+ int macro;
+{
+ Cursor = InputBuf; /* reset cursor */
+ LastChar = InputBuf;
+ InputLim = &InputBuf[INBUFSIZE - 2];
+ Mark = InputBuf;
+ MetaNext = 0;
+ CurrentKeyMap = CcKeyMap;
+ AltKeyMap = 0;
+ Hist_num = 0;
+ DoingArg = 0;
+ Argument = 1;
+#ifdef notdef
+ LastKill = KillBuf; /* no kill buffer */
+#endif
+ LastCmd = F_UNASSIGNED; /* previous command executed */
+ if (macro)
+ MacroLvl = -1; /* no currently active macros */
+}
+
+static Char *Input_Line = NULL;
+int
+Load_input_line()
+{
+#ifdef SUNOS4
+ long chrs = 0;
+#else /* !SUNOS4 */
+ /*
+ * *Everyone* else has an int, but SunOS wants long!
+ * This breaks where int != long (alpha)
+ */
+ int chrs = 0;
+#endif /* SUNOS4 */
+
+ if (Input_Line)
+ xfree((ptr_t) Input_Line);
+ Input_Line = NULL;
+
+ if (Tty_raw_mode)
+ return 0;
+
+#if defined(FIONREAD) && !defined(OREO)
+ (void) ioctl(SHIN, FIONREAD, (ioctl_t) &chrs);
+ if (chrs > 0) {
+ char buf[BUFSIZE];
+
+ chrs = read(SHIN, buf, (size_t) min(chrs, BUFSIZE - 1));
+ if (chrs > 0) {
+ buf[chrs] = '\0';
+ Input_Line = Strsave(str2short(buf));
+ PushMacro(Input_Line);
+ }
+#ifdef convex
+ /* need to print errno message in case file is migrated */
+ if (chrs < 0)
+ stderror(ERR_SYSTEM, progname, strerror(errno));
+#endif
+ }
+#endif /* FIONREAD && !OREO */
+ return chrs > 0;
+}
+
+/*
+ * Bugfix (in Swedish) by:
+ * Johan Widen
+ * SICS, PO Box 1263, S-163 13 SPANGA, SWEDEN
+ * {mcvax,munnari,cernvax,diku,inria,prlb2,penet,ukc,unido}!enea!sics.se!jw
+ * Internet: jw@sics.se
+ *
+ * (via Hans J Albertsson (thanks))
+ */
+void
+QuoteModeOn()
+{
+ if (MacroLvl >= 0)
+ return;
+
+#ifndef WINNT
+ qutty = edtty;
+
+#if defined(TERMIO) || defined(POSIX)
+ qutty.d_t.c_iflag &= ~ttylist[QU_IO][M_INPUT].t_clrmask;
+ qutty.d_t.c_iflag |= ttylist[QU_IO][M_INPUT].t_setmask;
+
+ qutty.d_t.c_oflag &= ~ttylist[QU_IO][M_OUTPUT].t_clrmask;
+ qutty.d_t.c_oflag |= ttylist[QU_IO][M_OUTPUT].t_setmask;
+
+ qutty.d_t.c_cflag &= ~ttylist[QU_IO][M_CONTROL].t_clrmask;
+ qutty.d_t.c_cflag |= ttylist[QU_IO][M_CONTROL].t_setmask;
+
+ qutty.d_t.c_lflag &= ~ttylist[QU_IO][M_LINED].t_clrmask;
+ qutty.d_t.c_lflag |= ttylist[QU_IO][M_LINED].t_setmask;
+#else /* GSTTY */
+ qutty.d_t.sg_flags &= ~ttylist[QU_IO][M_CONTROL].t_clrmask;
+ qutty.d_t.sg_flags |= ttylist[QU_IO][M_CONTROL].t_setmask;
+ qutty.d_lb &= ~ttylist[QU_IO][M_LOCAL].t_clrmask;
+ qutty.d_lb |= ttylist[QU_IO][M_LOCAL].t_setmask;
+
+#endif /* TERMIO || POSIX */
+ if (tty_setty(SHTTY, &qutty) == -1) {
+#ifdef DEBUG_TTY
+ xprintf("QuoteModeOn: tty_setty: %s\n", strerror(errno));
+#endif /* DEBUG_TTY */
+ return;
+ }
+#endif /* !WINNT */
+ Tty_quote_mode = 1;
+ return;
+}
+
+void
+QuoteModeOff()
+{
+ if (!Tty_quote_mode)
+ return;
+ Tty_quote_mode = 0;
+ if (tty_setty(SHTTY, &edtty) == -1) {
+#ifdef DEBUG_TTY
+ xprintf("QuoteModeOff: tty_setty: %s\n", strerror(errno));
+#endif /* DEBUG_TTY */
+ return;
+ }
+ return;
+}
diff --git a/contrib/tcsh/ed.inputl.c b/contrib/tcsh/ed.inputl.c
new file mode 100644
index 000000000000..2842d7db78ea
--- /dev/null
+++ b/contrib/tcsh/ed.inputl.c
@@ -0,0 +1,903 @@
+/* $Header: /src/pub/tcsh/ed.inputl.c,v 3.47 1999/04/20 07:48:39 christos Exp $ */
+/*
+ * ed.inputl.c: Input line handling.
+ */
+/*-
+ * Copyright (c) 1980, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "sh.h"
+
+RCSID("$Id: ed.inputl.c,v 3.47 1999/04/20 07:48:39 christos Exp $")
+
+#include "ed.h"
+#include "ed.defns.h" /* for the function names */
+#include "tw.h" /* for twenex stuff */
+
+#define OKCMD (INBUFSIZE+INBUFSIZE)
+
+/* ed.inputl -- routines to get a single line from the input. */
+
+extern bool tellwhat;
+extern bool MapsAreInited;
+extern bool Tty_raw_mode;
+
+/* mismatched first character */
+static Char mismatch[] =
+ {'!', '^' , '\\', '-', '%', '\0', '"', '\'', '`', '\0' };
+
+static int Repair __P((void));
+static int GetNextCommand __P((KEYCMD *, Char *));
+static int SpellLine __P((int));
+static int CompleteLine __P((void));
+static void RunCommand __P((Char *));
+static void doeval1 __P((Char **));
+
+static bool rotate = 0;
+
+
+static int
+Repair()
+{
+ if (NeedsRedraw) {
+ ClearLines();
+ ClearDisp();
+ NeedsRedraw = 0;
+ }
+ Refresh();
+ Argument = 1;
+ DoingArg = 0;
+ curchoice = -1;
+ return (int) (LastChar - InputBuf);
+}
+
+/* CCRETVAL */
+int
+Inputl()
+{
+ CCRETVAL retval;
+ KEYCMD cmdnum = 0;
+ extern KEYCMD NumFuns;
+ unsigned char tch; /* the place where read() goes */
+ Char ch;
+ int num; /* how many chars we have read at NL */
+ int expnum;
+ struct varent *crct = inheredoc ? NULL : adrof(STRcorrect);
+ struct varent *autol = adrof(STRautolist);
+ struct varent *matchbeep = adrof(STRmatchbeep);
+ struct varent *imode = adrof(STRinputmode);
+ Char *SaveChar, *CorrChar;
+ Char Origin[INBUFSIZE], Change[INBUFSIZE];
+ int matchval; /* from tenematch() */
+ COMMAND fn;
+ int curlen = 0;
+ int newlen;
+ int idx;
+
+ if (!MapsAreInited) /* double extra just in case */
+ ed_InitMaps();
+
+ ClearDisp(); /* reset the display stuff */
+ ResetInLine(0); /* reset the input pointers */
+ if (GettingInput)
+ MacroLvl = -1; /* editor was interrupted during input */
+
+ if (imode) {
+ if (!Strcmp(*(imode->vec), STRinsert))
+ inputmode = MODE_INSERT;
+ else if (!Strcmp(*(imode->vec), STRoverwrite))
+ inputmode = MODE_REPLACE;
+ }
+
+#if defined(FIONREAD) && !defined(OREO)
+ if (!Tty_raw_mode && MacroLvl < 0) {
+# ifdef SUNOS4
+ long chrs = 0;
+# else /* !SUNOS4 */
+ /*
+ * *Everyone* else has an int, but SunOS wants long!
+ * This breaks where int != long (alpha)
+ */
+ int chrs = 0;
+# endif /* SUNOS4 */
+
+ (void) ioctl(SHIN, FIONREAD, (ioctl_t) & chrs);
+ if (chrs == 0) {
+ if (Rawmode() < 0)
+ return 0;
+ }
+ }
+#endif /* FIONREAD && !OREO */
+
+ GettingInput = 1;
+ NeedsRedraw = 0;
+
+ if (tellwhat) {
+ copyn(InputBuf, WhichBuf, INBUFSIZE);
+ LastChar = InputBuf + (LastWhich - WhichBuf);
+ Cursor = InputBuf + (CursWhich - WhichBuf);
+ tellwhat = 0;
+ Hist_num = HistWhich;
+ }
+ if (Expand) {
+ (void) e_up_hist(0);
+ Expand = 0;
+ }
+ Refresh(); /* print the prompt */
+
+ for (num = OKCMD; num == OKCMD;) { /* while still editing this line */
+#ifdef DEBUG_EDIT
+ if (Cursor > LastChar)
+ xprintf("Cursor > LastChar\r\n");
+ if (Cursor < InputBuf)
+ xprintf("Cursor < InputBuf\r\n");
+ if (Cursor > InputLim)
+ xprintf("Cursor > InputLim\r\n");
+ if (LastChar > InputLim)
+ xprintf("LastChar > InputLim\r\n");
+ if (InputLim != &InputBuf[INBUFSIZE - 2])
+ xprintf("InputLim != &InputBuf[INBUFSIZE-2]\r\n");
+ if ((!DoingArg) && (Argument != 1))
+ xprintf("(!DoingArg) && (Argument != 1)\r\n");
+ if (CcKeyMap[0] == 0)
+ xprintf("CcKeyMap[0] == 0 (maybe not inited)\r\n");
+#endif
+
+ /* if EOF or error */
+ if ((num = GetNextCommand(&cmdnum, &ch)) != OKCMD) {
+ break;
+ }
+
+ if (cmdnum >= NumFuns) {/* BUG CHECK command */
+#ifdef DEBUG_EDIT
+ xprintf(CGETS(6, 1, "ERROR: illegal command from key 0%o\r\n"), ch);
+#endif
+ continue; /* try again */
+ }
+
+ /* now do the real command */
+ retval = (*CcFuncTbl[cmdnum]) (ch);
+
+ /* save the last command here */
+ LastCmd = cmdnum;
+
+ /* make sure fn is initialized */
+ fn = (retval == CC_COMPLETE_ALL) ? LIST_ALL : LIST;
+
+ /* use any return value */
+ switch (retval) {
+
+ case CC_REFRESH:
+ Refresh();
+ /*FALLTHROUGH*/
+ case CC_NORM: /* normal char */
+ Argument = 1;
+ DoingArg = 0;
+ /*FALLTHROUGH*/
+ case CC_ARGHACK: /* Suggested by Rich Salz */
+ /* <rsalz@pineapple.bbn.com> */
+ curchoice = -1;
+ curlen = (int) (LastChar - InputBuf);
+ break; /* keep going... */
+
+ case CC_EOF: /* end of file typed */
+ curchoice = -1;
+ curlen = (int) (LastChar - InputBuf);
+ num = 0;
+ break;
+
+ case CC_WHICH: /* tell what this command does */
+ tellwhat = 1;
+ copyn(WhichBuf, InputBuf, INBUFSIZE);
+ LastWhich = WhichBuf + (LastChar - InputBuf);
+ CursWhich = WhichBuf + (Cursor - InputBuf);
+ *LastChar++ = '\n'; /* for the benifit of CSH */
+ HistWhich = Hist_num;
+ Hist_num = 0; /* for the history commands */
+ num = (int) (LastChar - InputBuf); /* number characters read */
+ break;
+
+ case CC_NEWLINE: /* normal end of line */
+ curlen = 0;
+ curchoice = -1;
+ matchval = 1;
+ if (crct && (!Strcmp(*(crct->vec), STRcmd) ||
+ !Strcmp(*(crct->vec), STRall))) {
+ PastBottom();
+ copyn(Origin, InputBuf, INBUFSIZE);
+ SaveChar = LastChar;
+ if (SpellLine(!Strcmp(*(crct->vec), STRcmd)) == 1) {
+ PastBottom();
+ copyn(Change, InputBuf, INBUFSIZE);
+ *Strchr(Change, '\n') = '\0';
+ CorrChar = LastChar; /* Save the corrected end */
+ LastChar = InputBuf; /* Null the current line */
+ SoundBeep();
+ printprompt(2, short2str(Change));
+ Refresh();
+ if (read(SHIN, (char *) &tch, 1) < 0)
+#ifdef convex
+ /*
+ * need to print error message in case file
+ * is migrated
+ */
+ if (errno && errno != EINTR)
+ stderror(ERR_SYSTEM, progname, strerror(errno));
+#else
+ break;
+#endif
+ ch = tch;
+ if (ch == 'y' || ch == ' ') {
+ LastChar = CorrChar; /* Restore the corrected end */
+ xprintf(CGETS(6, 2, "yes\n"));
+ }
+ else {
+ copyn(InputBuf, Origin, INBUFSIZE);
+ LastChar = SaveChar;
+ if (ch == 'e') {
+ xprintf(CGETS(6, 3, "edit\n"));
+ *LastChar-- = '\0';
+ Cursor = LastChar;
+ printprompt(3, NULL);
+ ClearLines();
+ ClearDisp();
+ Refresh();
+ break;
+ }
+ else if (ch == 'a') {
+ xprintf(CGETS(6, 4, "abort\n"));
+ LastChar = InputBuf; /* Null the current line */
+ Cursor = LastChar;
+ printprompt(0, NULL);
+ Refresh();
+ break;
+ }
+ xprintf(CGETS(6, 5, "no\n"));
+ }
+ flush();
+ }
+ } else if (crct && !Strcmp(*(crct->vec), STRcomplete)) {
+ if (LastChar > InputBuf && LastChar[-1] == '\n') {
+ LastChar[-1] = '\0';
+ LastChar--;
+ Cursor = LastChar;
+ }
+ match_unique_match = 1; /* match unique matches */
+ matchval = CompleteLine();
+ match_unique_match = 0;
+ curlen = (int) (LastChar - InputBuf);
+ if (matchval != 1) {
+ PastBottom();
+ }
+ if (matchval == 0) {
+ xprintf(CGETS(6, 6, "No matching command\n"));
+ } else if (matchval == 2) {
+ xprintf(CGETS(6, 7, "Ambiguous command\n"));
+ }
+ if (NeedsRedraw) {
+ ClearLines();
+ ClearDisp();
+ NeedsRedraw = 0;
+ }
+ Refresh();
+ Argument = 1;
+ DoingArg = 0;
+ if (matchval == 1) {
+ PastBottom();
+ *LastChar++ = '\n';
+ *LastChar = '\0';
+ }
+ curlen = (int) (LastChar - InputBuf);
+ }
+ else
+ PastBottom();
+
+ if (matchval == 1) {
+ tellwhat = 0; /* just in case */
+ Hist_num = 0; /* for the history commands */
+ /* return the number of chars read */
+ num = (int) (LastChar - InputBuf);
+ /*
+ * For continuation lines, we set the prompt to prompt 2
+ */
+ printprompt(1, NULL);
+ }
+ break;
+
+ case CC_CORRECT:
+ if (tenematch(InputBuf, Cursor - InputBuf, SPELL) < 0)
+ SoundBeep(); /* Beep = No match/ambiguous */
+ curlen = Repair();
+ break;
+
+ case CC_CORRECT_L:
+ if (SpellLine(FALSE) < 0)
+ SoundBeep(); /* Beep = No match/ambiguous */
+ curlen = Repair();
+ break;
+
+
+ case CC_COMPLETE:
+ case CC_COMPLETE_ALL:
+ case CC_COMPLETE_FWD:
+ case CC_COMPLETE_BACK:
+ switch (retval) {
+ case CC_COMPLETE:
+ fn = RECOGNIZE;
+ curlen = (int) (LastChar - InputBuf);
+ curchoice = -1;
+ rotate = 0;
+ break;
+ case CC_COMPLETE_ALL:
+ fn = RECOGNIZE_ALL;
+ curlen = (int) (LastChar - InputBuf);
+ curchoice = -1;
+ rotate = 0;
+ break;
+ case CC_COMPLETE_FWD:
+ fn = RECOGNIZE_SCROLL;
+ curchoice++;
+ rotate = 1;
+ break;
+ case CC_COMPLETE_BACK:
+ fn = RECOGNIZE_SCROLL;
+ curchoice--;
+ rotate = 1;
+ break;
+ default:
+ abort();
+ }
+ if (InputBuf[curlen] && rotate) {
+ newlen = (int) (LastChar - InputBuf);
+ for (idx = (int) (Cursor - InputBuf);
+ idx <= newlen; idx++)
+ InputBuf[idx - newlen + curlen] =
+ InputBuf[idx];
+ LastChar = InputBuf + curlen;
+ Cursor = Cursor - newlen + curlen;
+ }
+ curlen = (int) (LastChar - InputBuf);
+
+
+ if (adrof(STRautoexpand))
+ (void) e_expand_history(0);
+ /*
+ * Modified by Martin Boyer (gamin@ireq-robot.hydro.qc.ca):
+ * A separate variable now controls beeping after
+ * completion, independently of autolisting.
+ */
+ expnum = (int) (Cursor - InputBuf);
+ switch (matchval = tenematch(InputBuf, Cursor-InputBuf, fn)){
+ case 1:
+ if (non_unique_match && matchbeep &&
+ (Strcmp(*(matchbeep->vec), STRnotunique) == 0))
+ SoundBeep();
+ break;
+ case 0:
+ if (matchbeep) {
+ if (Strcmp(*(matchbeep->vec), STRnomatch) == 0 ||
+ Strcmp(*(matchbeep->vec), STRambiguous) == 0 ||
+ Strcmp(*(matchbeep->vec), STRnotunique) == 0)
+ SoundBeep();
+ }
+ else
+ SoundBeep();
+ break;
+ default:
+ if (matchval < 0) { /* Error from tenematch */
+ curchoice = -1;
+ SoundBeep();
+ break;
+ }
+ if (matchbeep) {
+ if ((Strcmp(*(matchbeep->vec), STRambiguous) == 0 ||
+ Strcmp(*(matchbeep->vec), STRnotunique) == 0))
+ SoundBeep();
+ }
+ else
+ SoundBeep();
+ /*
+ * Addition by David C Lawrence <tale@pawl.rpi.edu>: If an
+ * attempted completion is ambiguous, list the choices.
+ * (PWP: this is the best feature addition to tcsh I have
+ * seen in many months.)
+ */
+ if (autol && (Strcmp(*(autol->vec), STRambiguous) != 0 ||
+ expnum == Cursor - InputBuf)) {
+ PastBottom();
+ fn = (retval == CC_COMPLETE_ALL) ? LIST_ALL : LIST;
+ (void) tenematch(InputBuf, Cursor-InputBuf, fn);
+ }
+ break;
+ }
+ if (NeedsRedraw) {
+ PastBottom();
+ ClearLines();
+ ClearDisp();
+ NeedsRedraw = 0;
+ }
+ Refresh();
+ Argument = 1;
+ DoingArg = 0;
+ break;
+
+ case CC_LIST_CHOICES:
+ case CC_LIST_ALL:
+ if (InputBuf[curlen] && rotate) {
+ newlen = (int) (LastChar - InputBuf);
+ for (idx = (int) (Cursor - InputBuf);
+ idx <= newlen; idx++)
+ InputBuf[idx - newlen + curlen] =
+ InputBuf[idx];
+ LastChar = InputBuf + curlen;
+ Cursor = Cursor - newlen + curlen;
+ }
+ curlen = (int) (LastChar - InputBuf);
+ if (curchoice >= 0)
+ curchoice--;
+
+ fn = (retval == CC_LIST_ALL) ? LIST_ALL : LIST;
+ /* should catch ^C here... */
+ if (tenematch(InputBuf, Cursor - InputBuf, fn) < 0)
+ SoundBeep();
+ Refresh();
+ Argument = 1;
+ DoingArg = 0;
+ break;
+
+
+ case CC_LIST_GLOB:
+ if (tenematch(InputBuf, Cursor - InputBuf, GLOB) < 0)
+ SoundBeep();
+ curlen = Repair();
+ break;
+
+ case CC_EXPAND_GLOB:
+ if (tenematch(InputBuf, Cursor - InputBuf, GLOB_EXPAND) <= 0)
+ SoundBeep(); /* Beep = No match */
+ curlen = Repair();
+ break;
+
+ case CC_NORMALIZE_PATH:
+ if (tenematch(InputBuf, Cursor - InputBuf, PATH_NORMALIZE) <= 0)
+ SoundBeep(); /* Beep = No match */
+ curlen = Repair();
+ break;
+
+ case CC_EXPAND_VARS:
+ if (tenematch(InputBuf, Cursor - InputBuf, VARS_EXPAND) <= 0)
+ SoundBeep(); /* Beep = No match */
+ curlen = Repair();
+ break;
+
+ case CC_NORMALIZE_COMMAND:
+ if (tenematch(InputBuf, Cursor - InputBuf, COMMAND_NORMALIZE) <= 0)
+ SoundBeep(); /* Beep = No match */
+ curlen = Repair();
+ break;
+
+ case CC_HELPME:
+ xputchar('\n');
+ /* should catch ^C here... */
+ (void) tenematch(InputBuf, LastChar - InputBuf, PRINT_HELP);
+ Refresh();
+ Argument = 1;
+ DoingArg = 0;
+ curchoice = -1;
+ curlen = (int) (LastChar - InputBuf);
+ break;
+
+ case CC_FATAL: /* fatal error, reset to known state */
+#ifdef DEBUG_EDIT
+ xprintf(CGETS(7, 8, "*** editor fatal ERROR ***\r\n\n"));
+#endif /* DEBUG_EDIT */
+ /* put (real) cursor in a known place */
+ ClearDisp(); /* reset the display stuff */
+ ResetInLine(1); /* reset the input pointers */
+ Refresh(); /* print the prompt again */
+ Argument = 1;
+ DoingArg = 0;
+ curchoice = -1;
+ curlen = (int) (LastChar - InputBuf);
+ break;
+
+ case CC_ERROR:
+ default: /* functions we don't know about */
+ DoingArg = 0;
+ Argument = 1;
+ SoundBeep();
+ flush();
+ curchoice = -1;
+ curlen = (int) (LastChar - InputBuf);
+ break;
+ }
+ }
+ (void) Cookedmode(); /* make sure the tty is set up correctly */
+ GettingInput = 0;
+ flush(); /* flush any buffered output */
+ return num;
+}
+
+void
+PushMacro(str)
+ Char *str;
+{
+ if (str != NULL && MacroLvl + 1 < MAXMACROLEVELS) {
+ MacroLvl++;
+ KeyMacro[MacroLvl] = str;
+ }
+ else {
+ SoundBeep();
+ flush();
+ }
+}
+
+/*
+ * Like eval, only using the current file descriptors
+ */
+static Char **gv = NULL, **gav = NULL;
+
+static void
+doeval1(v)
+ Char **v;
+{
+ Char **oevalvec;
+ Char *oevalp;
+ int my_reenter;
+ Char **savegv;
+ jmp_buf_t osetexit;
+
+ oevalvec = evalvec;
+ oevalp = evalp;
+ savegv = gv;
+ gav = v;
+
+
+ gflag = 0, tglob(gav);
+ if (gflag) {
+ gv = gav = globall(gav);
+ gargv = 0;
+ if (gav == 0)
+ stderror(ERR_NOMATCH);
+ gav = copyblk(gav);
+ }
+ else {
+ gv = NULL;
+ gav = copyblk(gav);
+ trim(gav);
+ }
+
+ getexit(osetexit);
+
+ /* PWP: setjmp/longjmp bugfix for optimizing compilers */
+#ifdef cray
+ my_reenter = 1; /* assume non-zero return val */
+ if (setexit() == 0) {
+ my_reenter = 0; /* Oh well, we were wrong */
+#else /* !cray */
+ if ((my_reenter = setexit()) == 0) {
+#endif /* cray */
+ evalvec = gav;
+ evalp = 0;
+ process(0);
+ }
+
+ evalvec = oevalvec;
+ evalp = oevalp;
+ doneinp = 0;
+
+ if (gv)
+ blkfree(gv);
+
+ gv = savegv;
+ resexit(osetexit);
+ if (my_reenter)
+ stderror(ERR_SILENT);
+}
+
+static void
+RunCommand(str)
+ Char *str;
+{
+ Char *cmd[2];
+
+ xputchar('\n'); /* Start on a clean line */
+
+ cmd[0] = str;
+ cmd[1] = NULL;
+
+ (void) Cookedmode();
+ GettingInput = 0;
+
+ doeval1(cmd);
+
+ (void) Rawmode();
+ GettingInput = 1;
+
+ ClearLines();
+ ClearDisp();
+ NeedsRedraw = 0;
+ Refresh();
+}
+
+static int
+GetNextCommand(cmdnum, ch)
+ KEYCMD *cmdnum;
+ register Char *ch;
+{
+ KEYCMD cmd = 0;
+ int num;
+
+ while (cmd == 0 || cmd == F_XKEY) {
+ if ((num = GetNextChar(ch)) != 1) { /* if EOF or error */
+ return num;
+ }
+#ifdef KANJI
+ if (!adrof(STRnokanji) && (*ch & META)) {
+ MetaNext = 0;
+ cmd = F_INSERT;
+ break;
+ }
+ else
+#endif /* KANJI */
+ if (MetaNext) {
+ MetaNext = 0;
+ *ch |= META;
+ }
+ /* XXX: This needs to be fixed so that we don't just truncate
+ * the character, we unquote it.
+ */
+ if (*ch < NT_NUM_KEYS)
+ cmd = CurrentKeyMap[*ch];
+ else
+ cmd = CurrentKeyMap[(unsigned char) *ch];
+ if (cmd == F_XKEY) {
+ XmapVal val;
+ CStr cstr;
+ cstr.buf = ch;
+ cstr.len = Strlen(ch);
+ switch (GetXkey(&cstr, &val)) {
+ case XK_CMD:
+ cmd = val.cmd;
+ break;
+ case XK_STR:
+ PushMacro(val.str.buf);
+ break;
+ case XK_EXE:
+ RunCommand(val.str.buf);
+ break;
+ default:
+ abort();
+ break;
+ }
+ }
+ if (!AltKeyMap)
+ CurrentKeyMap = CcKeyMap;
+ }
+ *cmdnum = cmd;
+ return OKCMD;
+}
+
+int
+GetNextChar(cp)
+ register Char *cp;
+{
+ register int num_read;
+ int tried = 0;
+ unsigned char tcp;
+
+ for (;;) {
+ if (MacroLvl < 0) {
+ if (!Load_input_line())
+ break;
+ }
+ if (*KeyMacro[MacroLvl] == 0) {
+ MacroLvl--;
+ continue;
+ }
+ *cp = *KeyMacro[MacroLvl]++ & CHAR;
+ if (*KeyMacro[MacroLvl] == 0) { /* Needed for QuoteMode On */
+ MacroLvl--;
+ }
+ return (1);
+ }
+
+ if (Rawmode() < 0) /* make sure the tty is set up correctly */
+ return 0; /* oops: SHIN was closed */
+
+#ifdef WINNT
+ __nt_want_vcode = 1;
+#endif /* WINNT */
+ while ((num_read = read(SHIN, (char *) &tcp, 1)) == -1) {
+ if (errno == EINTR)
+ continue;
+ if (!tried && fixio(SHIN, errno) != -1)
+ tried = 1;
+ else {
+#ifdef convex
+ /* need to print error message in case the file is migrated */
+ if (errno != EINTR)
+ stderror(ERR_SYSTEM, progname, strerror(errno));
+#endif /* convex */
+#ifdef WINNT
+ __nt_want_vcode = 0;
+#endif /* WINNT */
+ *cp = '\0';
+ return -1;
+ }
+ }
+#ifdef WINNT
+ if (__nt_want_vcode == 2)
+ *cp = __nt_vcode;
+ else
+ *cp = tcp;
+ __nt_want_vcode = 0;
+#else
+ *cp = tcp;
+#endif /* WINNT */
+ return num_read;
+}
+
+/*
+ * SpellLine - do spelling correction on the entire command line
+ * (which may have trailing newline).
+ * If cmdonly is set, only check spelling of command words.
+ * Return value:
+ * -1: Something was incorrectible, and nothing was corrected
+ * 0: Everything was correct
+ * 1: Something was corrected
+ */
+static int
+SpellLine(cmdonly)
+ int cmdonly;
+{
+ int endflag, matchval;
+ Char *argptr, *OldCursor, *OldLastChar;
+
+ OldLastChar = LastChar;
+ OldCursor = Cursor;
+ argptr = InputBuf;
+ endflag = 1;
+ matchval = 0;
+ do {
+ while (ismetahash(*argptr) || iscmdmeta(*argptr))
+ argptr++;
+ for (Cursor = argptr;
+ *Cursor != '\0' && ((Cursor != argptr && Cursor[-1] == '\\') ||
+ (!ismetahash(*Cursor) && !iscmdmeta(*Cursor)));
+ Cursor++)
+ continue;
+ if (*Cursor == '\0') {
+ Cursor = LastChar;
+ if (LastChar[-1] == '\n')
+ Cursor--;
+ endflag = 0;
+ }
+ /* Obey current history character settings */
+ mismatch[0] = HIST;
+ mismatch[1] = HISTSUB;
+ if (!Strchr(mismatch, *argptr) &&
+ (!cmdonly || starting_a_command(argptr, InputBuf))) {
+#ifdef WINNT
+ /*
+ * This hack avoids correcting drive letter changes
+ */
+ if((Cursor - InputBuf) != 2 || (char)InputBuf[1] != ':')
+#endif /* WINNT */
+ {
+#ifdef HASH_SPELL_CHECK
+ Char save;
+ size_t len = Cursor - InputBuf;
+
+ save = InputBuf[len];
+ InputBuf[len] = '\0';
+ if (find_cmd(InputBuf, 0) != 0) {
+ InputBuf[len] = save;
+ argptr = Cursor;
+ continue;
+ }
+ InputBuf[len] = save;
+#endif /* HASH_SPELL_CHECK */
+ switch (tenematch(InputBuf, Cursor - InputBuf, SPELL)) {
+ case 1: /* corrected */
+ matchval = 1;
+ break;
+ case -1: /* couldn't be corrected */
+ if (!matchval)
+ matchval = -1;
+ break;
+ default: /* was correct */
+ break;
+ }
+ }
+ if (LastChar != OldLastChar) {
+ if (argptr < OldCursor)
+ OldCursor += (LastChar - OldLastChar);
+ OldLastChar = LastChar;
+ }
+ }
+ argptr = Cursor;
+ } while (endflag);
+ Cursor = OldCursor;
+ return matchval;
+}
+
+/*
+ * CompleteLine - do command completion on the entire command line
+ * (which may have trailing newline).
+ * Return value:
+ * 0: No command matched or failure
+ * 1: One command matched
+ * 2: Several commands matched
+ */
+static int
+CompleteLine()
+{
+ int endflag, tmatch;
+ Char *argptr, *OldCursor, *OldLastChar;
+
+ OldLastChar = LastChar;
+ OldCursor = Cursor;
+ argptr = InputBuf;
+ endflag = 1;
+ do {
+ while (ismetahash(*argptr) || iscmdmeta(*argptr))
+ argptr++;
+ for (Cursor = argptr;
+ *Cursor != '\0' && ((Cursor != argptr && Cursor[-1] == '\\') ||
+ (!ismetahash(*Cursor) && !iscmdmeta(*Cursor)));
+ Cursor++)
+ continue;
+ if (*Cursor == '\0') {
+ Cursor = LastChar;
+ if (LastChar[-1] == '\n')
+ Cursor--;
+ endflag = 0;
+ }
+ if (!Strchr(mismatch, *argptr) && starting_a_command(argptr, InputBuf)) {
+ tmatch = tenematch(InputBuf, Cursor - InputBuf, RECOGNIZE);
+ if (tmatch <= 0) {
+ return 0;
+ } else if (tmatch > 1) {
+ return 2;
+ }
+ if (LastChar != OldLastChar) {
+ if (argptr < OldCursor)
+ OldCursor += (LastChar - OldLastChar);
+ OldLastChar = LastChar;
+ }
+ }
+ argptr = Cursor;
+ } while (endflag);
+ Cursor = OldCursor;
+ return 1;
+}
+
diff --git a/contrib/tcsh/ed.refresh.c b/contrib/tcsh/ed.refresh.c
new file mode 100644
index 000000000000..46333c996a1c
--- /dev/null
+++ b/contrib/tcsh/ed.refresh.c
@@ -0,0 +1,1317 @@
+/* $Header: /src/pub/tcsh/ed.refresh.c,v 3.25 1998/11/24 18:17:22 christos Exp $ */
+/*
+ * ed.refresh.c: Lower level screen refreshing functions
+ */
+/*-
+ * Copyright (c) 1980, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "sh.h"
+
+RCSID("$Id: ed.refresh.c,v 3.25 1998/11/24 18:17:22 christos Exp $")
+
+#include "ed.h"
+/* #define DEBUG_UPDATE */
+/* #define DEBUG_REFRESH */
+/* #define DEBUG_LITERAL */
+
+/* refresh.c -- refresh the current set of lines on the screen */
+
+Char *litptr[256];
+static int vcursor_h, vcursor_v;
+static int rprompt_h, rprompt_v;
+
+static void Draw __P((int));
+static void Vdraw __P((int));
+static void RefreshPromptpart __P((Char *));
+static void update_line __P((Char *, Char *, int));
+static void str_insert __P((Char *, int, int, Char *, int));
+static void str_delete __P((Char *, int, int, int));
+static void str_cp __P((Char *, Char *, int));
+static void PutPlusOne __P((int));
+static void cpy_pad_spaces __P((Char *, Char *, int));
+#if defined(DSPMBYTE)
+static Char *update_line_fix_mbyte_point __P((Char *, Char *, int));
+#endif
+#if defined(DEBUG_UPDATE) || defined(DEBUG_REFRESH) || defined(DEBUG_LITERAL)
+static void dprintf __P((char *, ...));
+#ifdef DEBUG_UPDATE
+static void dprintstr __P((char *, Char *, Char *));
+
+static void
+dprintstr(str, f, t)
+char *str;
+Char *f, *t;
+{
+ dprintf("%s:\"", str);
+ while (f < t)
+ dprintf("%c", *f++ & ASCII);
+ dprintf("\"\r\n");
+}
+#endif /* DEBUG_UPDATE */
+
+/* dprintf():
+ * Print to $DEBUGTTY, so that we can test editing on one pty, and
+ * print debugging stuff on another. Don't interrupt the shell while
+ * debugging cause you'll mangle up the file descriptors!
+ */
+static void
+#ifdef FUNCPROTO
+dprintf(char *fmt, ...)
+#else
+dprintf(va_list)
+ va_dcl
+#endif /* __STDC__ */
+{
+ static int fd = -1;
+ char *dtty;
+
+ if ((dtty = getenv("DEBUGTTY"))) {
+ int o;
+ va_list va;
+#ifdef FUNCPROTO
+ va_start(va, fmt);
+#else
+ char *fmt;
+ va_start(va);
+ fmt = va_arg(va, char *);
+#endif /* __STDC__ */
+
+ if (fd == -1)
+ fd = open(dtty, O_RDWR);
+ o = SHOUT;
+ flush();
+ SHOUT = fd;
+ xvprintf(fmt, va);
+ va_end(va);
+ flush();
+ SHOUT = o;
+ }
+}
+#endif /* DEBUG_UPDATE || DEBUG_REFRESH || DEBUG_LITERAL */
+
+static void
+Draw(c) /* draw c, expand tabs, ctl chars */
+ register int c;
+{
+ register Char ch = c & CHAR;
+
+ if (Isprint(ch)) {
+ Vdraw(c);
+ return;
+ }
+ /* from wolman%crltrx.DEC@decwrl.dec.com (Alec Wolman) */
+ if (ch == '\n') { /* expand the newline */
+ /*
+ * Don't force a newline if Vdraw does it (i.e. we're at end of line)
+ * - or we will get two newlines and possibly garbage in between
+ */
+ int oldv = vcursor_v;
+
+ Vdraw('\0'); /* assure end of line */
+ if (oldv == vcursor_v) {
+ vcursor_h = 0; /* reset cursor pos */
+ vcursor_v++;
+ }
+ return;
+ }
+ if (ch == '\t') { /* expand the tab */
+ for (;;) {
+ Vdraw(' ');
+ if ((vcursor_h & 07) == 0)
+ break; /* go until tab stop */
+ }
+ }
+ else if (Iscntrl(ch)) {
+#ifndef _OSD_POSIX
+ Vdraw('^');
+ if (ch == CTL_ESC('\177')) {
+ Vdraw('?');
+ }
+ else {
+ /* uncontrolify it; works only for iso8859-1 like sets */
+ Vdraw((c | 0100));
+#else /*_OSD_POSIX*/
+ if (ch == CTL_ESC('\177')) {
+ Vdraw('^');
+ Vdraw('?');
+ }
+ else {
+ if (Isupper(_toebcdic[_toascii[c]|0100])
+ || strchr("@[\\]^_", _toebcdic[_toascii[c]|0100]) != NULL)
+ {
+ Vdraw('^');
+ Vdraw(_toebcdic[_toascii[c]|0100]);
+ }
+ else
+ {
+ Vdraw('\\');
+ Vdraw(((c >> 6) & 7) + '0');
+ Vdraw(((c >> 3) & 7) + '0');
+ Vdraw((c & 7) + '0');
+ }
+#endif /*_OSD_POSIX*/
+ }
+ }
+#ifdef KANJI
+ else if (!adrof(STRnokanji)) {
+ Vdraw(c);
+ return;
+ }
+#endif
+ else {
+ Vdraw('\\');
+ Vdraw(((c >> 6) & 7) + '0');
+ Vdraw(((c >> 3) & 7) + '0');
+ Vdraw((c & 7) + '0');
+ }
+}
+
+static void
+Vdraw(c) /* draw char c onto V lines */
+ register int c;
+{
+#ifdef DEBUG_REFRESH
+# ifdef SHORT_STRINGS
+ dprintf("Vdrawing %6.6o '%c'\r\n", c, c & ASCII);
+# else
+ dprintf("Vdrawing %3.3o '%c'\r\n", c, c);
+# endif /* SHORT_STRNGS */
+#endif /* DEBUG_REFRESH */
+
+ Vdisplay[vcursor_v][vcursor_h] = (Char) c;
+ vcursor_h++; /* advance to next place */
+ if (vcursor_h >= TermH) {
+ Vdisplay[vcursor_v][TermH] = '\0'; /* assure end of line */
+ vcursor_h = 0; /* reset it. */
+ vcursor_v++;
+#ifdef DEBUG_REFRESH
+ if (vcursor_v >= TermV) { /* should NEVER happen. */
+ dprintf("\r\nVdraw: vcursor_v overflow! Vcursor_v == %d > %d\r\n",
+ vcursor_v, TermV);
+ abort();
+ }
+#endif /* DEBUG_REFRESH */
+ }
+}
+
+/*
+ * RefreshPromptpart()
+ * draws a prompt element, expanding literals (we know it's ASCIZ)
+ */
+static void
+RefreshPromptpart(buf)
+ Char *buf;
+{
+ register Char *cp;
+ static unsigned int litnum = 0;
+ if (buf == NULL)
+ {
+ litnum = 0;
+ return;
+ }
+
+ for (cp = buf; *cp; cp++) {
+ if (*cp & LITERAL) {
+ if (litnum < (sizeof(litptr) / sizeof(litptr[0]))) {
+ litptr[litnum] = cp;
+#ifdef DEBUG_LITERAL
+ dprintf("litnum = %d, litptr = %x:\r\n",
+ litnum, litptr[litnum]);
+#endif /* DEBUG_LITERAL */
+ }
+ while (*cp & LITERAL)
+ cp++;
+ if (*cp)
+ Vdraw((int) (litnum++ | LITERAL));
+ else {
+ /*
+ * XXX: This is a bug, we lose the last literal, if it is not
+ * followed by a normal character, but it is too hard to fix
+ */
+ break;
+ }
+ }
+ else
+ Draw(*cp);
+ }
+}
+
+/*
+ * Refresh()
+ * draws the new virtual screen image from the current input
+ * line, then goes line-by-line changing the real image to the new
+ * virtual image. The routine to re-draw a line can be replaced
+ * easily in hopes of a smarter one being placed there.
+ */
+static int OldvcV = 0;
+void
+Refresh()
+{
+ register int cur_line;
+ register Char *cp;
+ int cur_h, cur_v = 0, new_vcv;
+ int rhdiff;
+ Char oldgetting;
+
+#ifdef DEBUG_REFRESH
+ dprintf("PromptBuf = :%s:\r\n", short2str(PromptBuf));
+ dprintf("InputBuf = :%s:\r\n", short2str(InputBuf));
+#endif /* DEBUG_REFRESH */
+ oldgetting = GettingInput;
+ GettingInput = 0; /* avoid re-entrance via SIGWINCH */
+
+ /* reset the Vdraw cursor, temporarily draw rprompt to calculate its size */
+ vcursor_h = 0;
+ vcursor_v = 0;
+ RefreshPromptpart(NULL);
+ RefreshPromptpart(RPromptBuf);
+ rprompt_h = vcursor_h;
+ rprompt_v = vcursor_v;
+
+ /* reset the Vdraw cursor, draw prompt */
+ vcursor_h = 0;
+ vcursor_v = 0;
+ RefreshPromptpart(NULL);
+ RefreshPromptpart(PromptBuf);
+ cur_h = -1; /* set flag in case I'm not set */
+
+ /* draw the current input buffer */
+ for (cp = InputBuf; (cp < LastChar); cp++) {
+ if (cp == Cursor) {
+ cur_h = vcursor_h; /* save for later */
+ cur_v = vcursor_v;
+ }
+ Draw(*cp);
+ }
+
+ if (cur_h == -1) { /* if I haven't been set yet, I'm at the end */
+ cur_h = vcursor_h;
+ cur_v = vcursor_v;
+ }
+
+ rhdiff = TermH - vcursor_h - rprompt_h;
+ if (rprompt_h != 0 && rprompt_v == 0 && vcursor_v == 0 && rhdiff > 1) {
+ /*
+ * have a right-hand side prompt that will fit on
+ * the end of the first line with at least one
+ * character gap to the input buffer.
+ */
+ while (--rhdiff > 0) /* pad out with spaces */
+ Draw(' ');
+ RefreshPromptpart(RPromptBuf);
+ }
+ else {
+ rprompt_h = 0; /* flag "not using rprompt" */
+ rprompt_v = 0;
+ }
+
+ new_vcv = vcursor_v; /* must be done BEFORE the NUL is written */
+ Vdraw('\0'); /* put NUL on end */
+
+#ifdef DEBUG_REFRESH
+ dprintf("TermH=%d, vcur_h=%d, vcur_v=%d, Vdisplay[0]=\r\n:%80.80s:\r\n",
+ TermH, vcursor_h, vcursor_v, short2str(Vdisplay[0]));
+#endif /* DEBUG_REFRESH */
+
+#ifdef DEBUG_UPDATE
+ dprintf("updating %d lines.\r\n", new_vcv);
+#endif /* DEBUG_UPDATE */
+ for (cur_line = 0; cur_line <= new_vcv; cur_line++) {
+ /* NOTE THAT update_line MAY CHANGE Display[cur_line] */
+ update_line(Display[cur_line], Vdisplay[cur_line], cur_line);
+#ifdef WINNT
+ flush();
+#endif /* WINNT */
+
+ /*
+ * Copy the new line to be the current one, and pad out with spaces
+ * to the full width of the terminal so that if we try moving the
+ * cursor by writing the character that is at the end of the
+ * screen line, it won't be a NUL or some old leftover stuff.
+ */
+ cpy_pad_spaces(Display[cur_line], Vdisplay[cur_line], TermH);
+#ifdef notdef
+ (void) Strncpy(Display[cur_line], Vdisplay[cur_line], (size_t) TermH);
+ Display[cur_line][TermH] = '\0'; /* just in case */
+#endif
+ }
+#ifdef DEBUG_REFRESH
+ dprintf("\r\nvcursor_v = %d, OldvcV = %d, cur_line = %d\r\n",
+ vcursor_v, OldvcV, cur_line);
+#endif /* DEBUG_REFRESH */
+ if (OldvcV > new_vcv) {
+ for (; cur_line <= OldvcV; cur_line++) {
+ update_line(Display[cur_line], STRNULL, cur_line);
+ *Display[cur_line] = '\0';
+ }
+ }
+ OldvcV = new_vcv; /* set for next time */
+#ifdef DEBUG_REFRESH
+ dprintf("\r\nCursorH = %d, CursorV = %d, cur_h = %d, cur_v = %d\r\n",
+ CursorH, CursorV, cur_h, cur_v);
+#endif /* DEBUG_REFRESH */
+#ifdef WINNT
+ flush();
+#endif /* WINNT */
+ MoveToLine(cur_v); /* go to where the cursor is */
+ MoveToChar(cur_h);
+ SetAttributes(0); /* Clear all attributes */
+ flush(); /* send the output... */
+ GettingInput = oldgetting; /* reset to old value */
+}
+
+#ifdef notdef
+GotoBottom()
+{ /* used to go to last used screen line */
+ MoveToLine(OldvcV);
+}
+
+#endif
+
+void
+PastBottom()
+{ /* used to go to last used screen line */
+ MoveToLine(OldvcV);
+ (void) putraw('\r');
+ (void) putraw('\n');
+ ClearDisp();
+ flush();
+}
+
+
+/* insert num characters of s into d (in front of the character) at dat,
+ maximum length of d is dlen */
+static void
+str_insert(d, dat, dlen, s, num)
+ register Char *d;
+ register int dat, dlen;
+ register Char *s;
+ register int num;
+{
+ register Char *a, *b;
+
+ if (num <= 0)
+ return;
+ if (num > dlen - dat)
+ num = dlen - dat;
+
+#ifdef DEBUG_REFRESH
+ dprintf("str_insert() starting: %d at %d max %d, d == \"%s\"\n",
+ num, dat, dlen, short2str(d));
+ dprintf("s == \"%s\"n", short2str(s));
+#endif /* DEBUG_REFRESH */
+
+ /* open up the space for num chars */
+ if (num > 0) {
+ b = d + dlen - 1;
+ a = b - num;
+ while (a >= &d[dat])
+ *b-- = *a--;
+ d[dlen] = '\0'; /* just in case */
+ }
+#ifdef DEBUG_REFRESH
+ dprintf("str_insert() after insert: %d at %d max %d, d == \"%s\"\n",
+ num, dat, dlen, short2str(d));
+ dprintf("s == \"%s\"n", short2str(s));
+#endif /* DEBUG_REFRESH */
+
+ /* copy the characters */
+ for (a = d + dat; (a < d + dlen) && (num > 0); num--)
+ *a++ = *s++;
+
+#ifdef DEBUG_REFRESH
+ dprintf("str_insert() after copy: %d at %d max %d, d == \"%s\"\n",
+ num, dat, dlen, d, short2str(s));
+ dprintf("s == \"%s\"n", short2str(s));
+#endif /* DEBUG_REFRESH */
+}
+
+/* delete num characters d at dat, maximum length of d is dlen */
+static void
+str_delete(d, dat, dlen, num)
+ register Char *d;
+ register int dat, dlen, num;
+{
+ register Char *a, *b;
+
+ if (num <= 0)
+ return;
+ if (dat + num >= dlen) {
+ d[dat] = '\0';
+ return;
+ }
+
+#ifdef DEBUG_REFRESH
+ dprintf("str_delete() starting: %d at %d max %d, d == \"%s\"\n",
+ num, dat, dlen, short2str(d));
+#endif /* DEBUG_REFRESH */
+
+ /* open up the space for num chars */
+ if (num > 0) {
+ b = d + dat;
+ a = b + num;
+ while (a < &d[dlen])
+ *b++ = *a++;
+ d[dlen] = '\0'; /* just in case */
+ }
+#ifdef DEBUG_REFRESH
+ dprintf("str_delete() after delete: %d at %d max %d, d == \"%s\"\n",
+ num, dat, dlen, short2str(d));
+#endif /* DEBUG_REFRESH */
+}
+
+static void
+str_cp(a, b, n)
+ register Char *a, *b;
+ register int n;
+{
+ while (n-- && *b)
+ *a++ = *b++;
+}
+
+
+#if defined(DSPMBYTE) /* BY TAGA Nayuta VERY THANKS */
+static Char *
+update_line_fix_mbyte_point(start, target, d)
+ Char *start, *target;
+ int d;
+{
+ if (_enable_mbdisp) {
+ while (*start) {
+ if (target == start)
+ break;
+ if (target < start)
+ return target + d;
+ if (Ismbyte1(*start) && Ismbyte2(*(start + 1)))
+ start++;
+ start++;
+ }
+ }
+ return target;
+}
+#endif
+
+/* ****************************************************************
+ update_line() is based on finding the middle difference of each line
+ on the screen; vis:
+
+ /old first difference
+ /beginning of line | /old last same /old EOL
+ v v v v
+old: eddie> Oh, my little gruntle-buggy is to me, as lurgid as
+new: eddie> Oh, my little buggy says to me, as lurgid as
+ ^ ^ ^ ^
+ \beginning of line | \new last same \new end of line
+ \new first difference
+
+ all are character pointers for the sake of speed. Special cases for
+ no differences, as well as for end of line additions must be handled.
+**************************************************************** */
+
+/* Minimum at which doing an insert it "worth it". This should be about
+ * half the "cost" of going into insert mode, inserting a character, and
+ * going back out. This should really be calculated from the termcap
+ * data... For the moment, a good number for ANSI terminals.
+ */
+#define MIN_END_KEEP 4
+
+static void /* could be changed to make it smarter */
+update_line(old, new, cur_line)
+ register Char *old, *new;
+ int cur_line;
+{
+ register Char *o, *n, *p, c;
+ Char *ofd, *ols, *oe, *nfd, *nls, *ne;
+ Char *osb, *ose, *nsb, *nse;
+ int fx, sx;
+
+ /*
+ * find first diff
+ */
+ for (o = old, n = new; *o && (*o == *n); o++, n++)
+ continue;
+ ofd = o;
+ nfd = n;
+
+ /*
+ * Find the end of both old and new
+ */
+ while (*o)
+ o++;
+ /*
+ * Remove any trailing blanks off of the end, being careful not to
+ * back up past the beginning.
+ */
+ while (ofd < o) {
+ if (o[-1] != ' ')
+ break;
+ o--;
+ }
+ oe = o;
+ *oe = (Char) 0;
+
+ while (*n)
+ n++;
+
+ /* remove blanks from end of new */
+ while (nfd < n) {
+ if (n[-1] != ' ')
+ break;
+ n--;
+ }
+ ne = n;
+ *ne = (Char) 0;
+
+ /*
+ * if no diff, continue to next line of redraw
+ */
+ if (*ofd == '\0' && *nfd == '\0') {
+#ifdef DEBUG_UPDATE
+ dprintf("no difference.\r\n");
+#endif /* DEBUG_UPDATE */
+ return;
+ }
+
+ /*
+ * find last same pointer
+ */
+ while ((o > ofd) && (n > nfd) && (*--o == *--n))
+ continue;
+ ols = ++o;
+ nls = ++n;
+
+ /*
+ * find same begining and same end
+ */
+ osb = ols;
+ nsb = nls;
+ ose = ols;
+ nse = nls;
+
+ /*
+ * case 1: insert: scan from nfd to nls looking for *ofd
+ */
+ if (*ofd) {
+ for (c = *ofd, n = nfd; n < nls; n++) {
+ if (c == *n) {
+ for (o = ofd, p = n; p < nls && o < ols && *o == *p; o++, p++)
+ continue;
+ /*
+ * if the new match is longer and it's worth keeping, then we
+ * take it
+ */
+ if (((nse - nsb) < (p - n)) && (2 * (p - n) > n - nfd)) {
+ nsb = n;
+ nse = p;
+ osb = ofd;
+ ose = o;
+ }
+ }
+ }
+ }
+
+ /*
+ * case 2: delete: scan from ofd to ols looking for *nfd
+ */
+ if (*nfd) {
+ for (c = *nfd, o = ofd; o < ols; o++) {
+ if (c == *o) {
+ for (n = nfd, p = o; p < ols && n < nls && *p == *n; p++, n++)
+ continue;
+ /*
+ * if the new match is longer and it's worth keeping, then we
+ * take it
+ */
+ if (((ose - osb) < (p - o)) && (2 * (p - o) > o - ofd)) {
+ nsb = nfd;
+ nse = n;
+ osb = o;
+ ose = p;
+ }
+ }
+ }
+ }
+#ifdef notdef
+ /*
+ * If `last same' is before `same end' re-adjust
+ */
+ if (ols < ose)
+ ols = ose;
+ if (nls < nse)
+ nls = nse;
+#endif
+
+ /*
+ * Pragmatics I: If old trailing whitespace or not enough characters to
+ * save to be worth it, then don't save the last same info.
+ */
+ if ((oe - ols) < MIN_END_KEEP) {
+ ols = oe;
+ nls = ne;
+ }
+
+ /*
+ * Pragmatics II: if the terminal isn't smart enough, make the data dumber
+ * so the smart update doesn't try anything fancy
+ */
+
+ /*
+ * fx is the number of characters we need to insert/delete: in the
+ * beginning to bring the two same begins together
+ */
+ fx = (int) ((nsb - nfd) - (osb - ofd));
+ /*
+ * sx is the number of characters we need to insert/delete: in the end to
+ * bring the two same last parts together
+ */
+ sx = (int) ((nls - nse) - (ols - ose));
+
+ if (!T_CanIns) {
+ if (fx > 0) {
+ osb = ols;
+ ose = ols;
+ nsb = nls;
+ nse = nls;
+ }
+ if (sx > 0) {
+ ols = oe;
+ nls = ne;
+ }
+ if ((ols - ofd) < (nls - nfd)) {
+ ols = oe;
+ nls = ne;
+ }
+ }
+ if (!T_CanDel) {
+ if (fx < 0) {
+ osb = ols;
+ ose = ols;
+ nsb = nls;
+ nse = nls;
+ }
+ if (sx < 0) {
+ ols = oe;
+ nls = ne;
+ }
+ if ((ols - ofd) > (nls - nfd)) {
+ ols = oe;
+ nls = ne;
+ }
+ }
+
+ /*
+ * Pragmatics III: make sure the middle shifted pointers are correct if
+ * they don't point to anything (we may have moved ols or nls).
+ */
+ /* if the change isn't worth it, don't bother */
+ /* was: if (osb == ose) */
+ if ((ose - osb) < MIN_END_KEEP) {
+ osb = ols;
+ ose = ols;
+ nsb = nls;
+ nse = nls;
+ }
+
+ /*
+ * Now that we are done with pragmatics we recompute fx, sx
+ */
+ fx = (int) ((nsb - nfd) - (osb - ofd));
+ sx = (int) ((nls - nse) - (ols - ose));
+
+#ifdef DEBUG_UPDATE
+ dprintf("\n");
+ dprintf("ofd %d, osb %d, ose %d, ols %d, oe %d\n",
+ ofd - old, osb - old, ose - old, ols - old, oe - old);
+ dprintf("nfd %d, nsb %d, nse %d, nls %d, ne %d\n",
+ nfd - new, nsb - new, nse - new, nls - new, ne - new);
+ dprintf("xxx-xxx:\"00000000001111111111222222222233333333334\"\r\n");
+ dprintf("xxx-xxx:\"01234567890123456789012345678901234567890\"\r\n");
+ dprintstr("old- oe", old, oe);
+ dprintstr("new- ne", new, ne);
+ dprintstr("old-ofd", old, ofd);
+ dprintstr("new-nfd", new, nfd);
+ dprintstr("ofd-osb", ofd, osb);
+ dprintstr("nfd-nsb", nfd, nsb);
+ dprintstr("osb-ose", osb, ose);
+ dprintstr("nsb-nse", nsb, nse);
+ dprintstr("ose-ols", ose, ols);
+ dprintstr("nse-nls", nse, nls);
+ dprintstr("ols- oe", ols, oe);
+ dprintstr("nls- ne", nls, ne);
+#endif /* DEBUG_UPDATE */
+
+ /*
+ * CursorV to this line cur_line MUST be in this routine so that if we
+ * don't have to change the line, we don't move to it. CursorH to first
+ * diff char
+ */
+ MoveToLine(cur_line);
+
+#if defined(DSPMBYTE) /* BY TAGA Nayuta VERY THANKS */
+ ofd = update_line_fix_mbyte_point(old, ofd, -1);
+ osb = update_line_fix_mbyte_point(old, osb, 1);
+ ose = update_line_fix_mbyte_point(old, ose, -1);
+ ols = update_line_fix_mbyte_point(old, ols, 1);
+ nfd = update_line_fix_mbyte_point(new, nfd, -1);
+ nsb = update_line_fix_mbyte_point(new, nsb, 1);
+ nse = update_line_fix_mbyte_point(new, nse, -1);
+ nls = update_line_fix_mbyte_point(new, nls, 1);
+#endif
+
+ /*
+ * at this point we have something like this:
+ *
+ * /old /ofd /osb /ose /ols /oe
+ * v.....................v v..................v v........v
+ * eddie> Oh, my fredded gruntle-buggy is to me, as foo var lurgid as
+ * eddie> Oh, my fredded quiux buggy is to me, as gruntle-lurgid as
+ * ^.....................^ ^..................^ ^........^
+ * \new \nfd \nsb \nse \nls \ne
+ *
+ * fx is the difference in length between the the chars between nfd and
+ * nsb, and the chars between ofd and osb, and is thus the number of
+ * characters to delete if < 0 (new is shorter than old, as above),
+ * or insert (new is longer than short).
+ *
+ * sx is the same for the second differences.
+ */
+
+ /*
+ * if we have a net insert on the first difference, AND inserting the net
+ * amount ((nsb-nfd) - (osb-ofd)) won't push the last useful character
+ * (which is ne if nls != ne, otherwise is nse) off the edge of the screen
+ * (TermH - 1) else we do the deletes first so that we keep everything we
+ * need to.
+ */
+
+ /*
+ * if the last same is the same like the end, there is no last same part,
+ * otherwise we want to keep the last same part set p to the last useful
+ * old character
+ */
+ p = (ols != oe) ? oe : ose;
+
+ /*
+ * if (There is a diffence in the beginning) && (we need to insert
+ * characters) && (the number of characters to insert is less than the term
+ * width) We need to do an insert! else if (we need to delete characters)
+ * We need to delete characters! else No insert or delete
+ */
+ if ((nsb != nfd) && fx > 0 && ((p - old) + fx < TermH)) {
+#ifdef DEBUG_UPDATE
+ dprintf("first diff insert at %d...\r\n", nfd - new);
+#endif /* DEBUG_UPDATE */
+ /*
+ * Move to the first char to insert, where the first diff is.
+ */
+ MoveToChar(nfd - new);
+ /*
+ * Check if we have stuff to keep at end
+ */
+ if (nsb != ne) {
+#ifdef DEBUG_UPDATE
+ dprintf("with stuff to keep at end\r\n");
+#endif /* DEBUG_UPDATE */
+ /*
+ * insert fx chars of new starting at nfd
+ */
+ if (fx > 0) {
+#ifdef DEBUG_UPDATE
+ if (!T_CanIns)
+ dprintf(" ERROR: cannot insert in early first diff\n");
+#endif /* DEBUG_UPDATE */
+ Insert_write(nfd, fx);
+ str_insert(old, (int) (ofd - old), TermH, nfd, fx);
+ }
+ /*
+ * write (nsb-nfd) - fx chars of new starting at (nfd + fx)
+ */
+ so_write(nfd + fx, (nsb - nfd) - fx);
+ str_cp(ofd + fx, nfd + fx, (int) ((nsb - nfd) - fx));
+ }
+ else {
+#ifdef DEBUG_UPDATE
+ dprintf("without anything to save\r\n");
+#endif /* DEBUG_UPDATE */
+ so_write(nfd, (nsb - nfd));
+ str_cp(ofd, nfd, (int) (nsb - nfd));
+ /*
+ * Done
+ */
+ return;
+ }
+ }
+ else if (fx < 0) {
+#ifdef DEBUG_UPDATE
+ dprintf("first diff delete at %d...\r\n", ofd - old);
+#endif /* DEBUG_UPDATE */
+ /*
+ * move to the first char to delete where the first diff is
+ */
+ MoveToChar(ofd - old);
+ /*
+ * Check if we have stuff to save
+ */
+ if (osb != oe) {
+#ifdef DEBUG_UPDATE
+ dprintf("with stuff to save at end\r\n");
+#endif /* DEBUG_UPDATE */
+ /*
+ * fx is less than zero *always* here but we check for code
+ * symmetry
+ */
+ if (fx < 0) {
+#ifdef DEBUG_UPDATE
+ if (!T_CanDel)
+ dprintf(" ERROR: cannot delete in first diff\n");
+#endif /* DEBUG_UPDATE */
+ DeleteChars(-fx);
+ str_delete(old, (int) (ofd - old), TermH, -fx);
+ }
+ /*
+ * write (nsb-nfd) chars of new starting at nfd
+ */
+ so_write(nfd, (nsb - nfd));
+ str_cp(ofd, nfd, (int) (nsb - nfd));
+
+ }
+ else {
+#ifdef DEBUG_UPDATE
+ dprintf("but with nothing left to save\r\n");
+#endif /* DEBUG_UPDATE */
+ /*
+ * write (nsb-nfd) chars of new starting at nfd
+ */
+ so_write(nfd, (nsb - nfd));
+#ifdef DEBUG_REFRESH
+ dprintf("cleareol %d\n", (oe - old) - (ne - new));
+#endif /* DEBUG_UPDATE */
+#ifndef WINNT
+ ClearEOL((oe - old) - (ne - new));
+#else
+ /*
+ * The calculation above does not work too well on NT
+ */
+ ClearEOL(TermH - CursorH);
+#endif /*WINNT*/
+ /*
+ * Done
+ */
+ return;
+ }
+ }
+ else
+ fx = 0;
+
+ if (sx < 0) {
+#ifdef DEBUG_UPDATE
+ dprintf("second diff delete at %d...\r\n", (ose - old) + fx);
+#endif /* DEBUG_UPDATE */
+ /*
+ * Check if we have stuff to delete
+ */
+ /*
+ * fx is the number of characters inserted (+) or deleted (-)
+ */
+
+ MoveToChar((ose - old) + fx);
+ /*
+ * Check if we have stuff to save
+ */
+ if (ols != oe) {
+#ifdef DEBUG_UPDATE
+ dprintf("with stuff to save at end\r\n");
+#endif /* DEBUG_UPDATE */
+ /*
+ * Again a duplicate test.
+ */
+ if (sx < 0) {
+#ifdef DEBUG_UPDATE
+ if (!T_CanDel)
+ dprintf(" ERROR: cannot delete in second diff\n");
+#endif /* DEBUG_UPDATE */
+ DeleteChars(-sx);
+ }
+
+ /*
+ * write (nls-nse) chars of new starting at nse
+ */
+ so_write(nse, (nls - nse));
+ }
+ else {
+ int olen = (int) (oe - old + fx);
+ if (olen > TermH)
+ olen = TermH;
+#ifdef DEBUG_UPDATE
+ dprintf("but with nothing left to save\r\n");
+#endif /* DEBUG_UPDATE */
+ so_write(nse, (nls - nse));
+#ifdef DEBUG_REFRESH
+ dprintf("cleareol %d\n", olen - (ne - new));
+#endif /* DEBUG_UPDATE */
+#ifndef WINNT
+ ClearEOL(olen - (ne - new));
+#else
+ /*
+ * The calculation above does not work too well on NT
+ */
+ ClearEOL(TermH - CursorH);
+#endif /*WINNT*/
+ }
+ }
+
+ /*
+ * if we have a first insert AND WE HAVEN'T ALREADY DONE IT...
+ */
+ if ((nsb != nfd) && (osb - ofd) <= (nsb - nfd) && (fx == 0)) {
+#ifdef DEBUG_UPDATE
+ dprintf("late first diff insert at %d...\r\n", nfd - new);
+#endif /* DEBUG_UPDATE */
+
+ MoveToChar(nfd - new);
+ /*
+ * Check if we have stuff to keep at the end
+ */
+ if (nsb != ne) {
+#ifdef DEBUG_UPDATE
+ dprintf("with stuff to keep at end\r\n");
+#endif /* DEBUG_UPDATE */
+ /*
+ * We have to recalculate fx here because we set it
+ * to zero above as a flag saying that we hadn't done
+ * an early first insert.
+ */
+ fx = (int) ((nsb - nfd) - (osb - ofd));
+ if (fx > 0) {
+ /*
+ * insert fx chars of new starting at nfd
+ */
+#ifdef DEBUG_UPDATE
+ if (!T_CanIns)
+ dprintf(" ERROR: cannot insert in late first diff\n");
+#endif /* DEBUG_UPDATE */
+ Insert_write(nfd, fx);
+ str_insert(old, (int) (ofd - old), TermH, nfd, fx);
+ }
+
+ /*
+ * write (nsb-nfd) - fx chars of new starting at (nfd + fx)
+ */
+ so_write(nfd + fx, (nsb - nfd) - fx);
+ str_cp(ofd + fx, nfd + fx, (int) ((nsb - nfd) - fx));
+ }
+ else {
+#ifdef DEBUG_UPDATE
+ dprintf("without anything to save\r\n");
+#endif /* DEBUG_UPDATE */
+ so_write(nfd, (nsb - nfd));
+ str_cp(ofd, nfd, (int) (nsb - nfd));
+ }
+ }
+
+ /*
+ * line is now NEW up to nse
+ */
+ if (sx >= 0) {
+#ifdef DEBUG_UPDATE
+ dprintf("second diff insert at %d...\r\n", nse - new);
+#endif /* DEBUG_UPDATE */
+ MoveToChar(nse - new);
+ if (ols != oe) {
+#ifdef DEBUG_UPDATE
+ dprintf("with stuff to keep at end\r\n");
+#endif /* DEBUG_UPDATE */
+ if (sx > 0) {
+ /* insert sx chars of new starting at nse */
+#ifdef DEBUG_UPDATE
+ if (!T_CanIns)
+ dprintf(" ERROR: cannot insert in second diff\n");
+#endif /* DEBUG_UPDATE */
+ Insert_write(nse, sx);
+ }
+
+ /*
+ * write (nls-nse) - sx chars of new starting at (nse + sx)
+ */
+ so_write(nse + sx, (nls - nse) - sx);
+ }
+ else {
+#ifdef DEBUG_UPDATE
+ dprintf("without anything to save\r\n");
+#endif /* DEBUG_UPDATE */
+ so_write(nse, (nls - nse));
+
+ /*
+ * No need to do a clear-to-end here because we were doing
+ * a second insert, so we will have over written all of the
+ * old string.
+ */
+ }
+ }
+#ifdef DEBUG_UPDATE
+ dprintf("done.\r\n");
+#endif /* DEBUG_UPDATE */
+}
+
+
+static void
+cpy_pad_spaces(dst, src, width)
+ register Char *dst, *src;
+ register int width;
+{
+ register int i;
+
+ for (i = 0; i < width; i++) {
+ if (*src == (Char) 0)
+ break;
+ *dst++ = *src++;
+ }
+
+ while (i < width) {
+ *dst++ = ' ';
+ i++;
+ }
+ *dst = (Char) 0;
+}
+
+void
+RefCursor()
+{ /* only move to new cursor pos */
+ register Char *cp, c;
+ register int h, th, v;
+
+ /* first we must find where the cursor is... */
+ h = 0;
+ v = 0;
+ th = TermH; /* optimize for speed */
+
+ for (cp = PromptBuf; *cp; cp++) { /* do prompt */
+ if (*cp & LITERAL)
+ continue;
+ c = *cp & CHAR; /* extra speed plus strip the inverse */
+ h++; /* all chars at least this long */
+
+ /* from wolman%crltrx.DEC@decwrl.dec.com (Alec Wolman) */
+ /* lets handle newline as part of the prompt */
+
+ if (c == '\n') {
+ h = 0;
+ v++;
+ }
+ else {
+ if (c == '\t') { /* if a tab, to next tab stop */
+ while (h & 07) {
+ h++;
+ }
+ }
+ else if (Iscntrl(c)) { /* if control char */
+ h++;
+ if (h > th) { /* if overflow, compensate */
+ h = 1;
+ v++;
+ }
+ }
+ else if (!Isprint(c)) {
+ h += 3;
+ if (h > th) { /* if overflow, compensate */
+ h = h - th;
+ v++;
+ }
+ }
+ }
+
+ if (h >= th) { /* check, extra long tabs picked up here also */
+ h = 0;
+ v++;
+ }
+ }
+
+ for (cp = InputBuf; cp < Cursor; cp++) { /* do input buffer to Cursor */
+ c = *cp & CHAR; /* extra speed plus strip the inverse */
+ h++; /* all chars at least this long */
+
+ if (c == '\n') { /* handle newline in data part too */
+ h = 0;
+ v++;
+ }
+ else {
+ if (c == '\t') { /* if a tab, to next tab stop */
+ while (h & 07) {
+ h++;
+ }
+ }
+ else if (Iscntrl(c)) { /* if control char */
+ h++;
+ if (h > th) { /* if overflow, compensate */
+ h = 1;
+ v++;
+ }
+ }
+ else if (!Isprint(c)) {
+ h += 3;
+ if (h > th) { /* if overflow, compensate */
+ h = h - th;
+ v++;
+ }
+ }
+ }
+
+ if (h >= th) { /* check, extra long tabs picked up here also */
+ h = 0;
+ v++;
+ }
+ }
+
+ /* now go there */
+ MoveToLine(v);
+ MoveToChar(h);
+ flush();
+}
+
+static void
+PutPlusOne(c)
+ int c;
+{
+ (void) putraw(c);
+ Display[CursorV][CursorH++] = (Char) c;
+ if (CursorH >= TermH) { /* if we must overflow */
+ CursorH = 0;
+ CursorV++;
+ OldvcV++;
+ if (T_Margin & MARGIN_AUTO) {
+ if (T_Margin & MARGIN_MAGIC) {
+ (void) putraw(' ');
+ (void) putraw('\b');
+ }
+ }
+ else {
+ (void) putraw('\r');
+ (void) putraw('\n');
+ }
+ }
+}
+
+void
+RefPlusOne()
+{ /* we added just one char, handle it fast.
+ * assumes that screen cursor == real cursor */
+ register Char c, mc;
+
+ c = Cursor[-1] & CHAR; /* the char we just added */
+
+ if (c == '\t' || Cursor != LastChar) {
+ Refresh(); /* too hard to handle */
+ return;
+ }
+
+ if (rprompt_h != 0 && (TermH - CursorH - rprompt_h < 3)) {
+ Refresh(); /* clear out rprompt if less than one char gap*/
+ return;
+ } /* else (only do at end of line, no TAB) */
+
+ if (Iscntrl(c)) { /* if control char, do caret */
+#ifndef _OSD_POSIX
+ mc = (c == '\177') ? '?' : (c | 0100);
+ PutPlusOne('^');
+ PutPlusOne(mc);
+#else /*_OSD_POSIX*/
+ if (_toascii[c] == '\177' || Isupper(_toebcdic[_toascii[c]|0100])
+ || strchr("@[\\]^_", _toebcdic[_toascii[c]|0100]) != NULL)
+ {
+ mc = (_toascii[c] == '\177') ? '?' : _toebcdic[_toascii[c]|0100];
+ PutPlusOne('^');
+ PutPlusOne(mc);
+ }
+ else
+ {
+ PutPlusOne('\\');
+ PutPlusOne(((c >> 6) & 7) + '0');
+ PutPlusOne(((c >> 3) & 7) + '0');
+ PutPlusOne((c & 7) + '0');
+ }
+#endif /*_OSD_POSIX*/
+ }
+ else if (Isprint(c)) { /* normal char */
+ PutPlusOne(c);
+ }
+#ifdef KANJI
+ else if (!adrof(STRnokanji)) {
+ PutPlusOne(c);
+ }
+#endif
+ else {
+ PutPlusOne('\\');
+ PutPlusOne(((c >> 6) & 7) + '0');
+ PutPlusOne(((c >> 3) & 7) + '0');
+ PutPlusOne((c & 7) + '0');
+ }
+ flush();
+}
+
+/* clear the screen buffers so that new new prompt starts fresh. */
+
+void
+ClearDisp()
+{
+ register int i;
+
+ CursorV = 0; /* clear the display buffer */
+ CursorH = 0;
+ for (i = 0; i < TermV; i++)
+ (void) memset(Display[i], 0, TermH * sizeof(Display[0][0]));
+ OldvcV = 0;
+}
+
+void
+ClearLines()
+{ /* Make sure all lines are *really* blank */
+ register int i;
+
+ if (T_CanCEOL) {
+ /*
+ * Clear the lines from the bottom up so that if we try moving
+ * the cursor down by writing the character that is at the end
+ * of the screen line, we won't rewrite a character that shouldn't
+ * be there.
+ */
+ for (i = OldvcV; i >= 0; i--) { /* for each line on the screen */
+ MoveToLine(i);
+ MoveToChar(0);
+ ClearEOL(TermH);
+ }
+ }
+ else {
+ MoveToLine(OldvcV); /* go to last line */
+ (void) putraw('\r'); /* go to BOL */
+ (void) putraw('\n'); /* go to new line */
+ }
+}
diff --git a/contrib/tcsh/ed.screen.c b/contrib/tcsh/ed.screen.c
new file mode 100644
index 000000000000..2d4be8ad3a6c
--- /dev/null
+++ b/contrib/tcsh/ed.screen.c
@@ -0,0 +1,1706 @@
+/* $Header: /src/pub/tcsh/ed.screen.c,v 3.46 1999/02/06 15:18:56 christos Exp $ */
+/*
+ * ed.screen.c: Editor/termcap-curses interface
+ */
+/*-
+ * Copyright (c) 1980, 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include "sh.h"
+
+RCSID("$Id: ed.screen.c,v 3.46 1999/02/06 15:18:56 christos Exp $")
+
+#include "ed.h"
+#include "tc.h"
+#include "ed.defns.h"
+
+#ifndef POSIX
+/*
+ * We don't prototype these, cause some systems have them wrong!
+ */
+extern int tgetent __P(());
+extern char *tgetstr __P(());
+extern int tgetflag __P(());
+extern int tgetnum __P(());
+extern char *tgoto __P(());
+# define PUTPURE putpure
+# define PUTRAW putraw
+#else
+extern int tgetent __P((char *, char *));
+extern char *tgetstr __P((char *, char **));
+extern int tgetflag __P((char *));
+extern int tgetnum __P((char *));
+extern char *tgoto __P((char *, int, int));
+extern void tputs __P((char *, int, void (*)(int)));
+# define PUTPURE ((void (*)__P((int))) putpure)
+# define PUTRAW ((void (*)__P((int))) putraw)
+#endif
+
+
+/* #define DEBUG_LITERAL */
+
+/*
+ * IMPORTANT NOTE: these routines are allowed to look at the current screen
+ * and the current possition assuming that it is correct. If this is not
+ * true, then the update will be WRONG! This is (should be) a valid
+ * assumption...
+ */
+
+#define TC_BUFSIZE 2048
+
+#define GoodStr(a) (tstr[a].str != NULL && tstr[a].str[0] != '\0')
+#define Str(a) tstr[a].str
+#define Val(a) tval[a].val
+
+static struct {
+ char *b_name;
+ int b_rate;
+} baud_rate[] = {
+
+#ifdef B0
+ { "0", B0 },
+#endif
+#ifdef B50
+ { "50", B50 },
+#endif
+#ifdef B75
+ { "75", B75 },
+#endif
+#ifdef B110
+ { "110", B110 },
+#endif
+#ifdef B134
+ { "134", B134 },
+#endif
+#ifdef B150
+ { "150", B150 },
+#endif
+#ifdef B200
+ { "200", B200 },
+#endif
+#ifdef B300
+ { "300", B300 },
+#endif
+#ifdef B600
+ { "600", B600 },
+#endif
+#ifdef B900
+ { "900", B900 },
+#endif
+#ifdef B1200
+ { "1200", B1200 },
+#endif
+#ifdef B1800
+ { "1800", B1800 },
+#endif
+#ifdef B2400
+ { "2400", B2400 },
+#endif
+#ifdef B3600
+ { "3600", B3600 },
+#endif
+#ifdef B4800
+ { "4800", B4800 },
+#endif
+#ifdef B7200
+ { "7200", B7200 },
+#endif
+#ifdef B9600
+ { "9600", B9600 },
+#endif
+#ifdef EXTA
+ { "19200", EXTA },
+#endif
+#ifdef B19200
+ { "19200", B19200 },
+#endif
+#ifdef EXTB
+ { "38400", EXTB },
+#endif
+#ifdef B38400
+ { "38400", B38400 },
+#endif
+ { NULL, 0 }
+};
+
+#define T_al 0
+#define T_bl 1
+#define T_cd 2
+#define T_ce 3
+#define T_ch 4
+#define T_cl 5
+#define T_dc 6
+#define T_dl 7
+#define T_dm 8
+#define T_ed 9
+#define T_ei 10
+#define T_fs 11
+#define T_ho 12
+#define T_ic 13
+#define T_im 14
+#define T_ip 15
+#define T_kd 16
+#define T_kl 17
+#define T_kr 18
+#define T_ku 19
+#define T_md 20
+#define T_me 21
+#define T_nd 22
+#define T_se 23
+#define T_so 24
+#define T_ts 25
+#define T_up 26
+#define T_us 27
+#define T_ue 28
+#define T_vb 29
+#define T_DC 30
+#define T_DO 31
+#define T_IC 32
+#define T_LE 33
+#define T_RI 34
+#define T_UP 35
+#define T_str 36
+static struct termcapstr {
+ char *name;
+ char *long_name;
+ char *str;
+} tstr[T_str + 1];
+
+
+#define T_am 0
+#define T_pt 1
+#define T_li 2
+#define T_co 3
+#define T_km 4
+#define T_xn 5
+#define T_val 6
+static struct termcapval {
+ char *name;
+ char *long_name;
+ int val;
+} tval[T_val + 1];
+
+void
+terminit()
+{
+#ifdef NLS_CATALOGS
+ int i;
+
+ for (i = 0; i < T_str + 1; i++)
+ xfree((ptr_t) tstr[i].long_name);
+
+ for (i = 0; i < T_val + 1; i++)
+ xfree((ptr_t) tval[i].long_name);
+#endif
+
+ tstr[T_al].name = "al";
+ tstr[T_al].long_name = CSAVS(4, 1, "add new blank line");
+
+ tstr[T_bl].name = "bl";
+ tstr[T_bl].long_name = CSAVS(4, 2, "audible bell");
+
+ tstr[T_cd].name = "cd";
+ tstr[T_cd].long_name = CSAVS(4, 3, "clear to bottom");
+
+ tstr[T_ce].name = "ce";
+ tstr[T_ce].long_name = CSAVS(4, 4, "clear to end of line");
+
+ tstr[T_ch].name = "ch";
+ tstr[T_ch].long_name = CSAVS(4, 5, "cursor to horiz pos");
+
+ tstr[T_cl].name = "cl";
+ tstr[T_cl].long_name = CSAVS(4, 6, "clear screen");
+
+ tstr[T_dc].name = "dc";
+ tstr[T_dc].long_name = CSAVS(4, 7, "delete a character");
+
+ tstr[T_dl].name = "dl";
+ tstr[T_dl].long_name = CSAVS(4, 8, "delete a line");
+
+ tstr[T_dm].name = "dm";
+ tstr[T_dm].long_name = CSAVS(4, 9, "start delete mode");
+
+ tstr[T_ed].name = "ed";
+ tstr[T_ed].long_name = CSAVS(4, 10, "end delete mode");
+
+ tstr[T_ei].name = "ei";
+ tstr[T_ei].long_name = CSAVS(4, 11, "end insert mode");
+
+ tstr[T_fs].name = "fs";
+ tstr[T_fs].long_name = CSAVS(4, 12, "cursor from status line");
+
+ tstr[T_ho].name = "ho";
+ tstr[T_ho].long_name = CSAVS(4, 13, "home cursor");
+
+ tstr[T_ic].name = "ic";
+ tstr[T_ic].long_name = CSAVS(4, 14, "insert character");
+
+ tstr[T_im].name = "im";
+ tstr[T_im].long_name = CSAVS(4, 15, "start insert mode");
+
+ tstr[T_ip].name = "ip";
+ tstr[T_ip].long_name = CSAVS(4, 16, "insert padding");
+
+ tstr[T_kd].name = "kd";
+ tstr[T_kd].long_name = CSAVS(4, 17, "sends cursor down");
+
+ tstr[T_kl].name = "kl";
+ tstr[T_kl].long_name = CSAVS(4, 18, "sends cursor left");
+
+ tstr[T_kr].name = "kr";
+ tstr[T_kr].long_name = CSAVS(4, 19, "sends cursor right");
+
+ tstr[T_ku].name = "ku";
+ tstr[T_ku].long_name = CSAVS(4, 20, "sends cursor up");
+
+ tstr[T_md].name = "md";
+ tstr[T_md].long_name = CSAVS(4, 21, "begin bold");
+
+ tstr[T_me].name = "me";
+ tstr[T_me].long_name = CSAVS(4, 22, "end attributes");
+
+ tstr[T_nd].name = "nd";
+ tstr[T_nd].long_name = CSAVS(4, 23, "non destructive space");
+
+ tstr[T_se].name = "se";
+ tstr[T_se].long_name = CSAVS(4, 24, "end standout");
+
+ tstr[T_so].name = "so";
+ tstr[T_so].long_name = CSAVS(4, 25, "begin standout");
+
+ tstr[T_ts].name = "ts";
+ tstr[T_ts].long_name = CSAVS(4, 26, "cursor to status line");
+
+ tstr[T_up].name = "up";
+ tstr[T_up].long_name = CSAVS