static char *sccsid
= "@(#)cmd5.c 1.4 83/07/28";
static char *sourcefilename
;
static int lineno
; /* current line number in source file */
static char *argv
[100]; /* one line broken up into words */
static struct ww
*errwin
; /* window for error reporting */
static int errlineno
; /* lineno in errwin */
static char baderrwin
; /* can't open errwin */
char *s_name
; /* name of command */
int s_len
; /* number of characters to check */
int s_amin
; /* minimum argument */
int s_amax
; /* maximum argument */
int (*s_func
)(); /* the function */
static struct scmd scmd
[] = {
"window", 1, 4, 4, s_window
,
"escape", 1, 1, 1, s_escape
,
register struct scmd
*sp
;
if ((f
= fopen(filename
, "r")) == 0)
sourcefilename
= filename
;
for (lineno
= 1; fgets(buf
, sizeof buf
, f
) != 0; lineno
++) {
for (sp
= scmd
; sp
->s_name
; sp
++)
if (strncmp(*argv
, sp
->s_name
, sp
->s_len
) == 0)
if (strncmp(*argv
, sp
->s_name
) == 0)
if (sp
->s_amin
> argc
- 1)
error("Too few arguments.");
else if (sp
->s_amax
< argc
- 1)
error("Too many arguments.");
error("%s: Unknown command.", *argv
);
register char **pp
= argv
;
int col
, row
, ncol
, nrow
, id
;
if ((id
= findid()) < 0) {
error("Too many windows.");
w
= doopen(id
, nrow
, ncol
, row
, col
);
error("Can't open window: row %d col %d, %d rows %d cols.",
if (id
< 1 || id
> 9 || (w
= wwfind(id
)) == 0)
error("%d: No such window.", id
);
register char *q
= buf
, **pp
= argv
;
for (; *p
== ' ' || *p
== '\t'; p
++)
while (*p
&& *p
!= '\n' && *p
!= '#'
&& pp
< &argv
[sizeof argv
/sizeof *argv
- 1]) {
while (*p
&& *p
!= '\n' && *p
!= ' ' && *p
!= '\t')
for (; *p
== ' ' || *p
== '\t'; p
++)
error(fmt
, a
, b
, c
, d
, e
, f
, g
, h
)
if (errwin
== 0 && !baderrwin
) {
(void) sprintf(buf
, "Errors from %s", sourcefilename
);
if ((errwin
= openwin(ERRLINES
, buf
)) == 0) {
wwprintf(cmdwin
, "Can't open error window. ");
if (errlineno
++ > ERRLINES
- 4) {
wwprintf(errwin
, "\r\n");
wwprintf(errwin
, "line %d: ", lineno
);
wwprintf(errwin
, fmt
, a
, b
, c
, d
, e
, f
, g
, h
);
wwprintf(errwin
, "\r\n");