Commit | Line | Data |
---|---|---|
dadbf27e KB |
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 | |
e692f66f | 12 | static char sccsid[] = "@(#)rol.c 5.3 (Berkeley) %G%"; |
dadbf27e KB |
13 | #endif /* not lint */ |
14 | ||
ecbf4ad0 KB |
15 | #include <sys/types.h> |
16 | ||
ecbf4ad0 KB |
17 | #include <regex.h> |
18 | #include <setjmp.h> | |
19 | #include <stdio.h> | |
20 | #include <string.h> | |
21 | ||
e692f66f KB |
22 | #ifdef DBI |
23 | #include <db.h> | |
24 | #endif | |
25 | ||
dadbf27e | 26 | #include "ed.h" |
ecbf4ad0 | 27 | #include "extern.h" |
dadbf27e KB |
28 | |
29 | /* | |
30 | * After the command check the rest of the line to see nothing illegal | |
31 | * is following. Any single instance of a printsfx suffix is the only | |
32 | * legal thing to follow ( that is, a 'l', 'n', or 'p'). If a suffix | |
33 | * occurs the execution of that suffix occurs back in the cmd_loop | |
34 | * function after the command that called this function finishes | |
35 | * successfully. | |
36 | */ | |
dadbf27e KB |
37 | int |
38 | rol(inputt, errnum) | |
ecbf4ad0 KB |
39 | FILE *inputt; |
40 | int *errnum; | |
41 | { | |
42 | ss = getc(inputt); | |
43 | printsfx = 0; | |
dadbf27e | 44 | |
ecbf4ad0 KB |
45 | /* Only one of the suffix is allowed. */ |
46 | if (ss == 'p') | |
47 | printsfx = 1; | |
48 | else | |
49 | if (ss == 'n') | |
50 | printsfx = 2; | |
51 | else | |
52 | if (ss == 'l') | |
53 | printsfx = 4; | |
54 | else | |
55 | ungetc(ss, inputt); | |
dadbf27e | 56 | |
ecbf4ad0 KB |
57 | for (;;) { |
58 | ss = getc(inputt); | |
59 | if ((ss != ' ') && (ss != '\n') && (ss != EOF)) { | |
60 | *errnum = -1; | |
61 | strcpy(help_msg, "illegal command option"); | |
62 | return (1); | |
63 | } | |
64 | if ((ss == '\n') || (ss == EOF)) | |
65 | break; | |
66 | } | |
dadbf27e | 67 | |
ecbf4ad0 KB |
68 | /* Rest-of-line was okay. */ |
69 | return (0); | |
70 | } |