prettyness police
[unix-history] / usr / src / usr.bin / ctags / yacc.c
index c8910ba..b7d73e4 100644 (file)
@@ -6,26 +6,32 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)yacc.c     8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)yacc.c     8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #endif /* not lint */
 
+#include <ctype.h>
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdio.h>
 #include <string.h>
+
 #include "ctags.h"
 
 /*
  * y_entries:
  *     find the yacc tags and put them in.
  */
 #include "ctags.h"
 
 /*
  * y_entries:
  *     find the yacc tags and put them in.
  */
+void
 y_entries()
 {
 y_entries()
 {
-       register int    c;
-       register char   *sp;
-       register bool   in_rule;
+       int     c;
+       char    *sp;
+       bool    in_rule;
        char    tok[MAXTOKEN];
 
        char    tok[MAXTOKEN];
 
-       while (GETC(!=,EOF))
-               switch ((char)c) {
+       in_rule = NO;
+
+       while (GETC(!=, EOF))
+               switch (c) {
                case '\n':
                        SETLINE;
                        /* FALLTHROUGH */
                case '\n':
                        SETLINE;
                        /* FALLTHROUGH */
@@ -35,7 +41,7 @@ y_entries()
                case '\t':
                        break;
                case '{':
                case '\t':
                        break;
                case '{':
-                       if (skip_key((int)'}'))
+                       if (skip_key('}'))
                                in_rule = NO;
                        break;
                case '\'':
                                in_rule = NO;
                        break;
                case '\'':
@@ -44,42 +50,41 @@ y_entries()
                                in_rule = NO;
                        break;
                case '%':
                                in_rule = NO;
                        break;
                case '%':
-                       if (GETC(==,'%'))
+                       if (GETC(==, '%'))
                                return;
                                return;
-                       (void)ungetc(c,inf);
+                       (void)ungetc(c, inf);
                        break;
                case '/':
                        break;
                case '/':
-                       if (GETC(==,'*'))
+                       if (GETC(==, '*'))
                                skip_comment();
                        else
                                skip_comment();
                        else
-                               (void)ungetc(c,inf);
+                               (void)ungetc(c, inf);
                        break;
                case '|':
                case ';':
                        in_rule = NO;
                        break;
                default:
                        break;
                case '|':
                case ';':
                        in_rule = NO;
                        break;
                default:
-                       if (in_rule || !isalpha(c) && c != (int)'.'
-                           && c != (int)'_')
+                       if (in_rule || !isalpha(c) && c != '.' && c != '_')
                                break;
                        sp = tok;
                        *sp++ = c;
                                break;
                        sp = tok;
                        *sp++ = c;
-                       while (GETC(!=,EOF) && (intoken(c) || c == (int)'.'))
+                       while (GETC(!=, EOF) && (intoken(c) || c == '.'))
                                *sp++ = c;
                        *sp = EOS;
                        getline();              /* may change before ':' */
                        while (iswhite(c)) {
                                *sp++ = c;
                        *sp = EOS;
                        getline();              /* may change before ':' */
                        while (iswhite(c)) {
-                               if (c == (int)'\n')
+                               if (c == '\n')
                                        SETLINE;
                                        SETLINE;
-                               if (GETC(==,EOF))
+                               if (GETC(==, EOF))
                                        return;
                        }
                                        return;
                        }
-                       if (c == (int)':') {
-                               pfnote(tok,lineno);
+                       if (c == ':') {
+                               pfnote(tok, lineno);
                                in_rule = YES;
                        }
                        else
                                in_rule = YES;
                        }
                        else
-                               (void)ungetc(c,inf);
+                               (void)ungetc(c, inf);
                }
 }
 
                }
 }
 
@@ -87,10 +92,11 @@ y_entries()
  * toss_yysec --
  *     throw away lines up to the next "\n%%\n"
  */
  * toss_yysec --
  *     throw away lines up to the next "\n%%\n"
  */
+void
 toss_yysec()
 {
 toss_yysec()
 {
-       register int    c,                      /* read character */
-                       state;
+       int     c;                      /* read character */
+       int     state;
 
        /*
         * state == 0 : waiting
 
        /*
         * state == 0 : waiting
@@ -99,20 +105,21 @@ toss_yysec()
         * state == 3 : recieved second %
         */
        lineftell = ftell(inf);
         * state == 3 : recieved second %
         */
        lineftell = ftell(inf);
-       for (state = 0;GETC(!=,EOF);)
-               switch ((char)c) {
-                       case '\n':
-                               ++lineno;
-                               lineftell = ftell(inf);
-                               if (state == 3)         /* done! */
-                                       return;
-                               state = 1;              /* start over */
-                               break;
-                       case '%':
-                               if (state)              /* if 1 or 2 */
-                                       ++state;        /* goto 3 */
-                               break;
-                       default:
-                               state = 0;              /* reset */
+       for (state = 0; GETC(!=, EOF);)
+               switch (c) {
+               case '\n':
+                       ++lineno;
+                       lineftell = ftell(inf);
+                       if (state == 3)         /* done! */
+                               return;
+                       state = 1;              /* start over */
+                       break;
+               case '%':
+                       if (state)              /* if 1 or 2 */
+                               ++state;        /* goto 3 */
+                       break;
+               default:
+                       state = 0;              /* reset */
+                       break;
                }
 }
                }
 }