main() { Tokid a(Fileid("tokid.cpp"), 10); Tokid b(Fileid("./tokid.cpp"), 15); // Need pointer so that the delete in merge will work Eclass *e1 = new Eclass(5); e1->add_tokid(a); e1->add_tokid(b); cout << "e1:\n" << *e1; Eclass *e2 = new Eclass(5); Tokid c(Fileid("tokid.h"), 1); Tokid d(Fileid("./tokid.h"), 5); e2->add_tokid(c); e2->add_tokid(d); cout << "e2:\n" << *e2; Eclass *enew = merge(e1, e2); cout << "merged:\n" << *enew; Eclass *es = enew->split(2); cout << "split 0:\n" << *enew << "\n"; cout << "split 2:\n" << *es << "\n"; return (0); }
// Construct an object based on URL parameters FunQuery::FunQuery(FILE *of, bool icase, Attributes::size_type cp, bool e, bool r) : Query(!e, r, true), match_fid(false), id_ec(NULL), call(NULL), current_project(cp) { if (lazy) return; valid = true; // Query name char *qname = swill_getvar("n"); if (qname && *qname) name = qname; // Match specific file int ifid; if (swill_getargs("i(fid)", &ifid)) { match_fid = true; fid = Fileid(ifid); } // Function call declaration direct match if (!swill_getargs("p(call)", &call)) call = NULL; // Identifier EC match if (!swill_getargs("p(ec)", &id_ec)) { id_ec = NULL; // Type of boolean match char *m; if (!(m = swill_getvar("match"))) { fprintf(of, "Missing value: match"); valid = return_val = false; lazy = true; return; } match_type = *m; } mquery.set_match_type(match_type); cfun = !!swill_getvar("cfun"); macro = !!swill_getvar("macro"); writable = !!swill_getvar("writable"); ro = !!swill_getvar("ro"); pscope = !!swill_getvar("pscope"); fscope = !!swill_getvar("fscope"); defined = !!swill_getvar("defined"); if (!swill_getargs("i(ncallers)|i(ncallerop)", &ncallers, &ncallerop)) ncallerop = ec_ignore; exclude_fnre = !!swill_getvar("xfnre"); exclude_fure = !!swill_getvar("xfure"); exclude_fdre = !!swill_getvar("xfdre"); exclude_fre = !!swill_getvar("xfre"); // Compile regular expression specs if (!compile_re(of, "Function name", "fnre", fnre, match_fnre, str_fnre) || !compile_re(of, "Calling function name", "fure", fure, match_fure, str_fure) || !compile_re(of, "Called function name", "fdre", fdre, match_fdre, str_fdre) || !compile_re(of, "Filename", "fre", fre, match_fre, str_fre, (icase ? REG_ICASE : 0))) return; specified_order::set_order(mquery.get_sort_order(), mquery.get_reverse()); }
main(int argc, char *argv[]) { int i; int parse_parse(); Debug::db_read(); // Pass 1: scan files Block::enter(); // Linkage unit for (i = 1; i < argc; i++) { if (argv[i] == "-") { // Linkage unit separator Block::exit(); Block::enter(); continue; } Block::enter(); // Compilation unit Fchar::set_input(argv[i]); Fchar::push_input("/dds/src/research/ie/refactor/wdefs.h"); Fchar::push_input("/dds/src/research/ie/refactor/wincs.h"); Pdtoken::macros_clear(); if (parse_parse() != 0) exit(1); Block::exit(); // Compilation unit } Block::exit(); // Linkage unit // Pass 2: go through the files annotating identifiers deque_string color_names; // Some nice HTML colors color_names.push_back("ff0000"); color_names.push_back("bf0000"); color_names.push_back("00af00"); color_names.push_back("00ef00"); color_names.push_back("0000ff"); color_names.push_back("bfbf00"); color_names.push_back("00ffff"); color_names.push_back("ff00ff"); ifstream in; Fileid fi; Colormap cm; deque_string::const_iterator c = color_names.begin(); cout << "<html><title>Identifier groups</title>\n" "<body bgcolor=\"#ffffff\">\n"; for (i = 1; i < argc; i++) { if (argv[i] == "-") { // Linkage unit separator cout << "<p><hr><p>\n"; continue; } if (in.is_open()) in.close(); in.clear(); // Otherwise flags are dirty and open fails in.open(argv[i], ios::binary); if (in.fail()) { perror(argv[i]); exit(1); } cout << "<h2>" << argv[i] << "</h2>\n"; fi = Fileid(argv[i]); // Go through the file character by character for (;;) { Tokid ti; int val, len; ti = Tokid(fi, in.tellg()); if ((val = in.get()) == EOF) break; Eclass *ec; if ((ec = ti.check_ec()) && ec->get_size() > 1) { Colormap::const_iterator ci; ci = cm.find(ec); if (ci == cm.end()) { // Allocate new color cm[ec] = (*c); c++; if (c == color_names.end()) c = color_names.begin(); ci = cm.find(ec); } cout << "<font color=\"#" << (*ci).second << "\">"; int len = ec->get_len(); cout << (char)val; for (int j = 1; j < len; j++) cout << html((char)in.get()); cout << "</font>"; continue; } cout << html((char)val); } } cout << "</body></html>\n"; return (0); }