1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
/* Copyright (c) 2002 Hewlett-Packard under GPL version 2 or later */
#ifndef _PMCCABE_H_
#define _PMCCABE_H_
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <stdbool.h>
#ifdef __hpux
#include <strings.h>
#endif
#include <ctype.h>
/* Returned by gettoken() */
#define T_BASE 256
#define T_ASSIGN (T_BASE + 0)
#define T_LOGICAL (T_BASE + 1)
/* non-commented nuline returned by ncss_Getchar() */
#define T_NCNULINE (T_BASE + 1)
#define T_WORDS (T_BASE + 20)
#define T_IDENT (T_WORDS + 2)
#define T_IF (T_WORDS + 3)
#define T_WHILE (T_WORDS + 4)
#define T_CASE (T_WORDS + 5)
#define T_SWITCH (T_WORDS + 6)
#define T_FOR (T_WORDS + 7)
#define T_UNION (T_WORDS + 8)
#define T_STRUCT (T_WORDS + 9)
#define T_CLASS (T_WORDS + 10)
#define T_OPERATOR (T_WORDS + 11)
#define T_CONST (T_WORDS + 12)
#define T_NAMESPACE (T_WORDS + 13)
#define T_THROW (T_WORDS + 14)
#define T_VOLATILE (T_WORDS + 15)
#define T_ENUM (T_WORDS + 16)
#define STREQUAL(a, b) (strcmp((a),(b)) == 0)
#define ZERO(x) memset(&x, 0, sizeof x)
#define SHIFT(n) argc -= (n); argv += (n)
/* values for stats_t.type */
#define STATS_TOTAL 0
#define STATS_FILE 1
#define STATS_FUNCTION 2
#define STATS_CLASS 3
#define STATS_NAMESPACE 4
struct stats_t
{
char *name;
int nstatements;
int nfunctions;
int firstline;
int lastline;
int defline;
int nLines;
int nfor, nwhile, nswitch, ncase, nif;
int nand, nor, nq;
int nsemicolons;
struct stats_t *prev;
char type;
};
typedef struct stats_t stats_t;
/* can only nest this many names, including Total and file name */
#define MAXDEPTH 100
extern int Line, Linetokens, ncss_Line;
extern int Exit;
/* pmccabe.c - command-line options */
extern int Cyco;
extern int Softbuild;
extern int Verbose;
extern int Pass1;
extern int Totals;
extern int Totalsonly;
extern int Files;
extern int Filesonly;
extern int Threshold;
extern int Line;
extern int Ncss;
extern int Ncssfunction;
extern int Unbuf[256];
extern int *Unptr;
/* cparse.c */
int fancygettoken(char *buf, int classflag, int *line, int *nLine);
int toplevelstatement(stats_t * stats);
int findchar(char fc);
bool maybeclass(void);
bool maybenamespace(void);
void findsemicolon();
int getoverloadedop(char *buf);
int fancyfunction(char *buf, stats_t * fs, stats_t * fn);
void possiblefn(stats_t * stats, const char *name, int line1, int defline,
int nLine1);
int prefunction(int *nstatements);
int countfunction(stats_t * fn);
void countword(stats_t * fn, int id);
bool is_c_plus_plus(stats_t * stats, const char *name);
/* dmain.c */
void decomment(void);
int decomment_files(int argc, char *argv[]);
int ncss_files(int argc, char *argv[]);
/* gettoken.c */
int matchcurly();
int matchparen(void);
int skipws(void);
int getsimpleident(char *buf);
void ungettoken(int c, char *s);
int gettoken(char *buf, int *line, int *nLine);
int gettoken2(char *buf, int *line, int *nLine);
void operatorident(char *s, int c);
int identify(const char *ident);
void Ungetc(int c);
void ncss_Ungetc(int c);
void Ungets(char *s);
void ncss_Ungets(char *s);
int Getchar(void);
int ncss_Getchar(void);
/* nmain.c */
void file(char *fname, FILE * f);
void cycoprintstats(stats_t * fs, stats_t * fn);
void softbuildprintstats(stats_t * fs, stats_t * fn);
void printstats(stats_t * sp);
void fileerror(const char *s);
/* pmccabe.c */
int main(int argc, char *argv[]);
stats_t *stats_push(const char *name, int type);
stats_t *stats_current(void);
stats_t *stats_pop(stats_t * sp);
void stats_accumulate(stats_t * sp);
#define ISSPACE(c) ((c) == T_NCNULINE || (c) == '\n' \
|| (c) == '\t' || (c) == ' ' \
|| (c) == '\r')
#define ISIDENT1(c) (((c) >= 'a' && (c) <= 'z') \
|| ((c) >= 'A' && (c) <= 'Z') \
|| ((c) == '_'))
#define ISIDENT(c) ((ISIDENT1(c)) || ((c) >= '0' && (c) <= '9'))
#endif
|