home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / bsd_srcs / usr.bin / pascal / src / yyoptions.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-04-16  |  3.0 KB  |  114 lines

  1. /*-
  2.  * Copyright (c) 1980 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms, with or without
  6.  * modification, are permitted provided that the following conditions
  7.  * are met:
  8.  * 1. Redistributions of source code must retain the above copyright
  9.  *    notice, this list of conditions and the following disclaimer.
  10.  * 2. Redistributions in binary form must reproduce the above copyright
  11.  *    notice, this list of conditions and the following disclaimer in the
  12.  *    documentation and/or other materials provided with the distribution.
  13.  * 3. All advertising materials mentioning features or use of this software
  14.  *    must display the following acknowledgement:
  15.  *    This product includes software developed by the University of
  16.  *    California, Berkeley and its contributors.
  17.  * 4. Neither the name of the University nor the names of its contributors
  18.  *    may be used to endorse or promote products derived from this software
  19.  *    without specific prior written permission.
  20.  *
  21.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  22.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  23.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  24.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  25.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  26.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  27.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  28.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  29.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  30.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  31.  * SUCH DAMAGE.
  32.  */
  33.  
  34. #ifndef lint
  35. static char sccsid[] = "@(#)yyoptions.c    5.2 (Berkeley) 4/16/91";
  36. #endif /* not lint */
  37.  
  38. #include "whoami.h"
  39. #include "0.h"
  40. #include "tree_ty.h"    /* must be included for yy.h */
  41. #include "yy.h"
  42.  
  43. /*
  44.  * Options processes the option
  45.  * strings which can appear in
  46.  * comments and returns the next character.
  47.  */
  48. options()
  49. {
  50.     register c;
  51. #ifdef PI0
  52.     register ch;
  53. #endif
  54.     register char *optp;
  55.  
  56.     c = readch();
  57.     if (c != '$')
  58.         return (c);
  59.     do {
  60.         c = readch();
  61. #        ifdef PI0
  62.         ch = c;
  63. #        endif
  64.         switch (c) {
  65.             case 'b':
  66.                 optp = &opt( 'b' );
  67.                 c = readch();
  68.                 if (!digit(c))
  69.                     return (c);
  70.                 *optp = c - '0';
  71.                 c = readch();
  72.                 break;
  73. #            ifdef PC
  74.             case 'C':
  75.                     /*
  76.                      *    C is a replacement for t, fake it.
  77.                      */
  78.                 c = 't';
  79.                 /* and fall through */
  80.             case 'g':
  81. #            endif PC
  82.             case 'k':
  83.             case 'l':
  84.             case 'n':
  85.             case 'p':
  86.             case 's':
  87.             case 't':
  88.             case 'u':
  89.             case 'w':
  90.             case 'z':
  91.                 optp = &opt( c );
  92.                 c = readch();
  93.                 if (c == '+') {
  94.                     *optp = 1;
  95.                     c = readch();
  96.                 } else if (c == '-') {
  97.                     *optp = 0;
  98.                     c = readch();
  99.                 } else {
  100.                     return (c);
  101.                 }
  102.                 break;
  103.             default:
  104.                     return (c);
  105.             }
  106. #ifdef PI0
  107.         send(ROSET, ch, *optp);
  108. #endif
  109.     } while (c == ',');
  110.     if ( opt( 'u' ) )
  111.         setuflg();
  112.     return (c);
  113. }
  114.