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