home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3443 < prev    next >
Encoding:
Internet Message Format  |  1991-06-07  |  61.1 KB

  1. From: pvr@wang.com (Peter Reilley)
  2. Newsgroups: alt.sources
  3. Subject: BEAV (01/10) ver 1.2 Binary File Editor, new release
  4. Message-ID: <b6lmky.hmr@wang.com>
  5. Date: 6 Jun 91 13:24:33 GMT
  6.  
  7.  
  8.     This is the latest release of BEAV.   I am posting it to alt.sources
  9. because I my posting to comp.sources.unix has not been released by the 
  10. moderator.   It has sat in the mill for over 3 months.   I would like
  11. to find an archive for the source.   If someone would like to archive it
  12. and tell me where I would be most appreciative.    If this is not propper
  13. protocol please excuse me, I am reletively new to news.
  14.  
  15.     This release 1.20 of BEAV (Binary Editor And Viewer),
  16. a full featured binary file editor.      Just about any operation that 
  17. you could want to do to a binary file is possible with BEAV.   You 
  18. can insert or delete in the middle of a file thereby changing it's size.
  19. You can display and edit data in hex, octal, decimal, binary, ascii, 
  20. or ebcdic formats.   You can display data in byte, word, or long word 
  21. formats in either Intel or Motorola byte ordering.   You can send the 
  22. formatted display mode to a file or printer.
  23.  
  24.       Version 1.20  (3/10/91)  of  beav  contains  the  following
  25. fixes and enhancements;
  26.  
  27. *           Under   unix   files   are  created  with  read/write
  28.       permissions.
  29.  
  30. *           Fixed the  bug  in  the  terminal  I/O  routine  that
  31.       caused  beav  to  spin  rather  than  give  up control when
  32.       waiting for a character.
  33.  
  34. *           Added the ANSI #define that was missing for MSDOS.
  35.  
  36. *           Changed the D16 #define to a unsigned short.
  37.  
  38. *           Called ttclose on error exit.
  39.  
  40. *           Check and limit ncol and nrow to  the  actual  screen
  41.       array size.
  42.  
  43. *           Add  the  ability  to  load  key bindings from a file
  44.       automatically under MSDOS and unix.
  45.  
  46. *           Add delete current window command.
  47.  
  48. *           Support VT100 type function keys.
  49.  
  50.     BEAV is based on the source for emacs for display and keyboard handling 
  51. functions.   The binary file handling and display formats are special
  52. to BEAV.   There is a full manual included in this release.   There
  53. are makefiles for unix, xenix 286, and MSC 5.1 under DOS.   The old Wang PC
  54. is supported.   This has been tested on 286 and 386 PC's under SCO UNIX and
  55. XENIX as well as under UNIX on a MIPS system.
  56.     I am willing to maintain BEAV and will entertain suggestions for
  57. modifications and/or bug fixes.   I can be reached at;
  58.  
  59.         pvr@wang.com
  60.  
  61. or at;
  62.  
  63.         Peter Reilley
  64.         19 Heritage Cir.
  65.         Hudson, N.H. 03051
  66.  
  67. -----> CUT HERE <-----> CUT HERE <-----> CUT HERE <-----> CUT HERE <-----
  68. #! /bin/sh
  69. # This is a shell archive.  Remove anything before this line, then unpack
  70. # it by saving it into a file and typing "sh file".  To overwrite existing
  71. # files, type "sh file -c".  You can also feed this as standard input via
  72. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  73. # will see the following message at the end:
  74. #        "End of archive 1 (of 10)."
  75. # Contents:  cinfo.c ebcdic.c editor.lnk fileio.c kbd.c lintfunc.dec
  76. #   machine.c makefile.286 makefile.dos makefile.unx region.c spawn.c
  77. #   tcap.c termio.c tty.c ttyio.c wangpc.c word.c
  78. # Wrapped by pvr@elf on Thu Mar 14 08:16:45 1991
  79. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  80. if test -f 'cinfo.c' -a "${1}" != "-c" ; then 
  81.   echo shar: Will not clobber existing file \"'cinfo.c'\"
  82. else
  83. echo shar: Extracting \"'cinfo.c'\" \(2700 characters\)
  84. sed "s/^X//" >'cinfo.c' <<'END_OF_FILE'
  85. X/*
  86. X*        Character class tables.
  87. X* Do it yourself character classification
  88. X* macros, that understand the multinational character set,
  89. X* and let me ask some questions the standard macros (in
  90. X* ctype.h) don't let you ask.
  91. X*/
  92. X#define LINT_ARGS   1           /* enable lint type checking */
  93. X#include    "def.h"
  94. X#include    "lintfunc.dec"
  95. X/*
  96. X* This table, indexed by a character drawn
  97. X* from the 256 member character set, is used by my
  98. X* own character type macros to answer questions about the
  99. X* type of a character. It handles the full multinational
  100. X* character set, and lets me ask some questions that the
  101. X* standard "ctype" macros cannot ask.
  102. X*/
  103. Xchar    cinfo[256] =
  104. X{
  105. X
  106. X    _C, _C, _C, _C,             /* 0x0X     */
  107. X    _C, _C, _C, _C,
  108. X    _C, _C, _C, _C,
  109. X    _C, _C, _C, _C,
  110. X    _C, _C, _C, _C,             /* 0x1X     */
  111. X    _C, _C, _C, _C,
  112. X    _C, _C, _C, _C,
  113. X    _C, _C, _C, _C,
  114. X    0, 0, 0, 0,                 /* 0x2X     */
  115. X    _W, 0, 0, _W,
  116. X    0, 0, 0, 0,
  117. X    0, 0, 0, 0,
  118. X    _W, _W, _W, _W,             /* 0x3X     */
  119. X    _W, _W, _W, _W,
  120. X    _W, _W, 0, 0,
  121. X    0, 0, 0, 0,
  122. X    0, _U | _W, _U | _W, _U | _W,/* 0x4X     */
  123. X    _U | _W, _U | _W, _U | _W, _U | _W,
  124. X    _U | _W, _U | _W, _U | _W, _U | _W,
  125. X    _U | _W, _U | _W, _U | _W, _U | _W,
  126. X    _U | _W, _U | _W, _U | _W, _U | _W,/* 0x5X     */
  127. X    _U | _W, _U | _W, _U | _W, _U | _W,
  128. X    _U | _W, _U | _W, _U | _W, 0,
  129. X    0, 0, 0, _W,
  130. X    0, _L | _W, _L | _W, _L | _W,/* 0x6X     */
  131. X    _L | _W, _L | _W, _L | _W, _L | _W,
  132. X    _L | _W, _L | _W, _L | _W, _L | _W,
  133. X    _L | _W, _L | _W, _L | _W, _L | _W,
  134. X    _L | _W, _L | _W, _L | _W, _L | _W,/* 0x7X     */
  135. X    _L | _W, _L | _W, _L | _W, _L | _W,
  136. X    _L | _W, _L | _W, _L | _W, 0,
  137. X    0, 0, 0, _C,
  138. X    0, 0, 0, 0,                 /* 0x8X     */
  139. X    0, 0, 0, 0,
  140. X    0, 0, 0, 0,
  141. X    0, 0, 0, 0,
  142. X    0, 0, 0, 0,                 /* 0x9X     */
  143. X    0, 0, 0, 0,
  144. X    0, 0, 0, 0,
  145. X    0, 0, 0, 0,
  146. X    0, 0, 0, 0,                 /* 0xAX     */
  147. X    0, 0, 0, 0,
  148. X    0, 0, 0, 0,
  149. X    0, 0, 0, 0,
  150. X    0, 0, 0, 0,                 /* 0xBX     */
  151. X    0, 0, 0, 0,
  152. X    0, 0, 0, 0,
  153. X    0, 0, 0, 0,
  154. X    _U | _W, _U | _W, _U | _W, _U | _W,/* 0xCX     */
  155. X    _U | _W, _U | _W, _U | _W, _U | _W,
  156. X    _U | _W, _U | _W, _U | _W, _U | _W,
  157. X    _U | _W, _U | _W, _U | _W, _U | _W,
  158. X    0, _U | _W, _U | _W, _U | _W,/* 0xDX     */
  159. X    _U | _W, _U | _W, _U | _W, _U | _W,
  160. X    _U | _W, _U | _W, _U | _W, _U | _W,
  161. X    _U | _W, _U | _W, 0, _W,
  162. X    _L | _W, _L | _W, _L | _W, _L | _W,/* 0xEX     */
  163. X    _L | _W, _L | _W, _L | _W, _L | _W,
  164. X    _L | _W, _L | _W, _L | _W, _L | _W,
  165. X    _L | _W, _L | _W, _L | _W, _L | _W,
  166. X    0, _L | _W, _L | _W, _L | _W,/* 0xFX     */
  167. X    _L | _W, _L | _W, _L | _W, _L | _W,
  168. X    _L | _W, _L | _W, _L | _W, _L | _W,
  169. X    _L | _W, _L | _W, 0, 0
  170. X}
  171. X       ;
  172. END_OF_FILE
  173. if test 2700 -ne `wc -c <'cinfo.c'`; then
  174.     echo shar: \"'cinfo.c'\" unpacked with wrong size!
  175. fi
  176. chmod +x 'cinfo.c'
  177. # end of 'cinfo.c'
  178. fi
  179. if test -f 'ebcdic.c' -a "${1}" != "-c" ; then 
  180.   echo shar: Will not clobber existing file \"'ebcdic.c'\"
  181. else
  182. echo shar: Extracting \"'ebcdic.c'\" \(2681 characters\)
  183. sed "s/^X//" >'ebcdic.c' <<'END_OF_FILE'
  184. X
  185. X#define LINT_ARGS   1           /* enable lint type checking */
  186. X#include    "def.h"
  187. X
  188. Xextern    char    ERR_ebcdic[];
  189. X
  190. X#include    "lintfunc.dec"
  191. X/* Function definitions */
  192. X
  193. X/* This table defines the translation from EBCDIC code to ASCII. */
  194. X
  195. Xchar    ebcdic_table[] =
  196. X{0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 00-07 */
  197. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 08-0F */
  198. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 10-17 */
  199. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 18-1F */
  200. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 20-27 */
  201. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 28-2F */
  202. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 30-37 */
  203. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 38-3F */
  204. X    0x20, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 40-47 */
  205. X    0x2E, 0x2E, 0x2E, 0x2E, 0x3C, 0x28, 0x2B, 0x2E,/* 48-4F */
  206. X    0x26, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 50-57 */
  207. X    0x2E, 0x2E, 0x21, 0x24, 0x2A, 0x29, 0x3B, 0x5E,/* 58-5F */
  208. X    0x2D, 0x2F, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 60-67 */
  209. X    0x2E, 0x2E, 0x7C, 0x2E, 0x25, 0x5F, 0x3E, 0x3F,/* 68-6F */
  210. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x27, 0x2E, 0x2E,/* 70-77 */
  211. X    0x2E, 0x60, 0x3A, 0x23, 0x40, 0x2C, 0x3D, 0x22,/* 78-7F */
  212. X    0x2E, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,/* 80-87 */
  213. X    0x68, 0x69, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 88-8F */
  214. X    0x2E, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,/* 90-97 */
  215. X    0x71, 0x72, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* 98-9F */
  216. X    0x2E, 0x7E, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,/* A0-A7 */
  217. X    0x79, 0x7A, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* A8-AF */
  218. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* B0-B7 */
  219. X    0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* B8-BF */
  220. X    0x7B, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,/* C0-C7 */
  221. X    0x48, 0x49, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* C8-CF */
  222. X    0x7D, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,/* D0-D7 */
  223. X    0x51, 0x52, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* D8-DF */
  224. X    0x5C, 0x2E, 0X53, 0x54, 0x55, 0x56, 0x57, 0x58,/* E0-E7 */
  225. X    0x59, 0x5A, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E,/* E8-EF */
  226. X    0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,/* F0-F7 */
  227. X    0x38, 0x39, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E/* F8-FF */
  228. X};
  229. X
  230. X/* convert a ASCII character to an EBCDIC character */
  231. Xchar    to_ebcdic (ch)
  232. X
  233. Xchar    ch;
  234. X{
  235. X    int     cnt;
  236. X    char    buf[70], buf1[70];
  237. X
  238. X    for (cnt = 0; cnt < sizeof (ebcdic_table); cnt++)
  239. X        {
  240. X        if (ch == ebcdic_table[cnt])
  241. X            return (cnt);
  242. X        }
  243. X    sprintf (buf1, ERR_ebcdic, R_BYTE_FMT(curwp));
  244. X    sprintf (buf, buf1, ch);
  245. X    writ_echo(buf);
  246. X    return (0);
  247. X}
  248. END_OF_FILE
  249. if test 2681 -ne `wc -c <'ebcdic.c'`; then
  250.     echo shar: \"'ebcdic.c'\" unpacked with wrong size!
  251. fi
  252. chmod +x 'ebcdic.c'
  253. # end of 'ebcdic.c'
  254. fi
  255. if test -f 'editor.lnk' -a "${1}" != "-c" ; then 
  256.   echo shar: Will not clobber existing file \"'editor.lnk'\"
  257. else
  258. echo shar: Extracting \"'editor.lnk'\" \(193 characters\)
  259. sed "s/^X//" >'editor.lnk' <<'END_OF_FILE'
  260. XBASIC +BUFFER +CINFO +DISPLAY +ECHO +EXTEND + EBCDIC +
  261. XFILE +FILEIO +FORMAT +KBD +LINE +MAIN +RANDOM +REGION +
  262. XSEARCH +SPAWN +SYMBOL +TEXT +TTY +TTYIO +TTYKBD +
  263. XWINDOW +WORD + WANGPC
  264. XBEAV.EXE;
  265. END_OF_FILE
  266. if test 193 -ne `wc -c <'editor.lnk'`; then
  267.     echo shar: \"'editor.lnk'\" unpacked with wrong size!
  268. fi
  269. chmod +x 'editor.lnk'
  270. # end of 'editor.lnk'
  271. fi
  272. if test -f 'fileio.c' -a "${1}" != "-c" ; then 
  273.   echo shar: Will not clobber existing file \"'fileio.c'\"
  274. else
  275. echo shar: Extracting \"'fileio.c'\" \(4787 characters\)
  276. sed "s/^X//" >'fileio.c' <<'END_OF_FILE'
  277. X/*
  278. X*    file I/O.
  279. X*/
  280. X#include    <sys/types.h> 
  281. X#include        "def.h"
  282. X
  283. X#ifdef UNIX
  284. X#include    <fcntl.h> 
  285. X#include    <sys/stat.h> 
  286. X#endif
  287. Xextern    char    MSG_cnt_wr[];
  288. Xextern    char    MSG_wr_io_er[];
  289. Xextern    char    MSG_rd_er[];
  290. Xextern    char    MSG_bak[];
  291. Xextern    char    MSG_backup[];
  292. Xextern    char    MSG_back_er[];
  293. Xextern    char    MSG_back_of[];
  294. X
  295. X#include    "lintfunc.dec"
  296. X
  297. X#ifdef MSDOS
  298. Xstatic  FILE * ffp;
  299. X#endif
  300. X
  301. X#ifdef UNIX
  302. Xstatic  int ffp;
  303. X#endif
  304. X
  305. X/*
  306. X* Open a file for reading.
  307. X*/
  308. Xchar    ffropen (fn)
  309. Xchar   *fn;
  310. X{
  311. X#ifdef MSDOS
  312. X    if ((ffp = fopen (fn, "rb")) == NULL)/* pvr */
  313. X        return (FIOERR);;
  314. X    return (FIOSUC);
  315. X#endif
  316. X#ifdef UNIX
  317. X    if ((ffp = open (fn, O_RDONLY)) == -1)/* pvr */
  318. X        return (FIOERR);;
  319. X    return (FIOSUC);
  320. X#endif
  321. X}
  322. X/*
  323. X*   Get the file length
  324. X*/
  325. XA32 file_len ()
  326. X    {
  327. X#ifdef MSDOS
  328. X    return (filelength (fileno (ffp)));
  329. X#endif
  330. X#ifdef UNIX
  331. X    struct    stat    st;
  332. X    
  333. X    if (fstat (ffp, &st) == -1)
  334. X        return (-1);
  335. X    return (st.st_size);
  336. X#endif
  337. X    }
  338. X
  339. X/*
  340. X* Open a file for writing.
  341. X* Return TRUE if all is well, and
  342. X* FALSE on error (cannot create).
  343. X*/
  344. Xchar    ffwopen (fn)
  345. Xchar   *fn;
  346. X{
  347. X#ifdef MSDOS
  348. X    if ((ffp = fopen (fn, "wb")) == NULL)/* pvr */
  349. X        {
  350. X        writ_echo (MSG_cnt_wr);
  351. X        return (FIOERR);
  352. X        }
  353. X    return (FIOSUC);
  354. X#endif
  355. X#ifdef UNIX
  356. X    /* set perms  1.13 */
  357. X    if ((ffp = open (fn, O_WRONLY | O_CREAT, S_IREAD | S_IWRITE)) == -1)/* pvr */
  358. X        return (FIOERR);;
  359. X    return (FIOSUC);
  360. X#endif
  361. X}
  362. X
  363. X/*
  364. X* Close a file.
  365. X* Should look at the status.
  366. X*/
  367. Xchar    ffclose ()
  368. X{
  369. X#ifdef MSDOS
  370. X    fclose (ffp);
  371. X#endif
  372. X#ifdef UNIX
  373. X    close (ffp);
  374. X#endif
  375. X    return (FIOSUC);
  376. X}
  377. X
  378. X/*
  379. X* Write a line to the already
  380. X* opened file. The "buf" points to the
  381. X* buffer, and the "nbuf" is its length.   pvr
  382. X* Return the status.
  383. X*/
  384. Xchar    ffputline (buf, nbuf)
  385. Xregister char   buf[];
  386. Xint     nbuf;
  387. X{
  388. X    register int    i;
  389. X
  390. X#ifdef MSDOS
  391. X    i = fwrite (buf, 1, nbuf, ffp);
  392. X#endif
  393. X#ifdef UNIX 
  394. X    i = write (ffp, buf, nbuf);
  395. X#endif
  396. X
  397. X    if ((i != nbuf)
  398. X#ifdef MSDOS    
  399. X         || (ferror (ffp) != FALSE))
  400. X#else
  401. X        )
  402. X#endif     
  403. X        {
  404. X        writ_echo (MSG_wr_io_er);
  405. X        return (FIOERR);
  406. X        }
  407. X    return (FIOSUC);
  408. X}
  409. X
  410. X/*
  411. X* Read a line from a file, and store the bytes
  412. X* in the supplied buffer. Stop on end of file or after 'nbuf' characters. pvr
  413. X* the first byte in the buffer is the length in bytes.
  414. X*/
  415. Xchar    ffgetline (buf, nbuf, rbuf)
  416. Xregister char   *buf;
  417. Xregister int    *rbuf, nbuf;
  418. X{
  419. X
  420. X    register int    c;
  421. X    register int    i;
  422. X
  423. X#ifdef MSDOS
  424. X    *rbuf = fread (buf, 1, nbuf, ffp); 
  425. X#endif
  426. X
  427. X#ifdef UNIX
  428. X    *rbuf = read (ffp, buf, nbuf); 
  429. X#endif
  430. X
  431. X    /* End of file.         */
  432. X#ifdef MSDOS
  433. X    if (ferror (ffp) != FALSE)
  434. X        {
  435. X        writ_echo (MSG_rd_er);
  436. X        return (FIOERR);
  437. X        }
  438. X#endif
  439. X    if (*rbuf == 0)
  440. X        return (FIOEOF);
  441. X
  442. X    return (FIOSUC);
  443. X}
  444. X
  445. X/*
  446. X*   Seek to specified position in file.
  447. X*   Return the actual position in the file.
  448. X*/
  449. XA32     ffseek (posn)
  450. X    A32     posn;
  451. X    {
  452. X#ifdef MSDOS
  453. X    fseek (ffp, posn, SEEK_SET);
  454. X    return (ftell (ffp));
  455. X#endif
  456. X#ifdef UNIX
  457. X    return (lseek (ffp, posn, 0));
  458. X#endif
  459. X    }
  460. X
  461. X/*
  462. X* Some backup user on MS-DOS might want
  463. X* to determine some rule for doing backups on that
  464. X* system, and fix this. I don't use MS-DOS, so I don't
  465. X* know what the right rules would be. Return TRUE so
  466. X* the caller does not abort a write.
  467. X*/
  468. X#if BACKUP
  469. Xbool    fbackupfile (fname)
  470. Xchar   *fname;
  471. X{
  472. X    FILE * backupfile;
  473. X    char    backname[128];
  474. X    char   *source,
  475. X           *backup;
  476. X    extern char time_string[];
  477. X    char    buf[80];
  478. X
  479. X    source = fname;
  480. X    backup = backname;
  481. X    while ((*source > 0) && (*source != '.'))
  482. X        {
  483. X        *backup = *source;
  484. X        backup++;
  485. X        source++;
  486. X        *backup = 0;
  487. X        }
  488. X    strcat (backname, MSG_bak);
  489. X    sprintf (buf, MSG_backup, fname, backname);
  490. X    writ_echo (buf);
  491. X    unlink (backname);
  492. X#ifdef MSDOS
  493. X    if (rename (backname, fname) > 0)
  494. X#else
  495. X    if ((link (fname, backname) != 0) || (unlink (fname) != 0))
  496. X#endif
  497. X        {
  498. X        sprintf (buf, MSG_back_er, fname, backname);
  499. X        writ_echo (buf);
  500. X        return (FALSE);
  501. X        }
  502. X    return (TRUE);              /* Hack.                */
  503. X}
  504. X
  505. X#endif
  506. X
  507. X/*
  508. X* The string "fn" is a file name.
  509. X* Perform any required case adjustments. All systems
  510. X* we deal with so far have case insensitive file systems.
  511. X* We zap everything to lower case. The problem we are trying
  512. X* to solve is getting 2 buffers holding the same file if
  513. X* you visit one of them with the "caps lock" key down.
  514. X* On UNIX file names are dual case, so we leave
  515. X* everything alone.
  516. X*/
  517. Xvoid    adjustcase (fn)
  518. Xregister char  *fn;
  519. X{
  520. X    register int    c;
  521. X
  522. X    while ((c = *fn) != 0)
  523. X        {
  524. X        if (c >= 'A' && c <= 'Z')
  525. X            *fn = c + 'a' - 'A';
  526. X        ++fn;
  527. X        }
  528. X}
  529. X
  530. X
  531. END_OF_FILE
  532. if test 4787 -ne `wc -c <'fileio.c'`; then
  533.     echo shar: \"'fileio.c'\" unpacked with wrong size!
  534. fi
  535. chmod +x 'fileio.c'
  536. # end of 'fileio.c'
  537. fi
  538. if test -f 'kbd.c' -a "${1}" != "-c" ; then 
  539.   echo shar: Will not clobber existing file \"'kbd.c'\"
  540. else
  541. echo shar: Extracting \"'kbd.c'\" \(4640 characters\)
  542. sed "s/^X//" >'kbd.c' <<'END_OF_FILE'
  543. X/*                      KBD.C
  544. X*       Terminal independent keyboard handling.
  545. X*/
  546. X#define LINT_ARGS   1           /* enable lint type checking */
  547. X#include    "def.h"
  548. X
  549. Xchar    *keystrings ();
  550. X
  551. Xextern    char    MSG_tab[];
  552. Xextern    char    MSG_esc[];
  553. Xextern    char    MSG_ctl_x[];
  554. Xextern    char    MSG_ctl[];
  555. Xextern    char    MSG_fn[];
  556. Xextern    char    MSG_ret[];
  557. Xextern    char    MSG_bksp[];
  558. Xextern    char    MSG_space[];
  559. Xextern    char    MSG_rubout[];
  560. X
  561. X#include    "lintfunc.dec"
  562. X/*
  563. X* Read in a key, doing the terminal
  564. X* independent prefix handling. The terminal specific
  565. X* "getkbd" routine gets the first swing, and may return
  566. X* one of the special codes used by the special keys
  567. X* on the keyboard. The "getkbd" routine returns the
  568. X* C0 controls as received; this routine moves them to
  569. X* the right spot in 11 bit code.
  570. X*/
  571. Xint     getkey ()
  572. X{
  573. X
  574. X    register int    c;
  575. X    c = getkbd ();
  576. X    if (c == METACH)            /* M-           */
  577. X    {
  578. X        c = KMETA | getctl ();
  579. X#ifdef VT100KEY
  580. X        if ((c & KCHAR) == '[')
  581. X            c = KMETA | KCTRL | KCTLX | getctl ();    /* flag VT100 sequence */
  582. X#endif
  583. X    }
  584. X    else if (c == CTRLCH)        /* C-           */
  585. X        c = KCTRL | getctl ();
  586. X    else if (c == CTMECH)    /* C-M-         */
  587. X        c = KCTRL | KMETA | getctl ();
  588. X    else if (c >= 0x00 && c <= 0x1F)/* Relocate control.    */
  589. X        c = KCTRL | (c + '@');
  590. X
  591. X    if (c == (KCTRL | 'X'))     /* C-X          */
  592. X        c = KCTLX | getctl ();
  593. X    return (c);
  594. X}
  595. X
  596. X
  597. X/*
  598. X* Used above.
  599. X*/
  600. Xint     getctl ()
  601. X{
  602. X
  603. X    register int    c;
  604. X
  605. X#if 1
  606. X    c = getkbd ();
  607. X    if (c == METACH)            /* M-           */
  608. X        c = KMETA | getctl ();
  609. X    else
  610. X        if (c == CTRLCH)        /* C-           */
  611. X            c = KCTRL | getctl ();
  612. X    else
  613. X        if (c == CTMECH)    /* C-M-         */
  614. X            c = KCTRL | KMETA | getctl ();
  615. X     else
  616. X        if (c >= 0x00 && c <= 0x1F)/* Relocate control.    */
  617. X            c = KCTRL | (c + '@');
  618. X#else
  619. X    c = getkey ();              /* Note recursion   */
  620. X    if (ISLOWER (c & 0xFF))
  621. X        c = (c & ~0xFF) | TOUPPER (c & 0xFF);
  622. X    if (c >= 0x00 && c <= 0x1F) /* Relocate control.    */
  623. X        c = KCTRL | (c + '@');
  624. X#endif
  625. X    if (ISLOWER (c & 0xFF))
  626. X        c = (c & ~0xFF) | TOUPPER (c & 0xFF);
  627. X    return (c);
  628. X}
  629. X
  630. X
  631. X/*
  632. X* Transform a key code into a name,
  633. X* using a table for the special keys and combination
  634. X* of some hard code and some general processing for
  635. X* the rest. None of this code is terminal specific any
  636. X* more. This makes adding keys easier.
  637. X*/
  638. Xvoid keyname (cp, k)
  639. Xregister char  *cp;
  640. Xregister int    k;
  641. X{
  642. X    register char  *np;
  643. X    char    nbuf[3];
  644. X
  645. X    static char hex[] =
  646. X    {
  647. X        '0', '1', '2', '3',
  648. X        '4', '5', '6', '7',
  649. X        '8', '9', 'A', 'B',
  650. X        'C', 'D', 'E', 'F'
  651. X    };
  652. X    *cp = 0;    /* terminate previous string */
  653. X#ifdef VT100KEY
  654. X    if ((k & (KMETA | KCTRL | KCTLX)) == (int)(KMETA | KCTRL | KCTLX)) 
  655. X        {
  656. X        sprintf (&cp[strlen (cp)], MSG_fn);
  657. X        sprintf (&cp[strlen (cp)], "%c", k & KCHAR);
  658. X        return;
  659. X        }
  660. X#endif
  661. X    if (k & 0x80)
  662. X        {
  663. X        if ((np = keystrings (k)) != NULL)
  664. X            {
  665. X            if ((k & KMETA) != 0)
  666. X                sprintf (&cp[strlen (cp)], MSG_esc);
  667. X
  668. X            strcat (cp, np);
  669. X            }
  670. X        else
  671. X            cp[strlen (cp)] = 0;    /* null string */
  672. X        return;
  673. X        }
  674. X
  675. X    if ((k & KCTLX) != 0)
  676. X        {
  677. X        /* Ctl-X prefix.      */
  678. X        sprintf (&cp[strlen (cp)], MSG_ctl_x);
  679. X        k &= ~KCTLX;
  680. X        }
  681. X
  682. X    if ((k & KMETA) != 0)
  683. X        {
  684. X        /* Add Esc- mark.     */
  685. X        sprintf (&cp[strlen (cp)], MSG_esc);
  686. X        k &= ~KMETA;
  687. X        }
  688. X
  689. X    if (k == (KCTRL | 'I'))/* Some specials.   */
  690. X        np = MSG_tab;
  691. X    else
  692. X        {
  693. X        if (k == (KCTRL | 'M'))
  694. X            np = MSG_ret;
  695. X        else if (k == (KCTRL | 'H'))
  696. X            np = MSG_bksp;
  697. X        else if (k == ' ')
  698. X            np = MSG_space;
  699. X        else if (k == 0x7F)
  700. X            np = MSG_rubout;
  701. X        else
  702. X            {
  703. X            if ((k & KCTRL) != 0)
  704. X                {
  705. X                /* Add Ctl- mark.     */
  706. X                sprintf (&cp[strlen (cp)], MSG_ctl);
  707. X                }
  708. X            np = &nbuf[0];
  709. X            if (((k & KCHAR) >= 0x20 && (k & KCHAR) <= 0x7E)
  710. X                 || ((k & KCHAR) >= 0xA0 && (k & KCHAR) <= 0xFE))
  711. X                {
  712. X                nbuf[0] = k & KCHAR;/* Graphic.     */
  713. X                nbuf[1] = 0;
  714. X                }
  715. X            else
  716. X                {
  717. X                /* Non graphic.     */
  718. X                nbuf[0] = hex[(k >> 4) & 0x0F];
  719. X                nbuf[1] = hex[k & 0x0F];
  720. X                nbuf[2] = 0;
  721. X                }
  722. X            }
  723. X        }
  724. X    strcat (cp, np);
  725. X}
  726. X
  727. END_OF_FILE
  728. if test 4640 -ne `wc -c <'kbd.c'`; then
  729.     echo shar: \"'kbd.c'\" unpacked with wrong size!
  730. fi
  731. chmod +x 'kbd.c'
  732. # end of 'kbd.c'
  733. fi
  734. if test -f 'lintfunc.dec' -a "${1}" != "-c" ; then 
  735.   echo shar: Will not clobber existing file \"'lintfunc.dec'\"
  736. else
  737. echo shar: Extracting \"'lintfunc.dec'\" \(25 characters\)
  738. sed "s/^X//" >'lintfunc.dec' <<'END_OF_FILE'
  739. X/* Dummy include file */
  740. END_OF_FILE
  741. if test 25 -ne `wc -c <'lintfunc.dec'`; then
  742.     echo shar: \"'lintfunc.dec'\" unpacked with wrong size!
  743. fi
  744. # end of 'lintfunc.dec'
  745. fi
  746. if test -f 'machine.c' -a "${1}" != "-c" ; then 
  747.   echo shar: Will not clobber existing file \"'machine.c'\"
  748. else
  749. echo shar: Extracting \"'machine.c'\" \(2190 characters\)
  750. sed "s/^X//" >'machine.c' <<'END_OF_FILE'
  751. X/* This program sniffs around to see what type of MSDOS computer
  752. X    it is running in
  753. X*/
  754. X
  755. X/* Checks what type of machine it is running in and returns
  756. X        0 if unknown
  757. X        1 if Wang PC
  758. X        2 if Wang APC
  759. X        3 if IBM PC/XT
  760. X        4 if IBM PC/AT
  761. X        5 if IBM PC Jr
  762. X        6 if IBM PC
  763. X        7 if Wang Laptop
  764. X    8 if Wang PC200
  765. X        9 if Wang PC300
  766. X       10 if IBM PS/2
  767. X*/
  768. Xint host_mach()
  769. X{
  770. Xunsigned char far *memptr;
  771. Xunsigned char    c;
  772. Xint i, match;
  773. Xstatic char wang_pc[]={"WANG PROFE"};
  774. Xstatic char wang_apc[]={"WANG ADVAN"};
  775. Xstatic char wang_lap[]={"WANG"};
  776. X
  777. X/* test for Wang PC */
  778. Xmemptr = (unsigned char far *)0xFC003FC2L;
  779. Xmatch = 1;
  780. Xfor (i=0;(i<10 && match!=0);i++)
  781. X    {
  782. X    if(*memptr != wang_pc[i])
  783. X        match=0;
  784. X    memptr++;
  785. X    }
  786. Xif(match ==1)
  787. X    return(1);
  788. X
  789. X/* test for Wang APC */
  790. Xmemptr = (unsigned char far *)0xFC003FC2L;
  791. Xmatch = 1;
  792. Xfor (i=0;(i<10 && match!=0);i++)
  793. X    {
  794. X    if(*memptr != wang_apc[i])
  795. X    match=0;
  796. X    memptr++;
  797. X    }
  798. Xif(match ==1)
  799. X    return(2);
  800. X
  801. X/* test for Wang Laptop */
  802. Xmemptr = (unsigned char far *)0xFC003FC2L;
  803. Xmatch = 1;
  804. Xfor (i=0;(i<4 && match!=0);i++)
  805. X    {
  806. X    if(*memptr != wang_pc[i])
  807. X    match=0;
  808. X    memptr++;
  809. X    }
  810. Xif(match ==1)
  811. X    /* I should really do an INT 88h func 0 now to verify for sure
  812. X       but I'm too lazy!
  813. X    */
  814. X    return(7);
  815. X
  816. X/* Must be an IBM or clone */
  817. Xmemptr = (unsigned char far *)0xF000FFFEL;
  818. Xc = *memptr;
  819. X
  820. Xswitch(c)
  821. X    {
  822. Xcase 0xFC:  /* IBM AT or clone */
  823. X        /* for the moment a PC200 is the same as an AT */
  824. X            return(4);
  825. X
  826. Xcase 0xFD:  /* IBM PC Jr */
  827. X            return(5);
  828. X
  829. Xcase 0xFE:  /* IBM XT or clone */
  830. X            return(3);
  831. X
  832. Xcase 0xFF:  /* IBM PC or clone */
  833. X            return(6);
  834. X
  835. X    }
  836. X
  837. Xreturn(0);
  838. X}
  839. X
  840. X
  841. X
  842. Xmain()
  843. X{
  844. Xint machine;
  845. X
  846. Xmachine = host_mach();
  847. X
  848. Xprintf("This is a ");
  849. Xswitch(machine)
  850. X      {
  851. Xcase 0: printf("unknown type of machine\n");
  852. X        break;
  853. Xcase 1: printf("Wang PC\n");
  854. X        break;
  855. Xcase 2: printf("Wang Advanced PC\n");
  856. X        break;
  857. Xcase 3: printf("IBM PC/XT\n");
  858. X        break;
  859. Xcase 4: printf("IBM PC/AT\n");
  860. X        break;
  861. Xcase 5: printf("IBM PC Jr\n");
  862. X    break;
  863. Xcase 6: printf("IBM PC \n");
  864. X    break;
  865. Xcase 7: printf("Wang LapTop\n");
  866. X    break;
  867. X      }
  868. X
  869. X}
  870. END_OF_FILE
  871. if test 2190 -ne `wc -c <'machine.c'`; then
  872.     echo shar: \"'machine.c'\" unpacked with wrong size!
  873. fi
  874. chmod +x 'machine.c'
  875. # end of 'machine.c'
  876. fi
  877. if test -f 'makefile.286' -a "${1}" != "-c" ; then 
  878.   echo shar: Will not clobber existing file \"'makefile.286'\"
  879. else
  880. echo shar: Extracting \"'makefile.286'\" \(655 characters\)
  881. sed "s/^X//" >'makefile.286' <<'END_OF_FILE'
  882. X# This is a makefile for 286 xenix
  883. XCFLAGS=     -O -Ml -DUNIX
  884. X
  885. XOFILES=        basic.o ebcdic.o fileio.o region.o text.o wangpc.o \
  886. X    buffer.o echo.o main.o search.o tty.o window.o \
  887. X    cinfo.o extend.o kbd.o spawn.o ttyio.o termio.o tcap.o word.o \
  888. X    display.o file.o line.o random.o symbol.o ttykbd.o format.o
  889. X
  890. X
  891. XCFILES=     basic.c ebcdic.c fileio.c region.c text.c wangpc.c \
  892. X    buffer.c echo.c format.c main.c search.c tty.c window.c \
  893. X    cinfo.c extend.c kbd.c spawn.c ttyio.c termio.c tcap.c word.c \
  894. X    display.c file.c line.c random.c symbol.c ttykbd.c
  895. X
  896. XHFILES=     def.h
  897. X
  898. Xbeav:     $(OFILES)
  899. X    $(CC) $(CFLAGS) $(OFILES) -ltermcap -lc -o beav
  900. X
  901. X(OFILES):  $(HFILES)
  902. X
  903. END_OF_FILE
  904. if test 655 -ne `wc -c <'makefile.286'`; then
  905.     echo shar: \"'makefile.286'\" unpacked with wrong size!
  906. fi
  907. # end of 'makefile.286'
  908. fi
  909. if test -f 'makefile.dos' -a "${1}" != "-c" ; then 
  910.   echo shar: Will not clobber existing file \"'makefile.dos'\"
  911. else
  912. echo shar: Extracting \"'makefile.dos'\" \(1914 characters\)
  913. sed "s/^X//" >'makefile.dos' <<'END_OF_FILE'
  914. X# make BEAV  MSC 5.1
  915. X
  916. XBASIC.OBJ: BASIC.C DEF.H  LINTFUNC.DEC
  917. X CL -c  -Ml BASIC.C ;
  918. X
  919. XBUFFER.OBJ: BUFFER.C DEF.H  LINTFUNC.DEC
  920. X CL -c  -Ml BUFFER.C ;
  921. X
  922. XCINFO.OBJ: CINFO.C DEF.H  LINTFUNC.DEC
  923. X CL -c  -Ml CINFO.C ;
  924. X
  925. XDISPLAY.OBJ: DISPLAY.C DEF.H  LINTFUNC.DEC
  926. X CL -c  -Ml DISPLAY.C ;
  927. X
  928. XEBCDIC.OBJ: EBCDIC.C DEF.H  LINTFUNC.DEC
  929. X CL -c  -Ml EBCDIC.C ;
  930. X
  931. XECHO.OBJ: ECHO.C DEF.H  LINTFUNC.DEC
  932. X CL -c  -Ml ECHO.C ;
  933. X
  934. XEXTEND.OBJ: EXTEND.C DEF.H  LINTFUNC.DEC
  935. X CL -c  -Ml EXTEND.C ;
  936. X
  937. XFILE.OBJ: FILE.C DEF.H  LINTFUNC.DEC
  938. X CL -c  -Ml FILE.C ;
  939. X
  940. XFILEIO.OBJ: FILEIO.C DEF.H  LINTFUNC.DEC
  941. X CL -c  -Ml FILEIO.C ;
  942. X
  943. XFORMAT.OBJ: FORMAT.C DEF.H  LINTFUNC.DEC
  944. X CL -c  -Ml FORMAT.C ;
  945. X
  946. XKBD.OBJ: KBD.C DEF.H  LINTFUNC.DEC
  947. X CL -c  -Ml KBD.C ;
  948. X
  949. XLINE.OBJ: LINE.C DEF.H  LINTFUNC.DEC
  950. X CL -c  -Ml LINE.C ;
  951. X
  952. XMAIN.OBJ: MAIN.C DEF.H  LINTFUNC.DEC
  953. X CL -c  -Ml MAIN.C ;
  954. X
  955. XRANDOM.OBJ: RANDOM.C DEF.H  LINTFUNC.DEC
  956. X CL -c  -Ml RANDOM.C ;
  957. X
  958. XREGION.OBJ: REGION.C DEF.H  LINTFUNC.DEC
  959. X CL -c  -Ml REGION.C ;
  960. X
  961. XSEARCH.OBJ: SEARCH.C DEF.H  LINTFUNC.DEC
  962. X CL -c  -Ml SEARCH.C ;
  963. X
  964. XSPAWN.OBJ: SPAWN.C DEF.H  LINTFUNC.DEC
  965. X CL -c  -Ml SPAWN.C ;
  966. X
  967. XSYMBOL.OBJ: SYMBOL.C DEF.H  LINTFUNC.DEC
  968. X CL -c  -Ml SYMBOL.C ;
  969. X
  970. XTEXT.OBJ: TEXT.C DEF.H  LINTFUNC.DEC
  971. X CL -c  -Ml TEXT.C ;
  972. X
  973. XTTY.OBJ: TTY.C DEF.H  LINTFUNC.DEC
  974. X CL -c  -Ml TTY.C ;
  975. X
  976. XTTYIO.OBJ: TTYIO.C DEF.H  LINTFUNC.DEC
  977. X CL -c  -Ml TTYIO.C ;
  978. X
  979. XTTYKBD.OBJ: TTYKBD.C DEF.H  LINTFUNC.DEC
  980. X CL -c  -Ml TTYKBD.C ;
  981. X
  982. XWANGPC.OBJ: WANGPC.C DEF.H  LINTFUNC.DEC
  983. X CL -c  -Ml WANGPC.C ;
  984. X
  985. XWINDOW.OBJ: WINDOW.C DEF.H  LINTFUNC.DEC
  986. X CL -c  -Ml WINDOW.C ;
  987. X
  988. XWORD.OBJ: WORD.C DEF.H  LINTFUNC.DEC
  989. X CL -c  -Ml WORD.C ;
  990. X
  991. XBEAV.EXE: BASIC.OBJ BUFFER.OBJ CINFO.OBJ DISPLAY.OBJ ECHO.OBJ EXTEND.OBJ \
  992. X        EBCDIC.OBJ FILE.OBJ FILEIO.OBJ FORMAT.OBJ KBD.OBJ LINE.OBJ \
  993. X        MAIN.OBJ RANDOM.OBJ TEXT.OBJ \
  994. X        REGION.OBJ SEARCH.OBJ SPAWN.OBJ SYMBOL.OBJ TTY.OBJ TTYIO.OBJ   \
  995. X        TTYKBD.OBJ WINDOW.OBJ WORD.OBJ WANGPC.OBJ
  996. X LINK   @editor.lnk
  997. X
  998. X
  999. X
  1000. X
  1001. END_OF_FILE
  1002. if test 1914 -ne `wc -c <'makefile.dos'`; then
  1003.     echo shar: \"'makefile.dos'\" unpacked with wrong size!
  1004. fi
  1005. # end of 'makefile.dos'
  1006. fi
  1007. if test -f 'makefile.unx' -a "${1}" != "-c" ; then 
  1008.   echo shar: Will not clobber existing file \"'makefile.unx'\"
  1009. else
  1010. echo shar: Extracting \"'makefile.unx'\" \(615 characters\)
  1011. sed "s/^X//" >'makefile.unx' <<'END_OF_FILE'
  1012. XCFLAGS=     -O -DUNIX
  1013. X
  1014. XOFILES=        basic.o ebcdic.o fileio.o region.o text.o wangpc.o \
  1015. X    buffer.o echo.o main.o search.o tty.o window.o \
  1016. X    cinfo.o extend.o kbd.o spawn.o ttyio.o termio.o tcap.o word.o \
  1017. X    display.o file.o line.o random.o symbol.o ttykbd.o format.o
  1018. X
  1019. X
  1020. XCFILES=     basic.c ebcdic.c fileio.c region.c text.c wangpc.c \
  1021. X    buffer.c echo.c format.c main.c search.c tty.c window.c \
  1022. X    cinfo.c extend.c kbd.c spawn.c ttyio.c termio.c tcap.c word.c \
  1023. X    display.c file.c line.c random.c symbol.c ttykbd.c
  1024. X
  1025. XHFILES=     def.h
  1026. X
  1027. Xbeav:     $(OFILES)
  1028. X    $(CC) $(CFLAGS) $(OFILES) -ltermcap -lc -o beav
  1029. X
  1030. X(OFILES):  $(HFILES)
  1031. END_OF_FILE
  1032. if test 615 -ne `wc -c <'makefile.unx'`; then
  1033.     echo shar: \"'makefile.unx'\" unpacked with wrong size!
  1034. fi
  1035. # end of 'makefile.unx'
  1036. fi
  1037. if test -f 'region.c' -a "${1}" != "-c" ; then 
  1038.   echo shar: Will not clobber existing file \"'region.c'\"
  1039. else
  1040. echo shar: Extracting \"'region.c'\" \(4582 characters\)
  1041. sed "s/^X//" >'region.c' <<'END_OF_FILE'
  1042. X/*
  1043. X*       Region based commands.
  1044. X* The routines in this file
  1045. X* deal with the region, that magic space
  1046. X* between "." and mark. Some functions are
  1047. X* commands. Some functions are just for
  1048. X* internal use.
  1049. X*/
  1050. X#include    "def.h"
  1051. X
  1052. Xbool setsize ();
  1053. Xbool getregion ();
  1054. X
  1055. X
  1056. Xextern    char    MSG_reg_lrg[];
  1057. Xextern    char    MSG_sv_in_b[];
  1058. Xextern    char    MSG_sav_slf[];
  1059. Xextern    char    MSG_no_mark[];
  1060. X
  1061. X#include    "lintfunc.dec"
  1062. X/*
  1063. X* Kill the region. Ask "getregion"
  1064. X* to figure out the bounds of the region.
  1065. X* Move "." to the start, and kill the characters.
  1066. X*/
  1067. Xchar    killregion (f, n, k)
  1068. X{
  1069. X    register char   s;
  1070. X    REGION region;
  1071. X    int     error;
  1072. X
  1073. X    if ((s = getregion (®ion)) != TRUE)
  1074. X        return (s);
  1075. X    if ((lastflag & CFKILL) == 0)/* This is a kill type  */
  1076. X        kdelete ();             /* clean out k-buffer   */
  1077. X    thisflag |= CFKILL;         /* kill buffer stuff.   */
  1078. X    curwp -> w_dotp = region.r_linep;
  1079. X    curwp -> w_doto = region.r_offset;
  1080. X    error = ldelete (region.r_size, TRUE);
  1081. X    writ_echo (okmsg);
  1082. X    return (error);
  1083. X}
  1084. X
  1085. X
  1086. X/*
  1087. X* Copy all of the characters in the
  1088. X* region to the kill buffer. Don't move dot
  1089. X* at all. This is a bit like a kill region followed
  1090. X* by a yank.
  1091. X*/
  1092. Xchar    copyregion (f, n, k)
  1093. X{
  1094. X    register    LINE * linep;
  1095. X    register int    loffs;
  1096. X    register char   s;
  1097. X    REGION region;
  1098. X
  1099. X    if ((s = getregion (®ion)) != TRUE)
  1100. X        return (s);
  1101. X    if ((lastflag & CFKILL) == 0)/* Kill type command.   */
  1102. X        kdelete ();
  1103. X    thisflag |= CFKILL;
  1104. X    linep = region.r_linep;     /* Current line.    */
  1105. X    loffs = region.r_offset;    /* Current offset.  */
  1106. X    while (region.r_size--)
  1107. X        {
  1108. X        if (loffs == llength (linep))
  1109. X            {
  1110. X        /* End of line.     */
  1111. X            if ((s = kinsert ('\n')) != TRUE)
  1112. X                return (s);
  1113. X            linep = lforw (linep);
  1114. X            loffs = 0;
  1115. X            }
  1116. X        else
  1117. X            {
  1118. X        /* Middle of line.  */
  1119. X            if ((s = kinsert (lgetc (linep, loffs))) != TRUE)
  1120. X                return (s);
  1121. X            ++loffs;
  1122. X            }
  1123. X        }
  1124. X    writ_echo (okmsg);
  1125. X    return (TRUE);
  1126. X}
  1127. X
  1128. X/*
  1129. X* This routine figures out the bound of the region
  1130. X* in the current window, and stores the results into the fields
  1131. X* of the REGION structure. Dot and mark are usually close together,
  1132. X* but I don't know the order. The size is kept in a long. At the
  1133. X* end, after the size is figured out, it is assigned to the size
  1134. X* field of the region structure. If this assignment loses any bits,
  1135. X* then we print an error. This is "type independent" overflow
  1136. X* checking. All of the callers of this routine should be ready to
  1137. X* get an ABORT status, because I might add a "if regions is big,
  1138. X* ask before clobberring" flag.
  1139. X*/
  1140. Xbool getregion (rp)
  1141. Xregister    REGION * rp;
  1142. X{
  1143. X    if (curwp -> w_markp == NULL)
  1144. X        {
  1145. X        writ_echo (MSG_no_mark);
  1146. X        return (FALSE);
  1147. X        }
  1148. X
  1149. X    if (DOT_POS(curwp) < MARK_POS(curwp))
  1150. X        {
  1151. X        rp -> r_linep = curwp -> w_dotp;
  1152. X        rp -> r_offset = curwp -> w_doto;
  1153. X        rp -> r_size = (int)(MARK_POS(curwp) - DOT_POS(curwp));
  1154. X        }
  1155. X    else
  1156. X        {
  1157. X        rp -> r_linep = curwp -> w_markp;
  1158. X        rp -> r_offset = curwp -> w_marko;
  1159. X        rp -> r_size = (int)(DOT_POS(curwp) - MARK_POS(curwp));
  1160. X        }
  1161. X    return (TRUE);
  1162. X}
  1163. X
  1164. X/*
  1165. X* Set size, and check for overflow.
  1166. X*/
  1167. Xbool setsize (rp, size)
  1168. Xregister    REGION * rp;
  1169. Xregister long   size;
  1170. X{
  1171. X    rp -> r_size = size;
  1172. X    if (rp -> r_size != size)
  1173. X        {
  1174. X        writ_echo (MSG_reg_lrg);
  1175. X        return (FALSE);
  1176. X        }
  1177. X    return (TRUE);
  1178. X}
  1179. X
  1180. X
  1181. X/* save some region in a buffer
  1182. X* (use _usebuffer to handle non-existent buffers)
  1183. X* 
  1184. X* hack as it uses kill buffer to transfer stuff (quick and dirty!)
  1185. X* and doesn't do clever things at all with dot in destination buffer!
  1186. X*/
  1187. Xchar    save_region (f, n, k)
  1188. X{
  1189. X    char    bufn[NBUFN];
  1190. X    char    oldbufn[NBUFN];
  1191. X    register char   s;
  1192. X
  1193. X    if ((s = ereply (MSG_sv_in_b, bufn, NBUFN, NULL)) != TRUE)
  1194. X        return (s);
  1195. X
  1196. X    if (strcmp (bufn, curbp -> b_bname) == 0)
  1197. X        {
  1198. X        writ_echo (MSG_sav_slf);
  1199. X        return (FALSE);
  1200. X        }
  1201. X
  1202. X /* save this name for ughly reversal */
  1203. X    strcpy (oldbufn, curbp -> b_bname);
  1204. X
  1205. X /* copy stuff using killbuffer as work space -  hack !! * than move it to
  1206. X    named place using yank - Quick AND Dirty */
  1207. X    copyregion (f, n, k);
  1208. X    _usebuffer (bufn);
  1209. X    curbp -> b_flag |= BFSAV;   /* mark as a saved buffer */
  1210. X
  1211. X    yank (f, n, k);
  1212. X    kdelete ();                 /* clean out kill buffer */
  1213. X    _usebuffer (oldbufn);
  1214. X    writ_echo (okmsg);
  1215. X    return (TRUE);
  1216. X}
  1217. X
  1218. X
  1219. END_OF_FILE
  1220. if test 4582 -ne `wc -c <'region.c'`; then
  1221.     echo shar: \"'region.c'\" unpacked with wrong size!
  1222. fi
  1223. chmod +x 'region.c'
  1224. # end of 'region.c'
  1225. fi
  1226. if test -f 'spawn.c' -a "${1}" != "-c" ; then 
  1227.   echo shar: Will not clobber existing file \"'spawn.c'\"
  1228. else
  1229. echo shar: Extracting \"'spawn.c'\" \(1534 characters\)
  1230. sed "s/^X//" >'spawn.c' <<'END_OF_FILE'
  1231. X/*
  1232. X*    MS-DOS spawn command.com
  1233. X*/
  1234. X#include        "def.h"
  1235. X
  1236. Xextern    char    MSG_shell[];
  1237. Xextern    char    MSG_def_shell[];
  1238. Xextern    char    MSG_pmpt[];
  1239. Xextern    char    MSG_pt[];
  1240. Xextern    char    MSG_pme[];
  1241. Xextern    char    MSG_null[];
  1242. X
  1243. X#include    "lintfunc.dec"
  1244. X/* #include     <dos.h> */
  1245. X#if MSDOS
  1246. X#include        "process.h"
  1247. X#endif
  1248. Xchar   *cspec = NULL;           /* Command string.      */
  1249. Xchar   *pspec = NULL;
  1250. X
  1251. X/*
  1252. X* Create a subjob with a copy
  1253. X* of the command intrepreter in it. When the
  1254. X* command interpreter exits, mark the screen as
  1255. X* garbage so that you do a full repaint.
  1256. X*/
  1257. Xbool spawncli (f, n, k)
  1258. X{
  1259. X#if MSDOS
  1260. X
  1261. X    char   *getenv ();
  1262. X    char    old_prompt[128];
  1263. X    char    prompt_line[128];
  1264. X
  1265. X    ttcolor (CTEXT);            /* Normal color.        */
  1266. X    ttmove (nrow - 1, 0);       /* Last line.           */
  1267. X    ttflush ();
  1268. X    ttcooked ();
  1269. X#ifndef IBM
  1270. X    strcpy (prompt_line, MSG_pmpt);
  1271. X    pspec = getenv (MSG_pt);
  1272. X    strcpy (old_prompt, pspec);
  1273. X    strcat (prompt_line, pspec);
  1274. X    if (strlen (prompt_line - strlen (MSG_pme)) >= 64)
  1275. X    /* VERY rude, but setenv not found */
  1276. X        {
  1277. X        if (putenv (MSG_pmpt) == -1)
  1278. X            exit (1);
  1279. X        }
  1280. X    else
  1281. X        if (putenv (prompt_line) == -1)
  1282. X            exit (1);
  1283. X
  1284. X#endif
  1285. X    if (!cspec && !(cspec = getenv (MSG_shell)))/* jam */
  1286. X        cspec = MSG_def_shell;
  1287. X    spawnl (P_WAIT, cspec, MSG_null, NULL);
  1288. X    putenv (MSG_pme);
  1289. X    if (putenv (old_prompt) == -1)
  1290. X        exit (1);
  1291. X    ttraw ();
  1292. X    sgarbf = TRUE;
  1293. X#endif
  1294. X    return (TRUE);
  1295. X}
  1296. X
  1297. END_OF_FILE
  1298. if test 1534 -ne `wc -c <'spawn.c'`; then
  1299.     echo shar: \"'spawn.c'\" unpacked with wrong size!
  1300. fi
  1301. chmod +x 'spawn.c'
  1302. # end of 'spawn.c'
  1303. fi
  1304. if test -f 'tcap.c' -a "${1}" != "-c" ; then 
  1305.   echo shar: Will not clobber existing file \"'tcap.c'\"
  1306. else
  1307. echo shar: Extracting \"'tcap.c'\" \(2764 characters\)
  1308. sed "s/^X//" >'tcap.c' <<'END_OF_FILE'
  1309. X/*    tcap:    Unix V5, V7 and BS4.2 Termcap video driver
  1310. X        for beav
  1311. X*/
  1312. X
  1313. X#include "def.h"
  1314. X
  1315. X#ifdef UNIX
  1316. X
  1317. X#define    MARGIN    8
  1318. X#define    SCRSIZ    64
  1319. X#define    NPAUSE    10            /* # times thru update to pause */
  1320. X#define BEL     0x07
  1321. X#define ESC     0x1B
  1322. X
  1323. Xextern int      ttgetc();
  1324. Xextern int      ttputc();
  1325. Xextern int        tgetnum();
  1326. Xextern int      ttflush();
  1327. Xextern int      ttclose();
  1328. Xextern int      tput();
  1329. Xextern char     *tgoto();
  1330. X#if    COLOR
  1331. Xextern int        tcapfcol();
  1332. Xextern int        tcapbcol();
  1333. X#endif
  1334. X
  1335. X#define TCAPSLEN 315
  1336. Xchar tcapbuf[TCAPSLEN];
  1337. Xchar *UP, PC, *CM, *CE, *CL, *SO, *SE;
  1338. X
  1339. Xtcapopen()
  1340. X{
  1341. X        char *getenv();
  1342. X        char *t, *p, *tgetstr();
  1343. X        char tcbuf[1024];
  1344. X        char *tv_stype;
  1345. X        char err_str[72];
  1346. X
  1347. X        if ((tv_stype = getenv("TERM")) == NULL)
  1348. X        {
  1349. X                puts("Environment variable TERM not defined!\r");
  1350. X                 ttclose();
  1351. X                exit(1);
  1352. X        }
  1353. X
  1354. X        if ((tgetent(tcbuf, tv_stype)) != 1)
  1355. X        {
  1356. X                sprintf(err_str, "Unknown terminal type %s!\r", tv_stype);
  1357. X                puts(err_str);
  1358. X                 ttclose();    /* fix in 1.13 */
  1359. X                exit(1);
  1360. X        }
  1361. X
  1362. X       if ((nrow=(short)tgetnum("li")-1) == -1){
  1363. X               puts("termcap entry incomplete (lines)\r");
  1364. X               ttclose();    /* fix in 1.13 */
  1365. X               exit(1);
  1366. X       }
  1367. X        /* don't allow to specify a larger number of rows than we can handle 1.13 */
  1368. X        if (nrow > NROW)
  1369. X            nrow = NROW;
  1370. X
  1371. X       if ((ncol=(short)tgetnum("co")) == -1){
  1372. X               puts("Termcap entry incomplete (columns)\r");
  1373. X                ttclose();    /* fix in 1.13 */
  1374. X               exit(1);
  1375. X       }
  1376. X        /* don't allow to specify a larger number of cols than we can handle 1.13 */
  1377. X        if (ncol > NCOL)
  1378. X            ncol = NCOL;
  1379. X
  1380. X    p = tcapbuf;
  1381. X    t = tgetstr("pc", &p);
  1382. X    if(t)
  1383. X        PC = *t;
  1384. X
  1385. X    CL = tgetstr("cl", &p);
  1386. X    CM = tgetstr("cm", &p);
  1387. X    CE = tgetstr("ce", &p);
  1388. X    UP = tgetstr("up", &p);
  1389. X    SE = tgetstr("se", &p);
  1390. X    SO = tgetstr("so", &p);
  1391. X
  1392. X    if(CL == NULL || CM == NULL || UP == NULL)
  1393. X        {
  1394. X        puts("Incomplete termcap entry\r");
  1395. X        ttclose();    /* fix in 1.13 */
  1396. X        exit(1);
  1397. X        }
  1398. X
  1399. X    if (p >= &tcapbuf[TCAPSLEN])
  1400. X        {
  1401. X        puts("Terminal description too big!\r");
  1402. X        ttclose();    /* fix in 1.13 */
  1403. X        exit(1);
  1404. X        }
  1405. X}
  1406. X
  1407. Xtcapmove(row, col)
  1408. Xregister int row, col;
  1409. X{
  1410. X        putpad(tgoto(CM, col, row));
  1411. X}
  1412. X
  1413. Xtcapeeol()
  1414. X{
  1415. X        putpad(CE);
  1416. X}
  1417. X
  1418. Xtcapeeop()
  1419. X{
  1420. X        putpad(CL);
  1421. X}
  1422. X
  1423. Xtcaprev(state)        /* change reverse video status */
  1424. Xint state;        /* FALSE = normal video, TRUE = reverse video */
  1425. X
  1426. X{
  1427. X    static int revstate = FALSE;
  1428. X    if (state) {
  1429. X        if (SO != NULL)
  1430. X            putpad(SO);
  1431. X    } else
  1432. X        if (SE != NULL)
  1433. X            putpad(SE);
  1434. X}
  1435. X
  1436. Xputpad(str)
  1437. Xchar    *str;
  1438. X{
  1439. X    tputs(str, 1, ttputc);
  1440. X}
  1441. X
  1442. Xputnpad(str, n)
  1443. Xchar    *str;
  1444. X{
  1445. X    tputs(str, n, ttputc);
  1446. X}
  1447. X
  1448. X#endif
  1449. END_OF_FILE
  1450. if test 2764 -ne `wc -c <'tcap.c'`; then
  1451.     echo shar: \"'tcap.c'\" unpacked with wrong size!
  1452. fi
  1453. # end of 'tcap.c'
  1454. fi
  1455. if test -f 'termio.c' -a "${1}" != "-c" ; then 
  1456.   echo shar: Will not clobber existing file \"'termio.c'\"
  1457. else
  1458. echo shar: Extracting \"'termio.c'\" \(3581 characters\)
  1459. sed "s/^X//" >'termio.c' <<'END_OF_FILE'
  1460. X/*
  1461. X * The functions in this file negotiate with the operating system for
  1462. X * characters, and write characters in a barely buffered fashion on the display.
  1463. X * All operating systems.
  1464. X */
  1465. X
  1466. X#include    <sys/types.h>    /* 1.13 */
  1467. X#include    "def.h"
  1468. X
  1469. X#ifdef UNIX    /* System V */
  1470. X
  1471. X#include    <stdio.h>
  1472. X#include    <signal.h>
  1473. X#include    <termio.h>
  1474. X#include    <errno.h>
  1475. X#include    <fcntl.h>
  1476. Xint kbdflgs;            /* saved keyboard fd flags  */
  1477. Xint kbdpoll;            /* in O_NDELAY mode         */
  1478. Xint kbdqp;          /* there is a char in kbdq  */
  1479. Xchar kbdq;          /* char we've already read  */
  1480. Xstruct  termio  otermio;    /* original terminal characteristics */
  1481. Xstruct  termio  ntermio;    /* charactoristics to use inside */
  1482. X
  1483. Xextern    errno;        /* System error number -- Necessary when compiling in BSD 1.13 */
  1484. X
  1485. Xint     nrow;                   /* Terminal size, rows.         */
  1486. Xint     ncol;                   /* Terminal size, columns.      */
  1487. X
  1488. X/*
  1489. X * This function is called once to set up the terminal device streams.
  1490. X * On VMS, it translates TT until it finds the terminal, then assigns
  1491. X * a channel to it and sets it raw. On CPM it is a no-op.
  1492. X */
  1493. Xttopen()
  1494. X{
  1495. X    ioctl(0, TCGETA, &otermio); /* save old settings */
  1496. X    ntermio.c_iflag = 0;        /* setup new settings */
  1497. X    ntermio.c_oflag = 0;
  1498. X    ntermio.c_cflag = otermio.c_cflag;
  1499. X    ntermio.c_lflag = 0;
  1500. X    ntermio.c_line = otermio.c_line;
  1501. X    ntermio.c_cc[VMIN] = 1;
  1502. X    ntermio.c_cc[VTIME] = 0;
  1503. X    ioctl(0, TCSETAW, &ntermio); /* and activate them */
  1504. X    kbdflgs = fcntl( 0, F_GETFL, 0 );
  1505. X    kbdpoll = FALSE;
  1506. X    /* on all screens we are not sure of the initial position
  1507. X       of the cursor                    */
  1508. X    ttrow = 999;
  1509. X    ttcol = 999;
  1510. X    nrow = NROW;
  1511. X    ncol = NCOL;
  1512. X}
  1513. X
  1514. X/*
  1515. X * This function gets called just before we go back home to the command
  1516. X * interpreter. On VMS it puts the terminal back in a reasonable state.
  1517. X * Another no-operation on CPM.
  1518. X */
  1519. Xttclose()
  1520. X{
  1521. X    if (ioctl(0, TCSETAW, &otermio) == -1) /* restore terminal settings */
  1522. X        printf ("closing ioctl on dev 0 failure, error = %d\n", errno);
  1523. X    if (fcntl(0, F_SETFL, kbdflgs) == -1)
  1524. X        printf ("closing fcntl on dev 0 failure, error = %d\n", errno);
  1525. X}
  1526. X
  1527. X/*
  1528. X * Write a character to the display. On VMS, terminal output is buffered, and
  1529. X * we just put the characters in the big array, after checking for overflow.
  1530. X * On CPM terminal I/O unbuffered, so we just write the byte out. Ditto on
  1531. X * MS-DOS (use the very very raw console output routine).
  1532. X */
  1533. Xttputc(c)
  1534. X{
  1535. X    fputc(c, stdout);
  1536. X}
  1537. X
  1538. X/*
  1539. X * Flush terminal buffer. Does real work where the terminal output is buffered
  1540. X * up. A no-operation on systems where byte at a time terminal I/O is done.
  1541. X */
  1542. Xttflush()
  1543. X{
  1544. X   fflush(stdout);
  1545. X}
  1546. X
  1547. X/*
  1548. X * Read a character from the terminal, performing no editing and doing no echo
  1549. X * at all. More complex in VMS that almost anyplace else, which figures. Very
  1550. X * simple on CPM, because the system can do exactly what you want.
  1551. X */
  1552. Xttgetc()
  1553. X{
  1554. X    if( kbdqp )
  1555. X        kbdqp = FALSE;
  1556. X    else
  1557. X    {
  1558. X        if( kbdpoll && fcntl( 0, F_SETFL, kbdflgs ) < 0 )
  1559. X            return FALSE;
  1560. X        kbdpoll = FALSE;
  1561. X        while (read(0, &kbdq, 1) != 1)
  1562. X            ;
  1563. X    }
  1564. X    return ( kbdq & 127 );
  1565. X}
  1566. X
  1567. X/* typahead():    Check to see if any characters are already in the
  1568. X        keyboard buffer
  1569. X*/
  1570. Xttkeyready ()
  1571. X{
  1572. X    if( !kbdqp )
  1573. X    {
  1574. X        if( !kbdpoll && fcntl( 0, F_SETFL, kbdflgs | O_NDELAY ) < 0 )
  1575. X            return(FALSE);
  1576. X        kbdpoll = TRUE;    /*  fix in 1.13 */
  1577. X        kbdqp = (1 == read( 0, &kbdq, 1 ));
  1578. X    }
  1579. X    return ( kbdqp );
  1580. X}
  1581. X#endif
  1582. X
  1583. END_OF_FILE
  1584. if test 3581 -ne `wc -c <'termio.c'`; then
  1585.     echo shar: \"'termio.c'\" unpacked with wrong size!
  1586. fi
  1587. # end of 'termio.c'
  1588. fi
  1589. if test -f 'tty.c' -a "${1}" != "-c" ; then 
  1590.   echo shar: Will not clobber existing file \"'tty.c'\"
  1591. else
  1592. echo shar: Extracting \"'tty.c'\" \(6972 characters\)
  1593. sed "s/^X//" >'tty.c' <<'END_OF_FILE'
  1594. X/*
  1595. X*    Wang PC terminal display        TTY.C
  1596. X*
  1597. X*/
  1598. X#include        "def.h"
  1599. X
  1600. Xvoid    ttinit ();
  1601. Xvoid    tttidy ();
  1602. Xvoid    ttmove ();
  1603. Xvoid    tteeol ();
  1604. Xvoid    tteeop ();
  1605. Xvoid    ttbeep ();
  1606. Xvoid    asciiparm ();
  1607. Xvoid    ttnowindow ();    /* stub */
  1608. Xvoid    ttcolor ();
  1609. Xextern void tcapopen ();
  1610. Xextern void tcapmove ();
  1611. X#if     GOSLING
  1612. Xvoid    ttinsl ();
  1613. Xvoid    ttdell ();
  1614. X#endif
  1615. X
  1616. X#include    "lintfunc.dec"
  1617. X#ifdef MSDOS
  1618. X#include    "dos.h"
  1619. Xextern  bool    ibm_pc, mem_map;
  1620. X#endif
  1621. X#define BEL     0x07            /* BEL character.               */
  1622. X#define ESC     0x1B            /* ESC character.               */
  1623. X
  1624. Xextern int  ttrow;
  1625. Xextern int  ttcol;
  1626. Xextern int  tttop;
  1627. Xextern int  ttbot;
  1628. Xextern int  tthue;
  1629. X
  1630. Xint     tceeol = 3;             /* Costs.                       */
  1631. Xint     rowb = NROW;  
  1632. X
  1633. X/*
  1634. X* Initialize the terminal when the editor
  1635. X* gets started up.
  1636. X*/
  1637. Xvoid    ttinit ()
  1638. X{
  1639. X#ifdef MSDOS
  1640. X    ttraw ();
  1641. X#endif
  1642. X#ifdef UNIX 
  1643. X    tcapopen();
  1644. X#endif
  1645. X}
  1646. X
  1647. X/*
  1648. X* Clean up the terminal, in anticipation of
  1649. X* a return to the command interpreter.
  1650. X*/
  1651. Xvoid    tttidy ()
  1652. X{
  1653. X#ifdef MSDOS
  1654. X    ttcooked ();
  1655. X#endif
  1656. X}
  1657. X
  1658. X/*
  1659. X* Move the cursor to the specified
  1660. X* origin 0 row and column position. Try to
  1661. X* optimize out extra moves; redisplay may
  1662. X* have left the cursor in the right
  1663. X* location last time!
  1664. X*/
  1665. Xvoid    ttmove (row, col)
  1666. X{
  1667. X#ifdef MSDOS
  1668. X    union   REGS    regs;
  1669. X
  1670. X/* Move in both axes */
  1671. X    if (ibm_pc)
  1672. X        {
  1673. X        regs.h.ah = 2;
  1674. X        regs.h.dh = (char)row;
  1675. X        regs.h.dl = (char)col;
  1676. X        regs.h.bh = 0;
  1677. X        int86 (0x10, ®s, ®s); /* set cursor position */
  1678. X        }
  1679. X    else
  1680. X#endif
  1681. X#ifdef UNIX
  1682. X    tcapmove(row, col);
  1683. X#endif
  1684. X#if ANSI
  1685. X        {
  1686. X        ttputc (ESC);
  1687. X        ttputc ('[');
  1688. X        asciiparm (row + 1);
  1689. X        ttputc (';');
  1690. X        asciiparm (col + 1);
  1691. X        ttputc ('H');
  1692. X        }
  1693. X#endif
  1694. X    ttrow = row;
  1695. X    ttcol = col;
  1696. X}
  1697. X
  1698. X/*
  1699. X* Erase to end of line.
  1700. X*/
  1701. Xvoid    tteeol ()
  1702. X{
  1703. X    char    col, row, i;
  1704. X#ifdef MSDOS
  1705. X    union   REGS    regs;
  1706. X
  1707. X    if (ibm_pc)
  1708. X        {
  1709. X        regs.h.ah = 3;
  1710. X        regs.h.bh = 0;
  1711. X        int86 (0x10, ®s, ®s); /* get cursor position */
  1712. X        col = regs.h.dl;    
  1713. X        row = regs.h.dh;
  1714. X        for (i = col ; i < (NCOL - 1); i++)
  1715. X            {
  1716. X            regs.h.ah = 0x0e;
  1717. X            regs.h.bl = 0;
  1718. X            regs.h.bh = 0;
  1719. X            regs.h.al = ' ';
  1720. X            int86 (0x10, ®s, ®s); /* set cursor position */
  1721. X            }
  1722. X        /* put cursor back to original position */
  1723. X        regs.h.ah = 2;
  1724. X        regs.h.bh = 0;
  1725. X        regs.h.dl = col;    
  1726. X        regs.h.dh = row;
  1727. X        int86 (0x10, ®s, ®s); /* get cursor position */
  1728. X        }
  1729. X    else
  1730. X#endif
  1731. X#if ANSI
  1732. X        {
  1733. X        ttputc (ESC);
  1734. X        ttputc ('[');
  1735. X#ifdef MSDOS
  1736. X        if (ibm_pc)
  1737. X           ttputc ('0');    /* this is necessary in IBM PC's */
  1738. X#endif
  1739. X        ttputc ('K');
  1740. X        }
  1741. X#endif
  1742. X#ifdef UNIX
  1743. X    tcapeeol();
  1744. X#endif
  1745. X    }
  1746. X
  1747. X/*
  1748. X* Erase to end of page.
  1749. X* only ever used when cursor is at 0,0, so IBM screen erase
  1750. X* is same as eop
  1751. X*/
  1752. Xvoid    tteeop ()
  1753. X{
  1754. X#ifdef MSDOS
  1755. X    union   REGS    regs;
  1756. X    char    i, j;
  1757. X
  1758. X    if (ibm_pc)
  1759. X        {
  1760. X        for (j = 0 ; j < nrow; j++)
  1761. X            {
  1762. X            for (i = 0 ; i < NCOL; i++)
  1763. X                {
  1764. X                regs.h.ah = 0x0e;
  1765. X                regs.h.bl = 0;
  1766. X                regs.h.bh = 0;
  1767. X                regs.h.al = ' ';
  1768. X                int86 (0x10, ®s, ®s); /* set cursor position */
  1769. X                }
  1770. X            }
  1771. X        }
  1772. X    else
  1773. X#endif
  1774. X#if    ANSI
  1775. X        {
  1776. X        ttcolor (CTEXT);
  1777. X        ttputc (ESC);
  1778. X        ttputc ('[');
  1779. X#ifdef MSDOS
  1780. X        if (ibm_pc)
  1781. X            ttputc ('0');
  1782. X        else
  1783. X#endif
  1784. X            ttputc ('2');
  1785. X        ttputc ('J');
  1786. X        }
  1787. X#endif
  1788. X#ifdef UNIX
  1789. X    tcapeeop();
  1790. X#endif
  1791. X}
  1792. X
  1793. X/*
  1794. X* Make a noise.
  1795. X*/
  1796. Xvoid    ttbeep ()
  1797. X{
  1798. X    ttputc (BEL);
  1799. X    ttflush ();
  1800. X}
  1801. X
  1802. X/*
  1803. X* Convert a number to decimal
  1804. X* ascii, and write it out. Used to
  1805. X* deal with numeric arguments.
  1806. X*/
  1807. Xvoid    asciiparm (n)
  1808. Xregister int    n;
  1809. X{
  1810. X    register int    q;
  1811. X
  1812. X    q = n / 10;
  1813. X    if (q != 0)
  1814. X        asciiparm (q);
  1815. X    ttputc ((n % 10) + '0');
  1816. X}
  1817. X
  1818. X#if     GOSLING
  1819. X/*
  1820. X* Insert a block of blank lines onto the
  1821. X* screen, using a scrolling region that starts at row
  1822. X* "row" and extends down to row "bot".  Deal with the one
  1823. X* line case, which is a little bit special, with special
  1824. X* case code.
  1825. X*/
  1826. Xvoid    ttinsl (row, bot, nchunk)
  1827. X{
  1828. X    if (row == bot)
  1829. X        {
  1830. X    /* Funny case.          */
  1831. X        if (nchunk != 1)
  1832. X            abort ();
  1833. X        ttmove (row, 0);
  1834. X        tteeol ();
  1835. X        }
  1836. X    else
  1837. X        {
  1838. X    /* General case.        */
  1839. X        ttputc (ESC);
  1840. X        ttputc ('/');
  1841. X        asciiparm (row + 1);
  1842. X        ttputc (';');
  1843. X        asciiparm (bot + 1);
  1844. X        ttputc (';');
  1845. X        asciiparm (nchunk);
  1846. X        ttputc (';');
  1847. X        ttputc ('0');
  1848. X        ttputc ('S');
  1849. X        }
  1850. X}
  1851. X
  1852. X/*
  1853. X* Delete a block of lines, with the uppermost
  1854. X* line at row "row", in a screen slice that extends to
  1855. X* row "bot". The "nchunk" is the number of lines that have
  1856. X* to be deleted.  Watch for the pathalogical 1 line case,
  1857. X* where the scroll region is *not* the way to do it.
  1858. X* The block delete is used by the slightly more
  1859. X* optimal display code.
  1860. X*/
  1861. Xvoid    ttdell (row, bot, nchunk)
  1862. X{
  1863. X    if (row == bot)
  1864. X        {
  1865. X    /* Funny case.          */
  1866. X        if (nchunk != 1)
  1867. X            abort ();
  1868. X        ttmove (row, 0);
  1869. X        tteeol ();
  1870. X        }
  1871. X    else
  1872. X        {
  1873. X    /* General case.        */
  1874. X        ttputc (ESC);
  1875. X        ttputc ('/');
  1876. X        asciiparm (row + 1);
  1877. X        ttputc (';');
  1878. X        asciiparm (bot + 1);
  1879. X        ttputc (';');
  1880. X        asciiparm (nchunk);
  1881. X        ttputc (';');
  1882. X        ttputc ('1');
  1883. X        ttputc ('S');
  1884. X        }
  1885. X}
  1886. X#endif
  1887. X
  1888. X/*
  1889. X* Switch to full screen scroll. This is
  1890. X* used by "spawn.c" just before is suspends the
  1891. X* editor, and by "display.c" when it is getting ready
  1892. X* to exit.  This is a no-op.
  1893. X*/
  1894. Xvoid    ttnowindow (){}
  1895. X
  1896. X/*
  1897. X* Set the current writing color to the
  1898. X* specified color. Watch for color changes that are
  1899. X* not going to do anything (the color is already right)
  1900. X* and don't send anything to the display.
  1901. X*/
  1902. Xvoid    ttcolor (color)
  1903. Xregister int    color;
  1904. X{
  1905. X#ifdef MSDOS
  1906. X    if (mem_map)
  1907. X        {
  1908. X        tthue = color;          /* Save the color.      */
  1909. X        return;
  1910. X        }
  1911. X#endif
  1912. X#ifdef UNIX
  1913. X    if (color == CTEXT)
  1914. X        tcaprev (FALSE);
  1915. X    else    
  1916. X        tcaprev (TRUE);
  1917. X    tthue = color;          /* Save the color.      */
  1918. X#endif
  1919. X#if ANSI
  1920. X    if (color != tthue)
  1921. X        {
  1922. X        if (color == CTEXT)
  1923. X            {                   /* Normal video.        */
  1924. X            ttputc (ESC);
  1925. X            ttputc ('[');
  1926. X            ttputc ('0');
  1927. X            ttputc ('m');
  1928. X            }
  1929. X        else
  1930. X            if (color == CMODE)
  1931. X                {               /* Reverse video.       */
  1932. X                ttputc (ESC);
  1933. X                ttputc ('[');
  1934. X                ttputc ('7');
  1935. X                ttputc ('m');
  1936. X                }
  1937. X        tthue = color;          /* Save the color.      */
  1938. X        }
  1939. X#endif
  1940. X}
  1941. END_OF_FILE
  1942. if test 6972 -ne `wc -c <'tty.c'`; then
  1943.     echo shar: \"'tty.c'\" unpacked with wrong size!
  1944. fi
  1945. chmod +x 'tty.c'
  1946. # end of 'tty.c'
  1947. fi
  1948. if test -f 'ttyio.c' -a "${1}" != "-c" ; then 
  1949.   echo shar: Will not clobber existing file \"'ttyio.c'\"
  1950. else
  1951. echo shar: Extracting \"'ttyio.c'\" \(3623 characters\)
  1952. sed "s/^X//" >'ttyio.c' <<'END_OF_FILE'
  1953. X/*
  1954. X*
  1955. X*   MS-DOS terminal I/O.               TTYIO.C
  1956. X*/
  1957. X#if MSDOS
  1958. X#include        "def.h"
  1959. X
  1960. Xvoid    ttopen ();
  1961. Xvoid    ttclose (); /* stub */
  1962. Xvoid    ttputc ();
  1963. Xvoid    putline ();
  1964. Xvoid    ttflush (); /* stub */
  1965. Xint     ttkeyready ();
  1966. Xint     ttgetc ();
  1967. Xvoid    ttraw ();
  1968. Xvoid    ttcooked ();
  1969. Xint     set_crt_type ();
  1970. X#if RUNCHK  
  1971. Xchar    ERR_bd_pl[];
  1972. X#endif
  1973. X#include    "lintfunc.dec"
  1974. X#include    "dos.h"
  1975. X
  1976. Xint     slot;
  1977. Xint     scr_type;
  1978. X#define SCREEN_PORT (video_port)
  1979. Xstatic int  video_port =
  1980. X{0x1010
  1981. X};
  1982. X
  1983. Xextern  bool    wang_pc;
  1984. Xextern  bool    ibm_pc;
  1985. Xint     nrow;                   /* Terminal size, rows.         */
  1986. Xint     ncol;                   /* Terminal size, columns.      */
  1987. Xint     last_key;
  1988. X
  1989. X/*
  1990. X* Initialization.
  1991. X* Almost no operation in MS-DOS.
  1992. X*/
  1993. Xvoid ttopen ()
  1994. X{
  1995. X    if (wang_pc && !ibm_pc)
  1996. X        set_crt_type ();
  1997. X    nrow = NROW;
  1998. X    ncol = NCOL;
  1999. X}
  2000. X
  2001. Xvoid ttclose ()
  2002. X{
  2003. X}
  2004. Xvoid ttflush ()
  2005. X{
  2006. X}
  2007. X/*
  2008. X* Write character.
  2009. X*/
  2010. Xvoid ttputc (c)
  2011. X{
  2012. X    bdos (6, c, 0);
  2013. X}
  2014. X
  2015. Xvoid putline (row, startcol, stringsize, string)
  2016. Xint     row,
  2017. X        startcol,
  2018. X        stringsize;
  2019. Xchar   *string;
  2020. X{
  2021. X    extern int  tthue;
  2022. X    unsigned short *screen;
  2023. X    int     x,
  2024. X            attribute;
  2025. X    char    c_row, c_col, i;
  2026. X    union   REGS    regs;
  2027. X
  2028. X    if (ibm_pc)
  2029. X        {
  2030. X        c_row = row - 1;
  2031. X        c_col = startcol - 1;
  2032. X        for (i = 0; i < stringsize; i++)
  2033. X            {
  2034. X            regs.h.ah = 2;
  2035. X            regs.h.dh = c_row;
  2036. X            regs.h.dl= c_col;
  2037. X            regs.h.bh = 0;
  2038. X            int86 (0x10, ®s, ®s); /* set cursor position */
  2039. X        
  2040. X            if (tthue == CTEXT)
  2041. X                regs.h.bl = 0x07;
  2042. X            if (tthue == CMODE)
  2043. X                regs.h.bl = 0x70;
  2044. X            regs.h.ah = 9;
  2045. X            regs.h.bh = 0;
  2046. X            regs.h.al = string[i];
  2047. X            regs.x.cx= 1;
  2048. X            int86 (0x10, ®s, ®s); /* set cursor position */
  2049. X            c_col++;
  2050. X            }
  2051. X        }
  2052. X    else if (wang_pc)
  2053. X        {
  2054. X        if (tthue == CTEXT)
  2055. X            attribute = 0x00;
  2056. X        else
  2057. X            attribute = 0x02;
  2058. X
  2059. X        x = stringsize;
  2060. X        screen = (unsigned short *) WANG_CHARACTER_SCREEN;
  2061. X        screen += ((row - 1) * 80) + startcol - 1;
  2062. X        outp (SCREEN_PORT, 01);
  2063. X        while (x--)
  2064. X            {
  2065. X            *screen = (*string++ << 8) | attribute;
  2066. X            screen++;
  2067. X            }
  2068. X        outp (SCREEN_PORT, 00);
  2069. X        }
  2070. X}
  2071. X
  2072. X/* 
  2073. X*   return with a TRUE if key was struck.
  2074. X*/
  2075. Xint     ttkeyready ()
  2076. X{
  2077. X    int    cnt;
  2078. X
  2079. X    if (last_key != 0)
  2080. X        return (1);
  2081. X
  2082. X    last_key = bdos (6, 0xff, 0);
  2083. X    last_key &= 0xff;
  2084. X    if (last_key == 0)
  2085. X        return (0);
  2086. X    else
  2087. X        return (1);
  2088. X}
  2089. X
  2090. X/*
  2091. X* Read character.
  2092. X*/
  2093. Xint     ttgetc ()
  2094. X{
  2095. X    int     c;
  2096. X    if (last_key != 0)
  2097. X        {
  2098. X        c = last_key;
  2099. X        last_key = 0;
  2100. X        return (c);
  2101. X        }
  2102. X    ttcooked ();
  2103. X    c = (bdos (7, 0, 0) & 0xFF);
  2104. X    ttraw ();
  2105. X    return (c);
  2106. X}
  2107. X
  2108. X/* disable nasty cntrl-c during disk io!
  2109. X*/
  2110. Xvoid ttraw ()
  2111. X{
  2112. X    union REGS inregs, outregs;
  2113. X
  2114. X    inregs.h.al = 1;
  2115. X    inregs.h.ah = 0x33;
  2116. X    inregs.h.dl = 0;
  2117. X    intdos (&inregs, &outregs);
  2118. X/*
  2119. X    cntrlcoff();
  2120. X*/
  2121. X}
  2122. X
  2123. X/* re enable cntrl-c for keyboard 
  2124. X*/
  2125. Xvoid ttcooked ()
  2126. X{
  2127. X    union REGS inregs, outregs;
  2128. X
  2129. X    inregs.h.al = 1;
  2130. X    inregs.h.ah = 0x33;
  2131. X    intdos (&inregs, &outregs);
  2132. X    inregs.h.dl = 1;
  2133. X/*
  2134. X    cntrlcon();
  2135. X*/
  2136. X}
  2137. X
  2138. X/* switch physical monitors
  2139. X*/
  2140. Xstatic char str[] =
  2141. X{0x1b, '/', 1, 's'
  2142. X};
  2143. X
  2144. Xint     set_crt_type ()
  2145. X{
  2146. X    char    active_screen;
  2147. X
  2148. X    active_screen = getscreenstate ();
  2149. X    slot = active_screen & 0x0f;
  2150. X    scr_type = (active_screen & 0x70) >> 4;
  2151. X    video_port = 0x1010 | (slot << 8);
  2152. X}
  2153. X#endif
  2154. END_OF_FILE
  2155. if test 3623 -ne `wc -c <'ttyio.c'`; then
  2156.     echo shar: \"'ttyio.c'\" unpacked with wrong size!
  2157. fi
  2158. chmod +x 'ttyio.c'
  2159. # end of 'ttyio.c'
  2160. fi
  2161. if test -f 'wangpc.c' -a "${1}" != "-c" ; then 
  2162.   echo shar: Will not clobber existing file \"'wangpc.c'\"
  2163. else
  2164. echo shar: Extracting \"'wangpc.c'\" \(3557 characters\)
  2165. sed "s/^X//" >'wangpc.c' <<'END_OF_FILE'
  2166. X#define LINT_ARGS   1           /* enable lint type checking */
  2167. X#include "def.h"
  2168. X#include    "lintfunc.dec"
  2169. X#if MSDOS
  2170. X#include "dos.h"
  2171. X
  2172. Xtypedef struct SCREENINFO
  2173. X{
  2174. X    unsigned char   state;
  2175. X    unsigned char   scanoff;
  2176. X    unsigned short  bufseg;
  2177. X    unsigned char   colors;
  2178. X    unsigned char   row;
  2179. X    unsigned char   col;
  2180. X    unsigned char   attr;
  2181. X    unsigned char   auxmod;
  2182. X    unsigned char   auxmod2;
  2183. X} SCREENINFO;
  2184. X
  2185. Xtypedef struct SYSCONFIG
  2186. X{
  2187. X    unsigned short  version;
  2188. X    unsigned short  memsize;
  2189. X    unsigned short  reserved[2];
  2190. X    unsigned short  screen_count;
  2191. X    unsigned short  screens[4];
  2192. X} SYSCONFIG;
  2193. X
  2194. X#define SENDCHAR 6
  2195. X#define SENDLINE 0x0d
  2196. X#define BIOS 0x88
  2197. X#define GETSYSCON 1
  2198. X
  2199. Xbool    wang_pc = FALSE;
  2200. Xbool    ibm_pc = FALSE;
  2201. Xbool    mem_map = FALSE;
  2202. X
  2203. Xvoid    is_wang ()
  2204. X    {
  2205. X    union REGS inregs, outregs;
  2206. X    struct SREGS    segregs;
  2207. X    unsigned char far *memptr;
  2208. X    unsigned char    c;
  2209. X    int     i;
  2210. X    static  char wang_id[] = {"WANG"};
  2211. X    static  char ret_str[6];
  2212. X    char    *chr_ptr;
  2213. X
  2214. X    chr_ptr = ret_str;
  2215. X    /* test for Wang PC */
  2216. X    memptr = (unsigned char far *)0xFC003FC2L;
  2217. X    wang_pc = TRUE;
  2218. X    for (i=0;(i<4 && wang_pc);i++)
  2219. X        {
  2220. X        if(*memptr != wang_id[i])
  2221. X            wang_pc = FALSE;
  2222. X        memptr++;
  2223. X        }
  2224. X
  2225. X    if (wang_pc)
  2226. X        {
  2227. X        mem_map = TRUE;
  2228. X        ret_str[0] = 0xFF;      /* set to known value */
  2229. X        mem_map = TRUE;
  2230. X        inregs.h.al = 0x02;
  2231. X        inregs.h.ah = 0x44;
  2232. X        inregs.x.bx = 0;
  2233. X        inregs.x.cx = 1;
  2234. X        inregs.x.dx = FP_OFF (chr_ptr);
  2235. X        segregs.ds = FP_SEG (chr_ptr);
  2236. X    
  2237. X        int86x (0x21, &inregs, &outregs, &segregs);
  2238. X        if (ret_str[0] == 0x11)
  2239. X            {
  2240. X            ibm_pc = TRUE;
  2241. X            return;
  2242. X            }
  2243. X        ibm_pc = FALSE;
  2244. X        return;
  2245. X        }
  2246. X
  2247. X    /* Must be an IBM or clone */
  2248. X    memptr = (unsigned char far *)0xF000FFFEL;
  2249. X    c = *memptr;
  2250. X    switch(c)
  2251. X        {
  2252. X        case 0xFC:  /* IBM AT or clone */
  2253. X        case 0xFD:  /* IBM PC Jr */
  2254. X        case 0xFE:  /* IBM XT or clone */
  2255. X        case 0xFF:  /* IBM PC or clone */
  2256. X            mem_map = TRUE;
  2257. X            ibm_pc = TRUE;
  2258. X            return;
  2259. X        }
  2260. X    }
  2261. X
  2262. Xint     getsysconfig (outregs, segregs)
  2263. X        union REGS * outregs;
  2264. Xstruct SREGS   *segregs;
  2265. X{
  2266. X    union REGS inregs;
  2267. X
  2268. X    inregs.h.al = GETSYSCON;
  2269. X
  2270. X    int86x (BIOS, &inregs, outregs, segregs);
  2271. X}
  2272. X
  2273. Xchar    getscreenstate ()
  2274. X{
  2275. X    struct SREGS    segregs;
  2276. X    union REGS outregs;
  2277. X
  2278. X    struct SYSCONFIG   *config;
  2279. X    struct SCREENINFO  *screeninfo;
  2280. X    unsigned short *shortptr;
  2281. X    unsigned int    screen_count;
  2282. X
  2283. X    getsysconfig (&outregs, &segregs);
  2284. X
  2285. X /* set pointer to force register info into a long pointer. */
  2286. X    shortptr = (unsigned short *) & config;
  2287. X
  2288. X /* Offset is first, it comes back in BX */
  2289. X    *shortptr = (unsigned short) outregs.x.bx;
  2290. X    shortptr++;
  2291. X
  2292. X /* segment is in ES */
  2293. X    *shortptr = (unsigned short) segregs.es;
  2294. X
  2295. X /* Now, the config pointer should be set to the config table. */
  2296. X/*  printf("Version = %04x \n",config->version);
  2297. X    printf("Memsize = %04x \n",config->memsize);
  2298. X    printf("Screens = %04x \n",config->screen_count);
  2299. X*/
  2300. X    screen_count = config -> screen_count;
  2301. X    while (screen_count)
  2302. X        {
  2303. X        shortptr = (unsigned short *) & screeninfo;
  2304. X        *shortptr = (unsigned short) config -> screens[screen_count - 1];
  2305. X        shortptr++;
  2306. X        *shortptr = (unsigned short) segregs.es;
  2307. X        if (screeninfo -> state & 0x80)
  2308. X            break;
  2309. X        screen_count--;
  2310. X        }
  2311. X    return (screeninfo -> state);
  2312. X}
  2313. X#endif
  2314. END_OF_FILE
  2315. if test 3557 -ne `wc -c <'wangpc.c'`; then
  2316.     echo shar: \"'wangpc.c'\" unpacked with wrong size!
  2317. fi
  2318. chmod +x 'wangpc.c'
  2319. # end of 'wangpc.c'
  2320. fi
  2321. if test -f 'word.c' -a "${1}" != "-c" ; then 
  2322.   echo shar: Will not clobber existing file \"'word.c'\"
  2323. else
  2324. echo shar: Extracting \"'word.c'\" \(3025 characters\)
  2325. sed "s/^X//" >'word.c' <<'END_OF_FILE'
  2326. X/*
  2327. X*       Word mode commands.
  2328. X* The routines in this file
  2329. X* implement commands that work unit at
  2330. X* a time. There are all sorts of unit mode
  2331. X* commands. If I do any sentence and/or paragraph
  2332. X* mode commands, they are likely to be put in
  2333. X* this file.
  2334. X*/
  2335. X#define LINT_ARGS   1           /* enable lint type checking */
  2336. X#include    "def.h"
  2337. X
  2338. Xchar    forwunit ();
  2339. X
  2340. X#include    "lintfunc.dec"
  2341. X/*
  2342. X* Move the cursor backward by
  2343. X* "n" units. All of the details of motion
  2344. X* are performed by the "backchar" and "forwchar"
  2345. X* routines. Error if you try to move beyond
  2346. X* the buffers.
  2347. X*/
  2348. Xchar    backunit (f, n, k)
  2349. X{
  2350. X    char    ret;
  2351. X
  2352. X    if (n < 0)
  2353. X        return (forwunit (f, -n, KRANDOM));
  2354. X
  2355. X    curwp -> w_unit_offset = 0;
  2356. X    while (n--)
  2357. X        {
  2358. X        ret = move_ptr (curwp, -(long)R_B_PER_U(curwp), TRUE, TRUE, TRUE);
  2359. X        }
  2360. X    wind_on_dot (curwp);
  2361. X    curwp -> w_flag |= WFMODE;  /* update mode line */
  2362. X    return (ret);
  2363. X}
  2364. X
  2365. X
  2366. X/*
  2367. X* Move the cursor forward by
  2368. X* the specified number of units. All of the
  2369. X* motion is done by "forwchar". Error if you
  2370. X* try and move beyond the buffer's end.
  2371. X*/
  2372. Xchar    forwunit (f, n, k)
  2373. X{
  2374. X
  2375. X    if      (n < 0)
  2376. X                return (backunit (f, -n, KRANDOM));
  2377. X
  2378. X    curwp -> w_unit_offset = 0;
  2379. X    while (n--)
  2380. X        {
  2381. X        move_ptr (curwp, (long)R_B_PER_U(curwp), TRUE, TRUE, TRUE);
  2382. X        }
  2383. X    wind_on_dot (curwp);
  2384. X    curwp -> w_flag |= WFMODE;  /* update mode line */
  2385. X    return (TRUE);
  2386. X}
  2387. X
  2388. X
  2389. X/*
  2390. X* Kill forward by "n" units. The rules for final
  2391. X* status are now different. It is not considered an error
  2392. X* to delete fewer units than you asked. This lets you say
  2393. X* "kill lots of units" and have the command stop in a reasonable
  2394. X* way when it hits the end of the buffer.
  2395. X*/
  2396. Xbool delfunit (f, n, k)
  2397. X{
  2398. X    register    LINE * dotp;
  2399. X    register int    doto;
  2400. X
  2401. X    if (n < 0)
  2402. X        return (FALSE);
  2403. X    if ((lastflag & CFKILL) == 0)/* Purge kill buffer.   */
  2404. X        kdelete ();
  2405. X    thisflag |= CFKILL;
  2406. X    while (n--)
  2407. X        {
  2408. X        ldelete (R_B_PER_U(curwp), TRUE);
  2409. X        }
  2410. X    curwp -> w_flag |= WFHARD;
  2411. X    curwp -> w_unit_offset = 0;
  2412. X    return (TRUE);
  2413. X}
  2414. X
  2415. X
  2416. X/*
  2417. X* Kill backwards by "n" units. The rules
  2418. X* for success and failure are now different, to prevent
  2419. X* strange behavior at the start of the buffer. The command
  2420. X* only fails if something goes wrong with the actual delete
  2421. X* of the characters. It is successful even if no characters
  2422. X* are deleted, or if you say delete 5 units, and there are
  2423. X* only 4 units left. I considered making the first call
  2424. X* to "backchar" special, but decided that that would just
  2425. X* be wierd. Normally this is bound to "M-Rubout" and
  2426. X* to "M-Backspace".
  2427. X*/
  2428. Xbool delbunit (f, n, k)
  2429. X{
  2430. X    int size;
  2431. X
  2432. X    if (n < 0)
  2433. X        return (FALSE);
  2434. X    if ((lastflag & CFKILL) == 0)/* Purge kill buffer.   */
  2435. X        kdelete ();
  2436. X    thisflag |= CFKILL;
  2437. X    size = R_B_PER_U(curwp);
  2438. X    while (n--)
  2439. X        {
  2440. X        if (move_ptr (curwp, -((long)size), TRUE, TRUE, TRUE))
  2441. X            ldelete (size, TRUE);
  2442. X        }
  2443. X    curwp -> w_flag |= WFHARD;
  2444. X    return (TRUE);
  2445. X}
  2446. X
  2447. END_OF_FILE
  2448. if test 3025 -ne `wc -c <'word.c'`; then
  2449.     echo shar: \"'word.c'\" unpacked with wrong size!
  2450. fi
  2451. chmod +x 'word.c'
  2452. # end of 'word.c'
  2453. fi
  2454. echo shar: End of archive 1 \(of 10\).
  2455. cp /dev/null ark1isdone
  2456. MISSING=""
  2457. for I in 1 2 3 4 5 6 7 8 9 10 ; do
  2458.     if test ! -f ark${I}isdone ; then
  2459.     MISSING="${MISSING} ${I}"
  2460.     fi
  2461. done
  2462. if test "${MISSING}" = "" ; then
  2463.     echo You have unpacked all 10 archives.
  2464.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  2465. else
  2466.     echo You still need to unpack the following archives:
  2467.     echo "        " ${MISSING}
  2468. fi
  2469. ##  End of shell archive.
  2470. exit 0
  2471.  
  2472. -- 
  2473. >>>>>>>>>>>>>>>> Peter Reilley ..... pvr@wang.com <<<<<<<<<<<<<<<<<<<<<<<
  2474.                      Well, that about says it.
  2475.