diff -urN ng-1.4.4/Makefile ng-1.4.4-eota/Makefile --- ng-1.4.4/Makefile 1970-01-01 09:00:00.000000000 +0900 +++ ng-1.4.4-eota/Makefile 2005-12-13 23:15:47.000000000 +0900 @@ -0,0 +1,168 @@ +# $Id: Makefile,v 1.2 2000/09/30 15:59:42 amura Exp $ +# Makefile for MicroEMACS. +# Is there a better way to do the rebuilds, other than using +# the links? +# +# $Log: Makefile,v $ +# Revision 1.2 2000/09/30 15:59:42 amura +# add Canna configuration form config.h +# +# Revision 1.1.1.1 2000/06/27 01:47:59 amura +# import to CVS +# +# Modified for Ng 1.0 by Shigeki Yoshida (shige@csk.CO.JP) 1990.01.29 + +SYS = sysv + +# Canna configurations +#CANNADEF = -DCANNA +#CANNALIB = -L/usr/share/lib -lcanna +#CANNAINC = -I/usr/share/include +CANNADEF = +CANNALIB = +CANNAINC = + +# CDEFS gets defines, and gets passed to lint. CFLAGS gets flags, and doesn't +# get passed to lint. +# +# Now, compile time options are defined in a "config.h". +# +CDEFS = $(CANNADEF) +CFLAGS = -O $(CDEFS) $(CANNAINC) + +# If your machine have an alloca() in a libPW.a, please add -lPW to the LIBS. +#LIBS = $(CANNALIB) -lcurses -lPW +#LIBS = $(CANNALIB) -lcurses +LIBS = -lgt + +# If your machine don't have an alloca(), please define ALLOCA. +#ALLOCA = alloca.o +ALLOCA = + +CC = cc + +# Objects which only depend on the "standard" includes +OBJS = basic.o dir.o dired.o shell.o version.o window.o \ + kinsoku.o jump.o + +# Those with unique requirements +IND = buffer.o complt.o display.o cmode.o echo.o extend.o file.o \ + help.o kbd.o keymap.o line.o macro.o main.o match.o modes.o \ + paragraph.o random.o region.o regex.o re_search.o search.o \ + skg.o kanji.o undo.o word.o + +# System dependent objects +OOBJS = cinfo.o spawn.o ttyio-eota.o tty.o ttykbd.o eota.o termcap.o + +OBJ = $(OBJS) $(IND) $(OOBJS) fileio.o canna.o $(ALLOCA) + +OSRCS = cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c canna.c alloca.c +SRCS = basic.c cmode.c dir.c dired.c file.c line.c match.c paragraph.c \ + random.c region.c search.c shell.c version.c window.c word.c \ + buffer.c complt.c display.c echo.c extend.c help.c kbd.c \ + keymap.c macro.c main.c modes.c regex.c re_search.c kanji.c \ + kinsoku.c skg.c jump.c undo.c + +OINCS = ttydef.h sysdef.h chrdef.h +INCS = config.h def.h +REINCS = regex_e.h regex_j.h regex_j.c regex_e.h kanji_.h kanji_.c + +#PROG = mg +PROG = ng + +$(PROG): $(OBJ) + $(CC) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS) + +# strip mg once you're satisfied it'll run -- makes it much smaller +strip: + strip $(PROG) + +lint: $(SRCS) $(OSRCS) $(INCS) $(OINCS) + lint -ahbz $(CDEFS) $(SRCS) $(OSRCS) + +$(OBJ): $(INCS) $(OINCS) + +$(OOBJS): $(INCS) $(OINCS) + +buffer.o: $(INCS) $(OINCS) kbd.h undo.h + +cmode.o file.o line.o paragraph.o random.o region.o undo.o word.o: \ + $(INCS) $(OINCS) undo.h + +complt.o: $(INCS) $(OINCS) kbd.h complt.h + +display.o keymap.o modes.o fileio.o: \ + $(INCS) $(OINCS) kbd.h + +echo.o: $(INCS) $(OINCS) key.h macro.h complt.h + +extend.o help.o: \ + $(INCS) $(OINCS) kbd.h macro.h key.h + +kanji.o: $(INCS) $(OINCS) kinit.h + +kbd.o: $(INCS) $(OINCS) kbd.h macro.h key.h undo.h + +macro.o canna.o: \ + $(INCS) $(OINCS) macro.h key.h + +main.o search.o: \ + $(INCS) $(OINCS) macro.h + +match.o: $(INCS) $(OINCS) key.h + +re_search.o: $(INCS) $(OINCS) $(REINCS) macro.h + +regex.o: $(INCS) $(OINCS) $(REINCS) + +skg.o: $(INCS) $(OINCS) macro.h key.h undo.h + +sysdef.h: sys/$(SYS)/sysdef.h # Update links, if needed. + rm -f sysdef.h + ln sys/$(SYS)/sysdef.h . + +ttydef.h: sys/default/ttydef.h + rm -f ttydef.h + ln sys/default/ttydef.h . + +chrdef.h: sys/default/chrdef.h + rm -f chrdef.h + ln sys/default/chrdef.h . + +fileio.c: sys/$(SYS)/fileio.c + rm -f fileio.c + ln sys/$(SYS)/fileio.c . + +spawn.c: sys/$(SYS)/spawn.c + rm -f spawn.c + ln sys/$(SYS)/spawn.c . + +tty.c: sys/default/tty.c + rm -f tty.c + ln sys/default/tty.c . + +ttyio.c: sys/$(SYS)/ttyio.c + rm -f ttyio.c + ln sys/$(SYS)/ttyio.c . + +ttykbd.c: sys/default/ttykbd.c + rm -f ttykbd.c + ln sys/default/ttykbd.c . + +cinfo.c: sys/default/cinfo.c + rm -f cinfo.c + ln sys/default/cinfo.c . + +canna.c: sys/default/canna.c + rm -f canna.c + ln sys/default/canna.c . + +alloca.c: sys/default/alloca.c + rm -f alloca.c + ln sys/default/alloca.c . + +port: $(SRCS) $(INCS) + rm -f port + tar cfb port 1 $? + +clean:; rm -f $(OBJ) $(OSRCS) $(OINCS) diff -urN ng-1.4.4/config.h ng-1.4.4-eota/config.h --- ng-1.4.4/config.h 2000-11-16 23:22:08.000000000 +0900 +++ ng-1.4.4-eota/config.h 2005-12-13 22:49:21.000000000 +0900 @@ -18,7 +18,7 @@ #undef NO_DIR /* Disable dir change functions. */ /* If defined, NO_STARTUP must be also. */ -#undef NO_DIRED /* Disable "dired" mode. */ +#define NO_DIRED /* Disable "dired" mode. */ /* If not defined, ADDFUNC must be also.*/ #undef NO_DPROMPT /* Disable delayed prompt on multi-key sequences. */ @@ -86,7 +86,7 @@ #define KANJI /* Create KANJI handling version. */ -#define HANKANA /* Create Hankaku KANA handling version. */ +#undef HANKANA /* Create Hankaku KANA handling version. */ #define CURSOR_POS /* Cursor locates on next CHR after POINT */ diff -urN ng-1.4.4/docs/README.eota ng-1.4.4-eota/docs/README.eota --- ng-1.4.4/docs/README.eota 1970-01-01 09:00:00.000000000 +0900 +++ ng-1.4.4-eota/docs/README.eota 2006-01-23 20:47:42.000000000 +0900 @@ -0,0 +1,2 @@ +ng-1.4.4 を EOTA で動かすパッチは、浪花氏によって書かれた ng-1.3L 用の +パッチを元に作成しました。 diff -urN ng-1.4.4/eota.c ng-1.4.4-eota/eota.c --- ng-1.4.4/eota.c 1970-01-01 09:00:00.000000000 +0900 +++ ng-1.4.4-eota/eota.c 2005-12-13 23:23:41.000000000 +0900 @@ -0,0 +1,8 @@ +/* + * provide missing functions for EOTA + */ + +sigsetmask(int i) +{ + return 0; +} diff -urN ng-1.4.4/termcap.c ng-1.4.4-eota/termcap.c --- ng-1.4.4/termcap.c 1970-01-01 09:00:00.000000000 +0900 +++ ng-1.4.4-eota/termcap.c 2005-12-13 22:49:21.000000000 +0900 @@ -0,0 +1,361 @@ +/* $Id: termcap.c,v 1.1.1.1 2000/06/27 01:48:02 amura Exp $ */ +/* + * termcap.c - termcap library routines for MS-DOS and OS/2 + * + * This is nearly public domain termcap library routines, + * completely rewritten from the code of Norman Azadian's + * termcap routines, which is also not copyrighted. + * You may freely copy and distribute this program. + * + * Junn Ohta, September 1989 + */ + +/* + * $Log: termcap.c,v $ + * Revision 1.1.1.1 2000/06/27 01:48:02 amura + * import to CVS + * + */ + +/* 90.07.24 by S.Yoshida: Ng don't need this file. +#include "env.h" */ + +/* 90.07.24 by S.Yoshida: Ng always need termcap library. +#ifdef TERMCAP */ +/* 97.09.12 by amura: Ng don't need termcap when using TurboC conio */ +#ifndef TCCONIO + +#include + +#define TBSIZE 1024 /* size of termcap buffer (termcap dependent) */ + +/* + * termcap tcbuf; retained for later use of termcap routines + */ +static char *tcbuf; + +/* + * dummy variables; for compatibility with UNIX termcap + */ +extern char PC; +extern short ospeed; + +extern char *getenv(), *strcpy(), *strchr(); + +/* + * error exit + */ +static void +error(s) + char *s; +{ + fprintf(stderr, "termcap: %s\n", s); + exit(1); +} + +/* + * get an entry + */ +static int +getentry(fp, buf, room, name) + FILE *fp; + char *buf; + int room; + char *name; +{ + register char *p, *q; + int cont, len, c; + char line[TBSIZE]; + +next: + for (;;) { + if ((p = fgets(line, TBSIZE, fp)) == NULL) { + *buf = 0; + return 0; + } + line[TBSIZE-1] = 0; + if (*p >= 'A' && *p <= 'Z' || *p >= 'a' && *p <= 'z') + break; + } + for (p = line; *p && *p != '\r' && *p != '\n'; p++) + ; + if (cont = (p > line && p[-1] == '\\')) + p--; + *p = 0; + p = line; + for (;;) { + for (q = p; *q && *q != '|' && *q != ':'; q++) + ; + if (*q == 0) + goto next; + c = *q; + *q = 0; + if (!strcmp(name, p)) { + *q = c; + break; + } + *q = c; + p = q + 1; + } + while (*p != ':') + p++; + len = strlen(p); + if (room <= len) + error("tcbuf too long"); + strcpy(buf, p); + buf += len; + room -= len; + while (cont) { + if ((p = fgets(line, TBSIZE, fp)) == NULL) + error("unexpected eof"); + line[TBSIZE-1] = 0; + for (p = line; *p && *p != '\r' && *p != '\n'; p++) + ; + if (cont = (p > line && p[-1] == '\\')) + p--; + *p = 0; + for (p = line; *p == ' ' || *p == '\t'; p++) + ; + if (!*p || *p == '#') + continue; + len = strlen(p); + if (room <= len) + error("tcbuf too long"); + strcpy(buf, p); + buf += len; + room -= len; + } + return 1; +} + +/* + * get one capability value + */ +static char * +getcap(name) + register char *name; +{ + register char *p; + + if (tcbuf == NULL) + return NULL; + + p = tcbuf; + while (*p) { + if (*p++ != ':') + continue; + if (*p == *name && p[1] == name[1]) + return p + 2; + } + return NULL; +} + +/* + * tgetent + */ +int +tgetent(buf, name) + char *buf; + char *name; +{ + register char *p, *q; + char *file; + FILE *fp; + int ret; + + if ((file = getenv("TERMCAP")) == NULL) + file = "/etc/termcap"; + if ((fp = fopen(file, "r")) == NULL) + return -1; + p = buf; + if ((ret = getentry(fp, p, TBSIZE, name)) == 1) + tcbuf = buf; + fclose(fp); + while (p = getcap("tc")) { + for (q = p; *q && *q != ':'; q++) + ; + *q = 0; + p -= 2; + if ((fp = fopen(file, "r")) == NULL) + return -1; + ret = getentry(fp, p, TBSIZE-(int)(p-tcbuf), p+3); + fclose(fp); + } + return ret; +} + +/* + * tgetflag + */ +int +tgetflag(name) + char *name; +{ + register char *p; + + return ((p = getcap(name)) != NULL && *p == ':'); +} + +/* + * tgetnum + */ +int +tgetnum(name) + char *name; +{ + register char *p; + int num; + + if ((p = getcap(name)) == NULL || *p++ != '#') + return -1; + num = 0; + while (*p && *p != ':') + num = num * 10 + (*p++ - '0'); + return num; +} + +/* + * tgetstr + */ +char * +tgetstr(name, bufp) + char *name; + char **bufp; +{ + register char *p, *q; + char *ret; + int c; + + if ((p = getcap(name)) == NULL || *p++ != '=') + return NULL; + ret = q = *bufp; + while (*p && *p != ':') { + if (*p == '^') { + p++; + *q++ = *p++ & 0x1f; + continue; + } + if (*p != '\\') { + *q++ = *p++; + continue; + } + p++; + if (*p >= '0' && *p <= '7') { + c = *p++ - '0'; + if (*p >= '0' && *p <= '7') + c = (c << 3) + *p++ - '0'; + if (*p >= '0' && *p <= '7') + c = (c << 3) + *p++ - '0'; + *q++ = c; + continue; + } + switch (c = *p++) { + case 'E': c = '\033'; break; + case 'n': c = '\n'; break; + case 'r': c = '\r'; break; + case 'f': c = '\f'; break; + case 't': c = '\t'; break; + case 'b': c = '\b'; break; + } + *q++ = c; + } + *q++ = 0; + *bufp = q; + return ret; +} + +/* + * tgoto + */ +char * +tgoto(cm, col, row) + char *cm; + int col, row; +{ + register char *p, *q; + char *fmt; + int *val, tmp; + static char buf[20]; + + val = &row; + for (p = cm, q = buf; *p; p++) { + if (*p != '%') { + *q++ = *p; + continue; + } + switch (*++p) { + case 'd': + fmt = "%dX"; + goto num; + case '2': + fmt = "%02dX"; + goto num; + case '3': + fmt = "%03dX"; + num: + sprintf(q, fmt, *val); + while (*q != 'X') + q++; + val = &col; + break; + case '.': + *q++ = *val; + val = &col; + break; + case '+': + *q++ = *val + *++p; + val = &col; + break; + case '>': + p++; + if (*val > *p++) + *val += *p; + break; + case 'r': + tmp = row; + row = col; + col = tmp; + break; + case 'i': + row++; + col++; + break; + case 'n': + row ^= 0140; + col ^= 0140; + break; + case 'B': + *val += 6 * (*val / 10); + break; + case 'D': + *val -= 2 * (*val % 16); + break; + case '%': + *q++ = '%'; + break; + default: + return "OOPS"; + } + } + *q = 0; + return buf; +} + +/* + * tputs + */ +void +tputs(p, lines, outc) + register char *p; + int lines; + int (*outc)(); +{ + while (*p == '.' || *p == '*' || *p >= '0' && *p <= '9') + p++; + while (*p) + (*outc)(*p++); +} + +#endif /* TCCONIO */ +/* 90.07.24 by S.Yoshida: Ng always need termcap library. +#endif /*TERMCAP*/ diff -urN ng-1.4.4/ttyio-eota.c ng-1.4.4-eota/ttyio-eota.c --- ng-1.4.4/ttyio-eota.c 1970-01-01 09:00:00.000000000 +0900 +++ ng-1.4.4-eota/ttyio-eota.c 2005-12-13 23:01:04.000000000 +0900 @@ -0,0 +1,396 @@ +/* $Id: ttyio.c,v 1.1.1.1.2.1 2003/02/23 14:32:58 amura Exp $ */ +/* + * Ultrix-32 and Unix terminal I/O. + * The functions in this file + * negotiate with the operating system for + * keyboard characters, and write characters to + * the display in a barely buffered fashion. + */ + +/* + * $Log: ttyio.c,v $ + * Revision 1.1.1.1.2.1 2003/02/23 14:32:58 amura + * canna_init() must be called after setttysize() on ttyio.c + * + * Revision 1.1.1.1 2000/06/27 01:48:02 amura + * import to CVS + * + */ +/* 90.02.05 Modified for Ng 1.0 by S.Yoshida */ + +#include "config.h" /* 90.12.20 by S.Yoshida */ +#include "def.h" + +//#include +#ifdef ADDFUNC /* 90.02.14 by S.Yoshida */ +#include /* 90.02.13: For SIGWINCH. */ +#endif /* ADDFUNC */ +//#include /* 00.04.03: amura */ + +#define NOBUF 512 /* Output buffer size. */ + +char obuf[NOBUF]; /* Output buffer. */ +int nobuf; +#ifndef EOTA +struct sgttyb oldtty; /* V6/V7 stty data. */ +struct sgttyb newtty; +struct tchars oldtchars; /* V7 editing. */ +struct tchars newtchars; +struct ltchars oldltchars; /* 4.2 BSD editing. */ +struct ltchars newltchars; +#ifdef TIOCGWINSZ +struct winsize winsize; /* 4.3 BSD window sizing */ +#endif +#endif /* not EOTA */ +int nrow; /* Terminal size, rows. */ +int ncol; /* Terminal size, columns. */ +#ifdef ADDFUNC /* 90.02.14 by S.Yoshida */ +#ifdef SIGWINCH /* 90.02.13 by S.Yoshida */ +VOID ttwinch(); +#endif /* SIGWINCH */ +#endif /* ADDFUNC */ +#ifdef HAVE_GETSID +static int ttysavedp = FALSE; /* terminal state saved? */ +int job_control; +#endif + +/* + * This function gets called once, to set up + * the terminal channel. On Ultrix is's tricky, since + * we want flow control, but we don't want any characters + * stolen to send signals. Use CBREAK mode, and set all + * characters but start and stop to 0xFF. + */ +ttopen() { + register char *tv_stype; + char *getenv(), *tgetstr(), tcbuf[1024], err_str[72]; +#ifndef SUPPORT_ANSI + int sprintf(); +#endif + +#ifdef HAVE_GETSID + if( !ttysavedp ) + { + pid_t pid,pgid,sid; + + pid = getpid(); + pgid = getpgrp(); + sid = getsid(0); + if (pid == pgid && pgid != sid) + job_control = TRUE; + else + job_control = FALSE; + ttysavedp = TRUE; + } +#endif /* HAVE_GETSID */ + +/* do this the REAL way */ + if ((tv_stype = getenv("TERM")) == NULL) + { + puts("Environment variable TERM not defined!"); + exit(1); + } + + if((tgetent(tcbuf, tv_stype)) != 1) + { + (void) sprintf(err_str, "Unknown terminal type %s!", tv_stype); + puts(err_str); + exit(1); + } + if (ttraw() == FALSE) + panic("aborting due to terminal initialize failure"); +#ifdef ADDFUNC /* 90.02.14 by S.Yoshida */ +#ifdef SIGWINCH /* 90.02.13 by S.Yoshida */ + (void) signal(SIGWINCH, ttwinch); +#endif /* SIGWINCH */ +#endif /* ADDFUNC */ +#ifdef CANNA + canna_init(); +#endif +} + +/* + * This function sets the terminal to RAW mode, as defined for the current + * shell. This is called both by ttopen() above and by spawncli() to + * get the current terminal settings and then change them to what + * mg expects. Thus, stty changes done while spawncli() is in effect + * will be reflected in mg. + */ +ttraw() { +#ifndef EOTA + extern short ospeed; + + if (ioctl(0, TIOCGETP, (char *) &oldtty) < 0) { + ewprintf("ttopen can't get sgtty"); + return(FALSE); + } + newtty.sg_ospeed = ospeed = oldtty.sg_ospeed; + newtty.sg_ispeed = oldtty.sg_ispeed; + newtty.sg_erase = oldtty.sg_erase; + newtty.sg_kill = oldtty.sg_kill; + newtty.sg_flags = oldtty.sg_flags; + newtty.sg_flags &= ~(ECHO|CRMOD); /* Kill echo, CR=>NL. */ +#ifdef FLOWCONTROL + newtty.sg_flags |= CBREAK; /* Half-cooked mode. */ +#else + newtty.sg_flags |= RAW|ANYP; /* raw mode for 8 bit path.*/ +#endif + if (ioctl(0, TIOCSETP, (char *) &newtty) < 0) { + ewprintf("ttopen can't set sgtty"); + return(FALSE); + } + if (ioctl(0, TIOCGETC, (char *) &oldtchars) < 0) { + ewprintf("ttopen can't get chars"); + return(FALSE); + } + newtchars.t_intrc = 0xFF; /* Interrupt. */ + newtchars.t_quitc = 0xFF; /* Quit. */ +#if FLOWCONTROL + newtchars.t_startc = 0x11; /* ^Q, for terminal. */ + newtchars.t_stopc = 0x13; /* ^S, for terminal. */ +#else + newtchars.t_startc = 0xFF; /* ^Q, for terminal. */ + newtchars.t_stopc = 0xFF; /* ^S, for terminal. */ +#endif + newtchars.t_eofc = 0xFF; + newtchars.t_brkc = 0xFF; + if (ioctl(0, TIOCSETC, (char *) &newtchars) < 0) { + ewprintf("ttraw can't set chars"); + return(FALSE); + } + if (ioctl(0, TIOCGLTC, (char *) &oldltchars) < 0) { + panic("ttraw can't get ltchars"); + return(FALSE); + } + newltchars.t_suspc = 0xFF; /* Suspend #1. */ + newltchars.t_dsuspc = 0xFF; /* Suspend #2. */ + newltchars.t_rprntc = 0xFF; + newltchars.t_flushc = 0xFF; /* Output flush. */ + newltchars.t_werasc = 0xFF; + newltchars.t_lnextc = 0xFF; /* Literal next. */ + if (ioctl(0, TIOCSLTC, (char *) &newltchars) < 0) { + ewprintf("ttraw can't set ltchars"); + return(FALSE); + } +#else + dis_eof(0); +#endif /* not EOTA */ + setttysize() ; + return(TRUE); +} + +/* + * This function gets called just + * before we go back home to the shell. Put all of + * the terminal parameters back. + * Under UN*X this just calls ttcooked(), but the ttclose() hook is in + * because vttidy() in display.c expects it for portability reasons. + */ +ttclose() { + if (ttcooked() == FALSE) + panic(""); /* ttcooked() already printf'd */ +#ifdef CANNA + canna_end(); +#endif +} + +/* + * This function restores all terminal settings to their default values, + * in anticipation of exiting or suspending the editor. + */ + +ttcooked() { + ttflush(); +#ifndef EOTA + if (ioctl(0, TIOCSLTC, (char *) &oldltchars) < 0) { + ewprintf("ttclose can't set ltchars"); + return(FALSE); + } + if (ioctl(0, TIOCSETC, (char *) &oldtchars) < 0) { + ewprintf("ttclose can't set chars"); + return(FALSE); + } + if (ioctl(0, TIOCSETP, (char *) &oldtty) < 0) { + ewprintf("ttclose can't set sgtty"); + return(FALSE); + } +#else + ena_eof(0); +#endif /* not EOTA */ + return(TRUE); +} + +/* + * Write character to the display. + * Characters are buffered up, to make things + * a little bit more efficient. + */ +ttputc(c) +int c; +{ + if (nobuf >= NOBUF) + ttflush(); + obuf[nobuf++] = c; +} + +/* + * Flush output. + */ +ttflush() { + if (nobuf != 0) { + if (write(1, obuf, nobuf) != nobuf) + panic("ttflush write failed"); + nobuf = 0; + } +} + +#ifdef KANJI /* 90.02.05 by S.Yoshida */ +static int nkey = 0; /* The number of ungetc charactor. */ +static int keybuf[4]; /* Ungetc charactors. */ +#endif /* KANJI */ + +/* + * Read character from terminal. + * All 8 bits are returned, so that you can use + * a multi-national terminal. + */ +ttgetc() { + char buf[1]; + +#ifdef KANJI /* 90.02.05 by S.Yoshida */ + if (nkey > 0) { + return (keybuf[--nkey]); + } +#endif /* KANJI */ + while (read(0, &buf[0], 1) != 1) + ; + return (buf[0] & 0xFF); +} + +#ifdef KANJI /* 90.02.05 by S.Yoshida */ +/* + * Save pre-readed char to read again. + */ +ttungetc(c) +int c; +{ + keybuf[nkey++] = c; +} +#endif /* KANJI */ + +/* + * set the tty size. Functionized for 43BSD. + */ +setttysize() { + +#ifndef EOTA +#ifdef TIOCGWINSZ + if (ioctl(0, TIOCGWINSZ, (char *) &winsize) != -1) { + nrow = winsize . ws_row; + ncol = winsize . ws_col; + } else nrow = 0; + if(nrow<=0 || ncol<=0) +#endif +#else + struct winsize { + unsigned short int ws_row; + unsigned short int ws_col; + unsigned short int ws_xpixel; + unsigned short int ws_ypixel; + } ws; + + get_winsz(1, &ws); + nrow = ws.ws_row; + ncol = ws.ws_col; + if(nrow<=0 || ncol<=0) +#endif /* not EOTA */ + if ((nrow=tgetnum ("li")) <= 0 + || (ncol=tgetnum ("co")) <= 0) { + nrow = 24; + ncol = 80; + } + if (nrow > NROW) /* Don't crash if the */ + nrow = NROW; /* termcap entry is */ + if (ncol > NCOL) /* too big. */ + ncol = NCOL; +} + +#ifdef ADDFUNC /* 90.02.14 by S.Yoshida */ +#ifdef SIGWINCH /* 90.02.13 by S.Yoshida */ +/* + * Signal handler when window size has changed. + */ +VOID +ttwinch() +{ + refresh(FFRAND, 0); /* Very easy way... */ +#ifdef CANNA + canna_width(); +#endif /* CANNA */ +} +#endif /* SIGWINCH */ +#endif /* ADDFUNC */ + +/* + * typeahead returns TRUE if there are characters available to be read + * in. + */ +typeahead() { + int x; + +#ifdef KANJI /* 90.02.05 by S.Yoshida */ + if (nkey > 0) { + return (TRUE); + } +#endif /* KANJI */ +#ifndef EOTA + return((ioctl(0, FIONREAD, (char *) &x) < 0) ? 0 : x); +#else + return(FALSE); +#endif /* not EOTA */ +} + +/* + * panic - just exit, as quickly as we can. + */ +panic(s) char *s; { + (void) fputs("panic: ", stderr); + (void) fputs(s, stderr); + (void) fputc('\n', stderr); + (void) fflush(stderr); + abort(); /* To leave a core image. */ +} +#ifndef NO_DPROMPT +#include +/* + * A program to return TRUE if we wait for 2 seconds without anything + * happening, else return FALSE. Cribbed from mod.sources xmodem. + */ +int ttwait() { +#ifndef EOTA + FDSET readfd; +#endif /* not EOTA */ + struct timeval tmout; + +#ifdef KANJI /* 90.02.05 by S.Yoshida */ + if (nkey > 0) { + return (FALSE); + } +#endif /* KANJI */ +#ifdef BUGFIX /* 90.02.07 by S.Yoshida */ + tmout.tv_sec = 1; +#else /* NOT BUGFIX */ + tmout.tv_sec = 2; +#endif /* BUGFIX */ + tmout.tv_usec = 0; + +#ifndef EOTA + FD_ZERO(&readfd); + FD_SET(0, &readfd); + if ((select(1, &readfd, (FDSET *)0, (FDSET *)0, &tmout)) == 0) + return(TRUE); + return(FALSE); +#endif /* not EOTA */ + return(TRUE); +} +#endif