xref: /csrg-svn/contrib/ed/rol.c (revision 60663)
157699Sbostic /*-
2*60663Sbostic  * Copyright (c) 1992, 1993
3*60663Sbostic  *	The Regents of the University of California.  All rights reserved.
457699Sbostic  *
557699Sbostic  * This code is derived from software contributed to Berkeley by
657699Sbostic  * Rodney Ruddock of the University of Guelph.
757699Sbostic  *
857699Sbostic  * %sccs.include.redist.c%
957699Sbostic  */
1057699Sbostic 
1157699Sbostic #ifndef lint
12*60663Sbostic static char sccsid[] = "@(#)rol.c	8.1 (Berkeley) 05/31/93";
1357699Sbostic #endif /* not lint */
1457699Sbostic 
1557710Sbostic #include <sys/types.h>
1657710Sbostic 
1757710Sbostic #include <regex.h>
1857710Sbostic #include <setjmp.h>
1957710Sbostic #include <stdio.h>
2057710Sbostic #include <string.h>
2157710Sbostic 
2258315Sbostic #ifdef DBI
2358315Sbostic #include <db.h>
2458315Sbostic #endif
2558315Sbostic 
2657699Sbostic #include "ed.h"
2757710Sbostic #include "extern.h"
2857699Sbostic 
2957699Sbostic /*
3057699Sbostic  * After the command check the rest of the line to see nothing illegal
3157699Sbostic  * is following. Any single instance of a printsfx suffix is the only
3257699Sbostic  * legal thing to follow ( that is, a 'l', 'n', or 'p'). If a suffix
3357699Sbostic  * occurs the execution of that suffix occurs back in the cmd_loop
3457699Sbostic  * function after the command that called this function finishes
3557699Sbostic  * successfully.
3657699Sbostic  */
3757699Sbostic int
rol(inputt,errnum)3857699Sbostic rol(inputt, errnum)
3957710Sbostic 	FILE *inputt;
4057710Sbostic 	int *errnum;
4157699Sbostic {
4257710Sbostic 	ss = getc(inputt);
4357710Sbostic 	printsfx = 0;
4457699Sbostic 
4557710Sbostic 	/* Only one of the suffix is allowed. */
4657710Sbostic 	if (ss == 'p')
4757710Sbostic 		printsfx = 1;
4857710Sbostic 	else
4957710Sbostic 		if (ss == 'n')
5057710Sbostic 			printsfx = 2;
5157710Sbostic 		else
5257710Sbostic 			if (ss == 'l')
5357710Sbostic 				printsfx = 4;
5457710Sbostic 			else
5557710Sbostic 				ungetc(ss, inputt);
5657699Sbostic 
5757710Sbostic 	for (;;) {
5857710Sbostic 		ss = getc(inputt);
5957710Sbostic 		if ((ss != ' ') && (ss != '\n') && (ss != EOF)) {
6057710Sbostic 			*errnum = -1;
6157710Sbostic 			strcpy(help_msg, "illegal command option");
6257710Sbostic 			return (1);
6357710Sbostic 		}
6457710Sbostic 		if ((ss == '\n') || (ss == EOF))
6557710Sbostic 			break;
6657710Sbostic 	}
6757699Sbostic 
6857710Sbostic 	/* Rest-of-line was okay. */
6957710Sbostic 	return (0);
7057710Sbostic }
71