xref: /csrg-svn/contrib/ed/rol.c (revision 57710)
1 /*-
2  * Copyright (c) 1992 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Rodney Ruddock of the University of Guelph.
7  *
8  * %sccs.include.redist.c%
9  */
10 
11 #ifndef lint
12 static char sccsid[] = "@(#)rol.c	5.2 (Berkeley) 01/23/93";
13 #endif /* not lint */
14 
15 #include <sys/types.h>
16 
17 #include <db.h>
18 #include <regex.h>
19 #include <setjmp.h>
20 #include <stdio.h>
21 #include <string.h>
22 
23 #include "ed.h"
24 #include "extern.h"
25 
26 /*
27  * After the command check the rest of the line to see nothing illegal
28  * is following. Any single instance of a printsfx suffix is the only
29  * legal thing to follow ( that is, a 'l', 'n', or 'p'). If a suffix
30  * occurs the execution of that suffix occurs back in the cmd_loop
31  * function after the command that called this function finishes
32  * successfully.
33  */
34 int
35 rol(inputt, errnum)
36 	FILE *inputt;
37 	int *errnum;
38 {
39 	ss = getc(inputt);
40 	printsfx = 0;
41 
42 	/* Only one of the suffix is allowed. */
43 	if (ss == 'p')
44 		printsfx = 1;
45 	else
46 		if (ss == 'n')
47 			printsfx = 2;
48 		else
49 			if (ss == 'l')
50 				printsfx = 4;
51 			else
52 				ungetc(ss, inputt);
53 
54 	for (;;) {
55 		ss = getc(inputt);
56 		if ((ss != ' ') && (ss != '\n') && (ss != EOF)) {
57 			*errnum = -1;
58 			strcpy(help_msg, "illegal command option");
59 			return (1);
60 		}
61 		if ((ss == '\n') || (ss == EOF))
62 			break;
63 	}
64 
65 	/* Rest-of-line was okay. */
66 	return (0);
67 }
68