/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley Software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "sh.h"
#include <locale.h>
#include <dirent.h>
#include <string.h>
/*
* #include <stdlib.h>
*/
#include "sh.tconst.h"
/*
* C Shell
*/
/*
* contains DIR * for last opendir_(), its left open if an error
* longjmp (reset) occurs before it gets closed via closedir.
* if its not null in the error handler, then closedir it.
*/
/*
* Print error string s with optional argument arg.
* This routine always resets or exits. The flag haderr
* is set so the routine who catches the unwind can propogate
* it if they want.
*
* Note that any open files at the point of error will eventually
* be closed in the routine process in sh.c which is the only
* place error unwinds are ever caught.
*/
/*VARARGS1*/
void
char *s;
{
tchar **v;
char *ep;
/*
* Must flush before we print as we wish output before the error
* to go on (some form of) standard output, while output after
* goes on (some form of) diagnostic output.
* See flush in sh.print.c.
*/
flush();
timflg = 0; /* This isn't otherwise reset */
if (v = pargv)
if (v = gargv)
/*
* A zero arguments causes no printing, else print
* an error diagnostic here.
*/
if (s) {
}
didfds = 0; /* Forget about 0,1,2 */
errspl = 0;
}
errspl = 0;
if ( Dirp ){
}
/*
* Go away if -e or we are a child shell
*/
exit(1);
}
/*
* Reset the state of the input.
* This buffered seek to end of file will also
*/
btoeof();
if (tpgrp > 0)
reset(); /* Unwind */
}
/*
* Perror is the shells version of perror which should otherwise
* never be called.
*/
void
{
/*
* Perror uses unit 2, thus if we didn't set up the fd's
* we must set up unit 2 now else the diagnostic will disappear
*/
if (!didfds) {
}
}
void
{
flush();
haderr = 1;
}
/*
* The parser and scanner set up errors for later by calling seterr,
* which sets the variable err as a side effect; later to be tested,
* e.g. in process.
*/
void
seterr(char *s)
{
if (err == 0)
}
/* Set err to a splice of cp and dp, to be freed later in error() */
void
{
char *gdp;
if (err)
return;
/* Concatinate cp and dp in the allocated space. */
errspl++;/* Remember to xfree(err). */
}
/* Set err to a splice of cp with a string form of character d */
void
{
/* don't overwrite an existing error message */
if (err)
return;
#ifdef MBCHAR
{
int i;
chbuf[(i>0)?i:0] = (char) 0;
}
#else
#endif
/* Concatinate cp and d in the allocated space. */
errspl++; /* Remember to xfree(err). */
}