Annotation of 43BSD/contrib/emacs/shortnames/names.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  *     A quick and dirty C program to spit out possible identifiers
                      3:  *     from a stream of *.c and *.h files.  Takes a single parameter
                      4:  *     which specifies the minimum length of an identifier to be
                      5:  *     extracted.
                      6:  *
                      7:  */
                      8:  
                      9: #include <stdio.h>
                     10: #include <ctype.h>
                     11: 
                     12: #define FIRSTCHAR(a) (isalpha(a) || (a)=='_')
                     13: #define OTHERCHAR(a) (FIRSTCHAR(a) || isdigit(a))
                     14: #define TRUE 1
                     15: #define FALSE 0
                     16: 
                     17: int size = 0;
                     18: char buffer[512];
                     19: char *bp = buffer;
                     20: 
                     21: main (argc, argv)
                     22:      int argc;
                     23:      char *argv[];
                     24: {
                     25:   register int ch;
                     26:   register int spitout;
                     27:   register int eating_comment;
                     28: 
                     29:   if (argc = 2)
                     30:     {
                     31:       size = atoi (argv[1]);
                     32:     }
                     33:   spitout = FALSE;
                     34:   eating_comment = FALSE;
                     35:   while ((ch = getchar()) != EOF)
                     36:     {
                     37:       if (ch == '/')
                     38:        {
                     39:          if ((ch = getchar()) == EOF)
                     40:            {
                     41:              fprintf (stderr, "unexpected EOF!\n");
                     42:              exit (1);
                     43:            }
                     44:          else
                     45:            {
                     46:              if (ch == '*')
                     47:                {
                     48:                  eating_comment = TRUE;
                     49:                }
                     50:              else
                     51:                {
                     52:                  ungetc (ch, stdin);
                     53:                }
                     54:            }
                     55:        }
                     56:       else if (eating_comment && ch == '*')
                     57:        {
                     58:          if ((ch = getchar()) == EOF)
                     59:            {
                     60:              fprintf (stderr, "unexpected EOF!\n");
                     61:              exit (1);
                     62:            }
                     63:          else
                     64:            {
                     65:              if (ch == '/')
                     66:                {
                     67:                  eating_comment = FALSE;
                     68:                }
                     69:              else
                     70:                {
                     71:                  ungetc (ch, stdin);
                     72:                }
                     73:            }
                     74:        }
                     75:       else if (!eating_comment)
                     76:        {
                     77:          if (!spitout && FIRSTCHAR(ch))
                     78:            {
                     79:              spitout = TRUE;
                     80:              *bp++ = ch;
                     81:            }
                     82:          else if (spitout && OTHERCHAR(ch))
                     83:            {
                     84:              *bp++ = ch;
                     85:            }
                     86:          else if (spitout)
                     87:            {
                     88:              *bp++ = '\000';
                     89:              bp = buffer;
                     90:              if (strlen (bp) >= size)
                     91:                {
                     92:                  printf ("%s\n", bp);
                     93:                }
                     94:              spitout = FALSE;
                     95:            }
                     96:        }
                     97:     }
                     98:   return (0);
                     99: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.