aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-04-26 12:42:11 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2009-04-26 12:42:11 +0300
commitd50fc04ded36255465184a16c70eb4c50acdb199 (patch)
tree02a568794c2a211621d1fe39868eaad7963bdc43 /src
parent099a946ad4465c42db4737b247f1e89bd03c83ae (diff)
downloadtagr-d50fc04ded36255465184a16c70eb4c50acdb199.tar.gz
tagr-d50fc04ded36255465184a16c70eb4c50acdb199.tar.bz2
Introduce formats in preprocessor variables.
* configure.ac: Version 1.9.90 * NEWS: Likewise. * etc/Makefile.am (EXTRA_DIST): Add logfilter.awk uptmpl.sed * etc/logfilter.awk: New file * etc/uptmpl.sed: New file * etc/tagr.tmpl: Update * etc/upgrade.awk: Add copyleft header * gnulib.modules: Add fprintftime. * src/graph.c (rate_unit): Change to "Bytes per Second". (number_suffix, number_suffix_count): Move to grid.c * src/html.gram.y: Work with formats. * src/html.lex.l: Likewise. * src/output.c (update_output): Store NOW as a number and provide a formatting function for it. * src/tagr.h (union value, value_format_fn): New types. (pp_value_t): New members: fmt, format (add_numeric_value, add_string_value): Change return type. (init_value): New proto.
Diffstat (limited to 'src')
-rw-r--r--src/graph.c9
-rw-r--r--src/grid.c5
-rw-r--r--src/html.gram.y161
-rw-r--r--src/html.lex.l27
-rw-r--r--src/output.c23
-rw-r--r--src/tagr.h23
6 files changed, 173 insertions, 75 deletions
diff --git a/src/graph.c b/src/graph.c
index 16483bb..bfd00cb 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -55,9 +55,5 @@ int graph_h_margin[2] = { 100, 14 };
55int graph_v_margin[2] = { 14, 35 }; 55int graph_v_margin[2] = { 14, 35 };
56 56
57char *rate_unit = "Bits per Second"; 57char *rate_unit = "Bytes per Second";
58
59static char *short_suffix[] = {"", "k", "M", "G", "T"};
60char **number_suffix = short_suffix;
61size_t number_suffix_count = sizeof (short_suffix) / sizeof (short_suffix[0]);
62 58
63#define make_color_index(g, ar) \ 59#define make_color_index(g, ar) \
@@ -99,5 +95,6 @@ draw_graph (FILE *fp,
99 95
100#define ytr(y) \ 96#define ytr(y) \
101 (unsigned long) ((ymax >= (y) ? (ymax - (y)) : ymax) * yscale + graph_h_margin[1]) 97 (unsigned long) ((ymax >= (y) ? (ymax - (y)) : ymax) * \
98 yscale + graph_h_margin[1])
102#define xtr(x) \ 99#define xtr(x) \
103 (unsigned long) (growright ? \ 100 (unsigned long) (growright ? \
diff --git a/src/grid.c b/src/grid.c
index f4a75e1..1671753 100644
--- a/src/grid.c
+++ b/src/grid.c
@@ -81,4 +81,9 @@ grid_free_data (void *ptr)
81 81
82 82
83/* FIXME: Suffixes not yet used. */
84static char *short_suffix[] = {"", "k", "M", "G", "T"};
85char **number_suffix = short_suffix;
86size_t number_suffix_count = sizeof (short_suffix) / sizeof (short_suffix[0]);
87
83struct ygrid_data 88struct ygrid_data
84{ 89{
diff --git a/src/html.gram.y b/src/html.gram.y
index bce5e93..fae64ff 100644
--- a/src/html.gram.y
+++ b/src/html.gram.y
@@ -37,4 +37,6 @@ static FILE *tmp_file;
37static void out_char (int c); 37static void out_char (int c);
38static void out_value (pp_value_t *val); 38static void out_value (pp_value_t *val);
39static void deduce_format (pp_value_t *res,
40 const pp_value_t *a, const pp_value_t *b);
39 41
40%} 42%}
@@ -84,5 +86,5 @@ eval : IDENT
84 | obrace error cbrace 86 | obrace error cbrace
85 { 87 {
86 $$.type = unspecified_value; 88 init_value (&$$, unspecified_value, NULL);
87 } 89 }
88 ; 90 ;
@@ -109,14 +111,14 @@ expr : value
109 if ($1.type == unspecified_value 111 if ($1.type == unspecified_value
110 || $3.type == unspecified_value) 112 || $3.type == unspecified_value)
111 $$.type = unspecified_value; 113 init_value (&$$, unspecified_value, NULL);
112 else if ($1.type != $3.type) 114 else if ($1.type != $3.type)
113 { 115 {
114 yyerror ("type mismatch in addition"); 116 yyerror ("type mismatch in addition");
115 $$.type = unspecified_value; 117 init_value (&$$, unspecified_value, NULL);
116 } 118 }
117 else 119 else
118 { 120 {
119 $$.type = $1.type; 121 $$.type = $1.type;
120 $$.prec = maxprec ($1.prec, $3.prec); 122 deduce_format (&$$, &$1, &$3);
121 switch ($1.type) 123 switch ($1.type)
122 { 124 {
@@ -141,19 +143,19 @@ expr : value
141 if ($1.type == unspecified_value 143 if ($1.type == unspecified_value
142 || $3.type == unspecified_value) 144 || $3.type == unspecified_value)
143 $$.type = unspecified_value; 145 init_value (&$$, unspecified_value, NULL);
144 else if ($1.type != $3.type) 146 else if ($1.type != $3.type)
145 { 147 {
146 yyerror ("type mismatch in subtraction"); 148 yyerror ("type mismatch in subtraction");
147 $$.type = unspecified_value; 149 init_value (&$$, unspecified_value, NULL);
148 } 150 }
149 else if ($1.type == string_value) 151 else if ($1.type == string_value)
150 { 152 {
151 yyerror ("subtraction not defined for strings"); 153 yyerror ("subtraction not defined for strings");
152 $$.type = unspecified_value; 154 init_value (&$$, unspecified_value, NULL);
153 } 155 }
154 else 156 else
155 { 157 {
156 $$.type = $1.type; 158 $$.type = $1.type;
157 $$.prec = maxprec ($1.prec, $3.prec); 159 deduce_format (&$$, &$1, &$3);
158 $$.v.number = $1.v.number - $3.v.number; 160 $$.v.number = $1.v.number - $3.v.number;
159 } 161 }
@@ -163,19 +165,19 @@ expr : value
163 if ($1.type == unspecified_value 165 if ($1.type == unspecified_value
164 || $3.type == unspecified_value) 166 || $3.type == unspecified_value)
165 $$.type = unspecified_value; 167 init_value (&$$, unspecified_value, NULL);
166 else if ($1.type != $3.type) 168 else if ($1.type != $3.type)
167 { 169 {
168 yyerror ("type mismatch in multiplication"); 170 yyerror ("type mismatch in multiplication");
169 $$.type = unspecified_value; 171 init_value (&$$, unspecified_value, NULL);
170 } 172 }
171 else if ($1.type == string_value) 173 else if ($1.type == string_value)
172 { 174 {
173 yyerror ("multiplication not defined for strings"); 175 yyerror ("multiplication not defined for strings");
174 $$.type = unspecified_value; 176 init_value (&$$, unspecified_value, NULL);
175 } 177 }
176 else 178 else
177 { 179 {
178 $$.type = $1.type; 180 $$.type = $1.type;
179 $$.prec = maxprec ($1.prec, $3.prec); 181 deduce_format (&$$, &$1, &$3);
180 $$.v.number = $1.v.number * $3.v.number; 182 $$.v.number = $1.v.number * $3.v.number;
181 } 183 }
@@ -185,24 +187,24 @@ expr : value
185 if ($1.type == unspecified_value 187 if ($1.type == unspecified_value
186 || $3.type == unspecified_value) 188 || $3.type == unspecified_value)
187 $$.type = unspecified_value; 189 init_value (&$$, unspecified_value, NULL);
188 else if ($1.type != $3.type) 190 else if ($1.type != $3.type)
189 { 191 {
190 yyerror ("type mismatch in division"); 192 yyerror ("type mismatch in division");
191 $$.type = unspecified_value; 193 init_value (&$$, unspecified_value, NULL);
192 } 194 }
193 else if ($1.type == string_value) 195 else if ($1.type == string_value)
194 { 196 {
195 yyerror ("division not defined for strings"); 197 yyerror ("division not defined for strings");
196 $$.type = unspecified_value; 198 init_value (&$$, unspecified_value, NULL);
197 } 199 }
198 else if (fabs ($3.v.number) < 1.0e-5) 200 else if (fabs ($3.v.number) < 1.0e-5)
199 { 201 {
200 yyerror ("division by zero"); 202 yyerror ("division by zero");
201 $$.type = unspecified_value; 203 init_value (&$$, unspecified_value, NULL);
202 } 204 }
203 else 205 else
204 { 206 {
205 $$.type = $1.type; 207 $$.type = $1.type;
206 $$.prec = maxprec ($1.prec, $3.prec); 208 deduce_format (&$$, &$1, &$3);
207 $$.v.number = $1.v.number / $3.v.number; 209 $$.v.number = $1.v.number / $3.v.number;
208 } 210 }
@@ -211,14 +213,13 @@ expr : value
211 { 213 {
212 if ($2.type == unspecified_value) 214 if ($2.type == unspecified_value)
213 $$.type = unspecified_value; 215 init_value (&$$, unspecified_value, NULL);
214 else if ($2.type == string_value) 216 else if ($2.type == string_value)
215 { 217 {
216 yyerror ("unary minus not defined for strings"); 218 yyerror ("unary minus not defined for strings");
217 $$.type = unspecified_value; 219 init_value (&$$, unspecified_value, NULL);
218 } 220 }
219 else 221 else
220 { 222 {
221 $$.type = $2.type; 223 $$ = $2;
222 $$.prec = $2.prec;
223 $$.v.number = - $2.v.number; 224 $$.v.number = - $2.v.number;
224 } 225 }
@@ -227,9 +228,9 @@ expr : value
227 { 228 {
228 if ($2.type == unspecified_value) 229 if ($2.type == unspecified_value)
229 $$.type = unspecified_value; 230 init_value (&$$, unspecified_value, NULL);
230 else if ($2.type == string_value) 231 else if ($2.type == string_value)
231 { 232 {
232 yyerror ("unary plus not defined for strings"); 233 yyerror ("unary plus not defined for strings");
233 $$.type = unspecified_value; 234 init_value (&$$, unspecified_value, NULL);
234 } 235 }
235 else 236 else
@@ -243,7 +244,7 @@ value : IDENT
243 | NUMBER 244 | NUMBER
244 {