Mercurial > ~dholland > hg > ag > index.cgi
comparison anagram/guisupport/coveragedc.cpp @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /* | |
2 * AnaGram, A System for Syntax Directed Programming | |
3 * Copyright 1993-2002 Parsifal Software. All Rights Reserved. | |
4 * See the file COPYING for license and usage terms. | |
5 * | |
6 * coveragedc.cpp | |
7 */ | |
8 | |
9 #include <stdio.h> | |
10 #include "port.h" | |
11 | |
12 #include "coveragedc.h" | |
13 #include "dc.h" | |
14 #include "q1glbl.h" | |
15 #include "rule.h" | |
16 #include "stacks.h" | |
17 #include "ut.h" | |
18 #include "wm1.h" | |
19 | |
20 //#define INCLUDE_LOGGING | |
21 #include "log.h" | |
22 | |
23 | |
24 dc_ref read_counts(AgString fileName) { | |
25 LOGSECTION("read_counts"); | |
26 LOGV(fileName); | |
27 FILE *ag_file; | |
28 unsigned i; | |
29 long ag_file_id; | |
30 dc_ref window; | |
31 AgArray<unsigned> counts(nforms_base+1); | |
32 | |
33 ag_file = fopen(fileName.pointer(), "r"); | |
34 fscanf(ag_file, "%ld", &ag_file_id); | |
35 //ZALLOCATE_ST(rule_counts, nforms_base+1); | |
36 int k = 1; | |
37 for (i = 0; k && i <= nforms_base; i++) { | |
38 //k = fscanf(ag_file,"%d", &rule_counts[i]); | |
39 k = fscanf(ag_file,"%d", &counts[i]); | |
40 } | |
41 fclose(ag_file); | |
42 if (k) { | |
43 window = dc_ref(new rule_count_dc("Rule Coverage", counts)); | |
44 window->foot_title = fileName; | |
45 | |
46 return window; | |
47 } | |
48 return dc_ref(); | |
49 } | |
50 | |
51 static int rule_count_tabs[] = {8,0}; | |
52 | |
53 rule_count_dc::rule_count_dc(const char *name, AgArray<unsigned> ca) | |
54 : dc(name) | |
55 { | |
56 LOGSECTION("rule_count_dc::rule_count_dc"); | |
57 LOGV(name); | |
58 counts = ca; | |
59 des->d_size.y = nforms_base+1; | |
60 tab_stops = rule_count_tabs; | |
61 counts = ca; | |
62 } | |
63 | |
64 void rule_count_dc::getLine(unsigned ln) const { | |
65 ssprintf("%6u\t", counts[ln]); | |
66 append_item(ln, 1+map_form_number[ln].length()); | |
67 } | |
68 | |
69 void rule_count_dc::synchCursor(unsigned ln) const { | |
70 set_rule_line(ln); | |
71 } |