xref: /original-bsd/usr.bin/pascal/src/yyoptions.c (revision 7d595439)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  */
6 
7 #ifndef lint
8 static char sccsid[] = "@(#)yyoptions.c	5.1 (Berkeley) 06/05/85";
9 #endif not lint
10 
11 #include "whoami.h"
12 #include "0.h"
13 #include "tree_ty.h"	/* must be included for yy.h */
14 #include "yy.h"
15 
16 /*
17  * Options processes the option
18  * strings which can appear in
19  * comments and returns the next character.
20  */
21 options()
22 {
23 	register c;
24 #ifdef PI0
25 	register ch;
26 #endif
27 	register char *optp;
28 
29 	c = readch();
30 	if (c != '$')
31 		return (c);
32 	do {
33 		c = readch();
34 #		ifdef PI0
35 		ch = c;
36 #		endif
37 		switch (c) {
38 			case 'b':
39 				optp = &opt( 'b' );
40 				c = readch();
41 				if (!digit(c))
42 					return (c);
43 				*optp = c - '0';
44 				c = readch();
45 				break;
46 #		    ifdef PC
47 			case 'C':
48 				    /*
49 				     *	C is a replacement for t, fake it.
50 				     */
51 				c = 't';
52 				/* and fall through */
53 			case 'g':
54 #		    endif PC
55 			case 'k':
56 			case 'l':
57 			case 'n':
58 			case 'p':
59 			case 's':
60 			case 't':
61 			case 'u':
62 			case 'w':
63 			case 'z':
64 				optp = &opt( c );
65 				c = readch();
66 				if (c == '+') {
67 					*optp = 1;
68 					c = readch();
69 				} else if (c == '-') {
70 					*optp = 0;
71 					c = readch();
72 				} else {
73 					return (c);
74 				}
75 				break;
76 			default:
77 				    return (c);
78 			}
79 #ifdef PI0
80 		send(ROSET, ch, *optp);
81 #endif
82 	} while (c == ',');
83 	if ( opt( 'u' ) )
84 		setuflg();
85 	return (c);
86 }
87