home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Distributions / ucb / spencer_2bsd.tar.gz / 2bsd.tar / src / pi0 / yyoptions.c < prev    next >
C/C++ Source or Header  |  1980-02-17  |  1KB  |  66 lines

  1. /* Copyright (c) 1979 Regents of the University of California */
  2. #
  3. /*
  4.  * pi - Pascal interpreter code translator
  5.  *
  6.  * Charles Haley, Bill Joy UCB
  7.  * Version 1.2 January 1979
  8.  */
  9.  
  10. #include "0.h"
  11. #include "yy.h"
  12.  
  13. /*
  14.  * Options processes the option
  15.  * strings which can appear in
  16.  * comments and returns the next character.
  17.  */
  18. options()
  19. {
  20.     register c, ch;
  21.     register char *optp;
  22.     int ok;
  23.  
  24.     c = getchar();
  25.     if (c != '$')
  26.         return (c);
  27.     do {
  28.         ch = c = getchar();
  29.         switch (c) {
  30.             case 'b':
  31.                 optp = &opts['b'-'a'];
  32.                 goto optdig;
  33.             case 'x':
  34.                 optp = &opts['x'-'a'];
  35.                 goto optdig;
  36.             optdig:
  37.                 c = getchar();
  38.                 if (!digit(c))
  39.                     return (c);
  40.                 *optp = c - '0';
  41.                 c = getchar();
  42.                 break;
  43.             default:
  44.                 if (c < 'a' || c > 'z')
  45.                     return (c);
  46.                 optp = &opts[c-'a'];
  47.                 c = getchar();
  48.                 if (c == '+') {
  49.                     *optp = 1;
  50.                     c = getchar();
  51.                 } else if (c == '-') {
  52.                     *optp = 0;
  53.                     c = getchar();
  54.                 } else
  55.                     return (c);
  56.                 break;
  57.             }
  58. #ifdef PI0
  59.         send(ROSET, ch, *optp);
  60. #endif
  61.     } while (c == ',');
  62.     if (opts['u'-'a'])
  63.         setuflg();
  64.     return (c);
  65. }
  66.