/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/* Copyright (c) 1981 Regents of the University of California */
#include <sys/eucioctl.h>
#ifndef PRESUNEUC
#include <locale.h>
#ifdef putchar
#endif
#ifdef getchar
#endif
#endif /* PRESUNEUC */
#include "ex.h"
#include "ex_re.h"
#include "ex_tty.h"
#include "ex_vis.h"
/*
* Random routines, in alphabetical order.
*/
int
any(int c, unsigned char *s)
{
int x;
while (x = *s++)
if (x == c)
return (1);
return (0);
}
int
backtab(int i)
{
int j;
j = i % value(vi_SHIFTWIDTH);
if (j == 0)
j = value(vi_SHIFTWIDTH);
i -= j;
if (i < 0)
i = 0;
return (i);
}
void
change(void)
{
tchng++;
}
/*
* Column returns the number of
* columns occupied by printing the
* characters through position cp of the
* current line.
*/
int
{
if (cp == 0)
}
/* lcolumn is same as column except it returns number of columns
* occupied by characters before position
* cp of the current line
*/
int
{
if (cp == 0)
}
/*
* Ignore a comment to the end of the line.
* This routine eats the trailing newline so don't call donewline().
*/
void
comment(void)
{
int c;
do {
c = getchar();
} while (c != '\n' && c != EOF);
if (c == EOF)
ungetchar(c);
}
void
{
if (size > 0)
do
while (--size > 0);
}
void
{
if (size > 0)
do
while (--size > 0);
}
void
{
while (--size >= 0)
}
int
ctlof(int c)
{
}
void
dingdong(void)
{
putpad((unsigned char *)flash_screen);
else if (value(vi_ERRORBELLS))
}
int
{
int i;
unsigned char *cp;
genbuf[0] = 0;
return (i);
}
return (i);
}
void
{
syserror(1);
}
unsigned char *
int indent;
{
unsigned char *cp;
*cp++ = '\t';
*cp++ = ' ';
return (cp);
}
void
getDOT(void)
{
}
line *
getmark(c)
int c;
{
return (addr);
}
return (0);
}
void
ignnEOF(void)
{
int c = getchar();
if (c == EOF)
ungetchar(c);
else if (c=='"')
comment();
}
int
iswhite(int c)
{
return (c == ' ' || c == '\t');
}
int
{
if (c && !value(vi_BEAUTIFY))
return (0);
if (c >= ' ' && c != DELETE)
return (0);
switch (c) {
case '\t':
case '\n':
case '\f':
return (0);
default:
return (1);
}
}
void
killed(void)
{
}
void
{
extern char *verbalize();
if (inopen) {
return;
}
return;
} else {
if (cnt == 1) {
} else {
}
}
putNFL();
}
int
{
return (a - zero);
}
int
lineDOL(void)
{
}
int
lineDOT(void)
{
}
void
markDOT(void)
{
}
void
{
if (inopen)
}
}
int
markreg(int c)
{
if (c == '\'' || c == '`')
return ('z' + 1);
if (c >= 'a' && c <= 'z')
return (c);
return (0);
}
/*
* 'xxx@yyy' -> 'xxx' if terse, else 'xxx yyy'
* 'xxx|yyy' -> 'xxx' if terse, else 'yyy'
* All others map to themselves.
*/
/*
* The feature described above was disabled for localizable messaging.
*/
unsigned char *
unsigned char *str;
{
unsigned char *cp;
/* commented out for localizable messaging */
/* for (cp = str; *cp; cp++)
switch (*cp) {
case '@':
if (value(vi_TERSE))
*cp = 0;
else
*cp = ' ';
break;
case '|':
if (value(vi_TERSE) == 0)
return (cp + 1);
*cp = 0;
break;
} */
return (str);
}
/*VARARGS2*/
void
{
if (seekpt == 0)
return;
if (*cp == '\n')
vclreol();
if (enter_standout_mode && exit_bold)
putpad((unsigned char *)enter_standout_mode);
#ifdef PRESUNEUC
#else
#endif /* PRESUNEUC */
if (enter_standout_mode && exit_bold)
}
void
{
}
int
morelines(void)
{
unsigned char *end;
return -1;
/*
* Ask for end+2 sice we want end to be the last used location.
*/
end -= 64;
return -1;
} else {
endcore += 1024;
}
return (0);
}
void
nonzero(void)
{
notempty();
gettext("Nonzero address required on this command"));
}
}
int
notable(int i)
{
}
void
notempty(void)
{
gettext("No lines in the buffer"));
}
void
{
}
void
netchange(int i)
{
unsigned char *cp;
if (i > 0)
else
if (inopen) {
notecnt = i;
notenam = (unsigned char *)"";
return;
}
if (!notable(i))
return;
#ifdef PRESUNEUC
#else
#endif /* PRESUNEUC */
gettext("%d more lines") :
/*
* TRANSLATION_NOTE
* Reference order of arguments must not
* be changed using '%digit$', since vi's
* viprintf() does not support it.
*/
else
#ifdef PRESUNEUC
#else
#endif /* PRESUNEUC */
gettext("%d fewer lines") :
/*
* TRANSLATION_NOTE
* Reference order of arguments must not
* be changed using '%digit$', since vi's
* viprintf() does not support it.
*/
putNFL();
}
void
{
}
void
{
int oldglobmk;
*addr &= ~1;
*markp = n;
}
unsigned char *
plural(i)
long i;
{
return (i == 1 ? (unsigned char *)"" : (unsigned char *)"s");
}
int qcount();
short vcntcol;
int
{
int x, length;
int col;
int (*OO)();
vcntcol = 0;
length = 1;
else
if(length < 0)
length = 1;
}
pline(0);
/* put cursor at beginning of multibyte character */
col = 0;
}
if (gp)
while (*gp) {
if(length < 0) {
putoctal = 1;
putoctal = 0;
} else {
}
}
return (vcntcol);
}
/* This routine puts cursor after multibyte character */
int
{
int x, length;
int (*OO)();
vcntcol = 0;
length = 1;
else
if(length < 0)
length = 1;
}
pline(0);
if (gp)
while (*gp) {
if(length < 0) {
putoctal = 1;
putoctal = 0;
} else {
}
}
return (vcntcol);
}
int
qcount(c)
wchar_t c;
{
int cols;
#ifndef PRESUNEUC
int remcols;
short OWCOLS;
#endif /* PRESUNEUC */
if (c == '\t') {
return (0);
}
#ifdef PRESUNEUC
#else
cols = 0;
if (WCOLS == 0)
#endif /* PRESUNEUC */
return (0);
}
void
{
line t;
for (;;) {
t = *--a2;
return;
*a1++ = t;
}
}
void
{
int more;
if (!FIXUNDO)
return;
#ifdef UNDOTRACE
if (trace)
vudump("before save");
#endif
if (morelines() < 0)
gettext("Out of memory saving lines for undo - try using ed"));
if (more)
#ifdef UNDOTRACE
if (trace)
vudump("after save");
#endif
}
void
save12(void)
{
}
void
saveall(void)
{
}
int
span(void)
{
}
void
sync(void)
{
chng = 0;
tchng = 0;
xchng = 0;
}
int
skipwh(void)
{
int wh;
wh = 0;
wh++;
ignchar();
}
return (wh);
}
/*VARARGS2*/
void
{
errcnt++;
vclreol();
if (enter_standout_mode && exit_bold)
putpad((unsigned char *)enter_standout_mode);
if (enter_standout_mode && exit_bold)
}
unsigned char *
unsigned char *cp;
{
while (*cp)
cp++;
return (cp);
}
void
{
}
/*
* A system error has occurred that we need to perror.
* danger is true if we are unsure of the contents of
* the file or our buffer, e.g. a write error in the
* middle of a write operation, or a temp file error.
*/
void
{
int e = errno;
char *errstr;
extern char *strerror();
dirtcnt = 0;
putchar(' ');
if (danger)
edited = 0; /* for temp file errors, for example */
else
}
/*
* Return the column number that results from being in column col and
* hitting a tab, where tabs are set every ts columns. Work right for
* the case where col > columns, even if ts does not divide columns.
*/
int
{
} else
offset = 0;
return (result);
}
unsigned char *
vfindcol(i)
int i;
{
int length;
unsigned char x;
if(length < 0) {
putoctal = 1;
putoctal = 0;
} else {
}
}
return (cp);
}
unsigned char *
unsigned char *cp;
{
cp++;
return (cp);
}
unsigned char *
unsigned char *cp;
{
cp++;
return (cp);
}
int
{
int i;
i = 0;
for (;;)
switch (*cp++) {
case '\t':
break;
case ' ':
i++;
break;
default:
return (i);
}
}
void
{
markDOT();
}
/*
* When a hangup occurs our actions are similar to a preserve
* command. If the buffer has not been [Modified], then we do
* nothing but remove the temporary files and exit.
* Otherwise, we sync the temp file and then attempt a preserve.
* If the preserve succeeds, we unlink our temp files.
* If the preserve fails, we leave the temp files as they are
* as they are a backup even without preservation if they
* are not removed.
*/
/*ARGSUSED*/
void
int sig;
{
/*
* USG tty driver can send multiple HUP's!!
*/
if (chng == 0) {
cleanup(1);
}
if (setexit() == 0) {
if (preserve()) {
cleanup(1);
}
}
if (kflag)
if (xtflag)
}
/*
* Similar to onhup. This happens when any random core dump occurs,
* e.g. a bug in vi. We preserve the file and then generate a core.
*/
int sig;
{
static int timescalled = 0;
/*
* USG tty driver can send multiple HUP's!!
*/
if (inopen)
vsave();
(void) preserve();
}
if (timescalled < 2) {
cleanup(2);
/* We won't get past here */
}
if (kflag)
if (xtflag)
}
/*
* An interrupt occurred. Drain any output which
* is still in the output buffering pipeline.
* Catch interrupts again. Unless we are in visual
* reset the output state (out of -nl mode, e.g).
* Then like a normal error (with the \n before Interrupt
* suppressed in visual mode).
*/
/*ARGSUSED*/
void
int sig;
{
#ifndef CBREAK
#else
#endif
cancelalarm();
draino();
if (!inopen) {
pstop();
setlastchar('\n');
#ifdef CBREAK
}
#else
} else
vraw();
#endif
}
/*
* If we are interruptible, enable interrupts again.
* In some critical sections we turn interrupts off,
* but not very often.
*/
void
setrupt(void)
{
if (ruptible) {
#ifndef CBREAK
#else
#endif
#ifdef SIGTSTP
if (dosusp)
#endif
}
}
int
preserve(void)
{
#ifdef VMUNIX
tflush();
#endif
synctmp();
if (pid < 0)
return (0);
if (pid == 0) {
close(0);
}
waitfor();
return (1);
return (0);
}
#ifndef V6
void exit(i)
int i;
{
extern void _exit(int) __NORETURN;
#ifdef TRACE
if (trace)
#endif
_exit(i);
}
#endif
#ifdef SIGTSTP
/*
* We have just gotten a susp. Suspend and prepare to resume.
*/
extern void redraw();
/*ARGSUSED*/
void
int sig;
{
ttymode f;
int savenormtty;
vnfl();
putpad((unsigned char *)exit_ca_mode);
flush();
resetterm();
normtty = 0;
/* the pc stops here */
vcontin(0);
flush();
setty(f);
if (!inopen)
error(0);
else {
if(vcnt < 0) {
vclear();
vcnt = 0;
}
if (sig)
}
}
#endif
unsigned char *cursor;
{
int length;
if(length <= 0)
return(++cursor);
}
{
int length;
return(linebuf - 1);
if(length <= 0)
ccursor++;
else
}
return(ocursor);
}
int
{
if (!(MULTI_BYTE_MAX > 1))
return (0);
switch (flag) {
case 0:
return (-1);
return (0);
case 1:
return (-1);
return (0);
case 11:
return (0);
default:
return (-1);
}
}
#ifndef PRESUNEUC
/* locale specific initialization */
void
localize(void)
{
extern int wdchkind();
extern int wdbindf();
mc_wrap = 1;
fillerchar = mcfiller();
}
#endif /* PRESUNEUC */