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