From: wolff@inf.fu-berlin.de (Thomas Wolff)
Subject: Re: Editor mined (4/4)
Organization: Free University of Berlin, Germany
Date: Wed, 29 Jul 1992 18:03:33 GMT

#! /bin/sh
: This is a sharchive -- extract the files by running through sh

echo ---------------------- extracting posting-errors -----------------
sed 's/^,//' << \EOSED > posting-errors
,
,Posting the editor mined lead to some errors which I correct hereby.
,
,The last line of the file mined.prj was left out due to a missing line-end.
,In the files minedio.c and minedmp.c, I had several Escape characters 
,included literally in control strings. Obviously, they got killed somewhere 
,in the News system. I have replaced them with the \033 notation now.
,
,The mismatches in the files mined.prj and minedio.c only affect the MSDOS 
,version. Those in minedmp.c disable function key detection.
,
,This posting can be taken as a complete replacement of the previous (4/4) 
,part. It includes all 3 corrupted files.
,
,Sorry for the inconvenience. Moreover, there may also be undesirable 
,results for people who get the postings with bit 8 stripped off since 
,some characters with that bit set are also included literally.
,I list the mismatches here:
,File mined1.c:
,	char SHIFT_MARK = '';
,			   ^	This is the double right-angle '>>'
,	if (Mark != NIL_PTR) TABchar = (Mark [0] == '\0' ? '' : Mark [0]);
,			That is the bullet or dotcentered   ^
,File mined2.c:
,	((u_char) '\300' <= ch && ch != (u_char) '' && ch != (u_char) '') ||
,	(ch == (u_char) '')
,			 ^			  ^			^
,	   These are the multiplication and division sign and the Greek mu
,	Some more >> and << characters are in the comment to search ()
,File minedio.c:
,		SHIFT_MARK = '';	<- double right-angle '>>'
,	  else	SHIFT_MARK = '>';
,File minedmp.c:
,	The 8-bit characters in the generation tables for mined's 
,	diacritic prefix keys functions. I cannot list them all here.
,	If there is interest, I can send or post a uuencoded version.
,
,8 bit characters are also used in mined.help where referring to themselves, 
,and of course in the German mined.hilf.
,
,I typed the characters in literally since this appeared more natural to me 
,and also more logical in case the whole files would be translated into an 
,other character set. Octal notations would not be translated then and thus 
,incorrectly remain in the original character set.
,
,Thomas Wolff
,Freie Universit:at Berlin
,wolff@inf.fu-berlin.de
,
EOSED

echo ---------------------- extracting minedio.c -----------------
sed 's/^,//' << \EOSED > minedio.c
,/*  ==================================================================	*
, *				Editor mined				*
, *			Operating system dependant I/O			*
, *  ==================================================================	*/
,
,#include "mined.h"
,#include <errno.h>
,#include <signal.h>
,
,#ifdef CURSES
,#include <curses.h>
,#undef FALSE
,#undef TRUE
,#undef TERMIO	/* \ must be  */
,#undef SGTTY	/* / disabled */
,#endif
,
,#ifdef TERMIO
,#include <termios.h>
,#endif
,#ifdef SGTTY
,#include <sys/ioctl.h>	/* <sgtty.h> ? */
,#endif
,
,#ifdef msdos
,#include <conio.h>
,#undef SIGINT	/* signal (SIGINT, catchint) not understood */
,#define _getch_
,#endif
,
,#ifdef unix
,#include <sys/time.h>	/* for struct timeval (for select in inputreadyafter) */
,#define selectread	/* use select () ? */
,#endif
,
,#ifdef vms
,#undef u_char
,#include <socket.h>	/* for select () and struct timeval */
,#ifdef CURSES
,#define _getch_
,#endif
,#endif
,
,/*  ==================================================================	*
, *			Unix signalling routines			*
, *  ==================================================================	*/
,
,catch_signals (catch)
,  void (* catch) ();
,{
,#ifdef SIGHUP
,  signal (SIGHUP, catch);
,#endif
,#ifdef SIGILL
,  signal (SIGILL, catch);
,#endif
,#ifdef SIGTRAP
,  signal (SIGTRAP, catch);
,#endif
,#ifdef SIGABRT
,  signal (SIGABRT, catch);
,#endif
,#ifdef SIGEMT
,  signal (SIGEMT, catch);
,#endif
,#ifdef SIGFPE
,  signal (SIGFPE, catch);
,#endif
,#ifdef SIGBUS
,  signal (SIGBUS, catch);
,#endif
,#ifdef SIGSEGV
,  signal (SIGSEGV, catch);
,#endif
,#ifdef SIGSYS
,  signal (SIGSYS, catch);
,#endif
,#ifdef SIGPIPE
,  signal (SIGPIPE, catch);
,#endif
,#ifdef SIGALRM
,  signal (SIGALRM, catch);
,#endif
,#ifdef SIGTERM
,  signal (SIGTERM, catch);
,#endif
,#ifdef SIGXCPU
,  signal (SIGXCPU, catch);
,#endif
,#ifdef SIGXFSZ
,  signal (SIGXFSZ, catch);
,#endif
,#ifdef SIGVTALRM
,  signal (SIGVTALRM, catch);
,#endif
,#ifdef SIGPROF
,  signal (SIGPROF, catch);
,#endif
,#ifdef SIGLOST
,  signal (SIGLOST, catch);
,#endif
,#ifdef SIGUSR1
,  signal (SIGUSR1, catch);
,#endif
,#ifdef SIGUSR2
,  signal (SIGUSR2, catch);
,#endif
,}
,
,#ifdef SIGTSTP
,suspendmyself ()
,{
,  kill (getpid (), SIGTSTP);
,}
,FLAG cansuspendmyself = TRUE;
,#else
,suspendmyself () {}
,FLAG cansuspendmyself = FALSE;
,#endif
,
,#ifdef SIGWINCH
,/*
, * Catch the SIGWINCH signal sent to mined.
, */
,catchwinch ()
,{
,  winchg = TRUE;
,/*  if (waitingforinput == TRUE) RDwin ();	now done in __readchar () */
,  signal (SIGWINCH, catchwinch); /* Re-installation of the signal */
,}
,#endif
,
,#ifdef SIGQUIT
,/*
, * Catch the SIGQUIT signal (^\) sent to mined. It turns on the quitflag.
, */
,catchquit ()
,{
,#ifdef UNUSED /* Should not be needed with new __readchar () */
,/* Was previously needed on SUN but showed bad effects on Iris. */
,  static char quitchar = '\0';
,  if (waitingforinput == TRUE)
,	/* simulate input to enable immediate break also during input */
,	ioctl (input_fd, TIOCSTI, & quitchar);
,#endif
,  quit = TRUE;
,  signal (SIGQUIT, catchquit); /* Re-installation of the signal */
,}
,#endif
,
,#ifdef SIGINT
,/*
, * Catch the SIGINT signal (^C) sent if it cannot be ignored by tty driver
, */
,catchint ()
,{
,  intr = TRUE;
,  signal (SIGINT, catchint); /* Re-installation of the signal */
,}
,#endif
,
,/*  ==================================================================	*
, *			Terminal mode switcher				*
, *  ==================================================================	*/
,
,/*
, * Set and reset tty into CBREAK or old mode according to argument `state'.
, * It also sets all signal characters (except for ^\) to UNDEF. ^\ is caught.
, */
,raw_mode (state)
,  FLAG state;
,{
,#ifdef TERMIO
,  static struct termios old_termio;
,	 struct termios new_termio;
,#define gettermio(fd, iopoi)	tcgetattr (fd, iopoi);
,#define settermio(fd, iopoi)	tcsetattr (fd, TCSADRAIN, iopoi); /**/
,/* #define gettermio(fd, iopoi)	ioctl (fd, TCGETS, iopoi);
,   #define settermio(fd, iopoi)	ioctl (fd, TCSETSW, iopoi); /**/
,#endif
,#ifdef SGTTY
,  static struct sgttyb old_tty;
,	 struct sgttyb new_tty;
,  static int oldlmode;
,	 int lmode;
,  static struct tchars old_tchars;
,  static struct ltchars old_ltchars;
,#define NDEF '\377'
,  static struct tchars new_tchars = {NDEF, QUITCHAR, NDEF, NDEF, NDEF, NDEF};
,  static struct ltchars new_ltchars = {NDEF, NDEF, NDEF, NDEF, NDEF, NDEF};
,/* correspondence between the tchars/ltchars characters of the sgtty 
,   interface and the c_cc characters of the termios interface (codes vary):
,	sgtty		termio		sgtty		termio
,	t_intrc		VINTR		t_suspc		VSUSP
,	t_quitc		VQUIT		t_dsuspc	VDSUSP
,	t_startc	VSTART		t_rprntc	VREPRINT
,	t_stopc		VSTOP		t_flushc	VDISCARD
,	t_eofc		VEOF (VMIN)	t_werasc	VWERASE
,	t_brkc		VEOL (VTIME)	t_lnextc	VLNEXT
,*/
,#endif
,
,  if (state == OFF) {
,	isscreenmode = FALSE;
,#ifdef CURSES
,	endwin ();
,#ifdef vms
,	system ("set terminal /ttsync /nopasthru");
,#endif
,#else
,	end_screen_mode ();
,	flush ();
,#endif
,#ifdef TERMIO
,	settermio (input_fd, & old_termio);
,#endif
,#ifdef SGTTY
,	ioctl (input_fd, TIOCSETP, & old_tty);
,	ioctl (input_fd, TIOCSETC, & old_tchars);
,	ioctl (input_fd, TIOCSLTC, & old_ltchars);
,	ioctl (input_fd, TIOCLSET, & oldlmode);
,#endif
,	return;
,  }
,
,  else /* (state == ON) */ {
,	isscreenmode = TRUE;
,#ifdef CURSES
,	refresh ();
,#else
,	start_screen_mode ();
,	flush ();
,#endif
,#ifdef TERMIO
,	gettermio (input_fd, & old_termio);
,	gettermio (input_fd, & new_termio);
,
,	new_termio.c_iflag &= ~(ISTRIP|IXON|IXOFF);
,	new_termio.c_oflag &= ~OPOST;
,	new_termio.c_cflag &= ~(PARENB|CSIZE);
,	new_termio.c_cflag |= CS8;
,	new_termio.c_lflag &= ~(ICANON|ECHO);
,#define NDEF '\000'
,	new_termio.c_cc [VMIN] = 1;
,	new_termio.c_cc [VTIME] = 0;
,	new_termio.c_cc [VQUIT] = QUITCHAR;
,	new_termio.c_cc [VINTR] = NDEF;
,	new_termio.c_cc [VSUSP] = NDEF;
,#ifdef VDISCARD
,	new_termio.c_cc [VDISCARD] = NDEF;
,#endif
,	settermio (input_fd, & new_termio);
,#endif
,#ifdef SGTTY
,/* Save old tty settings */
,	ioctl (input_fd, TIOCGETP, & old_tty);
,	ioctl (input_fd, TIOCGETC, & old_tchars);
,	ioctl (input_fd, TIOCGLTC, & old_ltchars);
,	ioctl (input_fd, TIOCLGET, & oldlmode);
,/* Set line mode */
,/* If this feature should not be available on some system, RAW must be used
,   instead of CBREAK below to enable 8 bit characters on output */
,	lmode = oldlmode;
,	lmode |= LPASS8; /* enable 8 bit characters on input in CBREAK mode */
,	lmode |= LLITOUT; /* enable 8 bit characters on output in CBREAK mode;
,	    this may not be necessary in newer Unixes, e.g. SUN-OS 4;
,	    output handling is slightly complicated by LITOUT */
,	ioctl (input_fd, TIOCLSET, & lmode);
,/* Set tty to CBREAK (or RAW) mode */
,	new_tty = old_tty;
,	new_tty.sg_flags &= ~ECHO;
,	new_tty.sg_flags |= CBREAK;
,	ioctl (input_fd, TIOCSETP, & new_tty);
,/* Unset signal chars */
,	ioctl (input_fd, TIOCSETC, & new_tchars);  /* Only leaves QUITCHAR */
,	ioctl (input_fd, TIOCSLTC, & new_ltchars); /* Leaves nothing */
,#endif
,
,/* Define signal handlers */
,#ifdef SIGQUIT
,	signal (SIGQUIT, catchquit);	/* Catch QUITCHAR (^\) */
,#endif
,#ifdef SIGINT
,	signal (SIGINT, catchint);	/* Catch INTR char (^C) */
,#endif
,#ifdef SIGWINCH
,	signal (SIGWINCH, catchwinch);	/* Catch window size changes */
,#endif
,  }
,}
,
,/*  ==================================================================	*
, *			Unix I/O routines				*
, *  ==================================================================	*/
,
,#ifdef CURSES
,
,__putchar (c)
,  register u_char c;
,{ addch (c); }
,
,putstring (str)
,  register u_char * str;
,{ addstr (str); }
,
,flush ()
,{ refresh (); }
,
,FLAG can_add_line = TRUE, can_delete_line = TRUE, can_clear_eol = TRUE;
,
,clear_screen ()
,{
,  clear ();
,}
,clear_eol ()
,{
,  clrtoeol ();
,}
,scroll_forward ()
,{
,  scroll (stdscr);
,}
,scroll_reverse ()
,{ /* only called if cursor is at top of screen */
,  insertln ();
,}
,add_line (y)
,  register int y;
,{
,  move (y, 0);
,  insertln ();
,}
,delete_line (y)
,  register int y;
,{
,  move (y, 0);
,  deleteln ();
,}
,move_cursor (x, y)
,  register int x, y;
,{
,  move (y, x);
,}
,reverse_on ()
,{
,  standout ();
,}
,reverse_off ()
,{
,  standend ();
,}
,
,get_term_cap (TERMname)
,  char * TERMname;
,{
,#ifdef vms
,  system ("set terminal /pasthru /nottsync");
,#endif
,  initscr ();
,#ifdef vms
,  crmode ();
,#else
,  crmode (); /* cbreak (); */
,  nonl ();
,#endif
,  noecho ();
,  scrollok (stdscr, TRUE);
,#ifdef unix
,#ifndef vax
,  idlok (stdscr, TRUE);
,#ifndef sun
,  typeahead (input_fd);
,#endif
,#endif
,#endif
,
,  YMAX = LINES - 1;	/* # of lines */
,  XMAX = COLS - 1;	/* # of columns */
,  getwinsize ();
,}
,
,/*------------------------------------------------------------------------*/
,#else	/* not CURSES */
,
,__putchar (c)
,  register u_char c;
,{ writechar (output_fd, (c)); }
,
,putstring (str)
,  register u_char * str;
,{ writestring (output_fd, (str)); }
,
,flush ()
,{ flush_buffer (output_fd); }
,
,#ifdef unix
,
,/* Storage for the terminal control sequences */
,char *cCL, *cCE, *cSR, *cAL, *cDL, *cCS, *cSC, *cRC,
,     *cCM, *cSO, *cSE, *cVS, *cVE, *cTI, *cTE;
,#define aff1 0
,#define affmax YMAX
,
,FLAG can_add_line = FALSE, can_delete_line = FALSE, can_clear_eol = FALSE;
,
,clear_screen ()
,{
,  tputs (cCL, affmax, __putchar);
,}
,clear_eol ()
,{
,  if (cCE) tputs (cCE, aff1, __putchar);
,  else putstring (blank_line);
,}
,scroll_forward ()
,{
,  move_cursor (0, YMAX);
,/*  putchar ('\n');	*/
,  tputs ("\n", affmax, __putchar);
,}
,scroll_reverse ()
,{
,  tputs (cSR, affmax, __putchar);
,}
,add_line (y)
,  register int y;
,{
,  if (cAL) {
,	move_cursor (0, y);
,	tputs (cAL, affmax, __putchar);
,  }
,  else {
,	move_cursor (0, y);
,	tputs (cSC, aff1, __putchar);
,	tputs (tgoto (cCS, YMAX, y), aff1, __putchar);
,	tputs (cRC, aff1, __putchar);
,	tputs (cSR, affmax, __putchar);
,	tputs (tgoto (cCS, YMAX, 0), aff1, __putchar);
,	tputs (cRC, aff1, __putchar);
,  }
,}
,delete_line (y)
,  register int y;
,{
,  if (cDL) {
,	move_cursor (0, y);
,	tputs (cDL, affmax, __putchar);
,  }
,  else {
,	move_cursor (0, y);
,	tputs (cSC, aff1, __putchar);
,	tputs (tgoto (cCS, YMAX, y), aff1, __putchar);
,	move_cursor (0, YMAX);
,/*	putchar ('\n');	*/
,	tputs ("\n", affmax, __putchar);
,	tputs (tgoto (cCS, YMAX, 0), aff1, __putchar);
,	tputs (cRC, aff1, __putchar);
,  }
,}
,move_cursor (x, y)
,  register int x, y;
,{
,  tputs (tgoto (cCM, x, y), aff1, __putchar);
,}
,reverse_on ()
,{
,  tputs (cSO, aff1, __putchar);
,}
,reverse_off ()
,{
,  tputs (cSE, aff1, __putchar);
,}
,start_screen_mode ()
,{
,  tputs (cTI, affmax, __putchar);
,  tputs (cVS, affmax, __putchar);
,/* Install correct scrolling region in case terminal is bigger than assumed */
,/* (this effect was observed after window size changes of Sun windows): */
,  if (cCS) tputs (tgoto (cCS, YMAX, 0), aff1, __putchar);
,}
,end_screen_mode ()
,{
,  tputs (cTE, affmax, __putchar);
,  tputs (cVE, affmax, __putchar);
,}
,
,get_term_cap (TERMname)
,  char * TERMname;
,{
,#define termbuflen 100
,  char entry [1024];
,  static char termbuf [termbuflen];
,  char * loc = termbuf;
,  extern char * tgetstr ();
,
,  if (tgetent (entry, TERMname) <= 0) {
,	panic ("Unknown terminal", NIL_PTR);
,  }
,
,  YMAX = tgetnum ("li", & loc) - 1;	/* # of lines */
,  XMAX = tgetnum ("co", & loc) - 1;	/* # of columns */
,/* getenv ("LINES"), getenv ("COLUMNS") ?! */
,  getwinsize ();
,
,  cCL = tgetstr ("cl", & loc);	/* clear screen */
,  cCE = tgetstr ("ce", & loc);	/* clear to end of line */
,  cSR = tgetstr ("sr", & loc);	/* scroll reverse */
,  cAL = tgetstr ("al", & loc);	/* add line */
,  if (!cSR) cSR = cAL;
,  cDL = tgetstr ("dl", & loc);	/* delete line */
,  cCS = tgetstr ("cs", & loc);	/* change scrolling region */
,  cSC = tgetstr ("sc", & loc);	/* save cursor    \ needed with vt100   */
,  cRC = tgetstr ("rc", & loc);	/* restore cursor / for add/delete line */
,  cCM = tgetstr ("cm", & loc);	/* cursor motion */
,  cSO = tgetstr ("so", & loc);	/* stand out mode */
,  cSE = tgetstr ("se", & loc);	/* end " */
,  cVS = tgetstr ("vs", & loc);	/* visual mode */
,  cVE = tgetstr ("ve", & loc);	/* end " */
,  cTI = tgetstr ("ti", & loc);	/* positioning mode */
,  cTE = tgetstr ("te", & loc);	/* end " */
,
,  if (cAL || (cSR && cCS)) can_add_line = TRUE;
,  if (cDL || cCS) can_delete_line = TRUE;
,  if (cCE) can_clear_eol = TRUE;
,
,  if (loc > termbuf + termbuflen) {
,	panic ("Terminal control strings don't fit", NIL_PTR);
,  }
,  if (!cCL || !cCM || !cSR || !cCE /* || !cSO || !cSE */ ) {
,	panic ("Sorry, no mined on this type of terminal", NIL_PTR);
,  }
,}
,
,/*------------------------------------------------------------------------*/
,#endif unix
,
,#ifdef msdos
,#ifdef conio
,#include <conio.h>
,
,FLAG can_add_line = TRUE, can_delete_line = TRUE, can_clear_eol = TRUE;
,
,clear_screen ()
,{ clrscr (); }
,clear_eol ()
,{ clreol (); }
,scroll_forward ()
,{
,  move_cursor (0, YMAX);
,  putchar ('\n');
,}
,scroll_reverse ()
,{ /* only called if cursor is at top of screen */
,  insline ();
,}
,add_line (y)
,  register int y;
,{
,  move_cursor (0, y);
,  insline ();
,}
,delete_line (y)
,  register int y;
,{
,  move_cursor (0, y);
,  delline ();
,}
,move_cursor (x, y)
,{
,  gotoxy (x + 1, y + 1);
,}
,reverse_on ()
,{ highvideo ();
,}
,reverse_off ()
,{ normvideo ();
,}
,start_screen_mode ()
,{}
,end_screen_mode ()
,{}
,
,get_term ()
,{
,  getwinsize ();
,}
,
,getwinsize ()
,{
,/* this has to be extended to request the current screen size */
,  struct text_info scrinfo;
,
,  gettextinfo (& scrinfo);
,  /* This seems to be a junk procedure since no other information than
,     25 * 80 comes out in 50 lines mode */
,  YMAX = scrinfo.screenheight - 1;
,  XMAX = scrinfo.screenwidth - 1;
,}
,
,#else   # conio
,
,/* adjust the following values to the capabilities of your ANSI driver: */
,FLAG can_add_line = TRUE, can_delete_line = TRUE, can_clear_eol = TRUE;
,
,clear_screen ()
,{ putstring ("\033[2J"); }
,clear_eol ()
,{ putstring ("\033[K"); }
,scroll_forward ()
,{
,  move_cursor (0, YMAX);
,  putchar ('\n');
,}
,scroll_reverse ()
,{ /* only called if cursor is at top of screen */
,  putstring ("\033[1L");
,}
,add_line (y)
,  register int y;
,{
,  move_cursor (0, y);
,  putstring ("\033[1L");
,}
,delete_line (y)
,  register int y;
,{
,  move_cursor (0, y);
,  putstring ("\033[1M");
,}
,move_cursor (x, y)
,  register int x, y;
,{ static char s [11];
,  build_string (s, "\033[%d;%dH", y + 1, x + 1);
,  putstring (s);
,}
,char reverse_on_str [30] = "\033[7m";	/* inverse mode */
,char reverse_off_str [30] = "\033[27m";	/* inverse off */
,reverse_on ()
,{ putstring (reverse_on_str); /* 1m | 7m | 7m    | 7;2m */
,}
,reverse_off ()
,{ putstring (reverse_off_str); /* m  | 0m | 0m 1m | m    */
,}
,start_screen_mode ()
,{}
,end_screen_mode ()
,{}
,
,get_term ()
,{
,  char * colstr = unnull (getenv ("MINEDCOL"));
,  char * coloff = colstr;
,  while (* coloff != '\0' && * coloff != ' ') coloff ++;
,  if (* coloff == ' ') {* coloff = '\0'; coloff ++;}
,  if (* colstr != '\0') build_string (reverse_on_str, "\033[%sm", colstr);
,  if (* coloff != '\0') build_string (reverse_off_str, "\033[%sm", coloff);
,  getwinsize ();
,}
,
,getwinsize ()
,{
,  move_cursor (200, 200);
,  putstring ("\033[6n");
,  flush ();
,  (void) readchar (); (void) readchar ();
,  get_digits (& YMAX); YMAX = YMAX - 1;
,  get_digits (& XMAX); XMAX = XMAX - 1;
,  readchar ();	/* NNANSI sends a final return */
,}
,
,#endif else conio
,#endif msdos
,
,#endif else CURSES
,
,/*------------------------------------------------------------------------*/
,
,/*
, * Read a character from the operating system and handle interrupts.
, * Concerning problems due to the interference of read operations and
, * incoming signals (QUIT, WINCH) see the comments at readchar ().
, */
,strange (err)
,  char * err;
,{
,  ring_bell ();
,  error ("Read interrupted: ", err);
,  sleep (1);
,  ring_bell ();
,  return QUITCHAR;
,}
,
,/*
, * Is a character available within msec milliseconds from file no fid?
, */
,int
,inputreadyafter (fid, msec)
,  int fid;
,  int msec;
,{
,#ifdef selectread
,  int readfds;
,  static struct timeval timeoutstru = {0, 0};
,  register int nfds;
,
,  readfds = 1 << fid;
,  timeoutstru.tv_usec = 1000 * msec;
,  nfds = select (fid + 1, & readfds, 0, 0, & timeoutstru);
,  return nfds;
,#else
,  if (msec < 500)
,	return 1;
,  else	return 0;
,#endif
,}
,
,/*
, * Read a char from operating system, handle interrupts if possible, 
, * handle window size changes if possible.
, */
,#ifdef selectread
,__readchar ()
,{
,  u_char c;
,  register int n;
,  int readfds, exceptfds;
,
,  do {
,	if (winchg == TRUE) RDwin ();
,	readfds = 1 << input_fd;
,	exceptfds = readfds;
,	select (input_fd + 1, & readfds, 0, & exceptfds, 0);
,	if (exceptfds) {
,	   if (quit == TRUE) return QUITCHAR;
,	   else if (winchg == TRUE) ;
,	   else if (intr == TRUE) {intr = FALSE; return '\003';}
,	   else return strange ("exception");
,	}
,	else
,#ifdef _getch_
,	   return getch ();
,#else
,	{
,	   if ((n = read (input_fd, & c, 1)) == 1) return c;
,	   else if ((n == 0) || (geterrno () != EINTR))
,		panicio ("Error during character input", serror ());
,	   else return strange (serror ());
,	}
,#endif
,  } while (TRUE);
,}
,#else
,__readchar ()
,{
,  u_char c;
,
,#ifdef _getch_
,  c = getch ();
,  if (intr == TRUE) {intr = FALSE; c = '\003';}
,#else
,  if (read (input_fd, & c, 1) != 1 && quit == FALSE) {
,	if (geterrno () == EINTR) return __readchar ();
,	else panicio ("Error during character input", serror ());
,  }
,#endif
,  if (quit == TRUE) c = QUITCHAR;
,  return c;
,}
,#endif
,
,/*------------------------------------------------------------------------*/
,
,#ifdef vms
,
,get_term ()
,{
,  get_term_cap (NIL_PTR);
,}
,
,getwinsize ()
,{ }
,
,#endif vms
,
,#ifdef unix
,
,/*
, * Get current window size
, */
,getwinsize ()
,{
,  struct winsize winsiz;
,
,  ioctl (output_fd, TIOCGWINSZ, & winsiz);
,  if (winsiz.ws_row != 0) YMAX = winsiz.ws_row - 1;
,  if (winsiz.ws_col != 0) XMAX = winsiz.ws_col - 1;
,}
,
,/*
, * Get terminal information
, */
,get_term ()
,{
,  char * TERMname = (char *) getenv ("TERM");
,
,  if (TERMname == NIL_PTR)
,	panic ("Terminal not specified", NIL_PTR);
,
,/*
,  if (  (strisprefix ("vt", TERMname) && strlen (TERMname) > 2)
,     || strisprefix ("sun", TERMname)
,     || strisprefix ("xterm", TERMname)
,     )
,	SHIFT_MARK = '';
,  else	SHIFT_MARK = '>';
,*/
,
,  get_term_cap (TERMname);
,
,/* build_string (text_buffer, "Terminal is %s, %d * %d.\n", TERMname, YMAX+1, XMAX+1);
,  putstring (text_buffer); */
,}
,
,#endif unix
,
,/*  ==================================================================	*
, *				End					*
, *  ==================================================================	*/
EOSED

echo ---------------------- extracting minedmp.c -----------------
sed 's/^,//' << \EOSED > minedmp.c
,/*  ==================================================================	*
, *				Editor mined				*
, *			Command and character set mappings		*
, *  ==================================================================	*/
,
,#include "mined.h"
,
,#define iso_latin_1
,
,#ifdef msdos
,#undef iso_latin_1
,#undef dec_sup
,#define pc_charset
,#endif
,
,/*  ==================================================================	*
, *			character set coding				*
, *  ==================================================================	*/
,
,/*
, * Determine a default diacritic character value for _readchar ().
, * The characters are given literally except for the MSDOS version in order
, * not to depend on the function of a character set translator.
, * For all non-MSDOS platforms, ISO-Latin1 or the very similar 
, * DEC-Supplemental are assumed.
, * For MSDOS, characters for the "International Codepage" ("850") are 
, * generated which includes the real letters (not all graphic and Greek 
, * characters) of the old IBM codepage ("437") (which, by the way, some 
, * time ago someone must have designed in an attack of mental sickness).
, */
,u_char
,diacritic (c)
,  u_char c;
,{
,  /*	the following characters cannot be inserted by this function:
,	 and MSDOS graphics characters */
,  switch (c) {
,#ifdef pc_charset
,	case 'C' : return 128;
,	case 'c' : return 135;
,	case 'N' : return 165;
,	case 'n' : return 164;
,	case 's' : return 225;
,	case '!' : return 173;
,	case '$' : return 189;
,	case '/' : return 189;
,	case 'l' : return 156;
,	case 'L' : return 156;
,	case 'Y' : return 190;
,	case '+' : return 241;
,	case '?' : return 168;
,	case '0' : return 248;
,	case '1' : return 251;
,	case '2' : return 253;
,	case '3' : return 252;
,	case '<' : return 174;
,	case '>' : return 175;
,	case ':' : return 246;
,	case 'x' : return 158;
,	case 'f' : return 159;
,	case 'D' : return 209;
,	case 'd' : return 208;
,	case 'P' : return 232;
,	case 'p' : return 231;
,	case 'i' : return 213;
,	case '|' : return 221;
,	case '&' : return 244;
,	case '\\' : return 170;
,	case '_' : return 238;
,	case '-' : return 240;
,	case 'm' : return 230;
,	case '=' : return 242;
,	case '#' : return 245;
,	case '.' : return 250;
,	case ',' : return 247;
,	case '\'' : return 239;
,	case 'X' : return 207;
,#else
,	case 'C' : return '';
,	case 'c' : return '';
,	case 'N' : return '';
,	case 'n' : return '';
,	case 's' : return '';
,	case '!' : return '';
,	case '$' : return '';
,	case '/' : return '';
,	case 'l' : return '';
,	case 'L' : return '';
,	case 'Y' : return '';
,	case '+' : return '';
,	case '?' : return '';
,	case '0' : return '';
,	case '2' : return '';
,	case '<' : return '';
,	case '>' : return '';
,	case 'D' : return '';
,	case 'd' : return '';
,	case 'P' : return '';
,	case 'p' : return '';
,	case '|' : return '';
,	case '&' : return '';
,	case '\\' : return '';
,	case '_' : return '';
,	case '-' : return '';
,	case 'm' : return '';
,	case '#' : return '';
,	case '.' : return '';
,	case '*' : return '';
,	case ',' : return '';
,	case '\'' : return '';
,	case '1' : return '';
,	case '3' : return '';
,#ifdef iso_latin_1
,	case 'X' : return '';
,	case '"' : return '';
,	case 'x' : return '';
,	case ':' : return '';
,#endif
,#ifdef dec_sup
,	case 'X' : return ''; /*  */
,#endif
,#endif
,	default: return c;
,  }
,}
,
,grave (ch)
,  u_char ch;
,{
,	switch (ch) {
,#ifdef pc_charset
,		case 'A' : return 183;
,		case 'E' : return 212;
,		case 'I' : return 222;
,		case 'O' : return 227;
,		case 'U' : return 235;
,		case 'a' : return 133;
,		case 'e' : return 138;
,		case 'i' : return 141;
,		case 'o' : return 149;
,		case 'u' : return 151;
,#else
,		case 'A' : return '';
,		case 'E' : return '';
,		case 'I' : return '';
,		case 'O' : return '';
,		case 'U' : return '';
,		case 'a' : return '';
,		case 'e' : return '';
,		case 'i' : return '';
,		case 'o' : return '';
,		case 'u' : return '';
,#endif
,		default : return diacritic (ch);
,	}
,}
,circumflex (ch)
,  u_char ch;
,{
,	switch (ch) {
,#ifdef pc_charset
,		case 'A' : return 182;
,		case 'E' : return 210;
,		case 'I' : return 215;
,		case 'O' : return 226;
,		case 'U' : return 234;
,		case 'a' : return 131;
,		case 'e' : return 136;
,		case 'i' : return 140;
,		case 'o' : return 147;
,		case 'u' : return 150;
,#else
,		case 'A' : return '';
,		case 'E' : return '';
,		case 'I' : return '';
,		case 'O' : return '';
,		case 'U' : return '';
,		case 'a' : return '';
,		case 'e' : return '';
,		case 'i' : return '';
,		case 'o' : return '';
,		case 'u' : return '';
,#endif
,		default : return diacritic (ch);
,	}
,}
,acute (ch)
,  u_char ch;
,{
,	switch (ch) {
,#ifdef pc_charset
,		case 'A' : return 181;
,		case 'E' : return 144;
,		case 'I' : return 214;
,		case 'O' : return 224;
,		case 'U' : return 233;
,		case 'a' : return 160;
,		case 'e' : return 130;
,		case 'i' : return 161;
,		case 'o' : return 162;
,		case 'u' : return 163;
,		case 'Y' : return 237;
,		case 'y' : return 236;
,		case ' ' : return 239;
,#else
,		case 'A' : return '';
,		case 'E' : return '';
,		case 'I' : return '';
,		case 'O' : return '';
,		case 'U' : return '';
,		case 'a' : return '';
,		case 'e' : return '';
,		case 'i' : return '';
,		case 'o' : return '';
,		case 'u' : return '';
,		case ' ' : return '';
,#ifdef iso_latin_1
,		case 'Y' : return '';
,		case 'y' : return '';
,#endif
,#endif
,		default : return diacritic (ch);
,	}
,}
,diaeresis (ch)
,  u_char ch;
,{
,	switch (ch) {
,#ifdef pc_charset
,		case 'A' : return 142;
,		case 'E' : return 211;
,		case 'I' : return 216;
,		case 'O' : return 153;
,		case 'U' : return 154;
,		case 'a' : return 132;
,		case 'e' : return 137;
,		case 'i' : return 139;
,		case 'o' : return 148;
,		case 'u' : return 129;
,		case 'y' : return 152;
,		case ' ' : return 249;
,#else
,		case 'A' : return '';
,		case 'E' : return '';
,		case 'I' : return '';
,		case 'O' : return '';
,		case 'U' : return '';
,		case 'a' : return '';
,		case 'e' : return '';
,		case 'i' : return '';
,		case 'o' : return '';
,		case 'u' : return '';
,#ifdef iso_latin_1
,		case ' ' : return '';
,		case 'y' : return '\377'; /* '' aborts sun compiler */
,#endif
,#ifdef dec_sup
,		case 'Y' : return ''; /* capital  */
,		case 'y' : return ''; /*  */
,#endif
,#endif
,		default : return diacritic (ch);
,	}
,}
,tilde (ch)
,  u_char ch;
,{
,	switch (ch) {
,#ifdef pc_charset
,		case 'A' : return 199;
,		case 'O' : return 229;
,		case 'a' : return 198;
,		case 'o' : return 228;
,#else
,		case 'A' : return '';
,		case 'O' : return '';
,		case 'a' : return '';
,		case 'o' : return '';
,#ifdef dec_sup
,		case 'E' : return ''; /* OE */
,		case 'e' : return ''; /* oe */
,#endif
,#endif
,		default : return diacritic (ch);
,	}
,}
,angstrom (ch)
,  u_char ch;
,{
,	switch (ch) {
,#ifdef pc_charset
,		case 'A' : return 143;
,		case 'E' : return 146;
,		case 'O' : return 157;
,		case 'a' : return 134;
,		case 'e' : return 145;
,		case 'o' : return 155;
,#else
,		case 'A' : return '';
,		case 'E' : return '';
,		case 'O' : return '';
,		case 'a' : return '';
,		case 'e' : return '';
,		case 'o' : return '';
,#endif
,		default : return diacritic (ch);
,	}
,}
,
,/*  ==================================================================	*
, *		key and function key -> command mapping			*
, *  ==================================================================	*/
,
,/* The mapping between input codes and functions */
,
,extern MUP (), MDN (), MLF (), MRT (), MNW (), MPW (), GOTO (), GOMA ();
,extern SD (), SU (), PD (), PU (), HOME (), EF (), BL (), EL (), HIGH (), LOW ();
,extern S (), SNL (), LIB (), DPC (), DCC (), DLN (), DNW (), DPW (), CTRl ();
,extern QUED (), WT (), EDIT (), RD (), SH (), I (), FS (), REPT ();
,extern SFW (), SRV (), RS (), LR (), GR (), REPL ();
,extern MARK (), YA (), DT (), PT (), WB (), INF ();
,extern HOP (), CANCEL (), ESCAPE (), HELP (), BAD (), FUNKEY (), DIRECT ();
,extern EXED (), VIEW ();
,
,#ifdef unix
,#define NULLcmd BAD
,#define BSPcmd MLF
,#endif
,#ifdef msdos
,#define NULLcmd FUNKEY	/* since FUNcmd is 0 */
,#define BSPcmd DPC
,#endif
,#ifdef vms
,#define NULLcmd ESCAPE
,#define BSPcmd MLF
,#endif
,
,int (* key_map [256]) () =
,{	/* characters to functions map */
,   /* 000-017 */ NULLcmd, MPW, DCC, PD, MRT, MUP, MNW, GOTO,
,		 BSPcmd, S, S, DLN, HOP, SNL, RS, LIB,
,   /* 020-037 */ PT, HOP, PU, MLF, DNW, DT, CTRl, SU,
,		 MDN, YA, SD, ESCAPE, CANCEL, MARK, DPW, BAD,
,   /* 040-057 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 060-077 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 100-117 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 120-137 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 140-157 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 160-177 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, DPC,
,#ifdef msdos
,   /* 200-217 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 220-237 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,#else
,   /* 200-217 */ FUNKEY, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 220-237 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,#endif
,   /* 240-257 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 260-277 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 300-317 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 320-337 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 340-357 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,   /* 360-377 */ S, S, S, S, S, S, S, S, S, S, S, S, S, S, S, S,
,};
,
,#ifdef msdos
,/*
,function keys deliver NUL and the following codes:
,Block1: RGISOQHKPM
,Block2: GHIKMOPQRS	Pos1 Up PgUp Left Center Right End Down PdDn Ins
,Cntrl:	st <-/->
,Cntrl:	wu Pos1/End
,	v PgUp / PgDn
,F1-F10: ;<=>?@ABCD
,shift:	TUVWXYZ[\]
,cntrl:	^_`abcdefg
,alt:	hijklmnopq
,*/
,
,HELPF ()
,{ status_msg ("       F2 write  F3 edit  F6 \357  F7 \371  F8 search      F9 next  F10 hop"); }
,HELPS ()
,{ status_msg ("shift- F2 exit            F6 `  F7 ~  F8 search rev  F9 next  F10 hop"); }
,HELPC ()
,{ status_msg ("cntrl- F2 write  F3 view  F6 ^  F7 \370  F8 search next          F10 hop"); }
,HELPA ()
,{ status_msg ("alt-   F2 write buffer                F8 search rev           F10 hop"); }
,
,int (* pc_key_map [256]) () =
,{	/* function characters to functions map */
,   /* 000-017 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 020-037 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 040-057 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 060-077 */ I, I, I, I, I, I, I, I, I, I, I, HELPF, WT, EDIT, I, I,
,   /* 100-117 */ acute, diaeresis, SFW, RS, GOTO, I, I, MARK, MUP, PU, I, MLF, HOP, MRT, I, YA,
,   /* 120-137 */ MDN, PD, PT, DCC, HELPS, EXED, I, I, I, grave, tilde, SRV, RS, GOTO, HELPC, WT,
,   /* 140-157 */ VIEW, I, I, circumflex, angstrom, RS, I, GOTO, HELPA, WB, I, I, I, I, I, SRV,
,   /* 160-177 */ I, GOTO, I, MPW, MNW, DT, SD, HOP, I, I, I, I, I, I, I, I,
,   /* 200-217 */ I, I, I, I, SU, I, I, I, I, I, I, I, I, I, I, I,
,   /* 220-237 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 240-257 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 260-277 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 300-317 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 320-337 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 340-357 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I,
,   /* 360-377 */ I, I, I, I, I, I, I, I, I, I, I, I, I, I, I, I
,};
,#endif
,
,#ifndef msdos
,
,/* The mapping between function key sequences and functions */
,
,struct {char * fk; int (* fp) ();} keycode [] =
,{	/* Escape-key sequences of function keys */
,	/* VT100 and SUN */
,	"\033[A",	MUP,	/* move cursor up	*/
,	"\033[B",	MDN,	/* more cursor down	*/
,	"\033[C",	MRT,	/* more cursor right	*/
,	"\033[D",	MLF,	/* more cursor left	*/
,	/* SUN raw keycodes */
,	"\033[215z",	MUP,	/* move cursor up	*/
,	"\033[221z",	MDN,	/* more cursor down	*/
,	"\033[219z",	MRT,	/* more cursor right	*/
,	"\033[217z",	MLF,	/* more cursor left	*/
,	/* VT100 */
,	"\033[6~",	PD,	/* Next Screen	*/
,	"\033[5~",	PU,	/* Prev Screen	*/
,	"\033[4~",	MARK,	/* Select	*/
,	"\033[3~",	DT,	/* Remove	*/
,	"\033[2~",	PT,	/* Insert Here	*/
,	"\033[1~",	SFW,	/* Find		*/
,	"\033[29~",	YA,	/* Do		*/
,	"\033[28~",	HELP,	/* Help		*/
,	"\033[17~",	diaeresis, /* F6	*/
,	"\033[18~",	diaeresis, /* F7	*/
,	"\033[19~",	SFW,	/* F8	*/
,	"\033[20~",	RS,	/* F9	*/
,	"\033[21~",	I,	/* F10	*/
,	"\033[23~",	I,	/* F11	*/
,	"\033[24~",	I,	/* F12	*/
,	"\033[25~",	I,	/* F13	*/
,	"\033[26~",	I,	/* F14	*/
,	"\033[31~",	I,	/* F17	*/
,	"\033[32~",	I,	/* F18	*/
,	"\033[33~",	I,	/* F19	*/
,	"\033[34~",	I,	/* F20	*/
,	"\033OP",	HOP,	/* PF1	*/
,	"\033OQ",	SU,	/* PF2	*/
,	"\033OR",	SD,	/* PF3	*/
,	"\033OS",	I,	/* PF4	*/
,	/* SUN */
,	"\033[208z",	grave,		/* R1 */
,	"\033[209z",	circumflex,	/* R2 */
,	"\033[210z",	acute,		/* R3 */
,	"\033[211z",	diaeresis,	/* R4 */
,	"\033[212z",	tilde,		/* R5 */
,	"\033[213z",	angstrom,	/* R6 */
,	"\033[214z",	SU,	/* R7	*/
,	"\033[216z",	PU,	/* R9	*/
,	"\033[218z",	HOP,	/* R11	*/
,	"\033[220z",	SD,	/* R13	*/
,	"\033[222z",	PD,	/* R15	*/
,	"\033[254z",	GOMA,	/* - */
,	"\033[253z",	MARK,	/* + */
,	"\033[250z",	YA,	/* Enter */
,	"\033[249z",	DT,	/* Del */
,	"\033[247z",	PT,	/* Ins */
,	"\033[2z",		PT,	/* Ins (NeWS) */
,	"\033[192z",	MARK,	/* Stop */
,	"\033[193z",	I,	/* Again */
,	"\033[194z",	FS,	/* Props */
,	"\033[195z",	I,	/* Undo */
,	"\033[197z",	YA,	/* Copy */
,	"\033[199z",	PT,	/* Paste */
,	"\033[200z",	RS,	/* Find */
,	"\033[201z",	DT,	/* Cut */
,	"\033[196z",	HELP,	/* Help */
,	"\033[225z",	I,	/* F2 */
,	"\033[226z",	I,	/* F3 */
,	"\033[227z",	I,	/* F4 */
,	"\033[228z",	I,	/* F5 */
,	"\033[229z",	PU,	/* F6 */
,	"\033[230z",	PD,	/* F7 */
,	"\033[231z",	SFW,	/* F8 */
,	"\033[232z",	RS,	/* F9 */
,	"\033[233z",	I,	/* F10 */
,	"\033[234z",	I,	/* F11 */
,	"\033[235z",	I,	/* F12 */
,	/* Iris */
,	"\033[209q",	MARK,	/* Print Screen */
,	"\033[213q",	YA,	/* Scroll Lock */
,/*	"\033[217q",	I,	/* Pause */
,	"\033[139q",	PT,	/* Insert, Ins */
,	"\033[P",	DT,	/* Del */
,	"\033[H",	SU,	/* Home */
,	"\033[150q",	PU,	/* PgUp */
,	"\033[146q",	SD,	/* End */
,	"\033[154q",	PD,	/* PgDn */
,	"\033[000q",	HOP,	/* 5 */
,	"\033[001q",	I,	/* F1 */
,	"\033[002q",	I,	/* F2 */
,	"\033[005q",	I,	/* F5 */
,	"\033[006q",	I,	/* F6 */
,	"\033[007q",	I,	/* F7 */
,	"\033[008q",	SFW,	/* F8 */
,	"\033[009q",	RS,	/* F9 */
,	"\033[022q",	grave,		/* Shift-F10 */
,	"\033[023q",	circumflex,	/* Shift-F11 */
,	"\033[024q",	acute,		/* Shift-F12 */
,	"\033[010q",	diaeresis,	/* F10 */
,	"\033[011q",	tilde,		/* F11 */
,	"\033[012q",	angstrom,	/* F12 */
,	/* VT100 emulator at IBM-PC */
,	"\033M",		PU,	/* Pg Up */
,	"\033D",		PD,	/* Pg Dn */
,/*	"\033[H",		SU,	/* Home	, same at Iris */
,	"\033[24;1H",	SD,	/* End	*/
,	"\0331",		HOP,	/* Ins	*/
,		/* cursor keys and F1-4 same as VT100 */
,	/* crttool */
,	"\033m",		DIRECT,	/* direct cursor address */
,	NIL_PTR
,};
,
,#define MAXCODELEN 7 /* max. length of function key sequence to be detected, 
,			depending on the keycode table => used in mined1.c */
,
,#endif
,
,/*  ==================================================================	*
, *				End					*
, *  ==================================================================	*/
EOSED

echo ---------------------- extracting mined.h -----------------
sed 's/^,//' << \EOSED > mined.h
,/*  ====================================================================  *
, *				Mined.h					  *
, *  ====================================================================  */
,
,#ifndef minedH
,#define minedH
,
,#define msdos
,#ifdef unix
,#  undef msdos
,#endif
,#ifdef vms
,#  undef msdos
,#endif
,
,#ifdef msdos
,/* With Turbo-C, compile with memory model >= Compact */
,/* #define conio doesn't work with current combined positioning/output method */
,extern far * getenv ();
,extern far * getcwd ();
,#  define u_char unsigned char
,#  include <fcntl.h>
,#  define abort()	exit (1)
,#  define FUNcmd	'\000'
,#endif
,
,#ifdef vms
,#  define u_char unsigned char
,#  include <unixio.h>
,#  include <file.h>	/* for the O_... attributes to open () */
,#  include <unixlib.h>
,#  undef putchar
,#  undef FALSE
,#  undef TRUE
,#  define CURSES
,#  define FUNcmd	'\200'
,#endif
,
,#ifdef unix
,#  include <stdio.h>
,#  include <fcntl.h>
,#  undef putchar
,#  undef NULL
,#  undef EOF
,#  define FUNcmd	'\200'
,#endif
,
,/*------------------------------------------------------------------------*/
,
,extern clear_screen ();
,extern clear_eol ();
,extern scroll_forward ();
,extern scroll_reverse ();
,extern add_line (/* y */);
,extern delete_line (/* y */);
,extern move_cursor (/* x, y */);
,extern reverse_on ();
,extern reverse_off ();
,extern start_screen_mode ();
,extern end_screen_mode ();
,extern get_term ();
,extern getwinsize ();
,extern inputreadyafter ();
,extern __readchar ();
,
,/*------------------------------------------------------------------------*/
,
,/* Set cursor at coordinates x, y */
,#define set_cursor(nx, ny)	move_cursor(nx, ny)
,
,/* Screen size and display definitions. Coordinates start at 0, 0 */
,#ifdef msdos
,#  define maxYMAX		64
,#  define maxXMAX		132
,#else
,#  define maxYMAX		126	/* 73 */
,#  define maxXMAX		279	/* 163 */
,#endif
,
,extern short YMAX;
,extern short XMAX;
,#define SCREENMAX	(YMAX - 1)	/* last line displayed (first is 0) */
,#define XBREAK		(XMAX - 1)	/* Shift line display at this column */
,#define SHIFT_SIZE	25		/* Number of chars to shift */
,#define maxLINE_LEN	(maxXMAX + 1)	/* max screen line length */
,#define screen_BUFL	(maxXMAX * maxYMAX)	/* Size of I/O buffering */
,
,#define MAX_CHARS	1024		/* max chars on one line of text */
,		/* LINE_START must be rounded up to the lowest SHIFT_SIZE */
,#define LINE_START	(((-MAX_CHARS - 1) / SHIFT_SIZE) * SHIFT_SIZE \
,  				   - SHIFT_SIZE)
,#define LINE_END	(MAX_CHARS + 1)	/* Highest x-coordinate for line */
,
,#define BLOCK_SIZE	1024
,
,/* Return values of functions */
,#define ERRORS		-1
,#define NO_LINE		(ERRORS - 1)	/* Must be < 0 */
,#define FINE	 	(ERRORS + 1)
,#define NO_INPUT	(ERRORS + 2)
,
,#define STD_IN		0		/* Input file # */
,#define STD_OUT	 	1		/* Terminal output file # */
,#define STD_ERR		2
,
,#define REPORT	2		/* Report change of lines on # lines */
,
,/*
, * Common enum type for all flags used in mined.
, */
,typedef enum {
,/* General flags */
,  FALSE,
,  TRUE,
,  OFF,
,  ON,
,/* yank_status and other */
,  NOT_VALID,
,  VALID,
,
,/* Expression flags */
,  FORWARD,
,  REVERSE,
,
,/* Yank flags */
,  SMALLER,
,  BIGGER,
,  SAME,
,/*  EMPTY, */
,  NO_DELETE,
,  DELETE,
,  READ,
,  WRITE
,} FLAG;
,
,/*
, * The Line structure. Each line entry contains a pointer to the next line,
, * a pointer to the previous line, a pointer to the text and an unsigned char
, * telling at which offset of the line printing should start (usually 0).
, */
,struct Line {
,  struct Line * next;
,  struct Line * prev;
,  char * text;
,  unsigned char shift_count;
,};
,
,typedef struct Line LINE;
,
,/* Dummy line indicator */
,#define DUMMY		0x80
,#define DUMMY_MASK	0x7F
,
,/* Expression definitions */
,#define NO_MATCH	0
,#define MATCH		1
,#define REG_ERROR	2
,
,#define BEGIN_LINE	(2 * REG_ERROR)
,#define END_LINE	(2 * BEGIN_LINE)
,
,/*
, * The regex structure. Status can be any of 0, BEGIN_LINE or REG_ERROR. In
, * the last case, the result.err_mess field is assigned. Start_ptr and end_ptr
, * point to the match found. For more details see the documentation file.
, */
,struct regex {
,  union {
,  	char * err_mess;
,  	int * expression;
,  } result;
,  char status;
,  char * start_ptr;
,  char * end_ptr;
,};
,
,typedef struct regex REGEX;
,
,/* NULL definitions */
,#define NIL_PTR		((char *) 0)
,#define NIL_LINE	((LINE *) 0)
,#define NIL_REG		((REGEX *) 0)
,#define NIL_INT		((int *) 0)
,
,/*
, * Forward declarations
, */
,extern int nlines;		/* Number of lines in file */
,extern LINE * header;		/* Head of line list */
,extern LINE * tail;		/* Last line in line list */
,extern LINE * top_line;		/* First line of screen */
,extern LINE * bot_line;		/* Last line of screen */
,extern LINE * cur_line;		/* Current line in use */
,extern char * cur_text;		/* Pointer to char on current line in use */
,extern int last_y;		/* Last y of screen, usually SCREENMAX */
,
,extern int x, y;		/* x, y coordinates on screen */
,extern FLAG modified;		/* Set when file is modified */
,extern FLAG viewonly;		/* Set when view only mode is selected */
,extern FLAG quit;		/* Set when quit character is typed */
,extern FLAG intr;		/* Set when intr character is typed */
,extern FLAG winchg;		/* Set when the window size changes */
,extern FLAG waitingforinput;	/* Set while waiting for the next command key */
,extern FLAG isscreenmode;	/* Set when screen mode is on */
,extern int out_count;		/* Index in output buffer */
,extern char text_buffer [MAX_CHARS];	/* Buffer for modifying text */
,extern int input_fd;		/* File descriptors for terminal dialog */
,extern int output_fd;
,extern char SHIFT_MARK;
,extern char blank_line [];	/* For line clearance, in case terminal cannot do it */
,extern int fprot;		/* To be used for all file creatings */
,
,extern char yank_file [];	/* Temp. file for buffer */
,extern char yankie_file [];	/* Temp. file for inter-window buffer */
,extern char panic_file [];	/* file for panic-write-back */
,extern FLAG yank_status;	/* Status of yank_file */
,extern long chars_saved;	/* # of chars saved in buffer */
,
,extern int hop_flag;		/* set to 2 by HOP key function */
,
,extern FLAG can_add_line, can_delete_line, can_clear_eol;
,extern FLAG cansuspendmyself;
,extern char * get_line_err1;
,extern char * get_line_err2;
,extern char * serror ();
,extern char * serrorof ();
,extern int geterrno ();
,
,extern LINE * proceed ();
,extern LINE * match ();
,extern LINE * line_insert ();
,extern char * num_out ();
,extern get_digits ();
,extern char * basename ();
,extern u_char promptyn ();
,extern FLAG checkoverwrite ();
,extern delete_file ();
,extern char * unnull ();
,
,#define putchar(c)	__putchar (c)
,extern __putchar ();	/* do not use _putchar! it may conflict with curses */
,extern writechar ();
,extern putstring ();
,extern writestring ();
,extern flush ();
,extern flush_buffer ();
,
,extern char * alloc ();
,
,/*
, * String functions
, */
,#define streq(s1, s2)		(strcmp (s1, s2) == 0)
,#define strisprefix(s1, s2)	(strncmp (s2, s1, strlen (s1)) == 0)
,
,/*
, * Empty output buffer
, */
,#define clear_buffer()		(out_count = 0)
,
,/*
, * Ring bell on terminal
, */
,#define ring_bell()		putchar ('\07')
,
,#ifdef UNUSED	/* putchar, putstring, flush, and #include <curses.h> 
,		   are now in minedio.c */
,/*
, * Print character on terminal	- obsolete due to new putchar macro
, */
,#ifdef CURSES
,#  define putchar(c)		addch (c)
,#else
,#  define putchar(c)		writechar (output_fd, (c))
,#endif
,/*
, * Print string on terminal
, */
,#ifdef CURSES
,#  define putstring(str)	addstr (str)
,#else
,#  define putstring(str)	writestring (output_fd, (str))
,#endif
,/*
, * Flush output buffer
, */
,#ifdef CURSES
,#  define flush()		refresh ()
,#else
,#  define flush()		flush_buffer (output_fd)
,#endif
,
,#endif UNUSED
,
,/*
, * Print line on terminal at offset 0 and clear tail of line
, */
,#define line_print(line)	put_line (line, 0, TRUE)
,
,/*
, * Functions handling status_line. ON means in reverse video.
, */
,#define status_msg(str)		status_line (str, NIL_PTR)
,#define status_line(str1, str2)		\
,	bottom_line (ON, (str1), (str2), NIL_PTR, FALSE)
,#define status_beg(str)			\
,	bottom_line (ON, (str), NIL_PTR, NIL_PTR, TRUE)
,#define error(str1, str2)		\
,	bottom_line (ON, (str1), (str2), NIL_PTR, FALSE)
,#define get_string(str1, str2, fl)	\
,	bottom_line (ON, (str1), NIL_PTR, (str2), fl)
,#define clear_status()			\
,	bottom_line (OFF, NIL_PTR, NIL_PTR, NIL_PTR, FALSE)
,
,/*
, * Print info about current file and buffer.
, */
,#define fstatus(mess, cnt)	\
,	file_status ((mess), (cnt), file_name, nlines, writable, modified, viewonly)
,
,/*
, * Build formatted string.
, * If this definition is left out, a routine will be defined in mined1.c.
, */
,#define build_string sprintf /**/
,
,/*
, * Get real shift value.
, */
,#define get_shift(cnt)		((cnt) & DUMMY_MASK)
,
,/*
, * Special character.
, */
,#define QUITCHAR '\034' /* ^\ */
,
,/*------------------------------------------------------------------------*/
,#endif
,/*------------------------------------------------------------------------*/
EOSED

echo ---------------------- extracting mined.c -----------------
sed 's/^,//' << \EOSED > mined.c
,/* mined single compilation version for my attempts with Turbo-C
,   (since I don't know how to compile separately with it)
, */
,
,#define single_pass_compilation
,#include "minedmp.c"
,#include "mined1.c"
,#include "mined2.c"
,#include "minedio.c"
EOSED

echo ---------------------- extracting mined.prj -----------------
sed 's/^,//' << \EOSED > mined.prj
,mined1.c
,mined2.c
,minedio.c
,minedmp.c
EOSED

exit 0

Newsgroups: comp.editors,comp.emacs